OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_util.h" | 5 #include "media/base/android/media_codec_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 namespace media { | 35 namespace media { |
36 | 36 |
37 namespace { | 37 namespace { |
38 const char kMp3MimeType[] = "audio/mpeg"; | 38 const char kMp3MimeType[] = "audio/mpeg"; |
39 const char kAacMimeType[] = "audio/mp4a-latm"; | 39 const char kAacMimeType[] = "audio/mp4a-latm"; |
40 const char kOpusMimeType[] = "audio/opus"; | 40 const char kOpusMimeType[] = "audio/opus"; |
41 const char kVorbisMimeType[] = "audio/vorbis"; | 41 const char kVorbisMimeType[] = "audio/vorbis"; |
42 const char kAc3MimeType[] = "audio/ac3"; | 42 const char kAc3MimeType[] = "audio/ac3"; |
43 const char kEac3MimeType[] = "audio/eac3"; | 43 const char kEac3MimeType[] = "audio/eac3"; |
44 const char kBitstreamAudioMimeType[] = "audio/raw"; | |
44 const char kAvcMimeType[] = "video/avc"; | 45 const char kAvcMimeType[] = "video/avc"; |
45 const char kHevcMimeType[] = "video/hevc"; | 46 const char kHevcMimeType[] = "video/hevc"; |
46 const char kVp8MimeType[] = "video/x-vnd.on2.vp8"; | 47 const char kVp8MimeType[] = "video/x-vnd.on2.vp8"; |
47 const char kVp9MimeType[] = "video/x-vnd.on2.vp9"; | 48 const char kVp9MimeType[] = "video/x-vnd.on2.vp9"; |
49 | |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 static CodecProfileLevel MediaCodecProfileLevelToChromiumProfileLevel( | 52 static CodecProfileLevel MediaCodecProfileLevelToChromiumProfileLevel( |
51 JNIEnv* env, | 53 JNIEnv* env, |
52 const jobject& j_codec_profile_level) { | 54 const jobject& j_codec_profile_level) { |
53 VideoCodec codec = static_cast<VideoCodec>( | 55 VideoCodec codec = static_cast<VideoCodec>( |
54 Java_CodecProfileLevelAdapter_getCodec(env, j_codec_profile_level)); | 56 Java_CodecProfileLevelAdapter_getCodec(env, j_codec_profile_level)); |
55 VideoCodecProfile profile = static_cast<VideoCodecProfile>( | 57 VideoCodecProfile profile = static_cast<VideoCodecProfile>( |
56 Java_CodecProfileLevelAdapter_getProfile(env, j_codec_profile_level)); | 58 Java_CodecProfileLevelAdapter_getProfile(env, j_codec_profile_level)); |
57 int level = | 59 int level = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { | 93 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { |
92 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); | 94 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); |
93 JNIEnv* env = AttachCurrentThread(); | 95 JNIEnv* env = AttachCurrentThread(); |
94 ScopedJavaLocalRef<jstring> j_mime = | 96 ScopedJavaLocalRef<jstring> j_mime = |
95 ConvertUTF8ToJavaString(env, android_mime_type); | 97 ConvertUTF8ToJavaString(env, android_mime_type); |
96 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); | 98 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); |
97 } | 99 } |
98 | 100 |
99 // static | 101 // static |
100 std::string MediaCodecUtil::CodecToAndroidMimeType(AudioCodec codec) { | 102 std::string MediaCodecUtil::CodecToAndroidMimeType(AudioCodec codec) { |
103 if (IsPassthroughAudioFormat(codec)) | |
104 return kBitstreamAudioMimeType; | |
105 | |
101 switch (codec) { | 106 switch (codec) { |
102 case kCodecMP3: | 107 case kCodecMP3: |
103 return kMp3MimeType; | 108 return kMp3MimeType; |
104 case kCodecVorbis: | 109 case kCodecVorbis: |
105 return kVorbisMimeType; | 110 return kVorbisMimeType; |
106 case kCodecOpus: | 111 case kCodecOpus: |
107 return kOpusMimeType; | 112 return kOpusMimeType; |
108 case kCodecAAC: | 113 case kCodecAAC: |
109 return kAacMimeType; | 114 return kAacMimeType; |
110 case kCodecAC3: | 115 case kCodecAC3: |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 return true; | 358 return true; |
354 } | 359 } |
355 | 360 |
356 // static | 361 // static |
357 bool MediaCodecUtil::IsSetOutputSurfaceSupported() { | 362 bool MediaCodecUtil::IsSetOutputSurfaceSupported() { |
358 JNIEnv* env = AttachCurrentThread(); | 363 JNIEnv* env = AttachCurrentThread(); |
359 return Java_MediaCodecUtil_isSetOutputSurfaceSupported(env); | 364 return Java_MediaCodecUtil_isSetOutputSurfaceSupported(env); |
360 } | 365 } |
361 | 366 |
362 // static | 367 // static |
368 bool MediaCodecUtil::IsPassthroughAudioFormat(AudioCodec codec) { | |
369 return (codec == kCodecAC3 || codec == kCodecEAC3); | |
DaleCurtis
2017/05/04 19:05:44
Drop unnecessary parens.
AndyWu
2017/05/06 01:46:48
Done.
| |
370 } | |
371 | |
372 // static | |
363 bool MediaCodecUtil::CodecNeedsFlushWorkaround(MediaCodecBridge* codec) { | 373 bool MediaCodecUtil::CodecNeedsFlushWorkaround(MediaCodecBridge* codec) { |
364 int sdk_int = base::android::BuildInfo::GetInstance()->sdk_int(); | 374 int sdk_int = base::android::BuildInfo::GetInstance()->sdk_int(); |
365 std::string codec_name = codec->GetName(); | 375 std::string codec_name = codec->GetName(); |
366 return sdk_int < 18 || | 376 return sdk_int < 18 || |
367 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || | 377 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || |
368 "OMX.SEC.avc.dec.secure" == codec_name)) || | 378 "OMX.SEC.avc.dec.secure" == codec_name)) || |
369 (sdk_int == 19 && | 379 (sdk_int == 19 && |
370 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), | 380 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), |
371 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && | 381 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && |
372 ("OMX.Exynos.avc.dec" == codec_name || | 382 ("OMX.Exynos.avc.dec" == codec_name || |
373 "OMX.Exynos.avc.dec.secure" == codec_name)); | 383 "OMX.Exynos.avc.dec.secure" == codec_name)); |
374 } | 384 } |
375 | 385 |
376 } // namespace media | 386 } // namespace media |
OLD | NEW |