| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 package org.chromium.media; | 5 package org.chromium.media; |
| 6 | 6 |
| 7 import android.media.MediaCodecInfo.CodecProfileLevel; | 7 import android.media.MediaCodecInfo.CodecProfileLevel; |
| 8 | 8 |
| 9 import org.chromium.base.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 @CalledByNative("CodecProfileLevelAdapter") | 69 @CalledByNative("CodecProfileLevelAdapter") |
| 70 public int getLevel() { | 70 public int getLevel() { |
| 71 return mLevel; | 71 return mLevel; |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 private static class UnsupportedCodecProfileException extends RuntimeExcepti
on {} | 75 private static class UnsupportedCodecProfileException extends RuntimeExcepti
on {} |
| 76 | 76 |
| 77 private static int getCodecFromMime(String mime) { | 77 private static int getCodecFromMime(String mime) { |
| 78 if (mime.endsWith("vp9")) return VideoCodec.kCodecVP9; | 78 if (mime.endsWith("vp9")) return VideoCodec.CODEC_VP9; |
| 79 if (mime.endsWith("vp8")) return VideoCodec.kCodecVP8; | 79 if (mime.endsWith("vp8")) return VideoCodec.CODEC_VP8; |
| 80 if (mime.endsWith("avc")) return VideoCodec.kCodecH264; | 80 if (mime.endsWith("avc")) return VideoCodec.CODEC_H264; |
| 81 if (mime.endsWith("hevc")) return VideoCodec.kCodecHEVC; | 81 if (mime.endsWith("hevc")) return VideoCodec.CODEC_HEVC; |
| 82 throw new UnsupportedCodecProfileException(); | 82 throw new UnsupportedCodecProfileException(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 private static int mediaCodecProfileToChromiumMediaProfile(int codec, int pr
ofile) { | 85 private static int mediaCodecProfileToChromiumMediaProfile(int codec, int pr
ofile) { |
| 86 switch (codec) { | 86 switch (codec) { |
| 87 case VideoCodec.kCodecH264: | 87 case VideoCodec.CODEC_H264: |
| 88 switch (profile) { | 88 switch (profile) { |
| 89 case CodecProfileLevel.AVCProfileBaseline: | 89 case CodecProfileLevel.AVCProfileBaseline: |
| 90 return VideoCodecProfile.H264PROFILE_BASELINE; | 90 return VideoCodecProfile.H264PROFILE_BASELINE; |
| 91 case CodecProfileLevel.AVCProfileMain: | 91 case CodecProfileLevel.AVCProfileMain: |
| 92 return VideoCodecProfile.H264PROFILE_MAIN; | 92 return VideoCodecProfile.H264PROFILE_MAIN; |
| 93 case CodecProfileLevel.AVCProfileExtended: | 93 case CodecProfileLevel.AVCProfileExtended: |
| 94 return VideoCodecProfile.H264PROFILE_EXTENDED; | 94 return VideoCodecProfile.H264PROFILE_EXTENDED; |
| 95 case CodecProfileLevel.AVCProfileHigh: | 95 case CodecProfileLevel.AVCProfileHigh: |
| 96 return VideoCodecProfile.H264PROFILE_HIGH; | 96 return VideoCodecProfile.H264PROFILE_HIGH; |
| 97 case CodecProfileLevel.AVCProfileHigh10: | 97 case CodecProfileLevel.AVCProfileHigh10: |
| 98 return VideoCodecProfile.H264PROFILE_HIGH10PROFILE; | 98 return VideoCodecProfile.H264PROFILE_HIGH10PROFILE; |
| 99 case CodecProfileLevel.AVCProfileHigh422: | 99 case CodecProfileLevel.AVCProfileHigh422: |
| 100 return VideoCodecProfile.H264PROFILE_HIGH422PROFILE; | 100 return VideoCodecProfile.H264PROFILE_HIGH422PROFILE; |
| 101 case CodecProfileLevel.AVCProfileHigh444: | 101 case CodecProfileLevel.AVCProfileHigh444: |
| 102 return VideoCodecProfile.H264PROFILE_HIGH444PREDICTIVEPR
OFILE; | 102 return VideoCodecProfile.H264PROFILE_HIGH444PREDICTIVEPR
OFILE; |
| 103 default: | 103 default: |
| 104 throw new UnsupportedCodecProfileException(); | 104 throw new UnsupportedCodecProfileException(); |
| 105 } | 105 } |
| 106 case VideoCodec.kCodecVP8: | 106 case VideoCodec.CODEC_VP8: |
| 107 switch (profile) { | 107 switch (profile) { |
| 108 case CodecProfileLevel.VP8ProfileMain: | 108 case CodecProfileLevel.VP8ProfileMain: |
| 109 return VideoCodecProfile.VP8PROFILE_ANY; | 109 return VideoCodecProfile.VP8PROFILE_ANY; |
| 110 default: | 110 default: |
| 111 throw new UnsupportedCodecProfileException(); | 111 throw new UnsupportedCodecProfileException(); |
| 112 } | 112 } |
| 113 case VideoCodec.kCodecVP9: | 113 case VideoCodec.CODEC_VP9: |
| 114 switch (profile) { | 114 switch (profile) { |
| 115 case CodecProfileLevel.VP9Profile0: | 115 case CodecProfileLevel.VP9Profile0: |
| 116 return VideoCodecProfile.VP9PROFILE_PROFILE0; | 116 return VideoCodecProfile.VP9PROFILE_PROFILE0; |
| 117 case CodecProfileLevel.VP9Profile1: | 117 case CodecProfileLevel.VP9Profile1: |
| 118 return VideoCodecProfile.VP9PROFILE_PROFILE1; | 118 return VideoCodecProfile.VP9PROFILE_PROFILE1; |
| 119 case CodecProfileLevel.VP9Profile2: | 119 case CodecProfileLevel.VP9Profile2: |
| 120 return VideoCodecProfile.VP9PROFILE_PROFILE2; | 120 return VideoCodecProfile.VP9PROFILE_PROFILE2; |
| 121 case CodecProfileLevel.VP9Profile3: | 121 case CodecProfileLevel.VP9Profile3: |
| 122 return VideoCodecProfile.VP9PROFILE_PROFILE3; | 122 return VideoCodecProfile.VP9PROFILE_PROFILE3; |
| 123 default: | 123 default: |
| 124 throw new UnsupportedCodecProfileException(); | 124 throw new UnsupportedCodecProfileException(); |
| 125 } | 125 } |
| 126 case VideoCodec.kCodecHEVC: | 126 case VideoCodec.CODEC_HEVC: |
| 127 switch (profile) { | 127 switch (profile) { |
| 128 case CodecProfileLevel.HEVCProfileMain: | 128 case CodecProfileLevel.HEVCProfileMain: |
| 129 return VideoCodecProfile.HEVCPROFILE_MAIN; | 129 return VideoCodecProfile.HEVCPROFILE_MAIN; |
| 130 case CodecProfileLevel.HEVCProfileMain10: | 130 case CodecProfileLevel.HEVCProfileMain10: |
| 131 return VideoCodecProfile.HEVCPROFILE_MAIN10; | 131 return VideoCodecProfile.HEVCPROFILE_MAIN10; |
| 132 case CodecProfileLevel.HEVCProfileMain10HDR10: | 132 case CodecProfileLevel.HEVCProfileMain10HDR10: |
| 133 return VideoCodecProfile.HEVCPROFILE_MAIN_STILL_PICTURE; | 133 return VideoCodecProfile.HEVCPROFILE_MAIN_STILL_PICTURE; |
| 134 default: | 134 default: |
| 135 throw new UnsupportedCodecProfileException(); | 135 throw new UnsupportedCodecProfileException(); |
| 136 } | 136 } |
| 137 default: | 137 default: |
| 138 throw new UnsupportedCodecProfileException(); | 138 throw new UnsupportedCodecProfileException(); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 private static int mediaCodecLevelToChromiumMediaLevel(int codec, int level)
{ | 142 private static int mediaCodecLevelToChromiumMediaLevel(int codec, int level)
{ |
| 143 switch (codec) { | 143 switch (codec) { |
| 144 case VideoCodec.kCodecH264: | 144 case VideoCodec.CODEC_H264: |
| 145 switch (level) { | 145 switch (level) { |
| 146 case CodecProfileLevel.AVCLevel1: | 146 case CodecProfileLevel.AVCLevel1: |
| 147 return 10; | 147 return 10; |
| 148 case CodecProfileLevel.AVCLevel11: | 148 case CodecProfileLevel.AVCLevel11: |
| 149 return 11; | 149 return 11; |
| 150 case CodecProfileLevel.AVCLevel12: | 150 case CodecProfileLevel.AVCLevel12: |
| 151 return 12; | 151 return 12; |
| 152 case CodecProfileLevel.AVCLevel13: | 152 case CodecProfileLevel.AVCLevel13: |
| 153 return 13; | 153 return 13; |
| 154 case CodecProfileLevel.AVCLevel2: | 154 case CodecProfileLevel.AVCLevel2: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 return 42; | 171 return 42; |
| 172 case CodecProfileLevel.AVCLevel5: | 172 case CodecProfileLevel.AVCLevel5: |
| 173 return 50; | 173 return 50; |
| 174 case CodecProfileLevel.AVCLevel51: | 174 case CodecProfileLevel.AVCLevel51: |
| 175 return 51; | 175 return 51; |
| 176 case CodecProfileLevel.AVCLevel52: | 176 case CodecProfileLevel.AVCLevel52: |
| 177 return 52; | 177 return 52; |
| 178 default: | 178 default: |
| 179 throw new UnsupportedCodecProfileException(); | 179 throw new UnsupportedCodecProfileException(); |
| 180 } | 180 } |
| 181 case VideoCodec.kCodecVP8: | 181 case VideoCodec.CODEC_VP8: |
| 182 switch (level) { | 182 switch (level) { |
| 183 case CodecProfileLevel.VP8Level_Version0: | 183 case CodecProfileLevel.VP8Level_Version0: |
| 184 return 0; | 184 return 0; |
| 185 case CodecProfileLevel.VP8Level_Version1: | 185 case CodecProfileLevel.VP8Level_Version1: |
| 186 return 1; | 186 return 1; |
| 187 case CodecProfileLevel.VP8Level_Version2: | 187 case CodecProfileLevel.VP8Level_Version2: |
| 188 return 2; | 188 return 2; |
| 189 case CodecProfileLevel.VP8Level_Version3: | 189 case CodecProfileLevel.VP8Level_Version3: |
| 190 return 3; | 190 return 3; |
| 191 default: | 191 default: |
| 192 throw new UnsupportedCodecProfileException(); | 192 throw new UnsupportedCodecProfileException(); |
| 193 } | 193 } |
| 194 case VideoCodec.kCodecVP9: | 194 case VideoCodec.CODEC_VP9: |
| 195 switch (level) { | 195 switch (level) { |
| 196 case CodecProfileLevel.VP9Level1: | 196 case CodecProfileLevel.VP9Level1: |
| 197 return 10; | 197 return 10; |
| 198 case CodecProfileLevel.VP9Level11: | 198 case CodecProfileLevel.VP9Level11: |
| 199 return 11; | 199 return 11; |
| 200 case CodecProfileLevel.VP9Level2: | 200 case CodecProfileLevel.VP9Level2: |
| 201 return 20; | 201 return 20; |
| 202 case CodecProfileLevel.VP9Level21: | 202 case CodecProfileLevel.VP9Level21: |
| 203 return 21; | 203 return 21; |
| 204 case CodecProfileLevel.VP9Level3: | 204 case CodecProfileLevel.VP9Level3: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 217 return 52; | 217 return 52; |
| 218 case CodecProfileLevel.VP9Level6: | 218 case CodecProfileLevel.VP9Level6: |
| 219 return 60; | 219 return 60; |
| 220 case CodecProfileLevel.VP9Level61: | 220 case CodecProfileLevel.VP9Level61: |
| 221 return 61; | 221 return 61; |
| 222 case CodecProfileLevel.VP9Level62: | 222 case CodecProfileLevel.VP9Level62: |
| 223 return 62; | 223 return 62; |
| 224 default: | 224 default: |
| 225 throw new UnsupportedCodecProfileException(); | 225 throw new UnsupportedCodecProfileException(); |
| 226 } | 226 } |
| 227 case VideoCodec.kCodecHEVC: | 227 case VideoCodec.CODEC_HEVC: |
| 228 switch (level) { | 228 switch (level) { |
| 229 case CodecProfileLevel.HEVCHighTierLevel1: | 229 case CodecProfileLevel.HEVCHighTierLevel1: |
| 230 case CodecProfileLevel.HEVCMainTierLevel1: | 230 case CodecProfileLevel.HEVCMainTierLevel1: |
| 231 return 30; | 231 return 30; |
| 232 case CodecProfileLevel.HEVCHighTierLevel2: | 232 case CodecProfileLevel.HEVCHighTierLevel2: |
| 233 case CodecProfileLevel.HEVCMainTierLevel2: | 233 case CodecProfileLevel.HEVCMainTierLevel2: |
| 234 return 60; | 234 return 60; |
| 235 case CodecProfileLevel.HEVCHighTierLevel21: | 235 case CodecProfileLevel.HEVCHighTierLevel21: |
| 236 case CodecProfileLevel.HEVCMainTierLevel21: | 236 case CodecProfileLevel.HEVCMainTierLevel21: |
| 237 return 63; | 237 return 63; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 266 case CodecProfileLevel.HEVCMainTierLevel62: | 266 case CodecProfileLevel.HEVCMainTierLevel62: |
| 267 return 186; | 267 return 186; |
| 268 default: | 268 default: |
| 269 throw new UnsupportedCodecProfileException(); | 269 throw new UnsupportedCodecProfileException(); |
| 270 } | 270 } |
| 271 default: | 271 default: |
| 272 throw new UnsupportedCodecProfileException(); | 272 throw new UnsupportedCodecProfileException(); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 } | 275 } |
| OLD | NEW |