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

Side by Side Diff: media/base/android/ndk_media_codec_bridge.cc

Issue 2058113002: Add 'cbcs' encryption scheme support in Android media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/base/android/ndk_media_codec_bridge.h" 5 #include "media/base/android/ndk_media_codec_bridge.h"
6 6
7 #include <media/NdkMediaError.h> 7 #include <media/NdkMediaError.h>
8 #include <media/NdkMediaFormat.h> 8 #include <media/NdkMediaFormat.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer( 131 MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer(
132 int index, 132 int index,
133 const uint8_t* data, 133 const uint8_t* data,
134 size_t data_size, 134 size_t data_size,
135 const std::vector<char>& key_id, 135 const std::vector<char>& key_id,
136 const std::vector<char>& iv, 136 const std::vector<char>& iv,
137 const SubsampleEntry* subsamples, 137 const SubsampleEntry* subsamples,
138 int subsamples_size, 138 int subsamples_size,
139 const EncryptionScheme& encryption_scheme,
139 const base::TimeDelta& presentation_time) { 140 const base::TimeDelta& presentation_time) {
140 if (data_size > 141 if (data_size >
141 base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) { 142 base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) {
142 return MEDIA_CODEC_ERROR; 143 return MEDIA_CODEC_ERROR;
143 } 144 }
144 if (key_id.size() > 16 || iv.size()) 145 if (key_id.size() > 16 || iv.size())
145 return MEDIA_CODEC_ERROR; 146 return MEDIA_CODEC_ERROR;
146 if (data && !FillInputBuffer(index, data, data_size)) 147 if (data && !FillInputBuffer(index, data, data_size))
147 return MEDIA_CODEC_ERROR; 148 return MEDIA_CODEC_ERROR;
149 if (encryption_scheme.mode() != EncryptionScheme::CIPHER_MODE_AES_CTR ||
150 encryption_scheme.pattern().IsInEffect())
151 return MEDIA_CODEC_ERROR;
148 152
149 int new_subsamples_size = subsamples_size == 0 ? 1 : subsamples_size; 153 int new_subsamples_size = subsamples_size == 0 ? 1 : subsamples_size;
150 std::vector<size_t> clear_data, encrypted_data; 154 std::vector<size_t> clear_data, encrypted_data;
151 if (subsamples_size == 0) { 155 if (subsamples_size == 0) {
152 DCHECK(!subsamples); 156 DCHECK(!subsamples);
153 clear_data.push_back(0); 157 clear_data.push_back(0);
154 encrypted_data.push_back(data_size); 158 encrypted_data.push_back(data_size);
155 } else { 159 } else {
156 DCHECK_GT(subsamples_size, 0); 160 DCHECK_GT(subsamples_size, 0);
157 DCHECK(subsamples); 161 DCHECK(subsamples);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 const uint8_t** addr, 247 const uint8_t** addr,
244 size_t* capacity) { 248 size_t* capacity) {
245 const uint8_t* src_data = 249 const uint8_t* src_data =
246 AMediaCodec_getOutputBuffer(media_codec_.get(), index, capacity); 250 AMediaCodec_getOutputBuffer(media_codec_.get(), index, capacity);
247 *addr = src_data + offset; 251 *addr = src_data + offset;
248 *capacity -= offset; 252 *capacity -= offset;
249 return MEDIA_CODEC_OK; 253 return MEDIA_CODEC_OK;
250 } 254 }
251 255
252 } // namespace media 256 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698