sepfy / libpeer

WebRTC Library for IoT/Embedded Device using C
MIT License
804 stars 108 forks source link

Can libpeer support WHIP/WHEP standard signaling? #42

Closed chatop2020 closed 8 months ago

chatop2020 commented 9 months ago

Can libpeer support the real -time push flow of WEBRTC in ZLMediakit based on WHIP/WHEP standard signaling? zlmediakit opensource on github https://github.com/ZLMediaKit/ZLMediaKit thanks.

chatop2020 commented 9 months ago

是否可以支持zlmediakit的webrtc服务器?它可以使用http或WHIP/WHEP信令协议,能否尝试兼容一下?

chatop2020 commented 9 months ago

我的主要场景是使用在ESP32上,谢谢了

sepfy commented 9 months ago

您好, 我會研究下如何在ESP32上兼容WHIP/WHEP信令協議, 如果您的應用場景是將ESP32 Camera推流到流媒体服務器的話, 可能會面臨到編碼格式的問題 https://components.espressif.com/components/espressif/esp_h264

c4b4d4 commented 9 months ago

Hey there I'm also interesting in WHIP, mostly for ESP-EYE.

It makes all the handshaking way easier to integrate to third-party media servers. https://www.ietf.org/archive/id/draft-ietf-wish-whip-01.html

chatop2020 commented 9 months ago

您好, 我會研究下如何在ESP32上兼容WHIP/WHEP信令協議, 如果您的應用場景是將ESP32 Camera推流到流媒体服務器的話, 可能會面臨到編碼格式的問題 https://components.espressif.com/components/espressif/esp_h264

其实我主要是使用音频,当然H264能支持是最好的了

c4b4d4 commented 9 months ago

其实我主要是使用音频,当然H264能支持是最好的了

Yes. OPUS + H264 is ideal in my case of interest :)

chatop2020 commented 9 months ago

请问WHIP/WHEP支持现在有进度吗?

sepfy commented 9 months ago

Hi. 目前whip分支上的esp32s3範例已經能透過WHIP推流到ZLMediakit或Janus (Simple WHIP Server) 但尚未完成HTTPS的支持, 並且受限ESP32的效能, 我只有成功嘗試 OPUS (8000HZ/18000bps)和 H264 (96x96/7FPS), 可以透過修改config.h來設置media server地址

c4b4d4 commented 9 months ago

I have no problem about being HTTP on my side.

I will give it a try next week! Will let you know how it goes.

c4b4d4 commented 9 months ago

Hi,

I've tested the code and I haven't been able to receive the stream correctly. I doubt that my WHIP endpoint is not working correctly, since I can use it with other services.

I debugged a little bit the code and found where is getting stuck:

It's in an infinite loop in this line: https://github.com/sepfy/libpeer/blob/6ec50f7d4d96711a0d26b1888701102703949ae9/src/peer_connection.c#L347

I've added a LOG in this section

case PEER_CONNECTION_NEW:
      LOGI("NEW CONNECTION %d",pc->b_offer_created);
      if (!pc->b_offer_created) {
        peer_connection_state_new(pc);
      }
    break;

And well, the code is landing infinitely in PEER_CONNECTION_NEW and the value of pc->b_offer_created is always true

INFO    /libpeer-seed/libpeer/src/peer_connection.c  352     NEW CONNECTION 1
INFO    /libpeer-seed/libpeer/src/peer_connection.c  352     NEW CONNECTION 1
INFO    /libpeer-seed/libpeer/src/peer_connection.c  352     NEW CONNECTION 1
INFO    /libpeer-seed/libpeer/src/peer_connection.c  352     NEW CONNECTION 1
INFO    /libpeer-seed/libpeer/src/peer_connection.c  352     NEW CONNECTION 1

What could cause the code to be infinitely looping in this case? 🤔

Note:

I was also trying to add my own STUN SERVER, but it fails to be added the last logs I see are these:

INFO    /libpeer-seed/libpeer/src/agent.c    167     resolved_addr.port: 5349
ERROR   /libpeer-seed/libpeer/src/stun.c     196     Unknown Attribute Type: 0x802b
ERROR   /libpeer-seed/libpeer/src/stun.c     196     Unknown Attribute Type: 0x802c
ERROR   /libpeer-seed/libpeer/src/stun.c     196     Unknown Attribute Type: 0x8022

These attributes are for:

0x802b -> Response Origin
0x802c -> Other Address
0x8022 -> Software
c4b4d4 commented 9 months ago

I just increased the timeout at https://github.com/sepfy/libpeer/blob/whip/src/peer_signaling.c#L18 like @sepfy suggested and it's working now 😄

I haven't tried with my own STUN server, will try that now

chatop2020 commented 8 months ago

Hi. 目前whip分支上的esp32s3範例已經能透過WHIP推流到ZLMediakit或Janus (Simple WHIP Server) 但尚未完成HTTPS的支持, 並且受限ESP32的效能, 我只有成功嘗試 OPUS (8000HZ/18000bps)和 H264 (96x96/7FPS), 可以透過修改config.h來設置media server地址

感谢您的支持,谢谢,我试一下。

sepfy commented 8 months ago

WHIP supported 192d7f0d153ac9b53a6dfc538e10d3e689fecc33