将udpsrc动态添加到rtpbin会导致流停止,原因是未链接(-1)

时间:2018-08-03 11:21:52

标签: gstreamer

我正在尝试将udp src动态添加到正在运行的管道中。 例如

  void addAudioSource(std::string const ip, int const port, int const payloadtype)
  {
    std::string description = "autoaudiosrc ! queue ! audioconvert !  audio/x-raw,rate=16000 ! avenc_g722 ! rtpg722pay";

    audiosrc = Gst::Parse::create_bin(description, true);

    pipeline->add(audiosrc);
    {
      auto srcpad = audiosrc->get_static_pad("src");
      auto sinkpad = rtpbin->get_request_pad("send_rtp_sink_1");
      srcpad->link(sinkpad);
    }

    rtpudpsinkAudio->set_property("host", ip);
    rtpudpsinkAudio->set_property("port", port);
    rtpudpsinkAudio->set_property("sync",true);
    rtpudpsinkAudio->set_property("async",false);
    pipeline->add(rtpudpsinkAudio);
    {
      auto srcpad = rtpbin->get_static_pad("send_rtp_src_1");
      auto sinkpad = rtpudpsinkAudio->get_static_pad("sink");
      srcpad->link(sinkpad);
    }
    pipeline->set_state(Gst::State::STATE_PLAYING);  
}

---和---

  void addAudioSink(std::string const ip, int const port, int const payloadtype)
  {
    char const caps[] = "application/x-rtp,media=(string)audio,clock-rate=(int)8000,payload=(int)%d";
    char buffer[128] = {0};
    sprintf(buffer,caps,payloadtype);
    pipeline->add(rtpudpsrcAudio);
    rtpudpsrcAudio->set_property("caps",
        Gst::Caps::create_from_string(buffer));
    {
      auto srcpad = rtpudpsrcAudio->get_static_pad("src");
      auto sinkpad = rtpbin->get_request_pad("recv_rtp_sink_1");
      srcpad->link(sinkpad);
    }
    pipeline->set_state(Gst::State::STATE_PLAYING);
  }

当我不调用其他函数时,管道可以正常工作。

如果我尝试在addAudioSource之后的某个时间调用addAudioSink,则在通过应用程序进行调试时,总是会收到此错误

0:00:18.190302584 [334m 6945 [00m 0x555556669450 [36mINFO   [00m [00;01;34m           GST_EVENT gstevent.c:814:gst_event_new_caps: [00m creating caps event application/x-rtp, media=(string)audio, clock-rate=(int)8000, payload=(int)9, ssrc=(uint)1388635048
0:00:18.190323116 [334m 6945 [00m 0x555556669450 [36mINFO   [00m [00m             basesrc gstbasesrc.c:2965:gst_base_src_loop:<rtpudpsrcaudio-AVP-d80367f9-8361-458d-a52d-23db4d185996> [00m pausing after gst_pad_push() = not-linked
0:00:18.190333169 [334m 6945 [00m 0x555556669450 [33;01mWARN   [00m [00m             basesrc gstbasesrc.c:3055:gst_base_src_loop:<rtpudpsrcaudio-AVP-d80367f9-8361-458d-a52d-23db4d185996> [00m error: Internal data stream error.
0:00:18.190337616 [334m 6945 [00m 0x555556669450 [33;01mWARN   [00m [00m             basesrc gstbasesrc.c:3055:gst_base_src_loop:<rtpudpsrcaudio-AVP-d80367f9-8361-458d-a52d-23db4d185996> [00m error: streaming stopped, reason not-linked (-1)
0:00:18.190350252 [334m 6945 [00m 0x555556669450 [36mINFO   [00m [00;01;31;47m    GST_ERROR_SYSTEM gstelement.c:2145:gst_element_message_full_with_details:<rtpudpsrcaudio-AVP-d80367f9-8361-458d-a52d-23db4d185996> [00m posting message: Internal data stream error.
0:00:18.190358717 [334m 6945 [00m 0x555556669450 [36mINFO   [00m [00;01;31;47m    GST_ERROR_SYSTEM gstelement.c:2172:gst_element_message_full_with_details:<rtpudpsrcaudio-AVP-d80367f9-8361-458d-a52d-23db4d185996> [00m posted error message: Internal data stream error.

另一件事是,该管道大部分时间都在工作。 当我通过应用程序进行调试时,有时甚至在发布版本中,我只会遇到此错误。

我唯一能找到的问题是。 有时它说rtpssrcdemux0:src_2345243未链接,然后udpsrc失败,出现gst_pad_push()=未链接。 有一个我不明白的问题,管道大部分时间都在工作,它在25%的时间内失败了。

请帮助

0 个答案:

没有答案