| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // Check if device is in H.264 exception list. | 235 // Check if device is in H.264 exception list. |
| 236 if (mime.equals(H264_MIME_TYPE)) { | 236 if (mime.equals(H264_MIME_TYPE)) { |
| 237 List<String> exceptionModels = Arrays.asList(H264_HW_EXCEPTION_MODELS); | 237 List<String> exceptionModels = Arrays.asList(H264_HW_EXCEPTION_MODELS); |
| 238 if (exceptionModels.contains(Build.MODEL)) { | 238 if (exceptionModels.contains(Build.MODEL)) { |
| 239 Logging.w(TAG, "Model: " + Build.MODEL + " has black listed H.264 encode
r."); | 239 Logging.w(TAG, "Model: " + Build.MODEL + " has black listed H.264 encode
r."); |
| 240 return null; | 240 return null; |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { | 244 for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { |
| 245 MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); | 245 MediaCodecInfo info = null; |
| 246 if (!info.isEncoder()) { | 246 try { |
| 247 info = MediaCodecList.getCodecInfoAt(i); |
| 248 } catch (IllegalArgumentException e) { |
| 249 Logging.e(TAG, "Cannot retrieve encoder codec info", e); |
| 250 } |
| 251 if (info == null || !info.isEncoder()) { |
| 247 continue; | 252 continue; |
| 248 } | 253 } |
| 249 String name = null; | 254 String name = null; |
| 250 for (String mimeType : info.getSupportedTypes()) { | 255 for (String mimeType : info.getSupportedTypes()) { |
| 251 if (mimeType.equals(mime)) { | 256 if (mimeType.equals(mime)) { |
| 252 name = info.getName(); | 257 name = info.getName(); |
| 253 break; | 258 break; |
| 254 } | 259 } |
| 255 } | 260 } |
| 256 if (name == null) { | 261 if (name == null) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 274 } | 279 } |
| 275 supportedCodec = true; | 280 supportedCodec = true; |
| 276 break; | 281 break; |
| 277 } | 282 } |
| 278 } | 283 } |
| 279 if (!supportedCodec) { | 284 if (!supportedCodec) { |
| 280 continue; | 285 continue; |
| 281 } | 286 } |
| 282 | 287 |
| 283 // Check if HW codec supports known color format. | 288 // Check if HW codec supports known color format. |
| 284 CodecCapabilities capabilities = info.getCapabilitiesForType(mime); | 289 CodecCapabilities capabilities; |
| 290 try { |
| 291 capabilities = info.getCapabilitiesForType(mime); |
| 292 } catch (IllegalArgumentException e) { |
| 293 Logging.e(TAG, "Cannot retrieve encoder capabilities", e); |
| 294 continue; |
| 295 } |
| 285 for (int colorFormat : capabilities.colorFormats) { | 296 for (int colorFormat : capabilities.colorFormats) { |
| 286 Logging.v(TAG, " Color: 0x" + Integer.toHexString(colorFormat)); | 297 Logging.v(TAG, " Color: 0x" + Integer.toHexString(colorFormat)); |
| 287 } | 298 } |
| 288 | 299 |
| 289 for (int supportedColorFormat : colorList) { | 300 for (int supportedColorFormat : colorList) { |
| 290 for (int codecColorFormat : capabilities.colorFormats) { | 301 for (int codecColorFormat : capabilities.colorFormats) { |
| 291 if (codecColorFormat == supportedColorFormat) { | 302 if (codecColorFormat == supportedColorFormat) { |
| 292 // Found supported HW encoder. | 303 // Found supported HW encoder. |
| 293 Logging.d(TAG, "Found target encoder for mime " + mime + " : " + nam
e + | 304 Logging.d(TAG, "Found target encoder for mime " + mime + " : " + nam
e + |
| 294 ". Color: 0x" + Integer.toHexString(codecColorFormat)); | 305 ". Color: 0x" + Integer.toHexString(codecColorFormat)); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 checkOnMediaCodecThread(); | 650 checkOnMediaCodecThread(); |
| 640 try { | 651 try { |
| 641 mediaCodec.releaseOutputBuffer(index, false); | 652 mediaCodec.releaseOutputBuffer(index, false); |
| 642 return true; | 653 return true; |
| 643 } catch (IllegalStateException e) { | 654 } catch (IllegalStateException e) { |
| 644 Logging.e(TAG, "releaseOutputBuffer failed", e); | 655 Logging.e(TAG, "releaseOutputBuffer failed", e); |
| 645 return false; | 656 return false; |
| 646 } | 657 } |
| 647 } | 658 } |
| 648 } | 659 } |
| OLD | NEW |