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

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

Issue 14932020: Add Create() function to AudioCodecBridge and VideoCodecBridge to allow return of null pointers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 int MediaCodecBridge::GetOutputBuffers() { 270 int MediaCodecBridge::GetOutputBuffers() {
271 JNIEnv* env = AttachCurrentThread(); 271 JNIEnv* env = AttachCurrentThread();
272 272
273 j_output_buffers_.Reset( 273 j_output_buffers_.Reset(
274 JNI_MediaCodec::Java_MediaCodec_getOutputBuffers( 274 JNI_MediaCodec::Java_MediaCodec_getOutputBuffers(
275 env, j_media_codec_.obj())); 275 env, j_media_codec_.obj()));
276 276
277 return env->GetArrayLength(j_output_buffers_.obj()); 277 return env->GetArrayLength(j_output_buffers_.obj());
278 } 278 }
279 279
280 AudioCodecBridge::AudioCodecBridge(const AudioCodec codec) 280 AudioCodecBridge::AudioCodecBridge(const char* mime)
281 : MediaCodecBridge(AudioCodecToMimeType(codec)) { 281 : MediaCodecBridge(mime) {
282 } 282 }
283 283
284 bool AudioCodecBridge::Start( 284 bool AudioCodecBridge::Start(
285 const AudioCodec codec, int sample_rate, int channel_count, 285 const AudioCodec codec, int sample_rate, int channel_count,
286 const uint8* extra_data, size_t extra_data_size) { 286 const uint8* extra_data, size_t extra_data_size) {
287 JNIEnv* env = AttachCurrentThread(); 287 JNIEnv* env = AttachCurrentThread();
288 DCHECK(AudioCodecToMimeType(codec)); 288 DCHECK(AudioCodecToMimeType(codec));
289 289
290 ScopedJavaLocalRef<jstring> j_mime = 290 ScopedJavaLocalRef<jstring> j_mime =
291 ConvertUTF8ToJavaString(env, AudioCodecToMimeType(codec)); 291 ConvertUTF8ToJavaString(env, AudioCodecToMimeType(codec));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 env->DeleteLocalRef(codec_header); 343 env->DeleteLocalRef(codec_header);
344 env->DeleteLocalRef(identification_header); 344 env->DeleteLocalRef(identification_header);
345 } 345 }
346 346
347 JNI_MediaCodec::Java_MediaCodec_configure( 347 JNI_MediaCodec::Java_MediaCodec_configure(
348 env, media_codec(), j_format.obj(), NULL, NULL, 0); 348 env, media_codec(), j_format.obj(), NULL, NULL, 0);
349 StartInternal(); 349 StartInternal();
350 return true; 350 return true;
351 } 351 }
352 352
353 VideoCodecBridge::VideoCodecBridge(const VideoCodec codec) 353 VideoCodecBridge::VideoCodecBridge(const char* mime)
354 : MediaCodecBridge(VideoCodecToMimeType(codec)) { 354 : MediaCodecBridge(mime) {
355 } 355 }
356 356
357 bool VideoCodecBridge::Start( 357 bool VideoCodecBridge::Start(
358 const VideoCodec codec, const gfx::Size& size, jobject surface) { 358 const VideoCodec codec, const gfx::Size& size, jobject surface) {
359 JNIEnv* env = AttachCurrentThread(); 359 JNIEnv* env = AttachCurrentThread();
360 DCHECK(VideoCodecToMimeType(codec)); 360 DCHECK(VideoCodecToMimeType(codec));
361 361
362 ScopedJavaLocalRef<jstring> j_mime = 362 ScopedJavaLocalRef<jstring> j_mime =
363 ConvertUTF8ToJavaString(env, VideoCodecToMimeType(codec)); 363 ConvertUTF8ToJavaString(env, VideoCodecToMimeType(codec));
364 ScopedJavaLocalRef<jobject> j_format( 364 ScopedJavaLocalRef<jobject> j_format(
365 JNI_MediaFormat::Java_MediaFormat_createVideoFormat( 365 JNI_MediaFormat::Java_MediaFormat_createVideoFormat(
366 env, j_mime.obj(), size.width(), size.height())); 366 env, j_mime.obj(), size.width(), size.height()));
367 DCHECK(!j_format.is_null()); 367 DCHECK(!j_format.is_null());
368 JNI_MediaCodec::Java_MediaCodec_configure( 368 JNI_MediaCodec::Java_MediaCodec_configure(
369 env, media_codec(), j_format.obj(), surface, NULL, 0); 369 env, media_codec(), j_format.obj(), surface, NULL, 0);
370 StartInternal(); 370 StartInternal();
371 return true; 371 return true;
372 } 372 }
373 373
374 AudioCodecBridge* AudioCodecBridge::Create(
375 const AudioCodec codec) {
376 const char* mime = AudioCodecToMimeType(codec);
377 return mime ? new AudioCodecBridge(mime) : NULL;
378 }
379
380 VideoCodecBridge* VideoCodecBridge::Create(
381 const VideoCodec codec) {
382 const char* mime = VideoCodecToMimeType(codec);
383 return mime ? new VideoCodecBridge(mime) : NULL;
384 }
385
374 } // namespace media 386 } // namespace media
375 387
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698