OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ |
6 #define MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ | 6 #define MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "media/base/audio_decoder_config.h" | 16 #include "media/base/audio_decoder_config.h" |
17 #include "media/base/byte_queue.h" | 17 #include "media/base/byte_queue.h" |
18 #include "media/base/decrypt_config.h" | 18 #include "media/base/decrypt_config.h" |
19 #include "media/base/encryption_scheme.h" | |
19 #include "media/base/media_export.h" | 20 #include "media/base/media_export.h" |
20 #include "media/base/stream_parser.h" | 21 #include "media/base/stream_parser.h" |
21 #include "media/base/video_decoder_config.h" | 22 #include "media/base/video_decoder_config.h" |
22 #include "media/formats/mp2t/timestamp_unroller.h" | 23 #include "media/formats/mp2t/timestamp_unroller.h" |
23 #include "media/media_features.h" | 24 #include "media/media_features.h" |
24 | 25 |
25 namespace media { | 26 namespace media { |
26 | 27 |
27 class DecryptConfig; | 28 class DecryptConfig; |
28 class StreamParserBuffer; | 29 class StreamParserBuffer; |
29 | 30 |
30 namespace mp2t { | 31 namespace mp2t { |
31 | 32 |
32 class Descriptors; | 33 class Descriptors; |
34 class EsParser; | |
33 class PidState; | 35 class PidState; |
34 | 36 |
35 class MEDIA_EXPORT Mp2tStreamParser : public StreamParser { | 37 class MEDIA_EXPORT Mp2tStreamParser : public StreamParser { |
36 public: | 38 public: |
37 explicit Mp2tStreamParser(bool sbr_in_mimetype); | 39 explicit Mp2tStreamParser(bool sbr_in_mimetype); |
38 ~Mp2tStreamParser() override; | 40 ~Mp2tStreamParser() override; |
39 | 41 |
40 // StreamParser implementation. | 42 // StreamParser implementation. |
41 void Init(const InitCB& init_cb, | 43 void Init(const InitCB& init_cb, |
42 const NewConfigCB& config_cb, | 44 const NewConfigCB& config_cb, |
(...skipping 21 matching lines...) Expand all Loading... | |
64 StreamParser::BufferQueue video_queue; | 66 StreamParser::BufferQueue video_queue; |
65 }; | 67 }; |
66 | 68 |
67 // Callback invoked to register a Program Map Table. | 69 // Callback invoked to register a Program Map Table. |
68 // Note: Does nothing if the PID is already registered. | 70 // Note: Does nothing if the PID is already registered. |
69 void RegisterPmt(int program_number, int pmt_pid); | 71 void RegisterPmt(int program_number, int pmt_pid); |
70 | 72 |
71 // Callback invoked to register a PES pid. | 73 // Callback invoked to register a PES pid. |
72 // Possible values for |stream_type| are defined in: | 74 // Possible values for |stream_type| are defined in: |
73 // ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments". | 75 // ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments". |
74 // |pes_pid| is part of the Program Map Table refered by |pmt_pid|. | 76 // |pes_pid| is part of the Program Map Table.. |
servolk
2017/04/04 20:08:18
nit: extra dot at the end
dougsteed
2017/04/26 20:34:14
Done.
| |
75 // Some stream types are qualified by additional |descriptors|. | 77 // Some stream types are qualified by additional |descriptors|. |
76 void RegisterPes(int pmt_pid, | 78 void RegisterPes(int pes_pid, |
77 int pes_pid, | |
78 int stream_type, | 79 int stream_type, |
79 const Descriptors& descriptors); | 80 const Descriptors& descriptors); |
80 | 81 |
81 // Since the StreamParser interface allows only one audio & video streams, | 82 // Since the StreamParser interface allows only one audio & video streams, |
82 // an automatic PID filtering should be applied to select the audio & video | 83 // an automatic PID filtering should be applied to select the audio & video |
83 // streams. | 84 // streams. |
84 void UpdatePidFilter(); | 85 void UpdatePidFilter(); |
85 | 86 |
86 // Callback invoked each time the audio/video decoder configuration is | 87 // Callback invoked each time the audio/video decoder configuration is |
87 // changed. | 88 // changed. |
88 void OnVideoConfigChanged(int pes_pid, | 89 void OnVideoConfigChanged(int pes_pid, |
89 const VideoDecoderConfig& video_decoder_config); | 90 const VideoDecoderConfig& video_decoder_config); |
90 void OnAudioConfigChanged(int pes_pid, | 91 void OnAudioConfigChanged(int pes_pid, |
91 const AudioDecoderConfig& audio_decoder_config); | 92 const AudioDecoderConfig& audio_decoder_config); |
92 | 93 |
93 // Invoke the initialization callback if needed. | 94 // Invoke the initialization callback if needed. |
94 bool FinishInitializationIfNeeded(); | 95 bool FinishInitializationIfNeeded(); |
95 | 96 |
96 // Callback invoked by the ES stream parser | 97 // Callback invoked by the ES stream parser |
97 // to emit a new audio/video access unit. | 98 // to emit a new audio/video access unit. |
98 void OnEmitAudioBuffer( | 99 void OnEmitAudioBuffer( |
99 int pes_pid, | 100 int pes_pid, |
100 scoped_refptr<StreamParserBuffer> stream_parser_buffer); | 101 scoped_refptr<StreamParserBuffer> stream_parser_buffer); |
101 void OnEmitVideoBuffer( | 102 void OnEmitVideoBuffer( |
102 int pes_pid, | 103 int pes_pid, |
103 scoped_refptr<StreamParserBuffer> stream_parser_buffer); | 104 scoped_refptr<StreamParserBuffer> stream_parser_buffer); |
104 bool EmitRemainingBuffers(); | 105 bool EmitRemainingBuffers(); |
105 | 106 |
107 // Functions used to test stream type and create parsers as appropriate. | |
108 std::unique_ptr<EsParser> MaybeCreateH264Parser( | |
109 int pes_pid, | |
110 int stream_type, | |
111 const Descriptors& descriptors); | |
112 std::unique_ptr<EsParser> MaybeCreateAACParser( | |
113 int pes_pid, | |
114 int stream_type, | |
115 const Descriptors& descriptors); | |
116 std::unique_ptr<EsParser> MaybeCreateMpeg1AudioParser(int pes_pid, | |
117 int stream_type); | |
118 | |
106 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) | 119 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) |
107 std::unique_ptr<PidState> MakeCatPidState(); | 120 std::unique_ptr<PidState> MakeCatPidState(); |
108 void UnregisterCat(); | 121 void UnregisterCat(); |
109 | 122 |
110 // Register the PIDs for the Cenc packets (CENC-ECM and CENC-PSSH). | 123 // Register the PIDs for the Cenc packets (CENC-ECM and CENC-PSSH). |
111 void RegisterCencPids(int ca_pid, int pssh_pid); | 124 void RegisterCencPids(int ca_pid, int pssh_pid); |
112 void UnregisterCencPids(); | 125 void UnregisterCencPids(); |
113 | 126 |
127 // Register a default encryption scheme to be used for decoder configs. This | |
128 // value is only used in the absence of explicit encryption metadata, as might | |
129 // be the case during an unencrypted portion of a live stream. | |
130 void RegisterEncryptionScheme(const EncryptionScheme& scheme); | |
131 | |
114 // Register the DecryptConfig (parsed from CENC-ECM). | 132 // Register the DecryptConfig (parsed from CENC-ECM). |
115 void RegisterDecryptConfig(const DecryptConfig& config); | 133 void RegisterDecryptConfig(const DecryptConfig& config); |
116 | 134 |
117 // Register the PSSH (parsed from CENC-PSSH). | 135 // Register the PSSH (parsed from CENC-PSSH). |
118 void RegisterPsshBoxes(const std::vector<uint8_t>& init_data); | 136 void RegisterPsshBoxes(const std::vector<uint8_t>& init_data); |
119 | 137 |
120 const DecryptConfig* GetDecryptConfig() { return decrypt_config_.get(); } | 138 const DecryptConfig* GetDecryptConfig() { return decrypt_config_.get(); } |
121 #endif | 139 #endif |
122 | 140 |
123 // List of callbacks. | 141 // List of callbacks. |
(...skipping 27 matching lines...) Expand all Loading... | |
151 | 169 |
152 // Indicate whether a segment was started. | 170 // Indicate whether a segment was started. |
153 bool segment_started_; | 171 bool segment_started_; |
154 | 172 |
155 // Timestamp unroller. | 173 // Timestamp unroller. |
156 // Timestamps in PES packets must be unrolled using the same offset. | 174 // Timestamps in PES packets must be unrolled using the same offset. |
157 // So the unroller is global between PES pids. | 175 // So the unroller is global between PES pids. |
158 TimestampUnroller timestamp_unroller_; | 176 TimestampUnroller timestamp_unroller_; |
159 | 177 |
160 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) | 178 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) |
179 EncryptionScheme initial_scheme_; | |
161 std::unique_ptr<DecryptConfig> decrypt_config_; | 180 std::unique_ptr<DecryptConfig> decrypt_config_; |
162 #endif | 181 #endif |
163 | 182 |
164 DISALLOW_COPY_AND_ASSIGN(Mp2tStreamParser); | 183 DISALLOW_COPY_AND_ASSIGN(Mp2tStreamParser); |
165 }; | 184 }; |
166 | 185 |
167 } // namespace mp2t | 186 } // namespace mp2t |
168 } // namespace media | 187 } // namespace media |
169 | 188 |
170 #endif // MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ | 189 #endif // MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ |
OLD | NEW |