10000 enabled addTrack API for android and ios by yonatann · Pull Request #203 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

enabled addTrack API for android and ios #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,21 @@ private Map<String, Object> rtpParametersToMap(RtpParameters rtpParameters){
for(RtpParameters.Encoding encoding : rtpParameters.encodings){
ConstraintsMap map = new ConstraintsMap();
map.putBoolean("active",encoding.active);
map.putInt("maxBitrateBps", encoding.maxBitrateBps);
map.putInt("minBitrateBps", encoding.minBitrateBps);
map.putInt("maxFramerate", encoding.maxFramerate);
map.putInt("numTemporalLayers", encoding.numTemporalLayers);
map.putDouble("scaleResolutionDownBy", encoding.scaleResolutionDownBy);
if (encoding.maxBitrateBps != null) {
map.putInt("maxBitrateBps", encoding.maxBitrateBps);
}
if (encoding.minBitrateBps != null) {
map.putInt("minBitrateBps", encoding.minBitrateBps);
}
if (encoding.maxFramerate != null) {
map.putInt("maxFramerate", encoding.maxFramerate);
}
if (encoding.numTemporalLayers != null) {
map.putInt("numTemporalLayers", encoding.numTemporalLayers);
}
if (encoding.scaleResolutionDownBy != null) {
map.putDouble("scaleResolutionDownBy", encoding.scaleResolutionDownBy);
}
map.putLong("ssrc", encoding.ssrc);
encodings.pushMap(map);
}
Expand Down Expand Up @@ -581,8 +591,10 @@ private Map<String, Object> mediaTrackToMap(MediaStreamTrack track){
private Map<String, Object> dtmfSenderToMap(DtmfSender dtmfSender, String id){
ConstraintsMap info = new ConstraintsMap();
info.putString("dtmfSenderId",id);
info.putInt("interToneGap", dtmfSender.interToneGap());
info.putInt("duration",dtmfSender.duration());
if (dtmfSender != null) {
info.putInt("interToneGap", dtmfSender.interToneGap());
info.putInt("duration", dtmfSender.duration());
}
return info.toMap();
}

Expand All @@ -599,6 +611,7 @@ private Map<String, Object> rtpSenderToMap(RtpSender sender){
private Map<String, Object> rtpReceiverToMap(RtpReceiver receiver){
ConstraintsMap info = new ConstraintsMap();
info.putString("receiverId", receiver.id());
info.putMap("rtpParameters", rtpParametersToMap(receiver.getParameters()));
info.putMap("track", mediaTrackToMap(receiver.track()));
return info.toMap();
}
Expand Down
42 changes: 42 additions & 0 deletions ios/Classes/FlutterWebRTCPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,48 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
message:[NSString stringWithFormat:@"Error: peerConnection or mediaStream not found!"]
details:nil]);
}
} else if ([@"addTrack" isEqualToString:call.method]) {
NSDictionary* argsMap = call.arguments;

NSString* peerConnectionId = ((NSString*)argsMap[@"peerConnectionId"]);
NSString* trackId = ((NSString*)argsMap[@"trackId"]);
NSArray<NSString *> *streamIds = ((NSArray<NSString *>*)argsMap[@"streamIds"]);

RTCPeerConnection *peerConnection = self.peerConnections[peerConnectionId];
RTCMediaStreamTrack *track = self.localTracks[trackId];

if (peerConnection && track) {
RTCRtpSender* sender = [peerConnection addTrack:track streamIds:streamIds];

// TODO: properly map sender
result(@{
@"senderId": sender.senderId,
@"ownsTrack": @(YES),
@"dtmfSender": @{
@"dtmfSenderId": sender.senderId,
},
@"rtpParameters": @{
@"encodings": @[],
@"headerExtensions": @[],
@"codecs": @[],
@"rtcp": @{

},
},
8000 @"track": @{
@"id": sender.track.trackId,
@"kind": sender.track.kind,
@"label": sender.track.trackId,
@"enabled": @(sender.track.isEnabled),
@"remote": @(YES),
@"readyState": @"live"
}
});
} else {
result([FlutterError errorWithCode:[NSString stringWithFormat:@"%@Failed",call.method]
message:[NSString stringWithFormat:@"Error: peerConnection or track not found!"]
details:nil]);
}
} else if ([@"removeStream" isEqualToString:call.method]) {
NSDictionary* argsMap = call.arguments;

Expand Down
2 changes: 1 addition & 1 deletion ios/flutter_webrtc.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A new flutter plugin project.
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'libyuv-iOS'
s.dependency 'GoogleWebRTC', '1.1.27299'
s.dependency 'GoogleWebRTC', '1.1.29229'
s.ios.deployment_target = '9.0'
s.static_framework = true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/media_stream_track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MediaStreamTrack {
/// public:
factory MediaStreamTrack.fromMap(Map<dynamic, dynamic> map) {
return new MediaStreamTrack(
map['trackId'], map['label'], map['kind'], map['enabled']);
map['id'], map['label'], map['kind'], map['enabled']);
}

MediaStreamTrack(this._trackId, this._label, this._kind, this._enabled);
Expand Down
2 changes: 1 addition & 1 deletion lib/rtc_rtp_receiver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class RTCRtpReceiver {
OnFirstPacketReceivedCallback onFirstPacketReceived;

factory RTCRtpReceiver.fromMap(Map<dynamic, dynamic> map) {
MediaStreamTrack track = MediaStreamTrack.fromMap(map['trackInfo']);
MediaStreamTrack track = MediaStreamTrack.fromMap(map['track']);
RTCRtpParameters parameters =
RTCRtpParameters.fromMap(map['rtpParameters']);
return RTCRtpReceiver(map['receiverId'], track, parameters);
Expand Down
2 changes: 1 addition & 1 deletion lib/rtc_rtp_sender.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RTCRtpSender {
return new RTCRtpSender(
map['senderId'],
MediaStreamTrack.fromMap(map['track']),
RTCDTMFSender.fromMap(map['dtmfSender']),
RTCDTMFSender.fromMap(Map<String, dynamic>.from(map['dtmfSender'])),
RTCRtpParameters.fromMap(map['rtpParameters']),
map['ownsTrack']);
}
Expand Down
0