| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 package org.chromium.media; | 5 package org.chromium.media; |
| 6 | 6 |
| 7 import android.media.AudioFormat; | 7 import android.media.AudioFormat; |
| 8 import android.media.AudioManager; | 8 import android.media.AudioManager; |
| 9 import android.media.AudioTrack; | 9 import android.media.AudioTrack; |
| 10 import android.media.MediaCodec; | 10 import android.media.MediaCodec; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 ArrayList<CodecInfo> codecInfos = new ArrayList<CodecInfo>( | 177 ArrayList<CodecInfo> codecInfos = new ArrayList<CodecInfo>( |
| 178 decoderInfoMap.size() + encoderInfoMap.size()); | 178 decoderInfoMap.size() + encoderInfoMap.size()); |
| 179 codecInfos.addAll(encoderInfoMap.values()); | 179 codecInfos.addAll(encoderInfoMap.values()); |
| 180 codecInfos.addAll(decoderInfoMap.values()); | 180 codecInfos.addAll(decoderInfoMap.values()); |
| 181 return codecInfos.toArray(new CodecInfo[codecInfos.size()]); | 181 return codecInfos.toArray(new CodecInfo[codecInfos.size()]); |
| 182 } | 182 } |
| 183 | 183 |
| 184 /** |
| 185 * Get a name of default android codec. |
| 186 */ |
| 187 @SuppressWarnings("deprecation") |
| 188 @CalledByNative |
| 189 private static String getDefaultCodecName(String mime, int direction) { |
| 190 String codecName = ""; |
| 191 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { |
| 192 try { |
| 193 MediaCodec mediaCodec = null; |
| 194 if (direction == MEDIA_CODEC_ENCODER) { |
| 195 mediaCodec = MediaCodec.createEncoderByType(mime); |
| 196 } else { |
| 197 mediaCodec = MediaCodec.createDecoderByType(mime); |
| 198 } |
| 199 codecName = mediaCodec.getName(); |
| 200 mediaCodec.release(); |
| 201 } catch (Exception e) { |
| 202 Log.w(TAG, "getDefaultCodecName: Failed to create MediaCodec: "
+ |
| 203 mime + ", direction: " + direction, e); |
| 204 } |
| 205 } |
| 206 return codecName; |
| 207 } |
| 208 |
| 184 @SuppressWarnings("deprecation") | 209 @SuppressWarnings("deprecation") |
| 185 private static String getDecoderNameForMime(String mime) { | 210 private static String getDecoderNameForMime(String mime) { |
| 186 int count = MediaCodecList.getCodecCount(); | 211 int count = MediaCodecList.getCodecCount(); |
| 187 for (int i = 0; i < count; ++i) { | 212 for (int i = 0; i < count; ++i) { |
| 188 MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); | 213 MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); |
| 189 if (info.isEncoder()) { | 214 if (info.isEncoder()) { |
| 190 continue; | 215 continue; |
| 191 } | 216 } |
| 192 | 217 |
| 193 String[] supportedTypes = info.getSupportedTypes(); | 218 String[] supportedTypes = info.getSupportedTypes(); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 return AudioFormat.CHANNEL_OUT_QUAD; | 666 return AudioFormat.CHANNEL_OUT_QUAD; |
| 642 case 6: | 667 case 6: |
| 643 return AudioFormat.CHANNEL_OUT_5POINT1; | 668 return AudioFormat.CHANNEL_OUT_5POINT1; |
| 644 case 8: | 669 case 8: |
| 645 return AudioFormat.CHANNEL_OUT_7POINT1; | 670 return AudioFormat.CHANNEL_OUT_7POINT1; |
| 646 default: | 671 default: |
| 647 return AudioFormat.CHANNEL_OUT_DEFAULT; | 672 return AudioFormat.CHANNEL_OUT_DEFAULT; |
| 648 } | 673 } |
| 649 } | 674 } |
| 650 } | 675 } |
| OLD | NEW |