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

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

Powered by Google App Engine
This is Rietveld 408576698