From 9189efba3cd93f01153bd5e8971ce4df35b5835f Mon Sep 17 00:00:00 2001 From: shivansh Date: Thu, 17 Feb 2022 19:11:13 +0530 Subject: [PATCH] fixed #51 by making roomId type as dynamic Former-commit-id: 2f40bfb6756d4a3ac7c21a4d2013225d078ee8e0 [formerly c8ffbcb33fa904617cf94575ca3f9770ca4af6dd [formerly 2708ac20b5af7e5d66b34eac2eadd3108874a18e] [formerly 5c22602b798806a49aca69b993249218154355bb [formerly c1617feb4e404f7f0ded77bd5403d8e59696166d [formerly d86f44f11c0e825c8092be48d82a57a31782f5ba]]]] Former-commit-id: 9bb97df43191476ef903ab2eb2afab8ccbb8207b Former-commit-id: a8ccf02a8fbdd12ab04832fc320eb635b6bde6af [formerly 34f7af3507dc9429ca807e9a8c3a674266073d23] Former-commit-id: bf75fe6bc965c002959cc18ceabaf3f8474ee3bb Former-commit-id: 47726555ef30a8ec5e9795704cdaa3f8fd5a1a52 --- example/.flutter-plugins-dependencies | 2 +- example/lib/typed_examples/audio_bridge.dart | 2 +- .../typed_examples/screen_share_videoroom.dart | 2 +- example/lib/typed_examples/text_room.dart | 7 ++++--- example/lib/typed_examples/video_room.dart | 2 +- lib/janus_plugin.dart | 2 +- .../janus_audio_bridge_plugin.dart | 16 ++++++++-------- lib/wrapper_plugins/janus_text_room_plugin.dart | 6 +++--- lib/wrapper_plugins/janus_video_room_plugin.dart | 12 ++++++------ 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index bc058918..c4eebf04 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_ios","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.7/","dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_android","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.9/","dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.4/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.2/","dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_windows","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.4/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2022-02-17 18:52:57.865212","version":"2.10.0"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_ios","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.7/","dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_android","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.9/","dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.4/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.2/","dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.8.2/","dependencies":[]},{"name":"path_provider_windows","path":"/Users/zopper/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.4/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2022-02-17 19:08:19.195001","version":"2.10.0"} \ No newline at end of file diff --git a/example/lib/typed_examples/audio_bridge.dart b/example/lib/typed_examples/audio_bridge.dart index f67ced46..8d892945 100644 --- a/example/lib/typed_examples/audio_bridge.dart +++ b/example/lib/typed_examples/audio_bridge.dart @@ -20,7 +20,7 @@ class _AudioRoomState extends State { Map participants = {}; bool muted = false; bool callStarted = false; - String myRoom="1234"; + int myRoom=1234; @override void initState() { diff --git a/example/lib/typed_examples/screen_share_videoroom.dart b/example/lib/typed_examples/screen_share_videoroom.dart index 4a6a6555..5ea2752a 100644 --- a/example/lib/typed_examples/screen_share_videoroom.dart +++ b/example/lib/typed_examples/screen_share_videoroom.dart @@ -21,7 +21,7 @@ class _VideoRoomState extends State { JanusVideoRoomPlugin? remoteHandle; late int myId; MediaStream? myStream; - String myRoom = "1234"; + int myRoom = 1234; Map feedStreams = {}; Map subscriptions = {}; Map feeds = {}; diff --git a/example/lib/typed_examples/text_room.dart b/example/lib/typed_examples/text_room.dart index 4a819999..be6b97d1 100644 --- a/example/lib/typed_examples/text_room.dart +++ b/example/lib/typed_examples/text_room.dart @@ -15,6 +15,7 @@ class _TextRoomExampleState extends State { List textMessages = []; Map userNameDisplayMap = {}; late RestJanusTransport rest; + int myRoom=1234; late WebSocketJanusTransport ws; TextEditingController nameController = TextEditingController(); TextEditingController userNameController = TextEditingController(); @@ -40,7 +41,7 @@ class _TextRoomExampleState extends State { leave() async { try { - await textRoom.leaveRoom(1234); + await textRoom.leaveRoom(myRoom); setState(() { userNameDisplayMap = {}; textMessages = []; @@ -73,7 +74,7 @@ class _TextRoomExampleState extends State { child: ElevatedButton( onPressed: () async { await textRoom.joinRoom( - 1234, userNameController.text, + myRoom, userNameController.text, display: userNameController.text); Navigator.of(context).pop(dialog); }, @@ -169,7 +170,7 @@ class _TextRoomExampleState extends State { ); } Future sendMessage() async { - await textRoom.sendMessage("1234", nameController.text); + await textRoom.sendMessage(myRoom, nameController.text); nameController.text = ''; scrollToBottom(); } diff --git a/example/lib/typed_examples/video_room.dart b/example/lib/typed_examples/video_room.dart index 6c967291..62f075f5 100644 --- a/example/lib/typed_examples/video_room.dart +++ b/example/lib/typed_examples/video_room.dart @@ -22,7 +22,7 @@ class _VideoRoomState extends State { JanusVideoRoomPlugin? remoteHandle; late int myId; MediaStream? myStream; - String myRoom = "1234"; + int myRoom = 1234; Map feedStreams = {}; Map subscriptions = {}; Map feeds = {}; diff --git a/lib/janus_plugin.dart b/lib/janus_plugin.dart index f50216c7..aa9194ab 100644 --- a/lib/janus_plugin.dart +++ b/lib/janus_plugin.dart @@ -20,7 +20,7 @@ class JanusPlugin { bool _initialized = false; // internal method which takes care of type of roomId which is normally int but can be string if set in janus config for room _handleRoomIdTypeDifference(dynamic payload){ - payload["room"]=_context._stringIds==false?int.parse(payload["room"] as String):payload["room"]; + payload["room"]=_context._stringIds==false?payload["room"]:payload["room"].toString(); } late Stream _events; diff --git a/lib/wrapper_plugins/janus_audio_bridge_plugin.dart b/lib/wrapper_plugins/janus_audio_bridge_plugin.dart index 3a5ac5e5..e3851449 100644 --- a/lib/wrapper_plugins/janus_audio_bridge_plugin.dart +++ b/lib/wrapper_plugins/janus_audio_bridge_plugin.dart @@ -29,7 +29,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { ///[allowRtpParticipants] : true|false, whether participants should be allowed to join via plain RTP as well, default=false.
///[groups] : non-hierarchical array of string group names to use to gat participants, for external forwarding purposes only, optional.
/// - Future createRoom(String roomId, + Future createRoom(dynamic roomId, {bool permanent = true, String? description, String? secret, @@ -89,7 +89,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { ///[newIsPrivate] : true|false, whether the room should appear in a list request
///[permanent] : true|false, whether the room should be also removed from the config file, default=false /// - Future editRoom(String roomId, {String? secret, String? newDescription, String? newSecret, String? newPin, bool? newIsPrivate, bool? permanent}) async { + Future editRoom(dynamic roomId, {String? secret, String? newDescription, String? newSecret, String? newPin, bool? newIsPrivate, bool? permanent}) async { var payload = { "request": "edit", "room": roomId, @@ -127,7 +127,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { ///[record] : true|false, whether to record this user's contribution to a .mjr file (mixer not involved)
///[filename] : "basename of the file to record to, -audio.mjr will be added by the plugin
/// - Future joinRoom(String roomId, + Future joinRoom(dynamic roomId, {String? id, String? group, String? pin, @@ -225,7 +225,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { /// [participantId] unique numeric ID of the participant.
/// [mute] toggle mute status of the participant.
/// [secret] admin secret should be provided if configured.
- Future muteParticipant(String roomId, int participantId, bool mute, {String? secret}) async { + Future muteParticipant(dynamic roomId, int participantId, bool mute, {String? secret}) async { var payload = {"request": mute ? 'mute' : 'unmute', "secret": secret, "room": roomId, "id": participantId}..removeWhere((key, value) => value == null); _handleRoomIdTypeDifference(payload); JanusEvent response = JanusEvent.fromJson(await this.send(data: payload)); @@ -238,7 +238,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { /// To stop a previously created RTP forwarder.
/// [roomId] unique numeric ID of the room to stop the forwarder from.
/// [streamId] unique numeric ID of the RTP forwarder.
- Future stopRtpForward(String roomId, int streamId) async { + Future stopRtpForward(dynamic roomId, int streamId) async { var payload = {"request": "stop_rtp_forward", "room": roomId, "stream_id": streamId}; _handleRoomIdTypeDifference(payload); JanusEvent response = JanusEvent.fromJson(await this.send(data: payload)); @@ -252,7 +252,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { /// [roomId] unique numeric ID of the room to stop the forwarder from.
/// [participantId] unique numeric ID of the participant.
/// [secret] admin secret should be provided if configured.
- Future kickParticipant(String roomId, int participantId, {String? secret}) async { + Future kickParticipant(dynamic roomId, int participantId, {String? secret}) async { var payload = {"request": "kick", "secret": secret, "room": roomId, "id": participantId}..removeWhere((key, value) => value == null); _handleRoomIdTypeDifference(payload); JanusEvent response = JanusEvent.fromJson(await this.send(data: payload)); @@ -274,7 +274,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { /// [alwaysOn] true|false, whether silence should be forwarded when the room is empty.
/// [srtpCrypto] key to use as crypto (base64 encoded key as in SDES); optional.
/// [adminKey] key to use if adminKey is set for rtp forward as well.
- Future rtpForward(String roomId, String host, int port, + Future rtpForward(dynamic roomId, String host, int port, {String? group, String? adminKey, String? ssrc, String? codec, String? ptype, int? srtpSuite, bool? alwaysOn, String? hostFamily, String? srtpCrypto}) async { var payload = { "request": "rtp_forward", @@ -301,7 +301,7 @@ class JanusAudioBridgePlugin extends JanusPlugin { /// /// To get a list of the participants in a specific room of [roomId] /// - Future> listParticipants(String roomId) async { + Future> listParticipants(dynamic roomId) async { var payload = { "request": "listparticipants", "room": roomId, diff --git a/lib/wrapper_plugins/janus_text_room_plugin.dart b/lib/wrapper_plugins/janus_text_room_plugin.dart index 098c3171..115c86ee 100644 --- a/lib/wrapper_plugins/janus_text_room_plugin.dart +++ b/lib/wrapper_plugins/janus_text_room_plugin.dart @@ -92,7 +92,7 @@ class JanusTextRoomPlugin extends JanusPlugin { ///[ack] : true|false, whether the sender wants an ack for the sent message(s); optional, true by default
. ///[to] : username to send the message to; optional, only needed in case of private messages.
///[tos] : array of usernames to send the message to; optional, only needed in case of private messages.
- Future sendMessage(String roomId, String text, + Future sendMessage(dynamic roomId, String text, {bool? ack, String? to, List? tos}) async { if (setupDone) { var message = { @@ -121,7 +121,7 @@ class JanusTextRoomPlugin extends JanusPlugin { }; } - Future listParticipants(String roomId) async { + Future listParticipants(dynamic roomId) async { var payload = {"request": "listparticipants", "room": roomId}; } @@ -133,7 +133,7 @@ class JanusTextRoomPlugin extends JanusPlugin { /// [roomId] unique numeric ID of the room to stop the forwarder from.
/// [username] username of the participant to kick.
/// [secret] admin secret should be provided if configured.
- Future kickParticipant(String roomId, String username, + Future kickParticipant(dynamic roomId, String username, {String? secret}) async { var payload = { "request": "kick", diff --git a/lib/wrapper_plugins/janus_video_room_plugin.dart b/lib/wrapper_plugins/janus_video_room_plugin.dart index 3742c410..f3f499c5 100644 --- a/lib/wrapper_plugins/janus_video_room_plugin.dart +++ b/lib/wrapper_plugins/janus_video_room_plugin.dart @@ -6,7 +6,7 @@ class JanusVideoRoomPlugin extends JanusPlugin { /// This allows you to modify the room description, secret, pin and whether it's private or not: /// you won't be able to modify other more static properties, like the room ID, the sampling rate, /// the extensions-related stuff and so on - Future editRoom(String roomId, + Future editRoom(dynamic roomId, {String? secret, String? newDescription, String? newSecret, @@ -40,14 +40,14 @@ class JanusVideoRoomPlugin extends JanusPlugin { } /// Used to destroy an existing video room, whether created dynamically or statically - Future destroyRoom(String roomId, {String? secret, bool? permanent}) async { + Future destroyRoom(dynamic roomId, {String? secret, bool? permanent}) async { var payload = {"request": "destroy", "room": roomId, if (secret != null) "secret": secret, if (permanent != null) "permanent": permanent}; _handleRoomIdTypeDifference(payload); return (await this.send(data: payload)); } /// Used to create a new video room - Future createRoom(String roomId, {bool permanent = false, String? pin, Map? extras, List? allowed, String? isPrivate, String description = '', String? secret}) async { + Future createRoom(dynamic roomId, {bool permanent = false, String? pin, Map? extras, List? allowed, String? isPrivate, String description = '', String? secret}) async { var payload = {"request": "create", "room": roomId, "permanent": permanent, "description": description, ...?extras}; if (allowed != null) payload["allowed"] = allowed; if (isPrivate != null) payload["is_private"] = isPrivate; @@ -58,7 +58,7 @@ class JanusVideoRoomPlugin extends JanusPlugin { } /// get list of participants in a existing video room - Future getRoomParticipants(String roomId) async { + Future getRoomParticipants(dynamic roomId) async { var payload = {"request": "listparticipants", "room": roomId}; Map data = await this.send(data: payload); _handleRoomIdTypeDifference(payload); @@ -83,7 +83,7 @@ class JanusVideoRoomPlugin extends JanusPlugin { } /// joins the [JanusVideoRoom] as a media publisher on provided [roomId] with its name as [displayName] and optionally can provide your own [id]. - Future joinPublisher(String roomId, {String? pin, int? id, String? token, String? displayName}) async { + Future joinPublisher(dynamic roomId, {String? pin, int? id, String? token, String? displayName}) async { var payload = { "request": "join", "ptype": "publisher", @@ -106,7 +106,7 @@ class JanusVideoRoomPlugin extends JanusPlugin { /// joins the [JanusVideoRoom] as a media publisher on provided [roomId] with its name as [displayName] and optionally can provide your own [id]. Future Function({String? audioRecv, String? audioSend, String? videoRecv, String? videoSend})> joinSubscriber( - String roomId, { + dynamic roomId, { List? streams, int? privateId, int? feedId,