Renamed mp2t::MediaParser to mp2t::Mp2tMediaParser, removed filters namespace.

Change-Id: Ib4de2863d5e746b32703d49e721473a2ff6c8de7
This commit is contained in:
Thomas Inskip 2014-04-16 16:22:31 -07:00
parent faa12bd191
commit 4a39a0fc98
13 changed files with 35 additions and 61 deletions

View File

@ -60,7 +60,7 @@ Status Demuxer::Initialize() {
parser_.reset(new mp4::MP4MediaParser()); parser_.reset(new mp4::MP4MediaParser());
break; break;
case CONTAINER_MPEG2TS: case CONTAINER_MPEG2TS:
parser_.reset(new mp2t::MediaParser()); parser_.reset(new mp2t::Mp2tMediaParser());
break; break;
default: default:
NOTIMPLEMENTED(); NOTIMPLEMENTED();

View File

@ -6,7 +6,6 @@
#include "media/filters/h264_bit_reader.h" #include "media/filters/h264_bit_reader.h"
namespace media { namespace media {
namespace filters {
H264BitReader::H264BitReader() H264BitReader::H264BitReader()
: data_(NULL), : data_(NULL),
@ -111,5 +110,4 @@ size_t H264BitReader::NumEmulationPreventionBytesRead() {
return emulation_prevention_bytes_; return emulation_prevention_bytes_;
} }
} // namespace filters
} // namespace media } // namespace media

View File

@ -12,7 +12,6 @@
#include "base/basictypes.h" #include "base/basictypes.h"
namespace media { namespace media {
namespace filters {
// A class to provide bit-granularity reading of H.264 streams. // A class to provide bit-granularity reading of H.264 streams.
// This is not a generic bit reader class, as it takes into account // This is not a generic bit reader class, as it takes into account
@ -74,7 +73,6 @@ class H264BitReader {
DISALLOW_COPY_AND_ASSIGN(H264BitReader); DISALLOW_COPY_AND_ASSIGN(H264BitReader);
}; };
} // namespace filters
} // namespace media } // namespace media
#endif // MEDIA_FILTERS_H264_BIT_READER_H_ #endif // MEDIA_FILTERS_H264_BIT_READER_H_

View File

@ -6,7 +6,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace media { namespace media {
namespace filters {
TEST(H264BitReaderTest, ReadStreamWithoutEscapeAndTrailingZeroBytes) { TEST(H264BitReaderTest, ReadStreamWithoutEscapeAndTrailingZeroBytes) {
H264BitReader reader; H264BitReader reader;
@ -71,5 +70,4 @@ TEST(H264BitReaderTest, StopBitOccupyFullByte) {
EXPECT_FALSE(reader.HasMoreRBSPData()); EXPECT_FALSE(reader.HasMoreRBSPData());
} }
} // namespace filters
} // namespace media } // namespace media

View File

@ -9,7 +9,6 @@
#include "media/filters/h264_parser.h" #include "media/filters/h264_parser.h"
namespace media { namespace media {
namespace filters {
bool H264SliceHeader::IsPSlice() const { bool H264SliceHeader::IsPSlice() const {
return (slice_type % 5 == kPSlice); return (slice_type % 5 == kPSlice);
@ -1262,5 +1261,4 @@ H264Parser::Result H264Parser::ParseSEI(H264SEIMessage* sei_msg) {
return kOk; return kOk;
} }
} // namespace filters
} // namespace media } // namespace media

View File

@ -15,7 +15,6 @@
#include "media/filters/h264_bit_reader.h" #include "media/filters/h264_bit_reader.h"
namespace media { namespace media {
namespace filters {
// For explanations of each struct and its members, see H.264 specification // For explanations of each struct and its members, see H.264 specification
// at http://www.itu.int/rec/T-REC-H.264. // at http://www.itu.int/rec/T-REC-H.264.
@ -394,7 +393,6 @@ class H264Parser {
DISALLOW_COPY_AND_ASSIGN(H264Parser); DISALLOW_COPY_AND_ASSIGN(H264Parser);
}; };
} // namespace filters
} // namespace media } // namespace media
#endif // MEDIA_FILTERS_H264_PARSER_H_ #endif // MEDIA_FILTERS_H264_PARSER_H_

View File

@ -12,7 +12,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace media { namespace media {
namespace filters {
TEST(H264ParserTest, StreamFileParsing) { TEST(H264ParserTest, StreamFileParsing) {
base::FilePath file_path = GetTestDataFilePath("test-25fps.h264"); base::FilePath file_path = GetTestDataFilePath("test-25fps.h264");
@ -70,5 +69,4 @@ TEST(H264ParserTest, StreamFileParsing) {
} }
} }
} // namespace filters
} // namespace media } // namespace media

View File

@ -14,12 +14,6 @@
#include "media/filters/h264_parser.h" #include "media/filters/h264_parser.h"
#include "media/formats/mp2t/mp2t_common.h" #include "media/formats/mp2t/mp2t_common.h"
using media::filters::H264Parser;
using media::filters::H264PPS;
using media::filters::H264SliceHeader;
using media::filters::H264SPS;
using media::filters::H264NALU;
namespace media { namespace media {
namespace mp2t { namespace mp2t {

View File

@ -15,13 +15,11 @@
#include "media/formats/mp2t/es_parser.h" #include "media/formats/mp2t/es_parser.h"
namespace media { namespace media {
class OffsetByteQueue;
class VideoStreamInfo;
namespace filters {
class H264Parser; class H264Parser;
class OffsetByteQueue;
struct H264SPS; struct H264SPS;
} // namespace filters
} // namespace media } // namespace media
namespace media { namespace media {
@ -39,7 +37,7 @@ class EsParserH264 : public EsParser {
const EmitSampleCB& emit_sample_cb); const EmitSampleCB& emit_sample_cb);
virtual ~EsParserH264(); virtual ~EsParserH264();
// EsParser implementation. // EsParser implementation overrides.
virtual bool Parse(const uint8* buf, int size, int64 pts, int64 dts) OVERRIDE; virtual bool Parse(const uint8* buf, int size, int64 pts, int64 dts) OVERRIDE;
virtual void Flush() OVERRIDE; virtual void Flush() OVERRIDE;
virtual void Reset() OVERRIDE; virtual void Reset() OVERRIDE;
@ -68,7 +66,7 @@ class EsParserH264 : public EsParser {
// Update the video decoder config based on an H264 SPS. // Update the video decoder config based on an H264 SPS.
// Return true if successful. // Return true if successful.
bool UpdateVideoDecoderConfig(const filters::H264SPS* sps); bool UpdateVideoDecoderConfig(const H264SPS* sps);
// Callbacks to pass the stream configuration and the frames. // Callbacks to pass the stream configuration and the frames.
NewStreamInfoCB new_stream_info_cb_; NewStreamInfoCB new_stream_info_cb_;
@ -81,7 +79,7 @@ class EsParserH264 : public EsParser {
// H264 parser state. // H264 parser state.
// - |current_access_unit_pos_| is pointing to an annexB syncword // - |current_access_unit_pos_| is pointing to an annexB syncword
// representing the first NALU of an H264 access unit. // representing the first NALU of an H264 access unit.
scoped_ptr<filters::H264Parser> h264_parser_; scoped_ptr<H264Parser> h264_parser_;
int64 current_access_unit_pos_; int64 current_access_unit_pos_;
int64 next_access_unit_pos_; int64 next_access_unit_pos_;

View File

@ -17,12 +17,6 @@
#include "media/test/test_data_util.h" #include "media/test/test_data_util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using media::filters::H264Parser;
using media::filters::H264PPS;
using media::filters::H264SliceHeader;
using media::filters::H264SPS;
using media::filters::H264NALU;
namespace media { namespace media {
class VideoStreamInfo; class VideoStreamInfo;

View File

@ -108,7 +108,7 @@ bool PidState::PushTsPacket(const TsPacket& ts_packet) {
ts_packet.payload_size()); ts_packet.payload_size());
// At the minimum, when parsing failed, auto reset the section parser. // At the minimum, when parsing failed, auto reset the section parser.
// Components that use the MediaParser can take further action if needed. // Components that use the Mp2tMediaParser can take further action if needed.
if (!status) { if (!status) {
DVLOG(1) << "Parsing failed for pid = " << pid_; DVLOG(1) << "Parsing failed for pid = " << pid_;
ResetState(); ResetState();
@ -143,16 +143,16 @@ void PidState::ResetState() {
continuity_counter_ = -1; continuity_counter_ = -1;
} }
MediaParser::MediaParser() Mp2tMediaParser::Mp2tMediaParser()
: sbr_in_mimetype_(false), : sbr_in_mimetype_(false),
is_initialized_(false) { is_initialized_(false) {
} }
MediaParser::~MediaParser() { Mp2tMediaParser::~Mp2tMediaParser() {
STLDeleteValues(&pids_); STLDeleteValues(&pids_);
} }
void MediaParser::Init( void Mp2tMediaParser::Init(
const InitCB& init_cb, const InitCB& init_cb,
const NewSampleCB& new_sample_cb, const NewSampleCB& new_sample_cb,
const NeedKeyCB& need_key_cb) { const NeedKeyCB& need_key_cb) {
@ -167,8 +167,8 @@ void MediaParser::Init(
need_key_cb_ = need_key_cb; need_key_cb_ = need_key_cb;
} }
void MediaParser::Flush() { void Mp2tMediaParser::Flush() {
DVLOG(1) << "MediaParser::Flush"; DVLOG(1) << "Mp2tMediaParser::Flush";
// Flush the buffers and reset the pids. // Flush the buffers and reset the pids.
for (std::map<int, PidState*>::iterator it = pids_.begin(); for (std::map<int, PidState*>::iterator it = pids_.begin();
@ -185,8 +185,8 @@ void MediaParser::Flush() {
ts_byte_queue_.Reset(); ts_byte_queue_.Reset();
} }
bool MediaParser::Parse(const uint8* buf, int size) { bool Mp2tMediaParser::Parse(const uint8* buf, int size) {
DVLOG(1) << "MediaParser::Parse size=" << size; DVLOG(1) << "Mp2tMediaParser::Parse size=" << size;
// Add the data to the parser state. // Add the data to the parser state.
ts_byte_queue_.Push(buf, size); ts_byte_queue_.Push(buf, size);
@ -225,7 +225,7 @@ bool MediaParser::Parse(const uint8* buf, int size) {
// Create the PAT state here if needed. // Create the PAT state here if needed.
scoped_ptr<TsSection> pat_section_parser( scoped_ptr<TsSection> pat_section_parser(
new TsSectionPat( new TsSectionPat(
base::Bind(&MediaParser::RegisterPmt, base::Bind(&Mp2tMediaParser::RegisterPmt,
base::Unretained(this)))); base::Unretained(this))));
scoped_ptr<PidState> pat_pid_state( scoped_ptr<PidState> pat_pid_state(
new PidState(ts_packet->pid(), PidState::kPidPat, new PidState(ts_packet->pid(), PidState::kPidPat,
@ -251,7 +251,7 @@ bool MediaParser::Parse(const uint8* buf, int size) {
return EmitRemainingSamples(); return EmitRemainingSamples();
} }
void MediaParser::RegisterPmt(int program_number, int pmt_pid) { void Mp2tMediaParser::RegisterPmt(int program_number, int pmt_pid) {
DVLOG(1) << "RegisterPmt:" DVLOG(1) << "RegisterPmt:"
<< " program_number=" << program_number << " program_number=" << program_number
<< " pmt_pid=" << pmt_pid; << " pmt_pid=" << pmt_pid;
@ -271,7 +271,7 @@ void MediaParser::RegisterPmt(int program_number, int pmt_pid) {
DVLOG(1) << "Create a new PMT parser"; DVLOG(1) << "Create a new PMT parser";
scoped_ptr<TsSection> pmt_section_parser( scoped_ptr<TsSection> pmt_section_parser(
new TsSectionPmt( new TsSectionPmt(
base::Bind(&MediaParser::RegisterPes, base::Bind(&Mp2tMediaParser::RegisterPes,
base::Unretained(this), pmt_pid))); base::Unretained(this), pmt_pid)));
scoped_ptr<PidState> pmt_pid_state( scoped_ptr<PidState> pmt_pid_state(
new PidState(pmt_pid, PidState::kPidPmt, pmt_section_parser.Pass())); new PidState(pmt_pid, PidState::kPidPmt, pmt_section_parser.Pass()));
@ -279,7 +279,7 @@ void MediaParser::RegisterPmt(int program_number, int pmt_pid) {
pids_.insert(std::pair<int, PidState*>(pmt_pid, pmt_pid_state.release())); pids_.insert(std::pair<int, PidState*>(pmt_pid, pmt_pid_state.release()));
} }
void MediaParser::RegisterPes(int pmt_pid, void Mp2tMediaParser::RegisterPes(int pmt_pid,
int pes_pid, int pes_pid,
int stream_type) { int stream_type) {
// TODO(damienv): check there is no mismatch if the entry already exists. // TODO(damienv): check there is no mismatch if the entry already exists.
@ -297,17 +297,17 @@ void MediaParser::RegisterPes(int pmt_pid,
es_parser.reset( es_parser.reset(
new EsParserH264( new EsParserH264(
pes_pid, pes_pid,
base::Bind(&MediaParser::OnNewStreamInfo, base::Bind(&Mp2tMediaParser::OnNewStreamInfo,
base::Unretained(this)), base::Unretained(this)),
base::Bind(&MediaParser::OnEmitSample, base::Bind(&Mp2tMediaParser::OnEmitSample,
base::Unretained(this)))); base::Unretained(this))));
} else if (stream_type == kStreamTypeAAC) { } else if (stream_type == kStreamTypeAAC) {
es_parser.reset( es_parser.reset(
new EsParserAdts( new EsParserAdts(
pes_pid, pes_pid,
base::Bind(&MediaParser::OnNewStreamInfo, base::Bind(&Mp2tMediaParser::OnNewStreamInfo,
base::Unretained(this)), base::Unretained(this)),
base::Bind(&MediaParser::OnEmitSample, base::Bind(&Mp2tMediaParser::OnEmitSample,
base::Unretained(this)), base::Unretained(this)),
sbr_in_mimetype_)); sbr_in_mimetype_));
is_audio = true; is_audio = true;
@ -327,7 +327,7 @@ void MediaParser::RegisterPes(int pmt_pid,
pids_.insert(std::pair<int, PidState*>(pes_pid, pes_pid_state.release())); pids_.insert(std::pair<int, PidState*>(pes_pid, pes_pid_state.release()));
} }
void MediaParser::OnNewStreamInfo( void Mp2tMediaParser::OnNewStreamInfo(
scoped_refptr<StreamInfo>& new_stream_info) { scoped_refptr<StreamInfo>& new_stream_info) {
DCHECK(new_stream_info); DCHECK(new_stream_info);
DVLOG(1) << "OnVideoConfigChanged for pid=" << new_stream_info->track_id(); DVLOG(1) << "OnVideoConfigChanged for pid=" << new_stream_info->track_id();
@ -346,7 +346,7 @@ void MediaParser::OnNewStreamInfo(
FinishInitializationIfNeeded(); FinishInitializationIfNeeded();
} }
bool MediaParser::FinishInitializationIfNeeded() { bool Mp2tMediaParser::FinishInitializationIfNeeded() {
// Nothing to be done if already initialized. // Nothing to be done if already initialized.
if (is_initialized_) if (is_initialized_)
return true; return true;
@ -376,7 +376,7 @@ bool MediaParser::FinishInitializationIfNeeded() {
return true; return true;
} }
void MediaParser::OnEmitSample(uint32 pes_pid, void Mp2tMediaParser::OnEmitSample(uint32 pes_pid,
scoped_refptr<MediaSample>& new_sample) { scoped_refptr<MediaSample>& new_sample) {
DCHECK(new_sample); DCHECK(new_sample);
DVLOG(LOG_LEVEL_ES) DVLOG(LOG_LEVEL_ES)
@ -400,8 +400,8 @@ void MediaParser::OnEmitSample(uint32 pes_pid,
pid_state->second->sample_queue().push_back(new_sample); pid_state->second->sample_queue().push_back(new_sample);
} }
bool MediaParser::EmitRemainingSamples() { bool Mp2tMediaParser::EmitRemainingSamples() {
DVLOG(LOG_LEVEL_ES) << "mp2t::MediaParser::EmitRemainingBuffers"; DVLOG(LOG_LEVEL_ES) << "Mp2tMediaParser::EmitRemainingBuffers";
// No buffer should be sent until fully initialized. // No buffer should be sent until fully initialized.
if (!is_initialized_) if (!is_initialized_)

View File

@ -26,12 +26,12 @@ class TsSection;
typedef std::deque<scoped_refptr<MediaSample> > SampleQueue; typedef std::deque<scoped_refptr<MediaSample> > SampleQueue;
class MediaParser : public media::MediaParser { class Mp2tMediaParser : public MediaParser {
public: public:
explicit MediaParser(); explicit Mp2tMediaParser();
virtual ~MediaParser(); virtual ~Mp2tMediaParser();
// media::MediaParser implementation. // MediaParser implementation overrides.
virtual void Init(const InitCB& init_cb, virtual void Init(const InitCB& init_cb,
const NewSampleCB& new_sample_cb, const NewSampleCB& new_sample_cb,
const NeedKeyCB& need_key_cb) OVERRIDE; const NeedKeyCB& need_key_cb) OVERRIDE;
@ -87,7 +87,7 @@ class MediaParser : public media::MediaParser {
// Whether |init_cb_| has been invoked. // Whether |init_cb_| has been invoked.
bool is_initialized_; bool is_initialized_;
DISALLOW_COPY_AND_ASSIGN(MediaParser); DISALLOW_COPY_AND_ASSIGN(Mp2tMediaParser);
}; };
} // namespace mp2t } // namespace mp2t

View File

@ -28,13 +28,13 @@ class Mp2tMediaParserTest : public testing::Test {
video_frame_count_(0), video_frame_count_(0),
video_min_dts_(kNoTimestamp), video_min_dts_(kNoTimestamp),
video_max_dts_(kNoTimestamp) { video_max_dts_(kNoTimestamp) {
parser_.reset(new MediaParser()); parser_.reset(new Mp2tMediaParser());
} }
protected: protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap; typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
scoped_ptr<MediaParser> parser_; scoped_ptr<Mp2tMediaParser> parser_;
StreamMap stream_map_; StreamMap stream_map_;
int audio_frame_count_; int audio_frame_count_;
int video_frame_count_; int video_frame_count_;