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

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: Shot in the dark 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 553 }
554 554
555 // static 555 // static
556 bool VideoCodecBridge::IsKnownUnaccelerated(const VideoCodec& codec, 556 bool VideoCodecBridge::IsKnownUnaccelerated(const VideoCodec& codec,
557 MediaCodecDirection direction) { 557 MediaCodecDirection direction) {
558 return MediaCodecUtil::IsKnownUnaccelerated( 558 return MediaCodecUtil::IsKnownUnaccelerated(
559 VideoCodecToAndroidMimeType(codec), direction); 559 VideoCodecToAndroidMimeType(codec), direction);
560 } 560 }
561 561
562 // static 562 // static
563 VideoCodecBridge* VideoCodecBridge::CreateDecoder(const VideoCodec& codec, 563 VideoCodecBridge* VideoCodecBridge::CreateDecoder(
564 bool is_secure, 564 const VideoCodec& codec,
565 const gfx::Size& size, 565 bool is_secure,
566 jobject surface, 566 const gfx::Size& size,
567 jobject media_crypto, 567 jobject surface,
568 bool allow_adaptive_playback, 568 jobject media_crypto,
569 bool require_software_codec) { 569 const std::vector<uint8_t>& csd0,
570 const std::vector<uint8_t>& csd1,
571 bool allow_adaptive_playback,
572 bool require_software_codec) {
570 if (!MediaCodecUtil::IsMediaCodecAvailable()) 573 if (!MediaCodecUtil::IsMediaCodecAvailable())
571 return nullptr; 574 return nullptr;
572 575
573 const std::string mime = VideoCodecToAndroidMimeType(codec); 576 const std::string mime = VideoCodecToAndroidMimeType(codec);
574 if (mime.empty()) 577 if (mime.empty())
575 return nullptr; 578 return nullptr;
576 579
577 std::unique_ptr<VideoCodecBridge> bridge(new VideoCodecBridge( 580 std::unique_ptr<VideoCodecBridge> bridge(new VideoCodecBridge(
578 mime, is_secure, MEDIA_CODEC_DECODER, require_software_codec)); 581 mime, is_secure, MEDIA_CODEC_DECODER, require_software_codec));
579 if (!bridge->media_codec()) 582 if (!bridge->media_codec())
580 return nullptr; 583 return nullptr;
581 584
582 JNIEnv* env = AttachCurrentThread(); 585 JNIEnv* env = AttachCurrentThread();
583 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); 586 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime);
584 ScopedJavaLocalRef<jobject> j_format( 587 ScopedJavaLocalRef<jobject> j_format(
585 Java_MediaCodecBridge_createVideoDecoderFormat(env, j_mime, size.width(), 588 Java_MediaCodecBridge_createVideoDecoderFormat(env, j_mime, size.width(),
586 size.height())); 589 size.height()));
587 DCHECK(!j_format.is_null()); 590 DCHECK(!j_format.is_null());
591
592 if (!csd0.empty()) {
593 ScopedJavaLocalRef<jbyteArray> j_csd0 =
594 base::android::ToJavaByteArray(env, csd0.data(), csd0.size());
595 Java_MediaCodecBridge_setCodecSpecificData(env, j_format, 0, j_csd0);
596 }
597
598 if (!csd1.empty()) {
599 ScopedJavaLocalRef<jbyteArray> j_csd1 =
600 base::android::ToJavaByteArray(env, csd1.data(), csd1.size());
601 Java_MediaCodecBridge_setCodecSpecificData(env, j_format, 1, j_csd1);
602 }
603
588 if (!Java_MediaCodecBridge_configureVideo(env, bridge->media_codec(), 604 if (!Java_MediaCodecBridge_configureVideo(env, bridge->media_codec(),
589 j_format, surface, media_crypto, 0, 605 j_format, surface, media_crypto, 0,
590 allow_adaptive_playback)) { 606 allow_adaptive_playback)) {
591 return nullptr; 607 return nullptr;
592 } 608 }
593 609
594 return bridge->Start() ? bridge.release() : nullptr; 610 return bridge->Start() ? bridge.release() : nullptr;
595 } 611 }
596 612
597 // static 613 // static
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 if (adaptive_playback_supported_for_testing_ == 0) 666 if (adaptive_playback_supported_for_testing_ == 0)
651 return false; 667 return false;
652 else if (adaptive_playback_supported_for_testing_ > 0) 668 else if (adaptive_playback_supported_for_testing_ > 0)
653 return true; 669 return true;
654 JNIEnv* env = AttachCurrentThread(); 670 JNIEnv* env = AttachCurrentThread();
655 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), 671 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(),
656 width, height); 672 width, height);
657 } 673 }
658 674
659 } // namespace media 675 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/sdk_media_codec_bridge.h ('k') | media/base/android/sdk_media_codec_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698