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

Side by Side Diff: media/formats/mp2t/es_parser_adts.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.h ('k') | media/formats/mp2t/es_parser_adts.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_ES_PARSER_ADTS_H_ 5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "media/base/audio_decoder_config.h" 18 #include "media/base/audio_decoder_config.h"
19 #include "media/base/decrypt_config.h"
19 #include "media/base/media_export.h" 20 #include "media/base/media_export.h"
20 #include "media/formats/mp2t/es_parser.h" 21 #include "media/formats/mp2t/es_parser.h"
21 #include "media/formats/mpeg/adts_stream_parser.h" 22 #include "media/formats/mpeg/adts_stream_parser.h"
23 #include "media/media_features.h"
22 24
23 namespace media { 25 namespace media {
24 class AudioTimestampHelper; 26 class AudioTimestampHelper;
25 } 27 }
26 28
27 namespace media { 29 namespace media {
28 namespace mp2t { 30 namespace mp2t {
29 31
30 class MEDIA_EXPORT EsParserAdts : public EsParser { 32 class MEDIA_EXPORT EsParserAdts : public EsParser {
31 public: 33 public:
32 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; 34 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB;
33 35
34 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb, 36 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb,
35 const EmitBufferCB& emit_buffer_cb, 37 const EmitBufferCB& emit_buffer_cb,
36 bool sbr_in_mimetype); 38 bool sbr_in_mimetype);
39 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
40 EsParserAdts(const NewAudioConfigCB& new_audio_config_cb,
41 const EmitBufferCB& emit_buffer_cb,
42 const GetDecryptConfigCB& get_decrypt_config_cb,
43 bool use_hls_sample_aes,
44 bool sbr_in_mimetype);
45 #endif
46
37 ~EsParserAdts() override; 47 ~EsParserAdts() override;
38 48
39 // EsParser implementation. 49 // EsParser implementation.
40 void Flush() override; 50 void Flush() override;
41 51
42 private: 52 private:
43 struct AdtsFrame; 53 struct AdtsFrame;
44 54
45 // EsParser implementation. 55 // EsParser implementation.
46 bool ParseFromEsQueue() override; 56 bool ParseFromEsQueue() override;
47 void ResetInternal() override; 57 void ResetInternal() override;
48 58
49 // Synchronize the stream on an ADTS syncword (consuming bytes from 59 // Synchronize the stream on an ADTS syncword (consuming bytes from
50 // |es_queue_| if needed). 60 // |es_queue_| if needed).
51 // Returns true when a full ADTS frame has been found: in that case 61 // Returns true when a full ADTS frame has been found: in that case
52 // |adts_frame| structure is filled up accordingly. 62 // |adts_frame| structure is filled up accordingly.
53 // Returns false otherwise (no ADTS syncword found or partial ADTS frame). 63 // Returns false otherwise (no ADTS syncword found or partial ADTS frame).
54 bool LookForAdtsFrame(AdtsFrame* adts_frame); 64 bool LookForAdtsFrame(AdtsFrame* adts_frame);
55 65
56 // Skip an ADTS frame in the ES queue. 66 // Skip an ADTS frame in the ES queue.
57 void SkipAdtsFrame(const AdtsFrame& adts_frame); 67 void SkipAdtsFrame(const AdtsFrame& adts_frame);
58 68
59 // Signal any audio configuration change (if any). 69 // Signal any audio configuration change (if any).
60 // Return false if the current audio config is not 70 // Return false if the current audio config is not
61 // a supported ADTS audio config. 71 // a supported ADTS audio config.
62 bool UpdateAudioConfiguration(const uint8_t* adts_header, int size); 72 bool UpdateAudioConfiguration(const uint8_t* adts_header, int size);
63 73
74 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
75 void CalculateSubsamplesForAdtsFrame(const AdtsFrame& adts_frame,
76 std::vector<SubsampleEntry>* subsamples);
77 #endif
78
64 // Callbacks: 79 // Callbacks:
65 // - to signal a new audio configuration, 80 // - to signal a new audio configuration,
66 // - to send ES buffers. 81 // - to send ES buffers.
67 NewAudioConfigCB new_audio_config_cb_; 82 NewAudioConfigCB new_audio_config_cb_;
68 EmitBufferCB emit_buffer_cb_; 83 EmitBufferCB emit_buffer_cb_;
84 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
85 // - to obtain the current decrypt_config. Only called if use_hls_sample_aes_.
86 GetDecryptConfigCB get_decrypt_config_cb_;
87 bool use_hls_sample_aes_;
88 #endif
69 89
70 // True when AAC SBR extension is signalled in the mimetype 90 // True when AAC SBR extension is signalled in the mimetype
71 // (mp4a.40.5 in the codecs parameter). 91 // (mp4a.40.5 in the codecs parameter).
72 bool sbr_in_mimetype_; 92 bool sbr_in_mimetype_;
73 93
74 // Interpolated PTS for frames that don't have one. 94 // Interpolated PTS for frames that don't have one.
75 std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_; 95 std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
76 96
77 // Last audio config. 97 // Last audio config.
78 AudioDecoderConfig last_audio_decoder_config_; 98 AudioDecoderConfig last_audio_decoder_config_;
79 99
80 ADTSStreamParser adts_parser_; 100 ADTSStreamParser adts_parser_;
81 101
82 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); 102 DISALLOW_COPY_AND_ASSIGN(EsParserAdts);
83 }; 103 };
84 104
85 } // namespace mp2t 105 } // namespace mp2t
86 } // namespace media 106 } // namespace media
87 107
88 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ 108 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser.h ('k') | media/formats/mp2t/es_parser_adts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698