Skip to content

Commit

Permalink
fixed #51 by making roomId type as dynamic
Browse files Browse the repository at this point in the history
Former-commit-id: 2f40bfb6756d4a3ac7c21a4d2013225d078ee8e0 [formerly c8ffbcb [formerly 2708ac20b5af7e5d66b34eac2eadd3108874a18e] [formerly 5c22602b798806a49aca69b993249218154355bb [formerly c1617fe [formerly d86f44f11c0e825c8092be48d82a57a31782f5ba]]]]
Former-commit-id: 9bb97df43191476ef903ab2eb2afab8ccbb8207b
Former-commit-id: a8ccf02a8fbdd12ab04832fc320eb635b6bde6af [formerly 34f7af3]
Former-commit-id: bf75fe6bc965c002959cc18ceabaf3f8474ee3bb
Former-commit-id: 47726555ef30a8ec5e9795704cdaa3f8fd5a1a52
  • Loading branch information
shivansh committed Feb 17, 2022
1 parent 147172d commit 9189efb
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
2 changes: 1 addition & 1 deletion example/lib/typed_examples/audio_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class _AudioRoomState extends State<TypedAudioRoomV2> {
Map<String, AudioBridgeParticipants> participants = {};
bool muted = false;
bool callStarted = false;
String myRoom="1234";
int myRoom=1234;

@override
void initState() {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/typed_examples/screen_share_videoroom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _VideoRoomState extends State<TypedScreenShareVideoRoomV2Unified> {
JanusVideoRoomPlugin? remoteHandle;
late int myId;
MediaStream? myStream;
String myRoom = "1234";
int myRoom = 1234;
Map<int, dynamic> feedStreams = {};
Map<int?, dynamic> subscriptions = {};
Map<int, dynamic> feeds = {};
Expand Down
7 changes: 4 additions & 3 deletions example/lib/typed_examples/text_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class _TextRoomExampleState extends State<TypedTextRoom> {
List<dynamic> textMessages = [];
Map<String, String> userNameDisplayMap = {};
late RestJanusTransport rest;
int myRoom=1234;
late WebSocketJanusTransport ws;
TextEditingController nameController = TextEditingController();
TextEditingController userNameController = TextEditingController();
Expand All @@ -40,7 +41,7 @@ class _TextRoomExampleState extends State<TypedTextRoom> {

leave() async {
try {
await textRoom.leaveRoom(1234);
await textRoom.leaveRoom(myRoom);
setState(() {
userNameDisplayMap = {};
textMessages = [];
Expand Down Expand Up @@ -73,7 +74,7 @@ class _TextRoomExampleState extends State<TypedTextRoom> {
child: ElevatedButton(
onPressed: () async {
await textRoom.joinRoom(
1234, userNameController.text,
myRoom, userNameController.text,
display: userNameController.text);
Navigator.of(context).pop(dialog);
},
Expand Down Expand Up @@ -169,7 +170,7 @@ class _TextRoomExampleState extends State<TypedTextRoom> {
);
}
Future<void> sendMessage() async {
await textRoom.sendMessage("1234", nameController.text);
await textRoom.sendMessage(myRoom, nameController.text);
nameController.text = '';
scrollToBottom();
}
Expand Down
2 changes: 1 addition & 1 deletion example/lib/typed_examples/video_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _VideoRoomState extends State<TypedVideoRoomV2Unified> {
JanusVideoRoomPlugin? remoteHandle;
late int myId;
MediaStream? myStream;
String myRoom = "1234";
int myRoom = 1234;
Map<int, dynamic> feedStreams = {};
Map<int?, dynamic> subscriptions = {};
Map<int, dynamic> feeds = {};
Expand Down
2 changes: 1 addition & 1 deletion lib/janus_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<dynamic> _events;
Expand Down
16 changes: 8 additions & 8 deletions lib/wrapper_plugins/janus_audio_bridge_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>
///[groups] : non-hierarchical array of string group names to use to gat participants, for external forwarding purposes only, optional.<br>
///
Future<AudioRoomCreatedResponse> createRoom(String roomId,
Future<AudioRoomCreatedResponse> createRoom(dynamic roomId,
{bool permanent = true,
String? description,
String? secret,
Expand Down Expand Up @@ -89,7 +89,7 @@ class JanusAudioBridgePlugin extends JanusPlugin {
///[newIsPrivate] : true|false, whether the room should appear in a list request<br>
///[permanent] : true|false, whether the room should be also removed from the config file, default=false
///
Future<dynamic> editRoom(String roomId, {String? secret, String? newDescription, String? newSecret, String? newPin, bool? newIsPrivate, bool? permanent}) async {
Future<dynamic> editRoom(dynamic roomId, {String? secret, String? newDescription, String? newSecret, String? newPin, bool? newIsPrivate, bool? permanent}) async {
var payload = {
"request": "edit",
"room": roomId,
Expand Down Expand Up @@ -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)<br>
///[filename] : "basename of the file to record to, -audio.mjr will be added by the plugin<br>
///
Future<void> joinRoom(String roomId,
Future<void> joinRoom(dynamic roomId,
{String? id,
String? group,
String? pin,
Expand Down Expand Up @@ -225,7 +225,7 @@ class JanusAudioBridgePlugin extends JanusPlugin {
/// [participantId] unique numeric ID of the participant.<br>
/// [mute] toggle mute status of the participant.<br>
/// [secret] admin secret should be provided if configured.<br>
Future<dynamic> muteParticipant(String roomId, int participantId, bool mute, {String? secret}) async {
Future<dynamic> 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));
Expand All @@ -238,7 +238,7 @@ class JanusAudioBridgePlugin extends JanusPlugin {
/// To stop a previously created RTP forwarder.<br>
/// [roomId] unique numeric ID of the room to stop the forwarder from.<br>
/// [streamId] unique numeric ID of the RTP forwarder.<br>
Future<RtpForwardStopped> stopRtpForward(String roomId, int streamId) async {
Future<RtpForwardStopped> 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));
Expand All @@ -252,7 +252,7 @@ class JanusAudioBridgePlugin extends JanusPlugin {
/// [roomId] unique numeric ID of the room to stop the forwarder from.<br>
/// [participantId] unique numeric ID of the participant.<br>
/// [secret] admin secret should be provided if configured.<br>
Future<dynamic> kickParticipant(String roomId, int participantId, {String? secret}) async {
Future<dynamic> 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));
Expand All @@ -274,7 +274,7 @@ class JanusAudioBridgePlugin extends JanusPlugin {
/// [alwaysOn] true|false, whether silence should be forwarded when the room is empty.<br>
/// [srtpCrypto] key to use as crypto (base64 encoded key as in SDES); optional.<br>
/// [adminKey] key to use if adminKey is set for rtp forward as well.<br>
Future<RtpForwarderCreated> rtpForward(String roomId, String host, int port,
Future<RtpForwarderCreated> 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",
Expand All @@ -301,7 +301,7 @@ class JanusAudioBridgePlugin extends JanusPlugin {
///
/// To get a list of the participants in a specific room of [roomId]
///
Future<List<AudioBridgeParticipants>> listParticipants(String roomId) async {
Future<List<AudioBridgeParticipants>> listParticipants(dynamic roomId) async {
var payload = {
"request": "listparticipants",
"room": roomId,
Expand Down
6 changes: 3 additions & 3 deletions lib/wrapper_plugins/janus_text_room_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 <br>.
///[to] : username to send the message to; optional, only needed in case of private messages. <br>
///[tos] : array of usernames to send the message to; optional, only needed in case of private messages. <br>
Future<void> sendMessage(String roomId, String text,
Future<void> sendMessage(dynamic roomId, String text,
{bool? ack, String? to, List<String>? tos}) async {
if (setupDone) {
var message = {
Expand Down Expand Up @@ -121,7 +121,7 @@ class JanusTextRoomPlugin extends JanusPlugin {
};
}

Future<dynamic> listParticipants(String roomId) async {
Future<dynamic> listParticipants(dynamic roomId) async {
var payload = {"request": "listparticipants", "room": roomId};
}

Expand All @@ -133,7 +133,7 @@ class JanusTextRoomPlugin extends JanusPlugin {
/// [roomId] unique numeric ID of the room to stop the forwarder from.<br>
/// [username] username of the participant to kick.<br>
/// [secret] admin secret should be provided if configured.<br>
Future<dynamic> kickParticipant(String roomId, String username,
Future<dynamic> kickParticipant(dynamic roomId, String username,
{String? secret}) async {
var payload = {
"request": "kick",
Expand Down
12 changes: 6 additions & 6 deletions lib/wrapper_plugins/janus_video_room_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<dynamic> editRoom(String roomId,
Future<dynamic> editRoom(dynamic roomId,
{String? secret,
String? newDescription,
String? newSecret,
Expand Down Expand Up @@ -40,14 +40,14 @@ class JanusVideoRoomPlugin extends JanusPlugin {
}

/// Used to destroy an existing video room, whether created dynamically or statically
Future<dynamic> destroyRoom(String roomId, {String? secret, bool? permanent}) async {
Future<dynamic> 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<dynamic> createRoom(String roomId, {bool permanent = false, String? pin, Map<String, dynamic>? extras, List<String>? allowed, String? isPrivate, String description = '', String? secret}) async {
Future<dynamic> createRoom(dynamic roomId, {bool permanent = false, String? pin, Map<String, dynamic>? extras, List<String>? 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;
Expand All @@ -58,7 +58,7 @@ class JanusVideoRoomPlugin extends JanusPlugin {
}

/// get list of participants in a existing video room
Future<VideoRoomListParticipantsResponse?> getRoomParticipants(String roomId) async {
Future<VideoRoomListParticipantsResponse?> getRoomParticipants(dynamic roomId) async {
var payload = {"request": "listparticipants", "room": roomId};
Map data = await this.send(data: payload);
_handleRoomIdTypeDifference(payload);
Expand All @@ -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<void> joinPublisher(String roomId, {String? pin, int? id, String? token, String? displayName}) async {
Future<void> joinPublisher(dynamic roomId, {String? pin, int? id, String? token, String? displayName}) async {
var payload = {
"request": "join",
"ptype": "publisher",
Expand All @@ -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<Future<void> Function({String? audioRecv, String? audioSend, String? videoRecv, String? videoSend})> joinSubscriber(
String roomId, {
dynamic roomId, {
List<PublisherStream>? streams,
int? privateId,
int? feedId,
Expand Down

0 comments on commit 9189efb

Please sign in to comment.