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

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: 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
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>
11 11
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/native_library.h" 14 #include "base/native_library.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "media/base/encryption_scheme.h"
16 #include "media/base/subsample_entry.h" 17 #include "media/base/subsample_entry.h"
17 18
18 namespace { 19 namespace {
19 const char kMediaFormatKeyCropLeft[] = "crop-left"; 20 const char kMediaFormatKeyCropLeft[] = "crop-left";
20 const char kMediaFormatKeyCropRight[] = "crop-right"; 21 const char kMediaFormatKeyCropRight[] = "crop-right";
21 const char kMediaFormatKeyCropBottom[] = "crop-bottom"; 22 const char kMediaFormatKeyCropBottom[] = "crop-bottom";
22 const char kMediaFormatKeyCropTop[] = "crop-top"; 23 const char kMediaFormatKeyCropTop[] = "crop-top";
23 } 24 }
24 25
25 namespace media { 26 namespace media {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 130 }
130 131
131 MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer( 132 MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer(
132 int index, 133 int index,
133 const uint8_t* data, 134 const uint8_t* data,
134 size_t data_size, 135 size_t data_size,
135 const std::vector<char>& key_id, 136 const std::vector<char>& key_id,
136 const std::vector<char>& iv, 137 const std::vector<char>& iv,
137 const SubsampleEntry* subsamples, 138 const SubsampleEntry* subsamples,
138 int subsamples_size, 139 int subsamples_size,
140 const EncryptionScheme& encryption_scheme,
139 base::TimeDelta presentation_time) { 141 base::TimeDelta presentation_time) {
140 if (data_size > 142 if (data_size >
141 base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) { 143 base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) {
142 return MEDIA_CODEC_ERROR; 144 return MEDIA_CODEC_ERROR;
143 } 145 }
144 if (key_id.size() > 16 || iv.size()) 146 if (key_id.size() > 16 || iv.size())
145 return MEDIA_CODEC_ERROR; 147 return MEDIA_CODEC_ERROR;
146 if (data && !FillInputBuffer(index, data, data_size)) 148 if (data && !FillInputBuffer(index, data, data_size))
147 return MEDIA_CODEC_ERROR; 149 return MEDIA_CODEC_ERROR;
150 if (encryption_scheme.mode() != EncryptionScheme::CIPHER_MODE_AES_CTR ||
151 encryption_scheme.pattern().IsInEffect())
152 return MEDIA_CODEC_ERROR;
148 153
149 int new_subsamples_size = subsamples_size == 0 ? 1 : subsamples_size; 154 int new_subsamples_size = subsamples_size == 0 ? 1 : subsamples_size;
150 std::vector<size_t> clear_data, encrypted_data; 155 std::vector<size_t> clear_data, encrypted_data;
151 if (subsamples_size == 0) { 156 if (subsamples_size == 0) {
152 DCHECK(!subsamples); 157 DCHECK(!subsamples);
153 clear_data.push_back(0); 158 clear_data.push_back(0);
154 encrypted_data.push_back(data_size); 159 encrypted_data.push_back(data_size);
155 } else { 160 } else {
156 DCHECK_GT(subsamples_size, 0); 161 DCHECK_GT(subsamples_size, 0);
157 DCHECK(subsamples); 162 DCHECK(subsamples);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return MEDIA_CODEC_OK; 254 return MEDIA_CODEC_OK;
250 } 255 }
251 256
252 std::string NdkMediaCodecBridge::GetName() { 257 std::string NdkMediaCodecBridge::GetName() {
253 // The NDK api doesn't expose a getName like the Java one. 258 // The NDK api doesn't expose a getName like the Java one.
254 NOTIMPLEMENTED(); 259 NOTIMPLEMENTED();
255 return ""; 260 return "";
256 } 261 }
257 262
258 } // namespace media 263 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698