2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
#ifndef MEDIA_BASE_VIDEO_STREAM_INFO_H_
|
|
|
|
#define MEDIA_BASE_VIDEO_STREAM_INFO_H_
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/base/stream_info.h"
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 04:17:12 +00:00
|
|
|
namespace media {
|
|
|
|
|
2017-03-23 18:34:20 +00:00
|
|
|
enum class H26xStreamFormat {
|
|
|
|
kUnSpecified,
|
|
|
|
kAnnexbByteStream,
|
|
|
|
kNalUnitStreamWithParameterSetNalus,
|
|
|
|
kNalUnitStreamWithoutParameterSetNalus,
|
|
|
|
};
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Holds video stream information.
|
2013-09-24 04:17:12 +00:00
|
|
|
class VideoStreamInfo : public StreamInfo {
|
|
|
|
public:
|
2017-02-27 17:22:25 +00:00
|
|
|
VideoStreamInfo() = default;
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// Construct an initialized video stream info object.
|
2015-06-17 22:42:56 +00:00
|
|
|
/// @param pixel_width is the width of the pixel. 0 if unknown.
|
|
|
|
/// @param pixel_height is the height of the pixels. 0 if unknown.
|
2017-03-23 18:34:20 +00:00
|
|
|
VideoStreamInfo(int track_id,
|
|
|
|
uint32_t time_scale,
|
|
|
|
uint64_t duration,
|
|
|
|
Codec codec,
|
|
|
|
H26xStreamFormat h26x_stream_format,
|
|
|
|
const std::string& codec_string,
|
|
|
|
const uint8_t* codec_config,
|
|
|
|
size_t codec_config_size,
|
|
|
|
uint16_t width,
|
|
|
|
uint16_t height,
|
|
|
|
uint32_t pixel_width,
|
|
|
|
uint32_t pixel_height,
|
2017-05-15 16:22:06 +00:00
|
|
|
uint32_t trick_play_factor,
|
2017-03-23 18:34:20 +00:00
|
|
|
uint8_t nalu_length_size,
|
|
|
|
const std::string& language,
|
2013-09-24 04:17:12 +00:00
|
|
|
bool is_encrypted);
|
|
|
|
|
2017-01-24 00:55:02 +00:00
|
|
|
~VideoStreamInfo() override;
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @name StreamInfo implementation overrides.
|
|
|
|
/// @{
|
2015-07-22 23:40:45 +00:00
|
|
|
bool IsValidConfig() const override;
|
|
|
|
std::string ToString() const override;
|
2017-09-12 17:24:24 +00:00
|
|
|
std::unique_ptr<StreamInfo> Clone() const override;
|
2014-01-24 18:46:46 +00:00
|
|
|
/// @}
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2017-03-23 18:34:20 +00:00
|
|
|
H26xStreamFormat h26x_stream_format() const { return h26x_stream_format_; }
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t width() const { return width_; }
|
|
|
|
uint16_t height() const { return height_; }
|
2015-06-17 22:42:56 +00:00
|
|
|
/// Returns the pixel width.
|
|
|
|
/// @return 0 if unknown.
|
|
|
|
uint32_t pixel_width() const { return pixel_width_; }
|
|
|
|
/// Returns the pixel height.
|
|
|
|
/// @return 0 if unknown.
|
|
|
|
uint32_t pixel_height() const { return pixel_height_; }
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t nalu_length_size() const { return nalu_length_size_; }
|
2017-05-15 16:22:06 +00:00
|
|
|
uint32_t trick_play_factor() const { return trick_play_factor_; }
|
2017-03-21 23:14:46 +00:00
|
|
|
uint32_t playback_rate() const { return playback_rate_; }
|
2016-08-17 00:57:34 +00:00
|
|
|
const std::vector<uint8_t>& eme_init_data() const { return eme_init_data_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2015-09-16 22:22:22 +00:00
|
|
|
void set_width(uint32_t width) { width_ = width; }
|
|
|
|
void set_height(uint32_t height) { height_ = height; }
|
2015-08-20 19:06:02 +00:00
|
|
|
void set_pixel_width(uint32_t pixel_width) { pixel_width_ = pixel_width; }
|
|
|
|
void set_pixel_height(uint32_t pixel_height) { pixel_height_ = pixel_height; }
|
2017-05-15 16:22:06 +00:00
|
|
|
void set_trick_play_factor(uint32_t trick_play_factor) {
|
|
|
|
trick_play_factor_ = trick_play_factor;
|
2017-02-27 17:22:25 +00:00
|
|
|
}
|
2017-03-21 23:14:46 +00:00
|
|
|
void set_playback_rate(uint32_t playback_rate) {
|
|
|
|
playback_rate_ = playback_rate;
|
|
|
|
}
|
2016-08-17 00:57:34 +00:00
|
|
|
void set_eme_init_data(const uint8_t* eme_init_data,
|
|
|
|
size_t eme_init_data_size) {
|
|
|
|
eme_init_data_.assign(eme_init_data, eme_init_data + eme_init_data_size);
|
|
|
|
}
|
2015-08-20 19:06:02 +00:00
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
private:
|
2017-03-23 18:34:20 +00:00
|
|
|
H26xStreamFormat h26x_stream_format_;
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t width_;
|
|
|
|
uint16_t height_;
|
2015-06-17 22:42:56 +00:00
|
|
|
|
|
|
|
// pixel_width_:pixel_height_ is the sample aspect ratio.
|
|
|
|
// 0 means unknown.
|
|
|
|
uint32_t pixel_width_;
|
|
|
|
uint32_t pixel_height_;
|
2017-05-15 16:22:06 +00:00
|
|
|
uint32_t trick_play_factor_ = 0; // Non-zero for trick-play streams.
|
2017-03-21 23:14:46 +00:00
|
|
|
|
|
|
|
// Playback rate is the attribute for trick play stream, which signals the
|
|
|
|
// playout capabilities
|
|
|
|
// (http://dashif.org/wp-content/uploads/2016/12/DASH-IF-IOP-v4.0-clean.pdf,
|
|
|
|
// page 18, line 1). It is the ratio of main frame rate to the trick play
|
|
|
|
// frame rate. If the time scale and frame duration are not modified after
|
|
|
|
// trick play handler processing, the playback_rate equals to the number of
|
|
|
|
// frames between consecutive key frames selected for trick play stream. For
|
2017-05-15 16:22:06 +00:00
|
|
|
// example, if the video stream has GOP size of 10 and the trick play factor
|
|
|
|
// is 3, the key frames are in this trick play stream are [frame_0, frame_30,
|
2017-03-21 23:14:46 +00:00
|
|
|
// frame_60, ...]. Then the playback_rate is 30.
|
2017-05-16 16:59:52 +00:00
|
|
|
// Non-zero for trick-play streams.
|
|
|
|
uint32_t playback_rate_ = 0;
|
2013-09-24 04:17:12 +00:00
|
|
|
|
2017-03-11 02:48:04 +00:00
|
|
|
// Specifies the size of the NAL unit length field. Can be 1, 2 or 4 bytes, or
|
|
|
|
// 0 if the stream is not a NAL structured video stream or if it is an AnnexB
|
|
|
|
// byte stream.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t nalu_length_size_;
|
2013-11-12 20:32:44 +00:00
|
|
|
|
2016-08-17 00:57:34 +00:00
|
|
|
// Container-specific data used by CDM to generate a license request:
|
|
|
|
// https://w3c.github.io/encrypted-media/#initialization-data.
|
|
|
|
std::vector<uint8_t> eme_init_data_;
|
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
// Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
|
|
|
|
// generated copy constructor and assignment operator. Since the extra data is
|
|
|
|
// typically small, the performance impact is minimal.
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-09-24 04:17:12 +00:00
|
|
|
|
|
|
|
#endif // MEDIA_BASE_VIDEO_STREAM_INFO_H_
|