Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(730)

Unified Diff: media/mp2t/mp2t_stream_parser.h

Issue 23566013: Mpeg2 TS stream parser for media source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup - address comments from patch set #8 Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/mp2t/mp2t_stream_parser.h
diff --git a/media/mp2t/mp2t_stream_parser.h b/media/mp2t/mp2t_stream_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..68b74722f5187710b1f241f17c6c0e91e6025f91
--- /dev/null
+++ b/media/mp2t/mp2t_stream_parser.h
@@ -0,0 +1,137 @@
+// 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_MP2T_MP2T_STREAM_PARSER_H_
+#define MEDIA_MP2T_MP2T_STREAM_PARSER_H_
+
+#include <list>
+#include <map>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "media/base/audio_decoder_config.h"
+#include "media/base/byte_queue.h"
+#include "media/base/media_export.h"
+#include "media/base/stream_parser.h"
+#include "media/base/video_decoder_config.h"
+
+namespace media {
+
+class AudioDecoderConfig;
acolwell GONE FROM CHROMIUM 2013/09/16 06:19:30 nit: Not needed since you are including the .h.
damienv1 2013/09/17 02:58:22 Done.
+class StreamParserBuffer;
+class VideoDecoderConfig;
acolwell GONE FROM CHROMIUM 2013/09/16 06:19:30 Ditto
damienv1 2013/09/17 02:58:22 Done.
+
+namespace mp2t {
+
+class PidState;
+
+class MEDIA_EXPORT Mp2tStreamParser : public StreamParser {
+ public:
+ Mp2tStreamParser();
+ virtual ~Mp2tStreamParser();
+
+ // 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;
+
+ class AudioBufferWithConfig;
+ class VideoBufferWithConfig;
+
+ // Callback invoked to register a Program Map Table.
+ // Note: Does nothing if the PID is already registered.
+ void RegisterPmt(int program_number, int pmt_pid);
+
+ // Callback invoked to register a PES pid.
+ // Possible values for |stream_type| are defined in:
+ // ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments".
+ // |pes_pid| is part of the Program Map Table refered by |pmt_pid|.
+ void RegisterPes(int pmt_pid, int pes_pid, int stream_type);
+
+ // Since the StreamParser interface allows only one audio & video streams,
+ // an automatic PID filtering should be applied to select the audio & video
+ // streams.
+ void UpdatePidFilter();
+
+ // Callback invoked each time the audio/video decoder configuration is
+ // changing.
acolwell GONE FROM CHROMIUM 2013/09/16 06:19:30 nit: s/changing/changed/?
damienv1 2013/09/17 02:58:22 Done.
+ void OnVideoConfigChanged(int pes_pid,
+ const VideoDecoderConfig& video_decoder_config);
+ void OnAudioConfigChanged(int pes_pid,
+ const AudioDecoderConfig& audio_decoder_config);
+
+ // Invoke the initialization callback if needed.
+ void FinishInitializationIfNeeded();
+
+ // Callback invoked by the ES stream parser
+ // to emit a new audio/video access unit.
+ void OnEmitAudioBuffer(
+ int pes_pid,
+ scoped_refptr<StreamParserBuffer> stream_parser_buffer);
+ void OnEmitVideoBuffer(
+ int pes_pid,
+ scoped_refptr<StreamParserBuffer> stream_parser_buffer);
+
+ void EmitRemainingBuffers();
+ AudioDecoderConfig GetAudioBuffers(BufferQueue* video_queue);
+ VideoDecoderConfig GetVideoBuffers(BufferQueue* video_queue);
+
+ // 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_;
+
+ // Bytes of the TS stream.
+ ByteQueue ts_byte_queue_;
+
+ // List of PIDs and their state.
+ PidMap pids_;
+
+ // Selected audio and video PIDs.
+ int selected_audio_pid_;
+ int selected_video_pid_;
+
+ // Audio & video decoder config that applies to upcoming buffers.
+ AudioDecoderConfig audio_config_;
+ VideoDecoderConfig video_config_;
+
+ // Pending audio & video buffers.
+ std::list<AudioBufferWithConfig> audio_buffer_queue_;
+ std::list<VideoBufferWithConfig> video_buffer_queue_;
+
+ // Audio and Video decoder config of the last emitted buffers.
+ AudioDecoderConfig last_audio_config_;
+ VideoDecoderConfig last_video_config_;
+
+ // Whether |init_cb_| has been invoked.
+ bool is_initialized_;
+
+ // Indicate whether a segment was started.
+ bool segment_started_;
+ bool first_video_frame_in_segment_;
+ base::TimeDelta time_offset_;
+
+ DISALLOW_COPY_AND_ASSIGN(Mp2tStreamParser);
+};
+
+} // namespace mp2t
+} // namespace media
+
+#endif
+

Powered by Google App Engine
This is Rietveld 408576698