Jump to content
  • 0

getUserMedia automatically being called?


pangit
 Share

Question

Greetings,

  I have been looking at JS code included with the demo for the 'peer to peer' ("https://test.antmedia.io:5443/WebRTCAppEE/peer.html") as well as some other demo pages.  It seems that upon initial navigation to the page the browser prompts me to allow usage of my camera and microphone, obviously indicating a call to "getUserMedia".  However upon examination of the page script ...I am not seeing any explicit call of the "getUserMedia" method.  Therefore I am curious where this is being made, evidently on the server upon connection via websocket...?  Is there a potential over-ride to this behavior?  I might rather call the "getUserMedia" myself in my own (adapted) webpage code..possibly.

  Also the method "join(streamId)" is being called to join a remote user with the existing stream, however I do not see anything in the JS SDK guide (https://github.com/ant-media/Ant-Media-Server/wiki/WebRTC-JavaScript-SDK-Guide) about its usage.  It seems this function is probably performing all the necessary exchange of signalling information with the server however there seems to be no source code anywhere in that SDK guide about exactly what these functions are doing.

  In addition, for a peer/peer connection...there should be some sort of logic to determine if there are fewer than 2 connected users (in order to allow a 'join' for example).  Again where is this being determined?  Is this 'magic' all being performed on the Ant Media server someplace...out of developer view?

  Sorry if these are naive questions however I am new to Ant Media and  exploring the possibility of utilizing the platform in the near future.  I thank you in advance for any information.

 

Regards

 

 

  • Like 1
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi Pangit,

Have a good day.

Let me explain it. When WebSocket communication is started there is some processes working on js/webrtc_adaptor.js file. Please check below links:

https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/js/webrtc_adaptor.js#L220

https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/js/media_manager.js#L165

Please check this guide for using join message: https://github.com/ant-media/Ant-Media-Server/wiki/WebRTC-WebSocket-Messaging-Reference

I hope, it's clear for you.

Best Regards,

Selim

  • Like 1
Link to comment
Share on other sites

  • 0

Thank you for your reply Selim,

  As I understand what you have referenced in your response, the 'userGetMedia' will run upon navigation to the page as it is called by the WebSocket communication (which runs when page navigation is made).  Therefore EACH stream will be resolved and displayed in the browser video tags 'automatically' without any code needed to call this command.  This applies to both peers...the 'initial/local' and the 'remote' that has joined the session.

  In addition calling the 'join' will initiate signaling as the 'start' message will be sent from the server to the 'initial/local' peer so that both peers can connect and view one another in the webpage upon completion of the signalling process.  Therefore it becomes necessary to write code on the 'remote' client to exchange the proper messages with the server via WebSocket, as the 'join' command only begins the signalling process...correct?

  Please inform me if I am incorrect in my interpretation of these command functions.  I thank you again for your assistance. 

 

Regards

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...