20
20
21
21
import java .nio .ByteBuffer ;
22
22
/**
23
- * Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream on a SurfaceView .
23
+ * Implements org.webrtc.VideoRenderer.Callbacks by displaying the video stream on a SurfaceTexture .
24
24
* renderFrame() is asynchronous to avoid blocking the calling thread.
25
25
* This class is thread safe and handles access from potentially four different threads:
26
26
* Interaction from the main app in init, release, setMirror, and setScalingtype.
29
29
* Interaction with the layout framework in onMeasure and onSizeChanged.
30
30
*/
31
31
public class SurfaceTextureRenderer implements VideoRenderer .Callbacks {
32
- private static final String TAG = "SurfaceViewRenderer " ;
32
+ private static final String TAG = "SurfaceTextureRenderer " ;
33
33
34
34
private final SurfaceTexture texture ;
35
35
// Dedicated render thread.
@@ -53,16 +53,7 @@ public class SurfaceTextureRenderer implements VideoRenderer.Callbacks {
53
53
54
54
// These variables are synchronized on |layoutLock|.
55
55
private final Object layoutLock = new Object ();
56
- // These dimension values are used to keep track of the state in these functions: onMeasure(),
57
- // onLayout(), and surfaceChanged(). A new layout is triggered with requestLayout(). This happens
58
- // internally when the incoming frame size changes. requestLayout() can also be triggered
59
- // externally. The layout change is a two pass process: first onMeasure() is called in a top-down
60
- // traversal of the View tree, followed by an onLayout() pass that is also top-down. During the
61
- // onLayout() pass, each parent is responsible for positioning its children using the sizes
62
- // computed in the measure pass.
63
- // |desiredLayoutsize| is the layout size we have requested in onMeasure() and are waiting for to
64
- // take effect.
65
- private Point desiredLayoutSize = new Point ();
56
+
66
57
// |layoutSize|/|surfaceSize| is the actual current layout/surface size. They are updated in
67
58
// onLayout() and surfaceChanged() respectively.
68
59
private final Point layoutSize = new Point ();
@@ -75,8 +66,7 @@ public class SurfaceTextureRenderer implements VideoRenderer.Callbacks {
75
66
private int frameWidth ;
76
67
private int frameHeight ;
77
68
private int frameRotation ;
78
- // |scalingType| determines how the video will fill the allowed layout area in onMeasure().
79
- private RendererCommon .ScalingType scalingType = RendererCommon .ScalingType .SCALE_ASPECT_BALANCED ;
69
+
80
70
// If true, mirrors the video stream horizontally.
81
71
private boolean mirror ;
82
72
// Callback for reporting renderer events.
@@ -336,15 +326,6 @@ public void setMirror(final boolean mirror) {
336
326
}
337
327
}
338
328
339
- /**
340
- * Set how the video will fill the allowed layout area.
341
- */
342
- public void setScalingType (RendererCommon .ScalingType scalingType ) {
343
- synchronized (layoutLock ) {
344
- this .scalingType = scalingType ;
345
- }
346
- }
347
-
348
329
// VideoRenderer.Callbacks interface.
349
330
@ Override
350
331
public void renderFrame (VideoRenderer .I420Frame frame ) {
@@ -440,16 +421,7 @@ private boolean checkConsistentLayout() {
440
421
throw new IllegalStateException (getResourceName () + "Wrong thread." );
441
422
}
442
423
synchronized (layoutLock ) {
443
- // Return false while we are in the middle of a layout change.
444
- // XXX by Lyubomir Marinov <lyubomir.marinov@jitsi.org>: Do not wait for
445
- // layoutSize to become equal to desiredLayoutSize because that may never
446
- // happen: desiredLayoutSize expresses the desire of this View computed
447
- // during onMeasure but the final decision on layoutSize belongs to the
448
- // ViewParent of this View taken around the execution time of onLayout. If
449
- // this instance waits for the condition and its ViewParent does not
450
- // satisfy the request for desiredLayoutSize, this SurfaceViewRenderer
451
- // will render black.
452
- return /* layoutSize.equals(desiredLayoutSize) && */ surfaceSize .equals (layoutSize );
424
+ return surfaceSize .equals (layoutSize );
453
425
}
454
426
}
455
427
0 commit comments