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

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

Issue 23480036: Support creating secure decoder in MediaCodecBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/media_codec_bridge.h" 5 #include "media/base/android/media_codec_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/android/build_info.h" 10 #include "base/android/build_info.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // static 81 // static
82 bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) { 82 bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) {
83 JNIEnv* env = AttachCurrentThread(); 83 JNIEnv* env = AttachCurrentThread();
84 std::string mime = CodecTypeToMimeType(codec); 84 std::string mime = CodecTypeToMimeType(codec);
85 if (mime.empty()) 85 if (mime.empty())
86 return false; 86 return false;
87 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); 87 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime);
88 return !Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure).is_null(); 88 return !Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure).is_null();
89 } 89 }
90 90
91 // TODO(xhwang): Support creating secure MediaCodecBridge. 91 MediaCodecBridge::MediaCodecBridge(const std::string& mime, bool is_secure) {
92 MediaCodecBridge::MediaCodecBridge(const std::string& mime) {
93 JNIEnv* env = AttachCurrentThread(); 92 JNIEnv* env = AttachCurrentThread();
94 CHECK(env); 93 CHECK(env);
95 94
96 DCHECK(!mime.empty()); 95 DCHECK(!mime.empty());
97 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); 96 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime);
98 j_media_codec_.Reset(Java_MediaCodecBridge_create(env, j_mime.obj(), false)); 97 j_media_codec_.Reset(
98 Java_MediaCodecBridge_create(env, j_mime.obj(), is_secure));
99 } 99 }
100 100
101 MediaCodecBridge::~MediaCodecBridge() { 101 MediaCodecBridge::~MediaCodecBridge() {
102 JNIEnv* env = AttachCurrentThread(); 102 JNIEnv* env = AttachCurrentThread();
103 CHECK(env); 103 CHECK(env);
104 if (j_media_codec_.obj()) 104 if (j_media_codec_.obj())
105 Java_MediaCodecBridge_release(env, j_media_codec_.obj()); 105 Java_MediaCodecBridge_release(env, j_media_codec_.obj());
106 } 106 }
107 107
108 void MediaCodecBridge::StartInternal() { 108 void MediaCodecBridge::StartInternal() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // TODO(qinmin): Handling the case that not all the data can be copied. 235 // TODO(qinmin): Handling the case that not all the data can be copied.
236 DCHECK(size_to_copy == size) << 236 DCHECK(size_to_copy == size) <<
237 "Failed to fill all the data into the input buffer. Size to fill: " 237 "Failed to fill all the data into the input buffer. Size to fill: "
238 << size << ". Size filled: " << size_to_copy; 238 << size << ". Size filled: " << size_to_copy;
239 if (size_to_copy > 0) 239 if (size_to_copy > 0)
240 memcpy(direct_buffer, data, size_to_copy); 240 memcpy(direct_buffer, data, size_to_copy);
241 return size_to_copy; 241 return size_to_copy;
242 } 242 }
243 243
244 AudioCodecBridge::AudioCodecBridge(const std::string& mime) 244 AudioCodecBridge::AudioCodecBridge(const std::string& mime)
245 : MediaCodecBridge(mime) { 245 // Audio codec doesn't care about security level.
246 : MediaCodecBridge(mime, false) {
246 } 247 }
247 248
248 bool AudioCodecBridge::Start( 249 bool AudioCodecBridge::Start(
249 const AudioCodec codec, int sample_rate, int channel_count, 250 const AudioCodec codec, int sample_rate, int channel_count,
250 const uint8* extra_data, size_t extra_data_size, bool play_audio, 251 const uint8* extra_data, size_t extra_data_size, bool play_audio,
251 jobject media_crypto) { 252 jobject media_crypto) {
252 JNIEnv* env = AttachCurrentThread(); 253 JNIEnv* env = AttachCurrentThread();
253 254
254 if (!media_codec()) 255 if (!media_codec())
255 return false; 256 return false;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 base::android::ToJavaByteArray(env, buffer, numBytes); 394 base::android::ToJavaByteArray(env, buffer, numBytes);
394 Java_MediaCodecBridge_playOutputBuffer( 395 Java_MediaCodecBridge_playOutputBuffer(
395 env, media_codec(), byte_array.obj()); 396 env, media_codec(), byte_array.obj());
396 } 397 }
397 398
398 void AudioCodecBridge::SetVolume(double volume) { 399 void AudioCodecBridge::SetVolume(double volume) {
399 JNIEnv* env = AttachCurrentThread(); 400 JNIEnv* env = AttachCurrentThread();
400 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); 401 Java_MediaCodecBridge_setVolume(env, media_codec(), volume);
401 } 402 }
402 403
403 VideoCodecBridge::VideoCodecBridge(const std::string& mime) 404 VideoCodecBridge::VideoCodecBridge(const std::string& mime, bool is_secure)
404 : MediaCodecBridge(mime) { 405 : MediaCodecBridge(mime, is_secure) {
405 } 406 }
406 407
407 bool VideoCodecBridge::Start( 408 bool VideoCodecBridge::Start(
408 const VideoCodec codec, const gfx::Size& size, jobject surface, 409 const VideoCodec codec, const gfx::Size& size, jobject surface,
409 jobject media_crypto) { 410 jobject media_crypto) {
410 JNIEnv* env = AttachCurrentThread(); 411 JNIEnv* env = AttachCurrentThread();
411 412
412 if (!media_codec()) 413 if (!media_codec())
413 return false; 414 return false;
414 415
(...skipping 13 matching lines...) Expand all
428 } 429 }
429 StartInternal(); 430 StartInternal();
430 return true; 431 return true;
431 } 432 }
432 433
433 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec codec) { 434 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec codec) {
434 const std::string mime = AudioCodecToMimeType(codec); 435 const std::string mime = AudioCodecToMimeType(codec);
435 return mime.empty() ? NULL : new AudioCodecBridge(mime); 436 return mime.empty() ? NULL : new AudioCodecBridge(mime);
436 } 437 }
437 438
438 VideoCodecBridge* VideoCodecBridge::Create(const VideoCodec codec) { 439 VideoCodecBridge* VideoCodecBridge::Create(const VideoCodec codec,
440 bool is_secure) {
439 const std::string mime = VideoCodecToMimeType(codec); 441 const std::string mime = VideoCodecToMimeType(codec);
440 return mime.empty() ? NULL : new VideoCodecBridge(mime); 442 return mime.empty() ? NULL : new VideoCodecBridge(mime, is_secure);
441 } 443 }
442 444
443 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { 445 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) {
444 return RegisterNativesImpl(env); 446 return RegisterNativesImpl(env);
445 } 447 }
446 448
447 } // namespace media 449 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_codec_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698