我正在尝试将音频从浏览器流式传输到服务器上的gstreamer管道。
我目前正在使用Kurento,并修改Hello World示例以尝试将RTP端点连接到管道 - 但是遇到了麻烦。
我知道媒体已经到了那里,因为当我换掉录制端点时,我得到了有效的录音。
Kurento Node JS是:
pipeline.create("RtpEndpoint", {}, function(error, rtpEndpoint) {
if (error) {
console.log("Recorder problem");
return sendError(res, 500, error);
}
console.log("Creating WebRtcEndpoint");
pipeline.create('WebRtcEndpoint', function(error, webRtcEndpoint) {
if (error) {
return sendError(res, 500, error);
}
console.log("Processing sdpOffer at server and generating sdpAnswer");
webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer) {
if (error) {
webRtcEndpoint.release();
return sendError(res, 500, error);
}
console.log("Connecting loopback");
webRtcEndpoint.connect(webRtcEndpoint, function(error) {
if(error){
webRtcEndpoint.release();
return sendError(res, 500, error);
}
console.log("Sending sdpAnswer to client");
console.log(sdpAnswer);
webRtcEndpoint.connect(rtpEndpoint, function(error) {
if(error) {
webRtcEndpoint.release();
return sendError(res, 500, error);
}
rtpEndpoint.generateOffer(function(error, offer) {
fs.writeFile('/tmp/test.sdp',offer);
console.log("RTP OFFER GENERATED.");
});
});
res.type('application/sdp');
res.send(sdpAnswer);
});
});
});
});
和我的GStreamer管道是:
gst-launch-1.0 -vvvv filesrc location=/tmp/test.sdp ! sdpdemux ! decodebin ! autovideosink
返回
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Got context from element 'autovideosink0-actual-sink-glimage': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSrc:udpsrc0: timeout = 10000000000
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSrc:udpsrc2: timeout = 10000000000
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:send_rtcp_src: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_0: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_0.GstProxyPad:proxypad4: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession1.GstPad:send_rtcp_src: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_1: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstUDPSink:udpsink1.GstPad:sink: caps = application/x-rtcp
/GstPipeline:pipeline0/GstSDPDemux:sdpdemux0/GstRtpBin:rtpbin0.GstGhostPad:send_rtcp_src_1.GstProxyPad:proxypad7: caps = application/x-rtcp
ERROR: from element /GstPipeline:pipeline0/GstSDPDemux:sdpdemux0: Could not read from resource.
Additional debug info:
gstsdpdemux.c(1213): gst_sdp_demux_handle_message (): /GstPipeline:pipeline0/GstSDPDemux:sdpdemux0:
Could not receive any UDP packets for 10.0000 seconds, maybe your firewall is blocking it.
Execution ended after 0:00:10.062018001
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
它不适用于FFPMEG,VLC等 - 结果类似于“尝试5.3”:https://altanaitelecom.wordpress.com/2015/02/26/continue-streaming-broadcasting-live-video-call-to-non-webrtc-supported-browsers-and-media-players/
我不认为这是防火墙问题,因为管道和kurento实例位于同一个虚拟机(没有防火墙)上 - 并且录制端点可以工作。它是否被严重关联?有更简单的方法吗?
答案 0 :(得分:1)
使用RtpEndpoint很棘手,因为您需要完成de SDP协商。这意味着在
之后的某个地方rtpEndpoint.generateOffer(...
你应该调用
rtpEndpoint.processAnswer(sdpAnswer, ...)
棘手的部分是你需要从gstreamer管道获取sdpAnswer,如果你只想使用gst-launch,这不是一件容易的事。可能你最好的选择是编写一个小程序来创建管道并生成sdpAnswer,这样你就可以通过信号机制将它交还给rtpEndpoint了。