| OLD | NEW |
| 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 | 7 |
| 8 #include "base/android/build_info.h" | 8 #include "base/android/build_info.h" |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 return "audio/mp4a-latm"; | 45 return "audio/mp4a-latm"; |
| 46 default: | 46 default: |
| 47 return std::string(); | 47 return std::string(); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 static const std::string VideoCodecToAndroidMimeType(const VideoCodec& codec) { | 51 static const std::string VideoCodecToAndroidMimeType(const VideoCodec& codec) { |
| 52 switch (codec) { | 52 switch (codec) { |
| 53 case kCodecH264: | 53 case kCodecH264: |
| 54 return "video/avc"; | 54 return "video/avc"; |
| 55 case kCodecHEVC: |
| 56 return "video/hevc"; |
| 55 case kCodecVP8: | 57 case kCodecVP8: |
| 56 return "video/x-vnd.on2.vp8"; | 58 return "video/x-vnd.on2.vp8"; |
| 57 case kCodecVP9: | 59 case kCodecVP9: |
| 58 return "video/x-vnd.on2.vp9"; | 60 return "video/x-vnd.on2.vp9"; |
| 59 default: | 61 default: |
| 60 return std::string(); | 62 return std::string(); |
| 61 } | 63 } |
| 62 } | 64 } |
| 63 | 65 |
| 64 static const std::string CodecTypeToAndroidMimeType(const std::string& codec) { | 66 static const std::string CodecTypeToAndroidMimeType(const std::string& codec) { |
| 65 // TODO(xhwang): Shall we handle more detailed strings like "mp4a.40.2"? | 67 // TODO(xhwang): Shall we handle more detailed strings like "mp4a.40.2"? |
| 66 if (codec == "avc1") | 68 if (codec == "avc1") |
| 67 return "video/avc"; | 69 return "video/avc"; |
| 70 if (codec == "hvc1") |
| 71 return "video/hevc"; |
| 68 if (codec == "mp4a") | 72 if (codec == "mp4a") |
| 69 return "audio/mp4a-latm"; | 73 return "audio/mp4a-latm"; |
| 70 if (codec == "vp8" || codec == "vp8.0") | 74 if (codec == "vp8" || codec == "vp8.0") |
| 71 return "video/x-vnd.on2.vp8"; | 75 return "video/x-vnd.on2.vp8"; |
| 72 if (codec == "vp9" || codec == "vp9.0") | 76 if (codec == "vp9" || codec == "vp9.0") |
| 73 return "video/x-vnd.on2.vp9"; | 77 return "video/x-vnd.on2.vp9"; |
| 74 if (codec == "vorbis") | 78 if (codec == "vorbis") |
| 75 return "audio/vorbis"; | 79 return "audio/vorbis"; |
| 76 if (codec == "opus") | 80 if (codec == "opus") |
| 77 return "audio/opus"; | 81 return "audio/opus"; |
| 78 return std::string(); | 82 return std::string(); |
| 79 } | 83 } |
| 80 | 84 |
| 81 // TODO(qinmin): using a map to help all the conversions in this class. | 85 // TODO(qinmin): using a map to help all the conversions in this class. |
| 82 static const std::string AndroidMimeTypeToCodecType(const std::string& mime) { | 86 static const std::string AndroidMimeTypeToCodecType(const std::string& mime) { |
| 83 if (mime == "video/mp4v-es") | 87 if (mime == "video/mp4v-es") |
| 84 return "mp4v"; | 88 return "mp4v"; |
| 85 if (mime == "video/avc") | 89 if (mime == "video/avc") |
| 86 return "avc1"; | 90 return "avc1"; |
| 91 if (mime == "video/hevc") |
| 92 return "hvc1"; |
| 87 if (mime == "video/x-vnd.on2.vp8") | 93 if (mime == "video/x-vnd.on2.vp8") |
| 88 return "vp8"; | 94 return "vp8"; |
| 89 if (mime == "video/x-vnd.on2.vp9") | 95 if (mime == "video/x-vnd.on2.vp9") |
| 90 return "vp9"; | 96 return "vp9"; |
| 91 if (mime == "audio/mp4a-latm") | 97 if (mime == "audio/mp4a-latm") |
| 92 return "mp4a"; | 98 return "mp4a"; |
| 93 if (mime == "audio/mpeg") | 99 if (mime == "audio/mpeg") |
| 94 return "mp3"; | 100 return "mp3"; |
| 95 if (mime == "audio/vorbis") | 101 if (mime == "audio/vorbis") |
| 96 return "vorbis"; | 102 return "vorbis"; |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 JNIEnv* env = AttachCurrentThread(); | 843 JNIEnv* env = AttachCurrentThread(); |
| 838 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( | 844 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( |
| 839 env, media_codec(), width, height); | 845 env, media_codec(), width, height); |
| 840 } | 846 } |
| 841 | 847 |
| 842 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { | 848 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { |
| 843 return RegisterNativesImpl(env); | 849 return RegisterNativesImpl(env); |
| 844 } | 850 } |
| 845 | 851 |
| 846 } // namespace media | 852 } // namespace media |
| OLD | NEW |