8000 Add 'enabled' method for MediaStreamTrack. · CodeStrings/flutter-webrtc@03dcf58 · GitHub
[go: up one dir, main page]

Skip to content

Commit 03dcf58

Browse files
committed
Add 'enabled' method for MediaStreamTrack.
1 parent e34edbd commit 03dcf58

File tree

9 files changed

+30
-15
lines changed

9 files changed

+30
-15
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,15 @@ public void onMethodCall(MethodCall call, Result result) {
173173
String streamId = call.argument("streamId");
174174
mediaStreamRelease(streamId);
175175
result.success(null);
176-
} else if (call.method.equals("trackDispose")) {
176+
}else if (call.method.equals("mediaStreamTrackSetEnable")) {
177+
String trackId = call.argument("trackId");
178+
Boolean enabled = call.argument("enabled");
179+
MediaStreamTrack track = getTrackForId(trackId);
180+
if(track != null){
181+
track.setEnabled(enabled);
182+
}
183+
result.success(null);
184+
}else if (call.method.equals("trackDispose")) {
177185
String trackId = call.argument("trackId");
178186
localTracks.remove(trackId);
179187
result.success(null);

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
);
249249
inputPaths = (
250250
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
251-
"${PODS_ROOT}/.symlinks/flutter/ios/Flutter.framework",
251+
"${PODS_ROOT}/.symlinks/flutter/ios-release/Flutter.framework",
252252
"${PODS_ROOT}/.symlinks/plugins/flutter_webrtc/ios/WebRTC.framework",
253253
);
254254
name = "[CP] Embed Pods Frameworks";
@@ -273,7 +273,7 @@
273273
);
274274
runOnlyForDeploymentPostprocessing = 0;
275275
shellPath = /bin/sh;
276-
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
276+
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
277277
};
278278
E550E15CC3C61725E6821A4E /* [CP] Check Pods Manifest.lock */ = {
279279
isa = PBXShellScriptBuildPhase;

example/lib/src/get_user_media_sample.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_webrtc/webrtc.dart';
33
import 'dart:core';
44

5-
/**
5+
/*
66
* getUserMedia sample
77
*/
88
class GetUserMediaSample extends StatefulWidget {

example/lib/src/loopback_sample.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ class _MyAppState extends State<LoopBackSample> {
109109
]
110110
};
111111

112-
final Map<String, dynamic> offer_sdp_constraints = {
112+
final Map<String, dynamic> offerSdpConstraints = {
113113
"mandatory": {
114114
"OfferToReceiveAudio": true,
115115
"OfferToReceiveVideo": true,
116116
},
117117
"optional": [],
118118
};
119119

120-
final Map<String, dynamic> loopback_constraints = {
120+
final Map<String, dynamic> loopbackConstraints = {
121121
"mandatory": {},
122122
"optional": [
123123
{"DtlsSrtpKeyAgreement": false},
@@ -131,7 +131,7 @@ class _MyAppState extends State<LoopBackSample> {
131131
_localRenderer.srcObject = _localStream;
132132

133133
_peerConnection =
134-
await createPeerConnection(configuration, loopback_constraints);
134+
await createPeerConnection(configuration, loopbackConstraints);
135135

136136
_peerConnection.onSignalingState = _onSignalingState;
137137
_peerConnection.onIceGatheringState = _onIceGatheringState;
@@ -143,7 +143,7 @@ class _MyAppState extends State<LoopBackSample> {
143143

144144
_peerConnection.addStream(_localStream);
145145
RTCSessionDescription description =
146-
await _peerConnection.createOffer(offer_sdp_constraints);
146+
await _peerConnection.createOffer(offerSdpConstraints);
147147
print(description.sdp);
148148
_peerConnection.setLocalDescription(description);
149149
//change for loopback.
@@ -174,6 +174,7 @@ class _MyAppState extends State<LoopBackSample> {
174174
setState(() {
175175
_inCalling = false;
176176
});
177+
_timer.cancel();
177178
}
178179

179180
@override

ios/Classes/FlutterWebRTCPlugin.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
280280
[self.localStreams removeObjectForKey:streamId];
281281
}
282282
result(nil);
283+
}else if([@"mediaStreamTrackSetEnable" isEqualToString:call.method]){
284+
NSDictionary* argsMap = call.arguments;
285+
NSString* trackId = argsMap[@"trackId"];
286+
NSNumber *enabled = argsMap[@"enabled"];
287+
RTCMediaStreamTrack *track = self.localTracks[trackId];
288+
if(track != nil){
289+
track.isEnabled = enabled;
290+
}
291+
result(nil);
283292
}else if([@"trackDispose" isEqualToString:call.method]){
284293
NSDictionary* argsMap = call.arguments;
285294
NSString* trackId = argsMap[@"trackId"];

lib/media_stream.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import 'package:flutter/services.dart';
33
import 'media_stream_track.dart';
44
import 'utils.dart';
55

6-
7-
86
class MediaStream {
97
MethodChannel _channel = WebRTC.methodChannel();
108
String _streamId;
@@ -68,7 +66,6 @@ class MediaStream {
6866
return _videoTracks;
6967
}
7068

71-
@override
7269
Future<Null> dispose() async {
7370
await _channel.invokeMethod(
7471
'streamDispose',

lib/media_stream_track.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MediaStreamTrack {
1111
MediaStreamTrack(this._trackId, this._label, this._kind, this._enabled);
1212

1313
set enabled(bool enabled) {
14-
_channel.invokeMethod('mediaStreamTrackEnabled',
14+
_channel.invokeMethod('mediaStreamTrackSetEnable',
1515
<String, dynamic>{'trackId': _trackId, 'enabled': enabled});
1616
_enabled = enabled;
1717
}

lib/rtc_data_channel.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class RTCDataChannel {
5454
final Map<dynamic, dynamic> map = event;
5555
switch (map['event']) {
5656
case 'dataChannelStateChanged':
57-
int dataChannelId = map['id'];
57+
//int dataChannelId = map['id'];
5858
String state = map['state'];
5959
if (this.onDataChannelState != null)
6060
this.onDataChannelState(rtcDataChannelStateForString(state));
6161
break;
6262
case 'dataChannelReceiveMessage':
63-
int dataChannelId = map['id'];
63+
//int dataChannelId = map['id'];
6464
String type = map['type'];
6565
String data = map['data'];
6666
if (this.onMessage != null)

lib/rtc_video_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RTCVideoRenderer {
1919
int _textureId;
2020
int _rotation = 0;
2121
double _width = 0.0, _height = 0.0;
22-
bool _mirror = false;
22+
bool _mirror;
2323
MediaStream _srcObject;
2424
RTCVideoViewObjectFit _objectFit =
2525
RTCVideoViewObjectFit.RTCVideoViewObjectFitContain;

0 commit comments

Comments
 (0)
0