gpt4 book ai didi

android - 从 Android 流式传输到 VLC

转载 作者:行者123 更新时间:2023-11-30 04:05:57 25 4
gpt4 key购买 nike

我知道有人问过类似的问题,但我找不到我的具体问题的答案。

我正在尝试创建从 Android 相机到 VLC 播放器客户端的 RTSP/RTP 视频流。我已经编写了一个小型 RTSP 服务器来处理所有设置,VLC 似乎喜欢我的参数。但是,在发出 PLAY 命令并且我的应用程序开始发送视频流(通过 DatagramPackets)之后,VLC 播放器没有收到任何数据。

我正在使用 jlibrtp 库并像这样设置我的流

    sendSoc = new DatagramSocket(1238);
recSoc = new DatagramSocket(1239);
sess = new RTPSession(sendSoc, recSoc);
FakeClass fc = new FakeClass(); //This implements the RTPAppIntf but all the functions are empty
sess.RTPSessionRegister(fc, null, null);
sess.payloadType(96);
Participant p = new Participant("localhost",1236,1237);
sess.addParticipant(p);

这是我从 VLC 播放器看到的日志

Opening connection to 192.168.1.221, port 1234...
[0xb1003790] main art finder debug: no art finder module matching "any" could be loaded
[0xb1003790] main art finder debug: TIMER module_need() : 6.331 ms - Total 6.331 ms / 1 intvls (Avg 6.331 ms)
[0x9f653e0] main playlist debug: art not found for rtsp://192.168.1.221:1234
...remote connection opened
Sending request: OPTIONS rtsp://192.168.1.221:1234 RTSP/1.0
CSeq: 2
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)


Received 76 new bytes of response data.
Received a complete OPTIONS response:
RTSP/1.0 200 OK
CSeq: 2
Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE


Sending request: DESCRIBE rtsp://192.168.1.221:1234 RTSP/1.0
CSeq: 3
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Accept: application/sdp


Received 240 new bytes of response data.
Received a complete DESCRIBE response:
RTSP/1.0 200 OK
CSeq: 3
Content-Type: application/sdp

v=0
o=- 1343306778867 1343306778867 IN IP4 192.168.1.221
s=Droid Stream
i=Live Stream from Android Camera
t=1343306778873 0
m=video 1236/2 RTP/AVP 96
a=rtpmap:96 H264/9000


[0xb0101190] live555 demux debug: RTP subsession 'video/H264'
Sending request: SETUP rtsp://192.168.1.221:1234/ RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Transport: RTP/AVP;unicast;client_port=1236-1237


Received 128 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
CSeq: 4
Session: 1343306779273
Transport: RTP/AVP/UDP;unicast;client_port=1236-1237;server_port=1238-1239


[0xb5203c18] main input debug: selecting program id=0
[0xb0101190] live555 demux debug: setup start: 0.000000 stop:0.000000
Sending request: PLAY rtsp://192.168.1.221:1234 RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 1343306779273
Range: npt=0.000-


Received 71 new bytes of response data.
Received a complete PLAY response:
RTSP/1.0 200 OK
CSeq: 5
Session: 1343306779273
Range: npt=0.000-

..[剪辑]..

[0xb5203c18] main input debug: `rtsp://192.168.1.221:1234' successfully opened
[0xb0101190] live555 demux warning: no data received in 10s. Switching to TCP
Sending request: TEARDOWN rtsp://192.168.1.221:1234 RTSP/1.0
CSeq: 6
User-Agent: LibVLC/2.0.1 (LIVE555 Streaming Media v2011.12.23)
Session: 1343306779273

所以我不知道哪里出了问题。 VLC 应该在 android 设备端口 1236 上监听,但它没有看到数据包,所以我不知道它在哪里监听。可以告诉我这看起来是否正确吗?

最佳答案

发现问题是将我的数据包写入 Android 设备端口 1236 而不是客户端设备端口 1236。因此 SETUP 命令中的传输参数说明

Transport: RTP/AVP/UDP;unicast;client_port=1236-1237;server_port=1238-1239

表示服务器(Android 手机)将从服务器端口 1238 向客户端设备端口 1236 发送 RTP 数据包。同样,RTCP 通信将发生在服务器端口 1239 和客户端设备端口 1237 之间。

关于android - 从 Android 流式传输到 VLC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11669958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com