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

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

Issue 2365103002: Send the h264 SPS and PPS configuration parameters to AVDA (Closed)
Patch Set: Fix array init syntax Created 4 years, 2 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 (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 <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 598 }
599 599
600 // static 600 // static
601 bool VideoCodecBridge::IsKnownUnaccelerated(const VideoCodec& codec, 601 bool VideoCodecBridge::IsKnownUnaccelerated(const VideoCodec& codec,
602 MediaCodecDirection direction) { 602 MediaCodecDirection direction) {
603 return MediaCodecUtil::IsKnownUnaccelerated( 603 return MediaCodecUtil::IsKnownUnaccelerated(
604 VideoCodecToAndroidMimeType(codec), direction); 604 VideoCodecToAndroidMimeType(codec), direction);
605 } 605 }
606 606
607 // static 607 // static
608 VideoCodecBridge* VideoCodecBridge::CreateDecoder(const VideoCodec& codec, 608 VideoCodecBridge* VideoCodecBridge::CreateDecoder(
609 bool is_secure, 609 const VideoCodec& codec,
610 const gfx::Size& size, 610 bool is_secure,
611 jobject surface, 611 const gfx::Size& size,
612 jobject media_crypto, 612 jobject surface,
613 bool allow_adaptive_playback, 613 jobject media_crypto,
614 bool require_software_codec) { 614 const std::vector<uint8_t>& csd0,
615 const std::vector<uint8_t>& csd1,
616 bool allow_adaptive_playback,
617 bool require_software_codec) {
615 if (!MediaCodecUtil::IsMediaCodecAvailable()) 618 if (!MediaCodecUtil::IsMediaCodecAvailable())
616 return nullptr; 619 return nullptr;
617 620
618 const std::string mime = VideoCodecToAndroidMimeType(codec); 621 const std::string mime = VideoCodecToAndroidMimeType(codec);
619 if (mime.empty()) 622 if (mime.empty())
620 return nullptr; 623 return nullptr;
621 624
622 std::unique_ptr<VideoCodecBridge> bridge(new VideoCodecBridge( 625 std::unique_ptr<VideoCodecBridge> bridge(new VideoCodecBridge(
623 mime, is_secure, MEDIA_CODEC_DECODER, require_software_codec)); 626 mime, is_secure, MEDIA_CODEC_DECODER, require_software_codec));
624 if (!bridge->media_codec()) 627 if (!bridge->media_codec())
625 return nullptr; 628 return nullptr;
626 629
627 JNIEnv* env = AttachCurrentThread(); 630 JNIEnv* env = AttachCurrentThread();
628 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); 631 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime);
629 ScopedJavaLocalRef<jobject> j_format( 632 ScopedJavaLocalRef<jobject> j_format(
630 Java_MediaCodecBridge_createVideoDecoderFormat(env, j_mime, size.width(), 633 Java_MediaCodecBridge_createVideoDecoderFormat(env, j_mime, size.width(),
631 size.height())); 634 size.height()));
632 DCHECK(!j_format.is_null()); 635 DCHECK(!j_format.is_null());
636
637 if (!csd0.empty()) {
638 ScopedJavaLocalRef<jbyteArray> j_csd0 =
639 base::android::ToJavaByteArray(env, csd0.data(), csd0.size());
640 Java_MediaCodecBridge_setCodecSpecificData(env, j_format, 0, j_csd0);
641 }
642
643 if (!csd1.empty()) {
644 ScopedJavaLocalRef<jbyteArray> j_csd1 =
645 base::android::ToJavaByteArray(env, csd1.data(), csd1.size());
646 Java_MediaCodecBridge_setCodecSpecificData(env, j_format, 1, j_csd1);
647 }
648
633 if (!Java_MediaCodecBridge_configureVideo(env, bridge->media_codec(), 649 if (!Java_MediaCodecBridge_configureVideo(env, bridge->media_codec(),
634 j_format, surface, media_crypto, 0, 650 j_format, surface, media_crypto, 0,
635 allow_adaptive_playback)) { 651 allow_adaptive_playback)) {
636 return nullptr; 652 return nullptr;
637 } 653 }
638 654
639 return bridge->Start() ? bridge.release() : nullptr; 655 return bridge->Start() ? bridge.release() : nullptr;
640 } 656 }
641 657
642 // static 658 // static
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 if (adaptive_playback_supported_for_testing_ == 0) 711 if (adaptive_playback_supported_for_testing_ == 0)
696 return false; 712 return false;
697 else if (adaptive_playback_supported_for_testing_ > 0) 713 else if (adaptive_playback_supported_for_testing_ > 0)
698 return true; 714 return true;
699 JNIEnv* env = AttachCurrentThread(); 715 JNIEnv* env = AttachCurrentThread();
700 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), 716 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(),
701 width, height); 717 width, height);
702 } 718 }
703 719
704 } // namespace media 720 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698