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

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

Issue 1651673002: Add MediaCodecAudioDecoder implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A better linking issue fix Created 4 years, 10 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
« no previous file with comments | « media/base/android/sdk_media_codec_bridge.h ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sdk_media_codec_bridge.h" 5 #include "media/base/android/sdk_media_codec_bridge.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 bool AudioCodecBridge::IsKnownUnaccelerated(const AudioCodec& codec) { 327 bool AudioCodecBridge::IsKnownUnaccelerated(const AudioCodec& codec) {
328 return MediaCodecUtil::IsKnownUnaccelerated( 328 return MediaCodecUtil::IsKnownUnaccelerated(
329 AudioCodecToAndroidMimeType(codec), MEDIA_CODEC_DECODER); 329 AudioCodecToAndroidMimeType(codec), MEDIA_CODEC_DECODER);
330 } 330 }
331 331
332 AudioCodecBridge::AudioCodecBridge(const std::string& mime) 332 AudioCodecBridge::AudioCodecBridge(const std::string& mime)
333 // Audio codec doesn't care about security level and there is no need for 333 // Audio codec doesn't care about security level and there is no need for
334 // audio encoding yet. 334 // audio encoding yet.
335 : SdkMediaCodecBridge(mime, false, MEDIA_CODEC_DECODER) {} 335 : SdkMediaCodecBridge(mime, false, MEDIA_CODEC_DECODER) {}
336 336
337 bool AudioCodecBridge::ConfigureAndStart(const AudioDecoderConfig& config,
338 bool play_audio,
339 jobject media_crypto) {
340 const int channel_count =
341 ChannelLayoutToChannelCount(config.channel_layout());
342 const int64_t codec_delay_ns = base::Time::kNanosecondsPerSecond *
343 config.codec_delay() /
344 config.samples_per_second();
345 const int64_t seek_preroll_ns =
346 1000LL * config.seek_preroll().InMicroseconds();
347
348 return ConfigureAndStart(config.codec(), config.samples_per_second(),
349 channel_count, config.extra_data().data(),
350 config.extra_data().size(), codec_delay_ns,
351 seek_preroll_ns, play_audio, media_crypto);
352 }
353
337 bool AudioCodecBridge::ConfigureAndStart(const AudioCodec& codec, 354 bool AudioCodecBridge::ConfigureAndStart(const AudioCodec& codec,
338 int sample_rate, 355 int sample_rate,
339 int channel_count, 356 int channel_count,
340 const uint8_t* extra_data, 357 const uint8_t* extra_data,
341 size_t extra_data_size, 358 size_t extra_data_size,
342 int64_t codec_delay_ns, 359 int64_t codec_delay_ns,
343 int64_t seek_preroll_ns, 360 int64_t seek_preroll_ns,
344 bool play_audio, 361 bool play_audio,
345 jobject media_crypto) { 362 jobject media_crypto) {
346 JNIEnv* env = AttachCurrentThread(); 363 DVLOG(2) << __FUNCTION__ << ": "
364 << " codec:" << GetCodecName(codec)
365 << " samples_per_second:" << sample_rate
366 << " channel_count:" << channel_count
367 << " codec_delay_ns:" << codec_delay_ns
368 << " seek_preroll_ns:" << seek_preroll_ns
369 << " extra data size:" << extra_data_size
370 << " play audio:" << play_audio << " media_crypto:" << media_crypto;
347 371
348 if (!media_codec()) 372 if (!media_codec())
349 return false; 373 return false;
350 374
351 std::string codec_string = AudioCodecToAndroidMimeType(codec); 375 std::string codec_string = AudioCodecToAndroidMimeType(codec);
352 if (codec_string.empty()) 376 if (codec_string.empty())
353 return false; 377 return false;
354 378
379 JNIEnv* env = AttachCurrentThread();
380
355 ScopedJavaLocalRef<jstring> j_mime = 381 ScopedJavaLocalRef<jstring> j_mime =
356 ConvertUTF8ToJavaString(env, codec_string); 382 ConvertUTF8ToJavaString(env, codec_string);
357 ScopedJavaLocalRef<jobject> j_format(Java_MediaCodecBridge_createAudioFormat( 383 ScopedJavaLocalRef<jobject> j_format(Java_MediaCodecBridge_createAudioFormat(
358 env, j_mime.obj(), sample_rate, channel_count)); 384 env, j_mime.obj(), sample_rate, channel_count));
359 DCHECK(!j_format.is_null()); 385 DCHECK(!j_format.is_null());
360 386
361 if (!ConfigureMediaFormat(j_format.obj(), codec, extra_data, extra_data_size, 387 if (!ConfigureMediaFormat(j_format.obj(), codec, extra_data, extra_data_size,
362 codec_delay_ns, seek_preroll_ns)) { 388 codec_delay_ns, seek_preroll_ns)) {
363 return false; 389 return false;
364 } 390 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if (adaptive_playback_supported_for_testing_ == 0) 647 if (adaptive_playback_supported_for_testing_ == 0)
622 return false; 648 return false;
623 else if (adaptive_playback_supported_for_testing_ > 0) 649 else if (adaptive_playback_supported_for_testing_ > 0)
624 return true; 650 return true;
625 JNIEnv* env = AttachCurrentThread(); 651 JNIEnv* env = AttachCurrentThread();
626 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), 652 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(),
627 width, height); 653 width, height);
628 } 654 }
629 655
630 } // namespace media 656 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/sdk_media_codec_bridge.h ('k') | media/base/audio_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698