2020年10月14日 星期三

github GStreamer WebRTC demos 執行方法

首先在github上找到GStreamer WebRTC demos範例,對一個剛入門的人來說,按照裡面的說明實在是很不清楚。我是用C的sample去測試,以下這段原文應該是要開發者自己架一個Signalling Server,或者使用後面的網址當作Signalling Serve,8443 port是給wss協定用的,http網址後面不用加。

Serve the js/ directory on the root of your website, or open https://webrtc.nirbheek.in

The JS code assumes the signalling server is on port 8443 of the same server serving the HTML


接著這段是說用瀏覽器開啟https://webrtc.nirbheek.in後,上面會給一個id,等一下執行時的參數會用到。

Open the website in a browser and ensure that the status is "Registered with server, waiting for call", and note the id too.


可以在你解壓縮這個demo檔的下面找到/sendrecv/gst目錄,在這直接執行make或用後面的gcc指令做compile。

Build the sources in the gst/ directory on your machine. Use make or

gcc webrtc-sendrecv.c $(pkg-config --cflags --libs gstreamer-webrtc-1.0 gstreamer-sdp-1.0 libsoup-2.4 json-glib-1.0) -o webrtc-sendrecv


編譯成功就可以執行編譯出的執行檔,後面的ID就是填寫前面https://webrtc.nirbheek.in網站給的id。

Run webrtc-sendrecv --peer-id=ID with the id(這邊小寫易讓人混淆) from the browser. You will see state changes and an SDP exchange.


在我用的gst-inspect-1.0版本,範例webrtc-sendrecv.c程式碼裡的vp8enc似乎已找不到,但是目前還不知道怎麼單獨裝plugin,找了一下別人關於no element “vp8enc”的討論,有人用gst-inspect-1.0 |grep vpx來檢查是否有安裝vp8enc,我傻傻的照打,結果沒返回什麼東西,後來把vpx改成vp8,結果出現

vaapi:  vaapivp8enc: VA-API VP8 encoder

vaapi:  vaapivp8dec: VA-API VP8 decoder

libav:  avdec_vp8: libav On2 VP8 decoder

rtp:  rtpvp8pay: RTP VP8 payloader

rtp:  rtpvp8depay: RTP VP8 depayloader


於是就把webrtc-sendrecv.c裡的vp8enc改成vaapivp8enc,結果報了個錯no property "deadline" in element "vaapiencodevp8-0",看程式碼裡deadline看起來是vp8enc的參數,心一橫就把deadline給拿掉,就這樣…成功了。


看起來應該是把GStreamer抓到的data丟給WebRTC處理了,但詳細還是讀讀程式碼在說,看完再來更新這裡!真心希望寫這些demo code的好心大大,能把看的人都當白痴一樣寫教學,才能省掉一些研究的時間。


靠下面這些網站解決了我的問題:

Reference:

gstwebrtc-demos

GStreamer has grown a WebRTC implementation

尝试使用gstreamer webrtc进行流式传输时,“按需协商”如何工作?

Can't install VP9enc or Vp8enc in GStreamer

gstreamer: no element “vp8enc”

沒有留言:

張貼留言