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

Side by Side Diff: media/formats/mpeg/adts_header_parser.cc

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: move some gn defs Created 4 years, 8 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "media/formats/mpeg/adts_header_parser.h" 5 #include "media/formats/mpeg/adts_header_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/audio_codecs.h" 10 #include "media/base/audio_codecs.h"
11 #include "media/base/audio_decoder_config.h" 11 #include "media/base/audio_decoder_config.h"
12 #include "media/base/encryption_scheme.h"
ddorwin 2016/04/12 00:40:48 Do you need this?
dougsteed 2016/05/08 23:18:45 Since I use "EncryptionScheme" explicitly in this
12 #include "media/base/media_util.h" 13 #include "media/base/media_util.h"
13 #include "media/base/sample_format.h" 14 #include "media/base/sample_format.h"
14 #include "media/formats/mpeg/adts_constants.h" 15 #include "media/formats/mpeg/adts_constants.h"
15 16
16 namespace media { 17 namespace media {
17 18
18 namespace { 19 namespace {
19 20
20 size_t ExtractAdtsFrequencyIndex(const uint8_t* adts_header) { 21 size_t ExtractAdtsFrequencyIndex(const uint8_t* adts_header) {
21 return ((adts_header[2] >> 2) & 0xf); 22 return ((adts_header[2] >> 2) & 0xf);
22 } 23 }
23 24
24 size_t ExtractAdtsChannelConfig(const uint8_t* adts_header) { 25 size_t ExtractAdtsChannelConfig(const uint8_t* adts_header) {
25 return (((adts_header[3] >> 6) & 0x3) | ((adts_header[2] & 0x1) << 2)); 26 return (((adts_header[3] >> 6) & 0x3) | ((adts_header[2] & 0x1) << 2));
26 } 27 }
27 28
28 } // namespace (anonymous) 29 } // namespace (anonymous)
29 30
30 bool ParseAdtsHeader(const uint8_t* adts_header, 31 bool ParseAdtsHeader(const uint8_t* adts_header,
31 bool is_sbr, 32 bool is_sbr,
33 const EncryptionScheme& scheme,
32 AudioDecoderConfig* config) { 34 AudioDecoderConfig* config) {
33 DCHECK(adts_header); 35 DCHECK(adts_header);
34 36
35 size_t frequency_index = ExtractAdtsFrequencyIndex(adts_header); 37 size_t frequency_index = ExtractAdtsFrequencyIndex(adts_header);
36 if (frequency_index >= kADTSFrequencyTableSize) { 38 if (frequency_index >= kADTSFrequencyTableSize) {
37 // Frequency index 13 & 14 are reserved 39 // Frequency index 13 & 14 are reserved
38 // while 15 means that the frequency is explicitly written 40 // while 15 means that the frequency is explicitly written
39 // (not supported). 41 // (not supported).
40 return false; 42 return false;
41 } 43 }
(...skipping 27 matching lines...) Expand all
69 (frequency_index << 7) + 71 (frequency_index << 7) +
70 // channel_configuration is [0..7], per early out above. 72 // channel_configuration is [0..7], per early out above.
71 (channel_configuration << 3)); 73 (channel_configuration << 3));
72 std::vector<uint8_t> extra_data; 74 std::vector<uint8_t> extra_data;
73 extra_data.push_back(static_cast<uint8_t>(extra_data_int >> 8)); 75 extra_data.push_back(static_cast<uint8_t>(extra_data_int >> 8));
74 extra_data.push_back(static_cast<uint8_t>(extra_data_int & 0xff)); 76 extra_data.push_back(static_cast<uint8_t>(extra_data_int & 0xff));
75 77
76 DCHECK(config); 78 DCHECK(config);
77 *config = AudioDecoderConfig(kCodecAAC, kSampleFormatS16, 79 *config = AudioDecoderConfig(kCodecAAC, kSampleFormatS16,
78 kADTSChannelLayoutTable[channel_configuration], 80 kADTSChannelLayoutTable[channel_configuration],
79 extended_samples_per_second, extra_data, 81 extended_samples_per_second, extra_data, scheme);
80 Unencrypted());
81 82
82 return true; 83 return true;
83 } 84 }
84 85
85 } // namespace media 86 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698