Relax threading requirements in VideoEncoder.
Previous strict threading requirements we not always followed and this causes crashes in some scenarios. Bug: webrtc:7760 Change-Id: I4808edfff19c63a9c4a9585834d46f9c73bb1c4b Reviewed-on: https://webrtc-review.googlesource.com/13660 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20353}
This commit is contained in:
committed by
Commit Bot
parent
15c9cf732b
commit
5f5fc6845a
@ -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();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user