10000 Update. · MUBUSHER/flutter-webrtc@5427e4f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5427e4f

Browse files
committed
Update.
1 parent 13e7d32 commit 5427e4f

File tree

9 files changed

+98
-578
lines changed

9 files changed

+98
-578
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
.packages
3+
.vscode/.DS_Store
4+
example/pubspec.lock
5+
pubspec.lock
6+
example/ios/Podfile.lock

android/src/main/java/com/cloudwebrtc/webrtc/WebrtcPlugin.java renamed to android/src/main/java/com/cloudwebrtc/webrtc/FlutterWebRTCPlugin.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,26 @@
99
/**
1010
* WebrtcPlugin
1111
*/
12-
public class WebrtcPlugin implements MethodCallHandler {
12+
public class FlutterWebRTCPlugin implements MethodCallHandler {
1313

1414
private final Registrar registrar;
1515
private final MethodChannel channel;
1616

17+
/**
18+
* The implementation of {@code getUserMedia} extracted into a separate file
19+
* in order to reduce complexity and to (somewhat) separate concerns.
20+
*/
21+
private final GetUserMediaImpl getUserMediaImpl;
22+
1723
/**
1824
* Plugin registration.
1925
*/
2026
public static void registerWith(Registrar registrar) {
21-
final MethodChannel channel = new MethodChannel(registrar.messenger(), "webrtc");
22-
channel.setMethodCallHandler(new WebrtcPlugin(channel,registrar));
27+
final MethodChannel channel = new MethodChannel(registrar.messenger(), "cloudwebrtc.com/WebRTC.Method");
28+
channel.setMethodCallHandler(new FlutterWebRTCPlugin(registrar,channel));
2329
}
2430

25-
private WebrtcPlugin(Registrar registrar, MethodChannel channel) {
31+
private FlutterWebRTCPlugin(Registrar registrar, MethodChannel channel) {
2632
this.registrar = registrar;
2733
this.channel = channel;
2834
//channel.invokeMethod("onMessage", message.getData());

example/ios/Podfile.lock

Lines changed: 0 additions & 22 deletions
This file was deleted.

example/lib/main.dart

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,13 @@ class MyApp extends StatefulWidget {
1919
class _MyAppState extends State<MyApp> {
2020
MediaStream _localStream;
2121
RTCPeerConnection _peerConnection;
22-
var _width = 240.0;
23-
var _height = 180.0;
24-
var _rotation = 0;
25-
final _localVideoRenderer = new RTCVideoRenderer();
26-
final _remoteVideoRenderer = new RTCVideoRenderer();
22+
final _localRenderer = new RTCVideoRenderer();
23+
final _remoteRenderer = new RTCVideoRenderer();
2724

2825
@override
2926
initState() {
3027
super.initState();
3128
initPlatformState();
32-
_localVideoRenderer.onVideoRotationChange = _onVideoRotationChange;
33-
_localVideoRenderer.onVideoSizeChange = _onVideoSizeChange;
34-
}
35-
36-
_onVideoRotationChange(int textureId, int rotation)
37-
{
38-
setState((){
39-
_rotation = rotation;
40-
});
41-
}
42-
43-
_onVideoSizeChange(int textureId, double width, double height){
44-
4529
}
4630

4731
_onSignalingState(RTCSignalingState state) {
@@ -58,11 +42,11 @@ class _MyAppState extends State<MyApp> {
5842

5943
_onAddStream(MediaStream stream) {
6044
print('addStream: ' + stream.id);
61-
_remoteVideoRenderer.srcObject = stream;
45+
_remoteRenderer.srcObject = stream;
6246
}
6347

6448
_onRemoveStream(MediaStream stream) {
65-
_remoteVideoRenderer.srcObject = null;
49+
_remoteRenderer.srcObject = null;
6650
}
6751

6852
_onCandidate(RTCIceCandidate candidate) {
@@ -89,11 +73,7 @@ class _MyAppState extends State<MyApp> {
8973
"optional": [],
9074
}
9175
};
92-
/*
93-
final Map<String, dynamic> mediaConstraints = {
94-
"audio": true,
95-
"video": true,
96-
};*/
76+
9777
Map<String, dynamic> configuration = {
9878
"iceServers": [
9979
{"url": "stun:stun.l.google.com:19302"},
@@ -118,9 +98,9 @@ class _MyAppState extends State<MyApp> {
11898
// Platform messages may fail, so we use a try/catch PlatformException.
11999
try {
120100
_localStream = await getUserMedia(mediaConstraints);
121-
await _localVideoRenderer.initialize();
122-
await _remoteVideoRenderer.initialize();
123-
_localVideoRenderer.srcObject = _localStream;
101+
await _localRenderer.initialize();
102+
await _remoteRenderer.initialize();
103+
_localRenderer.srcObject = _localStream;
124104

125105
_peerConnection =
126106
await createPeerConnection(configuration, LOOPBACK_CONSTRAINTS);
@@ -161,30 +141,16 @@ class _MyAppState extends State<MyApp> {
161141
crossAxisAlignment: CrossAxisAlignment.start,
162142
children: [
163143
new Text('Loopback demo.'),
164-
new Transform(
165-
child: new Container(
166-
width: _width,
167-
height: _height,
168-
child: _remoteVideoRenderer.isInitialized
169-
? new Texture(textureId: _remoteVideoRenderer.renderId)
170-
: null,
171-
),
172-
alignment: FractionalOffset.center, // set transform origin
173-
transform: new Matrix4.identity()
174-
..rotateZ(_rotation * 3.1415927 / 180),
144+
new Container(
145+
width: 320.0,
146+
height: 240.0,
147+
child: new RTCVideoView(_localRenderer),
175148
),
176149
new Text('Local video'),
177-
new Transform(
178-
child: new Container(
179-
width: _width,
180-
height: _height,
181-
child: _remoteVideoRenderer.isInitialized
182-
? new Texture(textureId: _remoteVideoRenderer.renderId)
183-
: null,
184-
),
185-
alignment: FractionalOffset.center, // set transform origin
186-
transform: new Matrix4.identity()
187-
..rotateZ(90 * 3.1415927 / 180),
150+
new Container(
151+
width: 320.0,
152+
height: 240.0,
153+
child: new RTCVideoView(_remoteRenderer),
188154
),
189155
new Text('Remote video'),
190156
])),

0 commit comments

Comments
 (0)
0