diff --git a/sdk/android/api/org/webrtc/VideoDecoder.java b/sdk/android/api/org/webrtc/VideoDecoder.java index f5d8850c9d..76b030ca24 100644 --- a/sdk/android/api/org/webrtc/VideoDecoder.java +++ b/sdk/android/api/org/webrtc/VideoDecoder.java @@ -68,6 +68,9 @@ public interface VideoDecoder { * infinite number of frames before the decoded frame is consumed. */ boolean getPrefersLateDecoding(); - /** Should return a descriptive name for the implementation. */ + /** + * Should return a descriptive name for the implementation. Gets called once and cached. May be + * called from arbitrary thread. + */ String getImplementationName(); } diff --git a/sdk/android/api/org/webrtc/VideoEncoder.java b/sdk/android/api/org/webrtc/VideoEncoder.java index 1fb96011d0..27088468a3 100644 --- a/sdk/android/api/org/webrtc/VideoEncoder.java +++ b/sdk/android/api/org/webrtc/VideoEncoder.java @@ -12,7 +12,8 @@ package org.webrtc; /** * Interface for a video encoder that can be used with WebRTC. All calls will be made on the - * encoding thread. + * encoding thread. The encoder may be constructed on a different thread and changing thread after + * calling release is allowed. */ public interface VideoEncoder { /** Settings passed to the encoder by WebRTC. */ @@ -143,6 +144,9 @@ public interface VideoEncoder { VideoCodecStatus setRateAllocation(BitrateAllocation allocation, int framerate); /** Any encoder that wants to use WebRTC provided quality scaler must implement this method. */ ScalingSettings getScalingSettings(); - /** Should return a descriptive name for the implementation. Gets called once and cached. */ + /** + * Should return a descriptive name for the implementation. Gets called once and cached. May be + * called from arbitrary thread. + */ String getImplementationName(); } diff --git a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java index e9df705fb7..e0cd6b1ca6 100644 --- a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java +++ b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java @@ -141,6 +141,9 @@ class HardwareVideoEncoder implements VideoEncoder { this.forcedKeyFrameNs = TimeUnit.MILLISECONDS.toNanos(forceKeyFrameIntervalMs); this.bitrateAdjuster = bitrateAdjuster; this.sharedContext = sharedContext; + + // Allow construction on a different thread. + encodeThreadChecker.detachThread(); } @Override @@ -263,6 +266,9 @@ class HardwareVideoEncoder implements VideoEncoder { codec = null; outputThread = null; + // Allow changing thread after release. + encodeThreadChecker.detachThread(); + return returnValue; } @@ -414,7 +420,6 @@ class HardwareVideoEncoder implements VideoEncoder { @Override public String getImplementationName() { - encodeThreadChecker.checkIsOnValidThread(); return "HardwareVideoEncoder: " + codecName; }