| Index: media/mpeg2/mpeg2ts_stream_parser.h
|
| diff --git a/media/mpeg2/mpeg2ts_stream_parser.h b/media/mpeg2/mpeg2ts_stream_parser.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7c76b3c79bd3da19dfc778df9329dda59cd17d4c
|
| --- /dev/null
|
| +++ b/media/mpeg2/mpeg2ts_stream_parser.h
|
| @@ -0,0 +1,111 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef MEDIA_MPEG2_MPEG2TS_STREAM_PARSER_H_
|
| +#define MEDIA_MPEG2_MPEG2TS_STREAM_PARSER_H_
|
| +
|
| +#include <list>
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/stl_util.h"
|
| +#include "media/base/media_export.h"
|
| +#include "media/base/stream_parser.h"
|
| +
|
| +namespace media {
|
| +
|
| +class AudioDecoderConfig;
|
| +class StreamParserBuffer;
|
| +class VideoDecoderConfig;
|
| +
|
| +namespace mpeg2ts {
|
| +
|
| +class PidState;
|
| +
|
| +class MEDIA_EXPORT Mpeg2TsStreamParser : public StreamParser {
|
| + public:
|
| + Mpeg2TsStreamParser();
|
| + virtual ~Mpeg2TsStreamParser();
|
| +
|
| + // StreamParser implementation.
|
| + virtual void Init(const InitCB& init_cb,
|
| + const NewConfigCB& config_cb,
|
| + const NewBuffersCB& new_buffers_cb,
|
| + const NewTextBuffersCB& text_cb,
|
| + const NeedKeyCB& need_key_cb,
|
| + const AddTextTrackCB& add_text_track_cb,
|
| + const NewMediaSegmentCB& new_segment_cb,
|
| + const base::Closure& end_of_segment_cb,
|
| + const LogCB& log_cb) OVERRIDE;
|
| + virtual void Flush() OVERRIDE;
|
| + virtual bool Parse(const uint8* buf, int size) OVERRIDE;
|
| +
|
| + private:
|
| + typedef std::map<int, PidState*> PidMap;
|
| +
|
| + void RegisterPmt(int program_number, int pmt_pid);
|
| + void RegisterPes(int pmt_pid, int pes_pid, int stream_type);
|
| +
|
| + void OnVideoConfigChanged(int pes_pid,
|
| + const VideoDecoderConfig& video_decoder_config);
|
| + void OnAudioConfigChanged(int pes_pid,
|
| + const AudioDecoderConfig& audio_decoder_config);
|
| + void OnAudioVideoConfigChanged();
|
| + void OnEmitAudioBuffer(
|
| + int pes_pid,
|
| + scoped_refptr<StreamParserBuffer> stream_parser_buffer);
|
| + void OnEmitVideoBuffer(
|
| + int pes_pid,
|
| + scoped_refptr<StreamParserBuffer> stream_parser_buffer);
|
| + void EmitRemainingBuffers();
|
| + void StartSegmentIfNeeded();
|
| +
|
| + // List of callbacks.
|
| + InitCB init_cb_;
|
| + NewConfigCB config_cb_;
|
| + NewBuffersCB new_buffers_cb_;
|
| + NeedKeyCB need_key_cb_;
|
| + NewMediaSegmentCB new_segment_cb_;
|
| + base::Closure end_of_segment_cb_;
|
| + LogCB log_cb_;
|
| +
|
| + std::vector<uint8> ts_buffer_;
|
| +
|
| + // List of program numbers and the corresponding PIDs.
|
| + std::map<int, std::list<int> > programs_;
|
| +
|
| + // List of PIDs and their state.
|
| + PidMap pids_;
|
| + STLValueDeleter<PidMap> pids_deleter_;
|
| +
|
| + // Selected audio and video PIDs.
|
| + int selected_pmt_pid_;
|
| + int selected_audio_pid_;
|
| + int selected_video_pid_;
|
| +
|
| + // Audio & video config have to be sent all together.
|
| + // Remember the audio and video configs.
|
| + scoped_ptr<AudioDecoderConfig> audio_config_;
|
| + scoped_ptr<VideoDecoderConfig> video_config_;
|
| +
|
| + // Pending audio & video buffers.
|
| + StreamParser::BufferQueue audio_buffer_queue_;
|
| + StreamParser::BufferQueue video_buffer_queue_;
|
| +
|
| + // Whether init_cb_ has been invoked.
|
| + // i.e. whether the stream parser is initialized
|
| + // from the ChunkDemuxer perspective.
|
| + bool is_initialized_;
|
| +
|
| + // Indicate whether a segment was started.
|
| + bool segment_started_;
|
| + base::TimeDelta time_offset_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Mpeg2TsStreamParser);
|
| +};
|
| +
|
| +} // namespace mpeg2ts
|
| +} // namespace media
|
| +
|
| +#endif
|
|
|