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

Side by Side Diff: media/formats/mp2t/mp2t_stream_parser.h

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: rebase Created 4 years 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 unified diff | Download patch
« no previous file with comments | « media/formats/mp2t/es_parser_h264.cc ('k') | media/formats/mp2t/mp2t_stream_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/media_export.h" 19 #include "media/base/media_export.h"
19 #include "media/base/stream_parser.h" 20 #include "media/base/stream_parser.h"
20 #include "media/base/video_decoder_config.h" 21 #include "media/base/video_decoder_config.h"
21 #include "media/formats/mp2t/timestamp_unroller.h" 22 #include "media/formats/mp2t/timestamp_unroller.h"
23 #include "media/media_features.h"
22 24
23 namespace media { 25 namespace media {
24 26
27 class DecryptConfig;
25 class StreamParserBuffer; 28 class StreamParserBuffer;
26 29
27 namespace mp2t { 30 namespace mp2t {
28 31
32 class Descriptors;
29 class PidState; 33 class PidState;
30 34
31 class MEDIA_EXPORT Mp2tStreamParser : public StreamParser { 35 class MEDIA_EXPORT Mp2tStreamParser : public StreamParser {
32 public: 36 public:
33 explicit Mp2tStreamParser(bool sbr_in_mimetype); 37 explicit Mp2tStreamParser(bool sbr_in_mimetype);
34 ~Mp2tStreamParser() override; 38 ~Mp2tStreamParser() override;
35 39
36 // StreamParser implementation. 40 // StreamParser implementation.
37 void Init(const InitCB& init_cb, 41 void Init(const InitCB& init_cb,
38 const NewConfigCB& config_cb, 42 const NewConfigCB& config_cb,
(...skipping 22 matching lines...) Expand all
61 }; 65 };
62 66
63 // Callback invoked to register a Program Map Table. 67 // Callback invoked to register a Program Map Table.
64 // Note: Does nothing if the PID is already registered. 68 // Note: Does nothing if the PID is already registered.
65 void RegisterPmt(int program_number, int pmt_pid); 69 void RegisterPmt(int program_number, int pmt_pid);
66 70
67 // Callback invoked to register a PES pid. 71 // Callback invoked to register a PES pid.
68 // Possible values for |stream_type| are defined in: 72 // Possible values for |stream_type| are defined in:
69 // ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments". 73 // ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments".
70 // |pes_pid| is part of the Program Map Table refered by |pmt_pid|. 74 // |pes_pid| is part of the Program Map Table refered by |pmt_pid|.
71 void RegisterPes(int pmt_pid, int pes_pid, int stream_type); 75 // Some stream types are qualified by additional |descriptors|.
76 void RegisterPes(int pmt_pid,
77 int pes_pid,
78 int stream_type,
79 const Descriptors& descriptors);
72 80
73 // Since the StreamParser interface allows only one audio & video streams, 81 // Since the StreamParser interface allows only one audio & video streams,
74 // an automatic PID filtering should be applied to select the audio & video 82 // an automatic PID filtering should be applied to select the audio & video
75 // streams. 83 // streams.
76 void UpdatePidFilter(); 84 void UpdatePidFilter();
77 85
78 // Callback invoked each time the audio/video decoder configuration is 86 // Callback invoked each time the audio/video decoder configuration is
79 // changed. 87 // changed.
80 void OnVideoConfigChanged(int pes_pid, 88 void OnVideoConfigChanged(int pes_pid,
81 const VideoDecoderConfig& video_decoder_config); 89 const VideoDecoderConfig& video_decoder_config);
82 void OnAudioConfigChanged(int pes_pid, 90 void OnAudioConfigChanged(int pes_pid,
83 const AudioDecoderConfig& audio_decoder_config); 91 const AudioDecoderConfig& audio_decoder_config);
84 92
85 // Invoke the initialization callback if needed. 93 // Invoke the initialization callback if needed.
86 bool FinishInitializationIfNeeded(); 94 bool FinishInitializationIfNeeded();
87 95
88 // Callback invoked by the ES stream parser 96 // Callback invoked by the ES stream parser
89 // to emit a new audio/video access unit. 97 // to emit a new audio/video access unit.
90 void OnEmitAudioBuffer( 98 void OnEmitAudioBuffer(
91 int pes_pid, 99 int pes_pid,
92 scoped_refptr<StreamParserBuffer> stream_parser_buffer); 100 scoped_refptr<StreamParserBuffer> stream_parser_buffer);
93 void OnEmitVideoBuffer( 101 void OnEmitVideoBuffer(
94 int pes_pid, 102 int pes_pid,
95 scoped_refptr<StreamParserBuffer> stream_parser_buffer); 103 scoped_refptr<StreamParserBuffer> stream_parser_buffer);
96 bool EmitRemainingBuffers(); 104 bool EmitRemainingBuffers();
97 105
106 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
107 std::unique_ptr<PidState> MakeCatPidState();
108 void UnregisterCat();
109
110 // Register the PIDs for the Cenc packets (CENC-ECM and CENC-PSSH).
111 void RegisterCencPids(int ca_pid, int pssh_pid);
112 void UnregisterCencPids();
113
114 // Register the DecryptConfig (parsed from CENC-ECM).
115 void RegisterDecryptConfig(const DecryptConfig& config);
116
117 // Register the PSSH (parsed from CENC-PSSH).
118 void RegisterPsshBoxes(const std::vector<uint8_t>& init_data);
119
120 const DecryptConfig* GetDecryptConfig() { return decrypt_config_.get(); }
121 #endif
122
98 // List of callbacks. 123 // List of callbacks.
99 InitCB init_cb_; 124 InitCB init_cb_;
100 NewConfigCB config_cb_; 125 NewConfigCB config_cb_;
101 NewBuffersCB new_buffers_cb_; 126 NewBuffersCB new_buffers_cb_;
102 EncryptedMediaInitDataCB encrypted_media_init_data_cb_; 127 EncryptedMediaInitDataCB encrypted_media_init_data_cb_;
103 NewMediaSegmentCB new_segment_cb_; 128 NewMediaSegmentCB new_segment_cb_;
104 EndMediaSegmentCB end_of_segment_cb_; 129 EndMediaSegmentCB end_of_segment_cb_;
105 scoped_refptr<MediaLog> media_log_; 130 scoped_refptr<MediaLog> media_log_;
106 131
107 // True when AAC SBR extension is signalled in the mimetype 132 // True when AAC SBR extension is signalled in the mimetype
(...skipping 17 matching lines...) Expand all
125 bool is_initialized_; 150 bool is_initialized_;
126 151
127 // Indicate whether a segment was started. 152 // Indicate whether a segment was started.
128 bool segment_started_; 153 bool segment_started_;
129 154
130 // Timestamp unroller. 155 // Timestamp unroller.
131 // Timestamps in PES packets must be unrolled using the same offset. 156 // Timestamps in PES packets must be unrolled using the same offset.
132 // So the unroller is global between PES pids. 157 // So the unroller is global between PES pids.
133 TimestampUnroller timestamp_unroller_; 158 TimestampUnroller timestamp_unroller_;
134 159
160 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
161 std::unique_ptr<DecryptConfig> decrypt_config_;
162 #endif
163
135 DISALLOW_COPY_AND_ASSIGN(Mp2tStreamParser); 164 DISALLOW_COPY_AND_ASSIGN(Mp2tStreamParser);
136 }; 165 };
137 166
138 } // namespace mp2t 167 } // namespace mp2t
139 } // namespace media 168 } // namespace media
140 169
141 #endif // MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_ 170 #endif // MEDIA_FORMATS_MP2T_MP2T_STREAM_PARSER_H_
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_h264.cc ('k') | media/formats/mp2t/mp2t_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698