Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use webrtcbin create offer,only receive video

the gstreamer webrtc demo works fine.but all demo has a small problem: all webrtcbin that created offer must have some video/audio data to send. i want use webrtcbin create offer,and only receive video data from other webrtc peer.

all demo pipeline start from videotestsrc/audiotestsrc to make test data,so that webrtcbin can send data to remote peer. but i don't want send any data to remote,and i must create offer,not wait offer then answer.

i am try this pipeline:

pipeline = gst_parse_launch(
        "webrtcbin name=recv stun-server=stun://localhost:19302  "
        " ! rtpvp8depay ! vp8dec ! videoconvert ! queue ! fakevideosink ",
        &error);

then connect signal:

g_signal_connect(webrtc, "on-negotiation-needed", G_CALLBACK(on_negotiation_needed), NULL);
g_signal_connect(webrtc, "on-ice-candidate", G_CALLBACK(send_ice_candidate_message), NULL);

g_signal_connect(webrtc, "pad-added", G_CALLBACK(on_incoming_stream), pipeline); 

when i am run program,on_negotiation_needed is executed,and i call create-offer:

GstPromise* promise;
promise = gst_promise_new_with_change_func(on_offer_created, user_data, NULL);
g_signal_emit_by_name(webrtc, "create-offer", NULL, promise);

but it create very short sdp:

{"type":"offer","sdp":"v=0\r\no=- 7210256809476625085 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=ice-options:trickle\r\n"}

this sdp do not have any media info.

and,after create-offer called,callback on-ice-candidate should be called.in my program,this callback never called.

so,my question is:if webrtcbin have no media source,how can i make webrtcbin create correct offer that tell remote peer send media to local peer?

like image 961
宝蓝娃娃 Avatar asked Aug 09 '19 12:08

宝蓝娃娃


1 Answers

I recently tried to attempt the same thing in python but it should be the same in c. I also got that issue where I didn't get the ice candidates getting gathered until I added a transceiver to the webrtcbin element.

I think that when you add a source, it will automatically add the transceiver using the info offered by the source but when you use it as receive only, it doesn't know exactly what it will receive so you need to specify it. This is how I managed to do it in python:

    direction = GstWebRTC.WebRTCRTPTransceiverDirection.RECVONLY
    caps = Gst.caps_from_string("application/x-rtp,media=video,encoding-name=VP8/9000,payload=96")
    self.webrtc.emit('add-transceiver', direction, caps)

You will probably have the equivalent functions in c. I don't know if it will fix your sdp size issue as I also have it at the moment maybe there is something else to add to the webrtc element, but it should at least allow you to get the ice candidates.

like image 93
Guillaume Avatar answered Nov 05 '22 10:11

Guillaume