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