 Chromium Code Reviews
 Chromium Code Reviews Issue 23566013:
  Mpeg2 TS stream parser for media source.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 23566013:
  Mpeg2 TS stream parser for media source.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MP2T_MP2T_STREAM_PARSER_H_ | |
| 6 #define MEDIA_MP2T_MP2T_STREAM_PARSER_H_ | |
| 7 | |
| 8 #include <list> | |
| 9 #include <map> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "media/base/audio_decoder_config.h" | |
| 14 #include "media/base/byte_queue.h" | |
| 15 #include "media/base/media_export.h" | |
| 16 #include "media/base/stream_parser.h" | |
| 17 #include "media/base/video_decoder_config.h" | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 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.
 | |
| 22 class StreamParserBuffer; | |
| 23 class VideoDecoderConfig; | |
| 
acolwell GONE FROM CHROMIUM
2013/09/16 06:19:30
Ditto
 
damienv1
2013/09/17 02:58:22
Done.
 | |
| 24 | |
| 25 namespace mp2t { | |
| 26 | |
| 27 class PidState; | |
| 28 | |
| 29 class MEDIA_EXPORT Mp2tStreamParser : public StreamParser { | |
| 30 public: | |
| 31 Mp2tStreamParser(); | |
| 32 virtual ~Mp2tStreamParser(); | |
| 33 | |
| 34 // StreamParser implementation. | |
| 35 virtual void Init(const InitCB& init_cb, | |
| 36 const NewConfigCB& config_cb, | |
| 37 const NewBuffersCB& new_buffers_cb, | |
| 38 const NewTextBuffersCB& text_cb, | |
| 39 const NeedKeyCB& need_key_cb, | |
| 40 const AddTextTrackCB& add_text_track_cb, | |
| 41 const NewMediaSegmentCB& new_segment_cb, | |
| 42 const base::Closure& end_of_segment_cb, | |
| 43 const LogCB& log_cb) OVERRIDE; | |
| 44 virtual void Flush() OVERRIDE; | |
| 45 virtual bool Parse(const uint8* buf, int size) OVERRIDE; | |
| 46 | |
| 47 private: | |
| 48 typedef std::map<int, PidState*> PidMap; | |
| 49 | |
| 50 class AudioBufferWithConfig; | |
| 51 class VideoBufferWithConfig; | |
| 52 | |
| 53 // Callback invoked to register a Program Map Table. | |
| 54 // Note: Does nothing if the PID is already registered. | |
| 55 void RegisterPmt(int program_number, int pmt_pid); | |
| 56 | |
| 57 // Callback invoked to register a PES pid. | |
| 58 // Possible values for |stream_type| are defined in: | |
| 59 // ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments". | |
| 60 // |pes_pid| is part of the Program Map Table refered by |pmt_pid|. | |
| 61 void RegisterPes(int pmt_pid, int pes_pid, int stream_type); | |
| 62 | |
| 63 // Since the StreamParser interface allows only one audio & video streams, | |
| 64 // an automatic PID filtering should be applied to select the audio & video | |
| 65 // streams. | |
| 66 void UpdatePidFilter(); | |
| 67 | |
| 68 // Callback invoked each time the audio/video decoder configuration is | |
| 69 // changing. | |
| 
acolwell GONE FROM CHROMIUM
2013/09/16 06:19:30
nit: s/changing/changed/?
 
damienv1
2013/09/17 02:58:22
Done.
 | |
| 70 void OnVideoConfigChanged(int pes_pid, | |
| 71 const VideoDecoderConfig& video_decoder_config); | |
| 72 void OnAudioConfigChanged(int pes_pid, | |
| 73 const AudioDecoderConfig& audio_decoder_config); | |
| 74 | |
| 75 // Invoke the initialization callback if needed. | |
| 76 void FinishInitializationIfNeeded(); | |
| 77 | |
| 78 // Callback invoked by the ES stream parser | |
| 79 // to emit a new audio/video access unit. | |
| 80 void OnEmitAudioBuffer( | |
| 81 int pes_pid, | |
| 82 scoped_refptr<StreamParserBuffer> stream_parser_buffer); | |
| 83 void OnEmitVideoBuffer( | |
| 84 int pes_pid, | |
| 85 scoped_refptr<StreamParserBuffer> stream_parser_buffer); | |
| 86 | |
| 87 void EmitRemainingBuffers(); | |
| 88 AudioDecoderConfig GetAudioBuffers(BufferQueue* video_queue); | |
| 89 VideoDecoderConfig GetVideoBuffers(BufferQueue* video_queue); | |
| 90 | |
| 91 // List of callbacks. | |
| 92 InitCB init_cb_; | |
| 93 NewConfigCB config_cb_; | |
| 94 NewBuffersCB new_buffers_cb_; | |
| 95 NeedKeyCB need_key_cb_; | |
| 96 NewMediaSegmentCB new_segment_cb_; | |
| 97 base::Closure end_of_segment_cb_; | |
| 98 LogCB log_cb_; | |
| 99 | |
| 100 // Bytes of the TS stream. | |
| 101 ByteQueue ts_byte_queue_; | |
| 102 | |
| 103 // List of PIDs and their state. | |
| 104 PidMap pids_; | |
| 105 | |
| 106 // Selected audio and video PIDs. | |
| 107 int selected_audio_pid_; | |
| 108 int selected_video_pid_; | |
| 109 | |
| 110 // Audio & video decoder config that applies to upcoming buffers. | |
| 111 AudioDecoderConfig audio_config_; | |
| 112 VideoDecoderConfig video_config_; | |
| 113 | |
| 114 // Pending audio & video buffers. | |
| 115 std::list<AudioBufferWithConfig> audio_buffer_queue_; | |
| 116 std::list<VideoBufferWithConfig> video_buffer_queue_; | |
| 117 | |
| 118 // Audio and Video decoder config of the last emitted buffers. | |
| 119 AudioDecoderConfig last_audio_config_; | |
| 120 VideoDecoderConfig last_video_config_; | |
| 121 | |
| 122 // Whether |init_cb_| has been invoked. | |
| 123 bool is_initialized_; | |
| 124 | |
| 125 // Indicate whether a segment was started. | |
| 126 bool segment_started_; | |
| 127 bool first_video_frame_in_segment_; | |
| 128 base::TimeDelta time_offset_; | |
| 129 | |
| 130 DISALLOW_COPY_AND_ASSIGN(Mp2tStreamParser); | |
| 131 }; | |
| 132 | |
| 133 } // namespace mp2t | |
| 134 } // namespace media | |
| 135 | |
| 136 #endif | |
| 137 | |
| OLD | NEW |