libpeer icon indicating copy to clipboard operation
libpeer copied to clipboard

只收到ping/pong消息,没有视频和音频

Open xrz1181 opened this issue 9 months ago • 9 comments

Hi,我在开发板上运行sample程序,在 https://sepfy.github.io/libpeer/?id=fluffy-kind-lion 网页上没有显示audio和video,只收到ping/pong消息,可以帮我看看是什么问题吗?谢谢

/customer # ./sample -u mqtts://libpeer.com/public/fluffy-kind-lion =========== Parsed Arguments =========== URL : mqtts://libpeer.com/public/fluffy-kind-lion Token :

INFO /home/xrz/libpeer/src/agent.c 32 create IPv4 UDP socket: 3 INFO /home/xrz/libpeer/src/peer_connection.c 175 Datachannel allocates heap size: 153600 INFO /home/xrz/libpeer/src/peer_connection.c 182 Audio allocates heap size: 332800 INFO /home/xrz/libpeer/src/peer_connection.c 195 Video allocates heap size: 332800 INFO /home/xrz/libpeer/src/peer_signaling.c 134 Host: libpeer.com, Port: 8883, Path: /public/fluffy-kind-lion INFO /home/xrz/libpeer/src/ports.c 140 Resolved libpeer.com -> 5.78.82.24 INFO /home/xrz/libpeer/src/socket.c 230 Connecting to server: 5.78.82.24:8883 INFO /home/xrz/libpeer/src/socket.c 236 Server is connected INFO /home/xrz/libpeer/src/ssl_transport.c 106 start to handshake INFO /home/xrz/libpeer/src/ssl_transport.c 114 handshake success INFO /home/xrz/libpeer/src/peer_signaling.c 440 MQTT_Connect succeeded. INFO /home/xrz/libpeer/src/peer_signaling.c 456 Subscribing topic /public/fluffy-kind-lion/invoke INFO /home/xrz/libpeer/src/peer_signaling.c 382 MQTT Subscribe succeeded. state is changed: new INFO /home/xrz/libpeer/src/peer_connection.c 345 ice server: stun:stun.l.google.com:19302 INFO /home/xrz/libpeer/src/ports.c 140 Resolved stun.l.google.com -> 74.125.250.129 INFO /home/xrz/libpeer/src/agent.c 269 Resolved stun/turn server 74.125.250.129:19302 ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported ERROR /home/xrz/libpeer/src/ice.c 106 Only UDP transport is supported state is changed: checking state is changed: connected INFO /home/xrz/libpeer/src/dtls_srtp.c 308 Created inbound SRTP session INFO /home/xrz/libpeer/src/dtls_srtp.c 328 Created outbound SRTP session INFO /home/xrz/libpeer/src/peer_connection.c 436 SCTP create socket state is changed: completed on message: 0 ping, send pong on message: 0 ping, send pong on message: 0 ping, send pong on message: 0 ping, send pong on message: 0 ping, send pong on message: 0 ping, send pong on message: 0 ping, send pong on message: 0 ping, send pong

xrz1181 avatar Mar 24 '25 04:03 xrz1181

Hi, did you copy test.264 and alaw08m.wav to the folder of the test demo?

topworldcoder avatar Mar 28 '25 02:03 topworldcoder

Hi, did you copy test.264 and alaw08m.wav to the folder of the test demo?

Yes, I have copied these two files into the test demo folder.

xrz1181 avatar Mar 28 '25 02:03 xrz1181

Hi, first step, you can add log to the function peer_connection_outgoing_rtp_packet which sends RTP packets of H264 file or audio file. (your Log level is LEVEL_INFO, you can add logs using LOGI(...))

build and run sample again to see if the log printed.

topworldcoder avatar Mar 28 '25 03:03 topworldcoder

Hi, first step, you can add log to the function peer_connection_outgoing_rtp_packet which sends RTP packets of H264 file or audio file. (your Log level is LEVEL_INFO, you can add logs using LOGI(...))

build and run sample again to see if the log printed.

Changes can be: static void peer_connection_outgoing_rtp_packet(uint8_t* data, size_t size, void* user_data) { PeerConnection* pc = (PeerConnection*)user_data; dtls_srtp_encrypt_rtp_packet(&pc->dtls_srtp, data, (int*)&size); agent_send(&pc->agent, data, size); LOGI("send %.4x %.4x, %ld", (uint16_t)data, (uint16_t)(data + 2), size); }

Then logs can be shown like: peer_connection.c 60 send 6080 6700, 1310

topworldcoder avatar Mar 28 '25 03:03 topworldcoder

6080 6700, 13

okay,Thanks a lot for your reply。

xrz1181 avatar Mar 28 '25 05:03 xrz1181

Hi, first step, you can add log to the function peer_connection_outgoing_rtp_packet which sends RTP packets of H264 file or audio file. (your Log level is LEVEL_INFO, you can add logs using LOGI(...)) build and run sample again to see if the log printed.

Changes can be:

static void peer_connection_outgoing_rtp_packet(uint8_t* data, size_t size, void* user_data) { PeerConnection* pc = (PeerConnection*)user_data; dtls_srtp_encrypt_rtp_packet(&pc->dtls_srtp, data, (int*)&size); agent_send(&pc->agent, data, size); LOGI("send %.4x %.4x, %ld", (uint16_t)data, (uint16_t)(data + 2), size); } Then logs can be shown like: peer_connection.c 60 send 6080 6700, 1310

Hi,I add log to the function peer_connection_outgoing_rtp_packet then run the demo but the function has not been called.

xrz1181 avatar Apr 01 '25 08:04 xrz1181

Hi, first step, you can add log to the function peer_connection_outgoing_rtp_packet which sends RTP packets of H264 file or audio file. (your Log level is LEVEL_INFO, you can add logs using LOGI(...)) build and run sample again to see if the log printed.

Changes can be:

static void peer_connection_outgoing_rtp_packet(uint8_t* data, size_t size, void* user_data) { PeerConnection* pc = (PeerConnection*)user_data; dtls_srtp_encrypt_rtp_packet(&pc->dtls_srtp, data, (int*)&size); agent_send(&pc->agent, data, size); LOGI("send %.4x %.4x, %ld", (uint16_t)data, (uint16_t)(data + 2), size); } Then logs can be shown like: peer_connection.c 60 send 6080 6700, 1310

Hi,I add log to the function peer_connection_outgoing_rtp_packet then run the demo but the function has not been called.

Here are two key locations where adding logs can help troubleshoot the issue:

  1. reader_get_video_frame/reader_get_audio_frame: These functions read audio/video files and retrieve media frame data. Add logs here to verify if the functions are called.

  2. peer_connection_send_video/peer_connection_send_audio: These functions insert media frame data into the buffer for decoding. Add logs here to confirm if the functions are invoked.

Example: In the sample compiled from examples/generic/main.c, the code: pthread_create(&peer_connection_thread, NULL, peer_connection_task, NULL); creates a thread to execute peer_connection_loop.

When the PEER_CONNECTION_COMPLETED state is reached, rtp_encoder_encode is called to encode the audio/video, triggering the callback peer_connection_outgoing_rtp_packet.

Since rtp_encoder_encode pulls data from buffer_peak_head, note that the data source originates from buffer_push_tail (called by peer_connection_send_video/peer_connection_send_audio). Thus, adding logs in these functions will help verify if audio/video data is being inserted correctly.

topworldcoder avatar Apr 02 '25 09:04 topworldcoder

By the way, if you're using a custom test.264 file, check out issue #214 for further guidance.

topworldcoder avatar Apr 02 '25 09:04 topworldcoder

By the way, if you're using a custom test.264 file, check out issue #214 for further guidance.

Thanks you,I step by step to debug.

xrz1181 avatar Apr 03 '25 06:04 xrz1181