Added trick_play_rate to VideoStreamInfo.
Added ability to query the Demuxer for the container name (type). Change-Id: I328215f7c5badfe117c5419dd42f5262c568112a
This commit is contained in:
parent
581cb1fc4d
commit
a14ea461fb
|
@ -9,7 +9,6 @@
|
|||
#include "packager/base/bind.h"
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/stl_util.h"
|
||||
#include "packager/media/base/container_names.h"
|
||||
#include "packager/media/base/decryptor_source.h"
|
||||
#include "packager/media/base/key_source.h"
|
||||
#include "packager/media/base/media_sample.h"
|
||||
|
@ -33,6 +32,7 @@ Demuxer::Demuxer(const std::string& file_name)
|
|||
: file_name_(file_name),
|
||||
media_file_(NULL),
|
||||
init_event_received_(false),
|
||||
container_name_(CONTAINER_UNKNOWN),
|
||||
buffer_(new uint8_t[kBufSize]),
|
||||
cancelled_(false) {
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ Status Demuxer::Initialize() {
|
|||
break;
|
||||
bytes_read += read_result;
|
||||
}
|
||||
MediaContainerName container = DetermineContainer(buffer_.get(), bytes_read);
|
||||
container_name_ = DetermineContainer(buffer_.get(), bytes_read);
|
||||
|
||||
// Initialize media parser.
|
||||
switch (container) {
|
||||
switch (container_name_) {
|
||||
case CONTAINER_MOV:
|
||||
parser_.reset(new mp4::MP4MediaParser());
|
||||
break;
|
||||
|
@ -93,7 +93,7 @@ Status Demuxer::Initialize() {
|
|||
key_source_.get());
|
||||
|
||||
// Handle trailing 'moov'.
|
||||
if (container == CONTAINER_MOV)
|
||||
if (container_name_ == CONTAINER_MOV)
|
||||
static_cast<mp4::MP4MediaParser*>(parser_.get())->LoadMoov(file_name_);
|
||||
|
||||
if (!parser_->Parse(buffer_.get(), bytes_read)) {
|
||||
|
|
|
@ -65,6 +65,10 @@ class Demuxer {
|
|||
/// through MediaStream APIs.
|
||||
const std::vector<MediaStream*>& streams() { return streams_; }
|
||||
|
||||
/// @return Container name (type). Value is CONTAINER_UNKNOWN if the demuxer
|
||||
/// is not initialized.
|
||||
MediaContainerName container_name() { return container_name_; }
|
||||
|
||||
private:
|
||||
// Parser event handlers.
|
||||
void ParserInitEvent(const std::vector<scoped_refptr<StreamInfo> >& streams);
|
||||
|
@ -77,6 +81,7 @@ class Demuxer {
|
|||
Status init_parsing_status_;
|
||||
scoped_ptr<MediaParser> parser_;
|
||||
std::vector<MediaStream*> streams_;
|
||||
MediaContainerName container_name_;
|
||||
scoped_ptr<uint8_t[]> buffer_;
|
||||
scoped_ptr<KeySource> key_source_;
|
||||
bool cancelled_;
|
||||
|
|
|
@ -46,6 +46,7 @@ VideoStreamInfo::VideoStreamInfo(int track_id,
|
|||
const std::string& language,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
int16_t trick_play_rate,
|
||||
uint8_t nalu_length_size,
|
||||
const uint8_t* extra_data,
|
||||
size_t extra_data_size,
|
||||
|
@ -62,6 +63,7 @@ VideoStreamInfo::VideoStreamInfo(int track_id,
|
|||
codec_(codec),
|
||||
width_(width),
|
||||
height_(height),
|
||||
trick_play_rate_(trick_play_rate),
|
||||
nalu_length_size_(nalu_length_size) {
|
||||
}
|
||||
|
||||
|
@ -76,11 +78,13 @@ bool VideoStreamInfo::IsValidConfig() const {
|
|||
|
||||
std::string VideoStreamInfo::ToString() const {
|
||||
return base::StringPrintf(
|
||||
"%s codec: %s\n width: %d\n height: %d\n nalu_length_size: %d\n",
|
||||
"%s codec: %s\n width: %d\n height: %d\n trick_play_rate: %d\n"
|
||||
" nalu_length_size: %d\n",
|
||||
StreamInfo::ToString().c_str(),
|
||||
VideoCodecToString(codec_).c_str(),
|
||||
width_,
|
||||
height_,
|
||||
trick_play_rate_,
|
||||
nalu_length_size_);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ class VideoStreamInfo : public StreamInfo {
|
|||
const std::string& language,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
int16_t trick_play_rate,
|
||||
uint8_t nalu_length_size,
|
||||
const uint8_t* extra_data,
|
||||
size_t extra_data_size,
|
||||
|
@ -65,6 +66,7 @@ class VideoStreamInfo : public StreamInfo {
|
|||
VideoCodec codec_;
|
||||
uint16_t width_;
|
||||
uint16_t height_;
|
||||
int16_t trick_play_rate_; // Non-zero for trick-play streams.
|
||||
|
||||
// Specifies the normalized size of the NAL unit length field. Can be 1, 2 or
|
||||
// 4 bytes, or 0 if the size if unknown or the stream is not a AVC stream
|
||||
|
|
|
@ -63,6 +63,7 @@ scoped_refptr<StreamInfo> CreateVideoStreamInfo(
|
|||
param.language,
|
||||
param.width,
|
||||
param.height,
|
||||
0, // trick_play_rate
|
||||
param.nalu_length_size,
|
||||
vector_as_array(¶m.extra_data),
|
||||
param.extra_data.size(),
|
||||
|
|
|
@ -363,6 +363,7 @@ bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps) {
|
|||
std::string(),
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
H264ByteToUnitStreamConverter::kUnitStreamNaluLengthSize,
|
||||
decoder_config_record.data(),
|
||||
decoder_config_record.size(),
|
||||
|
|
|
@ -378,6 +378,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
|
|||
track->media.header.language,
|
||||
entry.width,
|
||||
entry.height,
|
||||
0, // trick_play_rate
|
||||
entry.avcc.length_size,
|
||||
&entry.avcc.data[0],
|
||||
entry.avcc.data.size(),
|
||||
|
|
|
@ -564,6 +564,7 @@ bool WvmMediaParser::ParseIndexEntry() {
|
|||
}
|
||||
|
||||
uint64_t track_duration = 0;
|
||||
int16_t trick_play_rate = 0;
|
||||
uint32_t sampling_frequency = kDefaultSamplingFrequency;
|
||||
uint32_t time_scale = kMpeg2ClockRate;
|
||||
uint16_t video_width = 0;
|
||||
|
@ -668,6 +669,9 @@ bool WvmMediaParser::ParseIndexEntry() {
|
|||
case TrackDuration:
|
||||
track_duration = value;
|
||||
break;
|
||||
case TrackTrickPlayRate:
|
||||
trick_play_rate = value;
|
||||
break;
|
||||
case VideoStreamId:
|
||||
video_pes_stream_id = value;
|
||||
break;
|
||||
|
@ -706,7 +710,7 @@ bool WvmMediaParser::ParseIndexEntry() {
|
|||
stream_infos_.push_back(new VideoStreamInfo(
|
||||
stream_id_count_, time_scale, track_duration, video_codec,
|
||||
video_codec_string, std::string(), video_width, video_height,
|
||||
nalu_length_size, NULL, 0, true));
|
||||
trick_play_rate, nalu_length_size, NULL, 0, true));
|
||||
program_demux_stream_map_[base::UintToString(index_program_id_) + ":" +
|
||||
base::UintToString(video_pes_stream_id)] =
|
||||
stream_id_count_++;
|
||||
|
|
Loading…
Reference in New Issue