Broadcast IP camera stream to connected viewers

547 views
Skip to first unread message

karthike...@gmail.com

unread,
Jul 1, 2016, 8:06:54 AM7/1/16
to kurento
Hey there,

I am using kurento one2many (nodejs version) model in my application. Till date I was using regular web cameras and PTZ cameras for broadcasting.  Meaning one presenter will start broadcasting and all the viewers will receive the camera stream. Now I would like to stream IPCamera from same presenter. By referring THIS example I am able to receive the IP camera stream in broadcaster's page. Now how can I send this stream to server so that all connected users can receive the IP camera stream. (similar to regular web cameras)

This is how i tried  

function startIpcamera() {
       
if(!address){
          window
.alert("You must set the video source URL first");
         
return;
       
}
       
   
var options = {
      remoteVideo
: videoOutput,
     
//onicecandidate : onIceCandidate
   
};
   webRtcPeer
= kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(options,
     
function(error){
       
if(error){
         
return console.error(error);
       
}
        webRtcPeer
.generateOffer(onOffer);
        webRtcPeer
.peerConnection.addEventListener('iceconnectionstatechange', function(event){
         
if(webRtcPeer && webRtcPeer.peerConnection){
            console
.log("oniceconnectionstatechange -> " + webRtcPeer.peerConnection.iceConnectionState);
            console
.log('icegatheringstate -> ' + webRtcPeer.peerConnection.iceGatheringState);
         
}
       
});
   
});
 
}


   
function onOffer(error, sdpOffer){
   
if(error) return onError(error);


        kurentoClient
(args.ws_uri, function(error, kurentoClient) {
               
if(error) return onError(error);


                kurentoClient
.create("MediaPipeline", function(error, p) {
                       
if(error) return onError(error);


                        pipeline
= p;


                        pipeline
.create("PlayerEndpoint", {uri: address}, function(error, player){
                         
if(error) return onError(error);


                          pipeline
.create("WebRtcEndpoint", function(error, webRtcEndpoint){
                               
if(error) return onError(error);


                                setIceCandidateCallbacks
(webRtcEndpoint, webRtcPeer, onError);


                                webRtcEndpoint
.processOffer(sdpOffer, function(error, sdpAnswer){
                                       
if(error) return onError(error);


                                    webRtcEndpoint
.gatherCandidates(onError);


                                        webRtcPeer
.processAnswer(sdpAnswer);
                               
});


                                player
.connect(webRtcEndpoint, function(error){
                                       
if(error) return onError(error);


                                        console
.log("PlayerEndpoint-->WebRtcEndpoint connection established");


                                        player
.play(function(error){
                                         
if(error) return onError(error);
                                                       
var id=1; if((cameraArr[1]) && fired) id=2;


                                                               
var message = {
                                                                        id
: 'broadcaster',
                                                                        sdpOffer
: sdpOffer,
                                                               
};
                                                                sendMessage
(message);
                                          console
.log("Player playing ...");
                                       
});
                               
});
                       
});
                       
});
               
});
       
});
}



But no success. Can anyone please guid me how to proceed ?

Thank You
Karthik Vaidya


Ivan Gracia

unread,
Jul 2, 2016, 1:27:15 PM7/2/16
to Kurento Public
Where's the code you just pasted? That doesn't look like the node.js one2many application. It looks like you are running KurentoClient in the browser.

If it's an IPCam that you want to share, the address must be accessible to the media server, as it will be the player in the KMS instance the one getting the stream.

Ivan Gracia



--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

karthike...@gmail.com

unread,
Jul 5, 2016, 2:24:15 AM7/5/16
to kurento, karthike...@gmail.com
Hi Ivan, 

I my application setup goes like this : 

  *  IP camera is in local network and is connected to presenters laptop through wifi
  *  Presenters laptop is connected to Central server where KMS is running 
  * All users will connect to central server to watch the session being broadcasted

Player endpoint is created in presenters laptop and ip camera's playback stream is available in presenter's system. I have created a webrtcEndpoint in presentor's side using playerEndpoint. I understand that I need a webrtc peer to send to server so that I can establish connection between presentor and server. Can I crerate a webrtcpeer using webrtcEndpoint? Or is there any other method ?? (May be my understanding is wrong). How can I transfer this stream to central server so that all users will get this stream. Below is the architecture diagram of the setup

 Thanks again
 Karthik Vaidya

Ivan Gracia

unread,
Jul 5, 2016, 3:33:43 AM7/5/16
to Kurento Public, karthike...@gmail.com
Well, you then need a way to put the IP camera's stream into a WebRTC endpoint. Don't think you can do that in the browser. You can either
  • Access the camer's IP from your KMS
  • Another media server in the same network, that can access the camera


Ivan Gracia



karthike...@gmail.com

unread,
Jul 5, 2016, 3:55:36 AM7/5/16
to kurento, karthike...@gmail.com
Hi Ivan,

If we see this code, I am getting WebRTC endpoint from player endpoint.. Is this not sufficient to do the task? 

function onOffer(error, sdpOffer){
   
if(error) return onError(error);
        kurentoClient
(args.ws_uri, function(error, kurentoClient) {
               
if(error) return onError(error);
                kurentoClient
.create("MediaPipeline", function(error, p) {
                       
if(error) return onError(error);
                        pipeline
= p;
                        pipeline
.create("PlayerEndpoint", {uri: address}, function(error, player){
                         
if(error) return onError(error);
                          pipeline
.create("WebRtcEndpoint", function(error, webRtcEndpoint){
                               
if(error) return onError(error);
                                setIceCandidateCallbacks
(webRtcEndpoint, webRtcPeer, onError);
                                webRtcEndpoint
.processOffer(sdpOffer, function(error, sdpAnswer){
                                       
if(error) return onError(error);
                                    webRtcEndpoint
.gatherCandidates(onError);
                                        webRtcPeer
.processAnswer(sdpAnswer);
                               
});
                                player
.connect(webRtcEndpoint, function(error){
                                       
if(error) return onError(error);
                                        console
.log("PlayerEndpoint-->WebRtcEndpoint connection established");
                                        player
.play(function(error){
                                         
if(error) return onError(error);                                                      

                                          console
.log("Player playing ...");

                                       
});
                               
});
                       
});
                       
});
               
});
       
});
}

If this is not sufficient then what I have to do for sending stream to server? or how can I create a werRtcPeer using this WebRtcEndpoint?

Thanks Again
Karthik Vaidya

On Friday, July 1, 2016 at 5:36:54 PM UTC+5:30, karthike...@gmail.com wrote:

Ivan Gracia

unread,
Jul 5, 2016, 4:03:10 AM7/5/16
to Kurento Public, karthike...@gmail.com
Look, those endpoints are really located in your media server. If you want the player endpoint to stream contents obtained from a live RTSP feed, it just follows that it is the media server instance the one that needs to have access to the RTSP feed.

You are not getting a WebRTC endpoint from a player endpoint. You are creating a WebRTC endpoint, in the media server, in the callback function executed after the creation of a PlayerEndpoint.

What you have in the browser client are just proxy objects, and what happens there is signaling.

Ivan Gracia



karthike...@gmail.com

unread,
Jul 5, 2016, 9:10:05 AM7/5/16
to kurento, karthike...@gmail.com
Hi Ivan,

Thanks for replying, and also thank you for explaining about the concept. I was not knowing that what we have in browser was just proxy objects.

Karthik Vaidya

On Friday, July 1, 2016 at 5:36:54 PM UTC+5:30, karthike...@gmail.com wrote:

Dilshan Gunasekara

unread,
Jun 7, 2018, 4:40:23 AM6/7/18
to kurento
what type of a ptz ip camera are you using?

like this?


On Friday, July 1, 2016 at 5:36:54 PM UTC+5:30, karthike...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages