X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Flibjingle%2Fsource%2Ftalk%2Fapp%2Fwebrtc%2Fjava%2Fsrc%2Forg%2Fwebrtc%2FMediaCodecVideoEncoder.java;h=cf11573b04434ac5fa86a3b1fe520abed9100b51;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=45b8d6ad60aece4ba795eeb34dde9ab5c029b630;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/libjingle/source/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java b/src/third_party/libjingle/source/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java index 45b8d6a..cf11573 100644 --- a/src/third_party/libjingle/source/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java +++ b/src/third_party/libjingle/source/talk/app/webrtc/java/src/org/webrtc/MediaCodecVideoEncoder.java @@ -78,7 +78,7 @@ class MediaCodecVideoEncoder { // Helper struct for findVp8HwEncoder() below. private static class EncoderProperties { - EncoderProperties(String codecName, int colorFormat) { + public EncoderProperties(String codecName, int colorFormat) { this.codecName = codecName; this.colorFormat = colorFormat; } @@ -106,26 +106,33 @@ class MediaCodecVideoEncoder { continue; // No VP8 support in this codec; try the next one. } Log.d(TAG, "Found candidate encoder " + name); + + // Check if this is supported HW encoder. + boolean supportedCodec = false; + for (String hwCodecPrefix : supportedHwCodecPrefixes) { + if (name.startsWith(hwCodecPrefix)) { + supportedCodec = true; + break; + } + } + if (!supportedCodec) { + continue; + } + CodecCapabilities capabilities = info.getCapabilitiesForType(VP8_MIME_TYPE); for (int colorFormat : capabilities.colorFormats) { Log.d(TAG, " Color: 0x" + Integer.toHexString(colorFormat)); } - // Check if this is supported HW encoder - for (String hwCodecPrefix : supportedHwCodecPrefixes) { - if (!name.startsWith(hwCodecPrefix)) { - continue; - } - // Check if codec supports either yuv420 or nv12 - for (int supportedColorFormat : supportedColorList) { - for (int codecColorFormat : capabilities.colorFormats) { - if (codecColorFormat == supportedColorFormat) { - // Found supported HW VP8 encoder - Log.d(TAG, "Found target encoder " + name + - ". Color: 0x" + Integer.toHexString(codecColorFormat)); - return new EncoderProperties(name, codecColorFormat); - } + // Check if codec supports either yuv420 or nv12. + for (int supportedColorFormat : supportedColorList) { + for (int codecColorFormat : capabilities.colorFormats) { + if (codecColorFormat == supportedColorFormat) { + // Found supported HW VP8 encoder. + Log.d(TAG, "Found target encoder " + name + + ". Color: 0x" + Integer.toHexString(codecColorFormat)); + return new EncoderProperties(name, codecColorFormat); } } } @@ -137,15 +144,6 @@ class MediaCodecVideoEncoder { return findVp8HwEncoder() != null; } - private static int bitRate(int kbps) { - // webrtc "kilo" means 1000, not 1024. Apparently. - // (and the price for overshooting is frame-dropping as webrtc enforces its - // bandwidth estimation, which is unpleasant). - // Since the HW encoder in the N5 overshoots, we clamp to a bit less than - // the requested rate. Sad but true. Bug 3194. - return kbps * 950; - } - private void checkOnMediaCodecThread() { if (mediaCodecThread.getId() != Thread.currentThread().getId()) { throw new RuntimeException( @@ -170,7 +168,7 @@ class MediaCodecVideoEncoder { try { MediaFormat format = MediaFormat.createVideoFormat(VP8_MIME_TYPE, width, height); - format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate(kbps)); + format.setInteger(MediaFormat.KEY_BIT_RATE, 1000 * kbps); format.setInteger("bitrate-mode", VIDEO_ControlRateConstant); format.setInteger(MediaFormat.KEY_COLOR_FORMAT, properties.colorFormat); // Default WebRTC settings @@ -241,7 +239,7 @@ class MediaCodecVideoEncoder { Log.v(TAG, "setRates: " + kbps + " kbps. Fps: " + frameRateIgnored); try { Bundle params = new Bundle(); - params.putInt(MediaCodec.PARAMETER_KEY_VIDEO_BITRATE, bitRate(kbps)); + params.putInt(MediaCodec.PARAMETER_KEY_VIDEO_BITRATE, 1000 * kbps); mediaCodec.setParameters(params); return true; } catch (IllegalStateException e) {