Android: Fix leaking software video codec instances.

Previously, wrapped native codec instances would leak the native object
if it was never used. This change fixes it by changing getNative method
to createNative.

Also fixes "Video codec hardware acceleration" setting in AppRTCMobile.

Bug: webrtc:7925
Change-Id: I53f6dc1dd5e37dea8d14278423122dede17719c5
Reviewed-on: https://webrtc-review.googlesource.com/24881
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20859}
This commit is contained in:
Sami Kalliomäki
2017-11-23 14:42:21 +01:00
committed by Commit Bot
parent 2a9dbe6e7e
commit aea1d1ad3f
12 changed files with 57 additions and 58 deletions

View File

@ -14,8 +14,17 @@ package org.webrtc;
* A combined video encoder that falls back on a secondary encoder if the primary encoder fails.
*/
public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
private final VideoEncoder fallback;
private final VideoEncoder primary;
public VideoEncoderFallback(VideoEncoder fallback, VideoEncoder primary) {
super(createNativeEncoder(fallback, primary));
this.fallback = fallback;
this.primary = primary;
}
@Override
long createNativeEncoder() {
return createNativeEncoder(fallback, primary);
}
private static native long createNativeEncoder(VideoEncoder fallback, VideoEncoder primary);