Skip to content
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

Trying to create live stream using video_room #7

Closed
alsiPanda opened this issue Oct 4, 2020 · 9 comments
Closed

Trying to create live stream using video_room #7

alsiPanda opened this issue Oct 4, 2020 · 9 comments

Comments

@alsiPanda
Copy link

Hi @shivanshtalwar0 , So i took your advice on rtp forwarding the video room for live streaming. But I hit a snag. I am probably not using the flutter_janus_client properly. But here's what I am trying to do. Setting up the RTP forwarding needs room id and user id as seen here https://ans.disi.unitn.it/redmine/projects/peerstreamer-ng/wiki/Few_notes_on_Janus_and_its_streaming_plugin , Now the room id is already known, since i created the room with id 5555, but user id is proving problematic. I tried this piece of code

var users ={"request": "listparticipants", "room": 5555};
plugin.send(message: users, onSuccess: (){print("MILADMIN list participants");});

But I keep getting this error at backend saying Invalid request on unconfigured participant. After some searching I think i am placing the above code in the wrong place. I have tried placing it inside different 'onSuccess(){}' but keep getting same error.

So where should I place the above code, so that it runs after I have joined the room as publisher ? Also where should I place the code for streaming ? I am currently placing it inside the j.connect after the j.plugin(videoroom) ends. Do I need a new j.connect for j.plugin(streaming) ? Thanks in advance.

@alsiPanda alsiPanda changed the title Trying to create live stream using wideo_room Trying to create live stream using video_room Oct 4, 2020
@shivanshtalwar0
Copy link
Collaborator

Reason why you getting that error is because you are trying to list down participants without attaching to any plugin handle and you are right about the issue listparticipants should be called only after you have attached plugin
Let me explain what j.connect do
It just takes your passed server details along with credentials create a session id and initialize keep alive timer
At this point you might think you have room and you can interact with room but in real you can't unless you attach the plugin like videoroom videocall or any other this is achieved by method j.attach(Plugin(.... Now when you successfully attached the plugin only then you can use listparticipants or any other operation because attach function creates handle id for that plugin also you need to join the room as publisher/subscriber before issuing listparticipants hope that explains your doubt

@shivanshtalwar0
Copy link
Collaborator

About streaming you definitely need to attach a new streaming plugin but that should happen on recieving side

@alsiPanda
Copy link
Author

Thanks @shivanshtalwar0 , that helped a lot, since I was pretty confused on how it worked exactly. I can now see the output from listparticipants in the terminal. But how do i get the output in a variable ? I tried var op = await plugin.send(....) but op prints as null. I also tried plugin.send( message: ... , onSuccess : (op){ print("$op"); } ) , still getting null. I couldn't get the user id from msg in onMessage either.

@shivanshtalwar0
Copy link
Collaborator

Reason why that happens is because send doesn't return anything and also in onSuccess you get nothing also because all this is supposed to work with both websocket and it is asynchronous in nature we cannot have future as janus_client is port of janusjs, all messages from the plugin can only be listened in onMessage handler where you attach plugin

@alsiPanda
Copy link
Author

alsiPanda commented Oct 4, 2020

Hi @shivanshtalwar0 , I tried adding a print statement to onMessage everywhere and also added some marker text at the start of print to see if the response from listparticipant was being printed from within onMessage. But its not, the output from listparticipant is beung printed as :

I/flutter ( 9957): {janus: success, session_id: 6008204003696953, transaction: da2d7246-ffd7-40b5-b78e-24e1bb05d8ba, sender: 3435438303399251, plugindata: {plugin: janus.plugin.videor
oom, data: {videoroom: participants, room: 1234, participants: [{id: 1825063680612332, display: miladmin, publisher: false}]}}}

Where as both onMessages have print statement as print("publisheronmsg msg: $msg"); . The above print as you can see is not being printed from inside onMessage for some reason. There are other things getting printed from within onMessage such as response for room joined or room configured.

I/flutter ( 9957): publisheronmsg : {videoroom: joined, room: 1234, description: Demo Room, id: 7052290495258748, private_id: 1485829053, publishers: []}

I/flutter ( 9957): publisheronmsg : {videoroom: event, room: 1234, configured: ok, audio_codec: opus, video_codec: vp8}

Unless the response for listparticipant appears in onMessage, I assume there is no other way to parse the json and get user id ?

@shivanshtalwar0
Copy link
Collaborator

I am afraid I can't assist you without going through your code, if you can share a sample repository of your code then only I can be sure what is going wrong and if there exists a legitimate bug in the code

@shivanshtalwar0
Copy link
Collaborator

Ahh don't bother i got the bug fixing as i am writing this 😃

@shivanshtalwar0
Copy link
Collaborator

fixed now you should be able to get response of all participants , make sure to update pubspec yaml file like this

  janus_client:
      git: https://github.com/shivanshtalwar0/flutter_janus_client.git

and run flutter pub get and flutter pub upgrade

@shivanshtalwar0
Copy link
Collaborator

@alsiPanda new version out 0.0.4 with streaming support, all fixes, and improvements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants