10000 Clean · PushoN/flutter-webrtc@c399fda · GitHub
[go: up one dir, main page]

Skip to content

Commit c399fda

Browse files
committed
Clean
1 parent 9a97ba5 commit c399fda

File tree

5 files changed

+17
-71
lines changed

5 files changed

+17
-71
lines changed

android/src/main/java/com/cloudwebrtc/webrtc/DataChannelObserver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public void onCancel(Object o) {
5252
}
5353

5454
@Override
55-
public void onBufferedAmountChange(long amount) {
56-
}
55+
public void onBufferedAmountChange(long amount) { }
5756

5857
@Override
5958
public void onStateChange() {

android/src/main/java/com/cloudwebrtc/webrtc/FlutterRTCVideoRenderer.java

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Dispose(){
3131

3232
/**
3333
* The {@code RendererEvents} which listens to rendering events reported by
34-
* {@link #surfaceViewRenderer}.
34+
* {@link #surfaceTextureRenderer}.
3535
*/
3636
private final RendererEvents rendererEvents
3737
= new RendererEvents() {
@@ -43,9 +43,6 @@ public void onFirstFrameRendered() {
4343
public void onFrameResolutionChanged(
4444
int videoWidth, int videoHeight,
4545
int rotation) {
46-
FlutterRTCVideoRenderer.this.onFrameResolutionChanged(
47-
videoWidth, videoHeight,
48-
rotation);
4946

5047
if(eventSink != null)
5148
{
@@ -72,7 +69,7 @@ public void onFrameResolutionChanged(
7269
}
7370
};
7471

75-
private final SurfaceTextureRenderer surfaceViewRenderer;
72+
private final SurfaceTextureRenderer surfaceTextureRenderer;
7673

7774
/**
7875
* The {@code VideoRenderer}, if any, which renders {@link #videoTrack} on
@@ -89,7 +86,7 @@ public void onFrameResolutionChanged(
8986
EventChannel.EventSink eventSink;
9087

9188
public FlutterRTCVideoRenderer(SurfaceTexture texture, Context context) {
92-
this.surfaceViewRenderer = new SurfaceTextureRenderer(context, texture);
89+
this.surfaceTextureRenderer = new SurfaceTextureRenderer(context, texture);
9390
this.texture = texture;
9491
this.eventSink = null;
9592
}
@@ -112,30 +109,8 @@ public void onCancel(Object o) {
112109
eventSink = null;
113110
}
114111

115-
private final SurfaceTextureRenderer getSurfaceViewRenderer() {
116-
return surfaceViewRenderer;
117-
}
118-
119-
private void onFrameResolutionChanged(
120-
int videoWidth, int videoHeight,
121-
int rotation) {
122-
boolean changed = false;
123-
/*
124-
synchronized (layoutSyncRoot) {
125-
if (this.frameHeight != videoHeight) {
126-
this.frameHeight = videoHeight;
127-
changed = true;
128-
}
129-
if (this.frameRotation != rotation) {
130-
this.frameRotation = rotation;
131-
changed = true;
132-
}
133-
if (this.frameWidth != videoWidth) {
134-
this.frameWidth = videoWidth;
135-
changed = true;
136-
}
137-
}
138-
*/
112+
private final SurfaceTextureRenderer getSurfaceTextureRenderer() {
113+
return surfaceTextureRenderer;
139114
}
140115

141116
/**
@@ -148,7 +123,7 @@ private void removeRendererFromVideoTrack() {
148123
videoRenderer.dispose();
149124
videoRenderer = null;
150125

151-
getSurfaceViewRenderer().release();
126+
getSurfaceTextureRenderer().release();
152127
}
153128
}
154129

@@ -212,7 +187,7 @@ private void tryAddRendererToVideoTrack() {
212187
return;
213188
}
214189

215-
SurfaceTextureRenderer surfaceViewRenderer = getSurfaceViewRenderer();
190+
SurfaceTextureRenderer surfaceViewRenderer = getSurfaceTextureRenderer();
216191
surfaceViewRenderer.init(sharedContext, rendererEvents);
217192

218193
videoRenderer = new VideoRenderer(surfaceViewRenderer);

android/src/main/java/com/cloudwebrtc/webrtc/FlutterWebRTCPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import io.flutter.view.TextureRegistry;
3737

3838
/**
39-
* WebrtcPlugin
39+
* FlutterWebRTCPlugin
4040
*/
4141
public class FlutterWebRTCPlugin implements MethodCallHandler {
4242

android/src/main/java/com/cloudwebrtc/webrtc/GetUserMediaImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ void getUserMedia(
305305
final ConstraintsMap constraints,
306306
final Result result,
307307
final MediaStream mediaStream) {
308+
308309
// TODO: change getUserMedia constraints format to support new syntax
309310
// constraint format seems changed, and there is no mandatory any more.
310311
// and has a new syntax/attrs to specify resolution
@@ -361,8 +362,7 @@ public void onStop() {
361362
});
362363

363364
if (videoCapturer != null) {
364-
365-
365+
366366
PeerConnectionFactory pcFactory = plugin.mFactory;
367367
VideoSource videoSource = pcFactory.createVideoSource(videoCapturer);
368368

@@ -539,7 +539,7 @@ private void getUserMedia(
539539
// https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia
540540
// with respect to distinguishing the various causes of failure.
541541
result.error(
542-
/* type */ null,
542+
/* type */ "GetUserMediaFailed",
543543
"Failed to create new track", null);
544544
return;
545545
}

android/src/main/java/com/cloudwebrtc/webrtc/SurfaceTextureRenderer.java

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import java.nio.ByteBuffer;
2222
/**
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.
2424
* renderFrame() is asynchronous to avoid blocking the calling thread.
2525
* This class is thread safe and handles access from potentially four different threads:
2626
* Interaction from the main app in init, release, setMirror, and setScalingtype.
@@ -29,7 +29,7 @@
2929
* Interaction with the layout framework in onMeasure and onSizeChanged.
3030
*/
3131
public class SurfaceTextureRenderer implements VideoRenderer.Callbacks {
32-
private static final String TAG = "SurfaceViewRenderer";
32+
private static final String TAG = "SurfaceTextureRenderer";
3333

3434
private final SurfaceTexture texture;
3535
// Dedicated render thread.
@@ -53,16 +53,7 @@ public class SurfaceTextureRenderer implements VideoRenderer.Callbacks {
5353

5454
// These variables are synchronized on |layoutLock|.
5555
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+
6657
// |layoutSize|/|surfaceSize| is the actual current layout/surface size. They are updated in
6758
// onLayout() and surfaceChanged() respectively.
6859
private final Point layoutSize = new Point();
@@ -75,8 +66,7 @@ public class SurfaceTextureRenderer implements VideoRenderer.Callbacks {
7566
private int frameWidth;
7667
private int frameHeight;
7768
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+
8070
// If true, mirrors the video stream horizontally.
8171
private boolean mirror;
8272
// Callback for reporting renderer events.
@@ -336,15 +326,6 @@ public void setMirror(final boolean mirror) {
336326
}
337327
}
338328

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-
348329
// VideoRenderer.Callbacks interface.
349330
@Override
350331
public void renderFrame(VideoRenderer.I420Frame frame) {
@@ -440,16 +421,7 @@ private boolean checkConsistentLayout() {
440421
throw new IllegalStateException(getResourceName() + "Wrong thread.");
441422
}
442423
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);
453425
}
454426
}
455427

0 commit comments

Comments
 (0)
0