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