2017-04-23 25 views
0

지점 A에서 kurento 미디어 서버로 오디오 스트림을 보내고 gstreamer를 사용하여 지점 B에서 해당 오디오 스트림을 수신하려고합니다. 나는 무엇을 성취하려고합니까?gstreamer를 사용하는 kurento 미디어 서버의 오디오 스트림을 청취하십시오.

(포인트 A) ---- GSTREAMER가있는 오디오 스트림 보내기 ---> (음악) ---- 오디오 스트림 -----> (포인트 B) --- GSTREMAER로 오디오를 얻으십시오 ----!

function createOutGoingAudioStream() { 

var sdpOffer = " v=0\r\n" 
     + "o=- 0 0 IN IP4 0.0.0.0\r\n" 
     + "c=IN IP4 0.0.0.0\r\n" 
     + "t=0 0\r\n" 
     + "m=audio 5005 RTP/AVP 0\r\n" 
     + "a=rtpmap:0 PCMU/8000\r\n"; 

var pipeline; 
console.log(); 
console.log("Starting Audio Stream from Command Post.....");  

// get kurento client 
    getKurentoClient(function(error, kurentoClient) { 
     if (error) { 
      return callback(error); 
     } 


    // create media pipe line 
     kurentoClient.create('MediaPipeline', function(error, pipeline) { 
      if (error) { 
        return callback(error); 
      } 

      // create first rtpEndpoint for the incoming audio stream  
     pipeline.create('RtpEndpoint', function(error, rtpEndpoint) { 
       if (error) { 
        pipeline.release(); 
       return callback(error); 
       } 
      console.log('audio RTP Endpoint created successfully!'); 

      rtpEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) { 
          if (error) { 
            pipeline.release(); 
            return callback(error); 
          } 
       console.log(sdpAnswer); 
       console.log(); 
         // Start a gstreamer audio stream over the audio port that we got from the kurento server 
         var jsonSdpAnswer = transform.parse(sdpAnswer); 
         var port = jsonSdpAnswer.media[0].port; 

       console.log("Starting audio stream to the kurento server: "); 
            console.log('sh gstreamer.sh ' + port + ' > log.txt') 

       exec('sh gstreamer.sh ' + port + ' > log.txt', function(err, stdout, stderr) { 
          if (err) { 
            console.error(err); 
            return; 
          } 
         //if all is ok nothing wil prompt to the console 
         console.log(stdout); 
         }); 
      }); 

      // create second rtpEndpoint for the outgoing to the odroid's audio stream  
         pipeline.create('RtpEndpoint', function(error, outRtpEndpoint) { 
           if (error) { 
             pipeline.release(); 
             return callback(error); 
           } 
           console.log('second RTP Endpoint created successfully!'); 


       rtpEndpoint.connect(outRtpEndpoint, function(error){ 
         if(error) return onError(error); 
       }); 
       outRtpEndpoint.generateOffer(function(error,offerSdp){ 
        if(error) return onError(error); 
        console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") 
        console.log(offerSdp); 
       }); 
         }); 
     }); 
    }); 
}); 
} 

나는 kurento 서버 outRtpEndpoint의 sdpOffer에서 얻을 그것은 다음과 같습니다 :

지금까지 내가 코드를 넣고 쓴

sdp Offer가 무슨 상관하지 않습니다 난 그 일을 원하지 않는 그 흐름을 듣기 위해 노력하고 있습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까 ?

정말 도움이됩니다.

감사합니다 !!!

답변

0

나는 문제를 해결할 수있었습니다. 브라우저 (webrtcEndpoint)에서 A 지점의 소스 오디오 스트림을 가져 와서 해당 끝점을 rtpEndpoint에 연결하면 거기에서 스트림을 B 지점으로 가져옵니다. (지점 A - 웹 브라우저 -> webrtcEndpoint) -> (Kurento -> rtpEndpoint) -> (점 B - ffplay).

ffplay rtp://IP_FROM_THE_SDP_OFFER_IN_THE_CODE_ABOVE:AUDIO_PORT_FROM_THE_SDP_OFFER_FROM_THE_CODE_ABOVE 
: 당신이, 당신이 스트림을들을 수있는 스트리밍 컴퓨터에서

function createOutGoingAudioStream(sessionId,ws, sdpOffer, callback){ 
if (!sessionId) { 
    return callback('Cannot use undefined sessionId'); 
} 

getKurentoClient(function(error, kurentoClient) { 
    if (error) { 
     return callback(error); 
    } 

    kurentoClient.create('MediaPipeline', function(error, pipeline) { 
     if (error) { 
      return callback(error); 
     } 

     createMediaElements(pipeline, ws, function(error, webRtcEndpoint) { 
      if (error) { 
       pipeline.release(); 
       return callback(error); 
      } 

      if (candidatesQueue[sessionId]) { 
       while(candidatesQueue[sessionId].length) { 
        var candidate = candidatesQueue[sessionId].shift(); 
        webRtcEndpoint.addIceCandidate(candidate); 
       } 
      } 

      connectMediaElements(webRtcEndpoint, function(error) { 
       if (error) { 
        pipeline.release(); 
        return callback(error); 
       } 

       webRtcEndpoint.on('OnIceCandidate', function(event) { 
        var candidate = kurento.getComplexType('IceCandidate')(event.candidate); 
        ws.send(JSON.stringify({ 
         id : 'iceCandidate', 
         candidate : candidate 
        })); 
       }); 

       webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) { 
        if (error) { 
         pipeline.release(); 
         return callback(error); 
        } 

        sessions[sessionId] = { 
         'pipeline' : pipeline, 
         'webRtcEndpoint' : webRtcEndpoint 
        } 
        return callback(null, sdpAnswer); 
       }); 

       webRtcEndpoint.gatherCandidates(function(error) { 
        if (error) { 
         return callback(error); 
        } 



          var sdp = 'v=0'; 
          sdp += '\nc=IN IP4 IP_WHERE_YOU_WANT_TO_GET_THE_STREAM'; // this is the ip where the kurento should stream to 
          sdp += '\nm=audio 8080 RTP/AVP 0'; // at port 8080 you will have an audio stream 
          sdp += '\na=rtpmap:0 PCMU/8000'; 
          sdp += '\nm=video 9090 RTP/AVP 101'; // at port 9090 you will have a video stream 
          sdp += '\na=rtpmap:101 H264/90000'; 

          pipeline.create('RtpEndpoint', function(err, rtpEndpoint){ 
          rtpEndpoint.processOffer(sdp, function(error, sdpAnswer) { 
            if (error) { 
              return callback(error); 
            } 

       console.log("################################################"); 
       console.log(sdpAnswer); 
       console.log("################################################"); 
          }); 


      webRtcEndpoint.connect(rtpEndpoint, function(err, rtpEndpoint) { if(err) { console.log("Error!"); } }); 
          }); 

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