Closed brothercorvo closed 1 year ago
I think I'm seeing something similar with the Android flavour of TAK: rtsp-simple-server 0.21.6 works and mediamtx 0.22.0 doesn't. (Neither does 0.22.1, 0.22.2, 0.23.8 or 1.0.0.) However, having examined my logs, I'd put the blame on the other foot.
I have two Android phones and a Linux PC all on one network. One phone is running TAK-ICU and broadcasts to the media server on the PC. The other phone is running ATAK and is trying to see the video. All versions tested with the default configuration file, except that I've set "logLevel: debug".) Obviously the re-branding isn't the cause, but it does allow me to have last-known-good and first-known-bad versions installed at the same time.
I don't think TAK ICU's available through the Play store, but I also don't think it is a factor. To judge from the logs, any video source would do because the problem lies at the other end of the chain. I noticed the problem while using ATAK 4.4.0.0. The Play store is offering 4.8.1.27 right now and that does not have the problem. It works fine with mediamtx. Since I happen to have access to a cart-load of old ATAK APKs, I can report that the problem still existed in 4.5.1.12 but disappeared with 4.6.0.1. I also note that a simple gstreamer client does not exhibit the problem:
gst-launch-1.0 playbin uri=rtsp://build4.khtest.local:8554/live/ken
All things considered, my guess would be that the problem is/was in the TAK client and it is fixed in more recent versions. I haven't used WinTAK and I've no idea which version you are using, but it would be worth a look. A brief search suggests that it is currently at "version 4.1.something" but I've no idea if WinTAK version numbers are comparable to ATAK ones. (They ought to bear some resemblance, since I'd hope there was a large shared code-base, but perhaps I'm being naive!)
Comparing the logs for 0.21.6 and 0.22.0 (which I'll post next) I think I can offer a clearer description of my symptoms. You might want to enable "logLevel: debug" yourself and see what your WinTAK is saying. I don't know enough about the RTSP protocol to know if one or other end is being "unforgiving", or enough to write a more helpful bug report for the WinTAK people if that turns out to be our conclusion. I'd appreciate it if someone who knows about RTSP can cast an eye over the logs and comment on that.
Here is the log output from rtsp-simple-server 0.21.6, which works.
I start the server at the command line:
me@BUILD4:~$ sudo /usr/local/bin/rtsp-simple-server /usr/local/etc/rtsp-simple-server.yml
2023/08/17 13:54:54 INF MediaMTX / rtsp-simple-server v0.21.6
2023/08/17 13:54:54 DEB path manager created
2023/08/17 13:54:54 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2023/08/17 13:54:54 INF [RTMP] listener opened on :1935
2023/08/17 13:54:54 INF [HLS] listener opened on :8888
2023/08/17 13:54:54 INF [WebRTC] listener opened on :8889 (HTTP)
Then I start broadcasting from TAK-ICU:
2023/08/17 13:56:27 INF [RTSP] [conn 192.168.66.82:47392] opened
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [c->s] OPTIONS rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
CSeq: 1
User-Agent: Lavf58.20.100
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [s->c] RTSP/1.0 200 OK
CSeq: 1
Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN
Server: gortsplib
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [c->s] ANNOUNCE rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
CSeq: 2
Content-Length: 147
Content-Type: application/sdp
User-Agent: Lavf58.20.100
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.66.68
t=0 0
a=tool:libavformat 58.20.100
m=video 0 RTP/AVP 33
a=control:streamid=0
2023/08/17 13:56:27 INF [RTSP] [session 0c142625] created by 192.168.66.82:47392
2023/08/17 13:56:27 DEB [path live/ken] created
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [s->c] RTSP/1.0 200 OK
CSeq: 2
Server: gortsplib
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [c->s] SETUP rtsp://build4.khtest.local:8554/live/ken/streamid=0 RTSP/1.0
CSeq: 3
Transport: RTP/AVP/UDP;unicast;client_port=17528-17529;mode=record
User-Agent: Lavf58.20.100
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [s->c] RTSP/1.0 200 OK
CSeq: 3
Server: gortsplib
Session: 9bdfe466-535f-4eeb-a458-8481a5e41267
Transport: RTP/AVP;unicast;client_port=17528-17529;server_port=8000-8001
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [c->s] RECORD rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
CSeq: 4
Range: npt=0.000-
Session: 9bdfe466-535f-4eeb-a458-8481a5e41267
User-Agent: Lavf58.20.100
2023/08/17 13:56:27 INF [RTSP] [session 0c142625] is publishing to path 'live/ken', with UDP, 1 track (Generic)
2023/08/17 13:56:27 DEB [RTSP] [conn 192.168.66.82:47392] [s->c] RTSP/1.0 200 OK
CSeq: 4
Server: gortsplib
Session: 9bdfe466-535f-4eeb-a458-8481a5e41267
Then I try to see the video in ATAK on the other phone:
2023/08/17 13:59:02 INF [RTSP] [conn 192.168.66.65:52032] opened
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [c->s] OPTIONS rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
CSeq: 1
User-Agent: Lavf58.29.100
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [s->c] RTSP/1.0 200 OK
CSeq: 1
Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN
Server: gortsplib
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [c->s] DESCRIBE rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
Accept: application/sdp
CSeq: 2
User-Agent: Lavf58.29.100
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [s->c] RTSP/1.0 200 OK
CSeq: 2
Content-Base: rtsp://build4.khtest.local:8554/live/ken/
Content-Length: 146
Content-Type: application/sdp
Server: gortsplib
v=0
o=- 0 0 IN IP4 127.0.0.1
s=Stream
c=IN IP4 0.0.0.0
t=0 0
m=video 0 RTP/AVP 33
a=control:mediaUUID=c3e0cb44-58f6-4a77-8ead-18fd08f49684
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [c->s] SETUP rtsp://build4.khtest.local:8554/live/ken/ RTSP/1.0
CSeq: 3
Transport: RTP/AVP/UDP;unicast;client_port=34280-34281
User-Agent: Lavf58.29.100
2023/08/17 13:59:02 INF [RTSP] [session 0be5b779] created by 192.168.66.65:52032
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [s->c] RTSP/1.0 200 OK
CSeq: 3
Server: gortsplib
Session: 37436cdf-434d-4ab3-b331-a17b8fde35a4;timeout=60
Transport: RTP/AVP;unicast;client_port=34280-34281;server_port=8000-8001;ssrc=BBBCD6BC
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [c->s] PLAY rtsp://build4.khtest.local:8554/live/ken/ RTSP/1.0
CSeq: 4
Range: npt=0.000-
Session: 37436cdf-434d-4ab3-b331-a17b8fde35a4
User-Agent: Lavf58.29.100
2023/08/17 13:59:02 INF [RTSP] [session 0be5b779] is reading from path 'live/ken', with UDP, 1 track (Generic)
2023/08/17 13:59:02 DEB [RTSP] [conn 192.168.66.65:52032] [s->c] RTSP/1.0 200 OK
CSeq: 4
RTP-Info: url=rtsp://build4.khtest.local:8554/live/ken/mediaUUID=c3e0cb44-58f6-4a77-8ead-18fd08f49684;seq=19122;rtptime=2787208795
Server: gortsplib
Session: 37436cdf-434d-4ab3-b331-a17b8fde35a4;timeout=60
This works. There are further short exchanges every 30 seconds until I close everything down. I doubt those are relevant here, so I'll omit them.
Here is the log output from mediamtx 0.22.0, which doesn't work with older versions of ATAK.
I start the server at the command line:
me@BUILD4:~$ sudo /usr/local/bin/mediamtx /usr/local/etc/mediamtx.yml
2023/08/17 14:15:57 INF MediaMTX / rtsp-simple-server v0.22.0
2023/08/17 14:15:57 DEB path manager created
2023/08/17 14:15:57 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2023/08/17 14:15:57 INF [RTMP] listener opened on :1935
2023/08/17 14:15:57 INF [HLS] listener opened on :8888
2023/08/17 14:15:57 INF [WebRTC] listener opened on :8889 (HTTP)
Then I start broadcasting from TAK-ICU. I'll omit these log entries because they don't differ from the previous case except for trivia like timestamps, port numbers and session IDs.
Then I try to see the video in ATAK on the other phone, which fails to connect:
2023/08/17 14:19:49 INF [RTSP] [conn 192.168.66.65:52174] opened
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [c->s] OPTIONS rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
CSeq: 1
User-Agent: Lavf58.29.100
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [s->c] RTSP/1.0 200 OK
CSeq: 1
Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN
Server: gortsplib
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [c->s] DESCRIBE rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
Accept: application/sdp
CSeq: 2
User-Agent: Lavf58.29.100
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [s->c] RTSP/1.0 200 OK
CSeq: 2
Content-Base: rtsp://build4.khtest.local:8554/live/ken/
Content-Length: 187
Content-Type: application/sdp
Server: gortsplib
v=0
o=- 0 0 IN IP4 127.0.0.1
s=Stream
c=IN IP4 0.0.0.0
t=0 0
m=video 0 RTP/AVP 33
a=control:rtsp://build4.khtest.local:8554/live/ken/mediaUUID=633371f6-dec9-4434-8ee0-0133d516ab5b
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [c->s] SETUP rtsp://build4.khtest.local:8554/live/ken/ RTSP/1.0
CSeq: 3
Transport: RTP/AVP/UDP;unicast;client_port=12296-12297
User-Agent: Lavf58.29.100
2023/08/17 14:19:49 INF [RTSP] [session 5db713b4] created by 192.168.66.65:52174
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [s->c] RTSP/1.0 200 OK
CSeq: 3
Server: gortsplib
Session: 98358143-7f3f-4d48-98fc-0723c11144c7;timeout=60
Transport: RTP/AVP;unicast;client_port=12296-12297;server_port=8000-8001;ssrc=276F89D0
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [c->s] PLAY rtsp://build4.khtest.local:8554/live/ken/mediaUUID=633371f6-dec9-4434-8ee0-0133d516ab5b RTSP/1.0
CSeq: 4
Range: npt=0.000-
Session: 98358143-7f3f-4d48-98fc-0723c11144c7
User-Agent: Lavf58.29.100
2023/08/17 14:19:49 DEB [RTSP] [conn 192.168.66.65:52174] [s->c] RTSP/1.0 400 Bad Request
CSeq: 4
Server: gortsplib
2023/08/17 14:19:49 INF [RTSP] [conn 192.168.66.65:52174] closed (path has changed, was '/live/ken', now is '/live/ken/mediaUUID=633371f6-dec9-4434-8ee0-0133d516ab5b')
2023/08/17 14:19:49 INF [RTSP] [session 5db713b4] destroyed (not in use)
In CSeq 2, the server returns a different SDP attribute (using a full URL and not just the mediaUUID) and this apparently causes the client to issue a PLAY request at CSeq 4 using a new URL that includes the mediaUUID. The server considers that to be a mal-formed request and refuses to proceed.
I mentioned that a simple gstreamer pipeline is not rejected. The relevant part of log in this case is as follows:
2023/08/17 14:35:22 DEB [RTSP] [conn 127.0.0.1:52336] [c->s] DESCRIBE rtsp://build4.khtest.local:8554/live/ken RTSP/1.0
Accept: application/sdp
CSeq: 2
Date: Thu, 17 Aug 2023 13:35:22 GMT
User-Agent: GStreamer/1.18.4
2023/08/17 14:35:22 DEB [RTSP] [conn 127.0.0.1:52336] [s->c] RTSP/1.0 200 OK
CSeq: 2
Content-Base: rtsp://build4.khtest.local:8554/live/ken/
Content-Length: 187
Content-Type: application/sdp
Server: gortsplib
v=0
o=- 0 0 IN IP4 127.0.0.1
s=Stream
c=IN IP4 0.0.0.0
t=0 0
m=video 0 RTP/AVP 33
a=control:rtsp://build4.khtest.local:8554/live/ken/mediaUUID=e3d6d1ab-2d2c-4134-8d64-f60c3bbdf3d3
2023/08/17 14:35:22 DEB [RTSP] [conn 127.0.0.1:52336] [c->s] SETUP rtsp://build4.khtest.local:8554/live/ken/mediaUUID=e3d6d1ab-2d2c-4134-8d64-f60c3bbdf3d3 RTSP/1.0
CSeq: 3
Date: Thu, 17 Aug 2023 13:35:22 GMT
Transport: RTP/AVP;unicast;client_port=48586-48587
User-Agent: GStreamer/1.18.4
2023/08/17 14:35:22 INF [RTSP] [session ee54ac2b] created by 127.0.0.1:52336
2023/08/17 14:35:23 DEB [RTSP] [conn 127.0.0.1:52336] [s->c] RTSP/1.0 200 OK
CSeq: 3
Server: gortsplib
Session: 07a29d61-1ed0-439e-a7ec-c89a31c8a73d;timeout=60
Transport: RTP/AVP;unicast;client_port=48586-48587;server_port=8000-8001;ssrc=5F8115A6
2023/08/17 14:35:23 DEB [RTSP] [conn 127.0.0.1:52336] [c->s] PLAY rtsp://build4.khtest.local:8554/live/ken/ RTSP/1.0
CSeq: 4
Date: Thu, 17 Aug 2023 13:35:23 GMT
Range: npt=0-
Session: 07a29d61-1ed0-439e-a7ec-c89a31c8a73d
User-Agent: GStreamer/1.18.4
2023/08/17 14:35:23 INF [RTSP] [session ee54ac2b] is reading from path 'live/ken', with UDP, 1 track (Generic)
2023/08/17 14:35:23 DEB [RTSP] [conn 127.0.0.1:52336] [s->c] RTSP/1.0 200 OK
CSeq: 4
RTP-Info: url=rtsp://build4.khtest.local:8554/live/ken/mediaUUID=e3d6d1ab-2d2c-4134-8d64-f60c3bbdf3d3;seq=2924;rtptime=2281421386
Server: gortsplib
Session: 07a29d61-1ed0-439e-a7ec-c89a31c8a73d;timeout=60
The same SDP is returned in CSeq 2, but the gstreamer client responds by requesting a SETUP of a URL with the mediaUUID and then PLAY a URL without it. This appears to be acceptable. The newer versions of ATAK also do this, but the older ATAK clients seem to have those URLs the other way around. (With rtsp-simple-server, which advertised the "reduced" SDP attribute, neither URL has anything appended.)
@backformation the reason why absolute URLs are used in control attributes is to fix compatibility between GStreamer and URLs with queries. This change was introduced in https://github.com/bluenviron/gortsplib/pull/210 and is included in v0.22.0 and not v0.21.0. The change won't be reversed.
Can you confirm that the issue is solved in recent versions of ATAK?
Yes, I don't have a problem with ATAK 4.6 or later. I can't see why a non-military user would not be using a later version than that. (I know that some military users have very conservative policies around updates, but that's really their problem, not yours.)
I don't know about WinTAK, which is what the original poster is using. It's a port from Android to Windows and depending on how the project is being managed, it might be a port from an older codebase and might still have the bug. If so, brothercorvo can point them at their own (Android 4.6) codebase for the fix.
(Of course, that's always assuming that he gets similar logs to mine when he enables "logLevel: debug".)
This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.
Which version are you using?
v0.22.2
Which operating system are you using?
Describe the issue
WinTAk try to establish the connection, using several SETUP statements, but the server in version v0.22.2 fail to establish communication. @aler9 I can confirm that this is a bug that has been introduced in the last year. using version v0.18.0, I can connect successfully with the same sequence:
Transport: RTP/AVP/UDP;unicast;client_port=16076-16077 // trying to use UDP that is disabled
499 7.813985 192.168.1.150 198.199.70.185 RTSP 216 SETUP rtsp://198.199.70.185:8554/live/Corvo/ RTSP/1.0
Transport: RTP/AVP/TCP;unicast;interleaved=0-1500 7.858533 198.199.70.185 192.168.1.150 RTSP 184 Reply: RTSP/1.0 200 OK
// switch to TCPstream starts
Describe how to replicate the issue
Connect to a RTSP stream using WinTAK (any version)
Did you attach the server logs?
yes in the server logs �[90m2023/05/11 14:06:57 �[0m�[32mINF�[0m [RTSP] [conn 129.222.188.14:59163] opened �[90m2023/05/11 14:06:57 �[0m�[32mINF�[0m [RTSP] [session 2852d870] created by 129.222.188.14:59163 �[90m2023/05/11 14:06:57 �[0m�[32mINF�[0m [RTSP] [conn 129.222.188.14:59163] closed (path has changed, was '/live/Corvo', now is '/live/Corvo/trackID=0')
I was able to connect with a prev. version of mediamtx (Dec 2021)
Did you attach a network dump?
Wireshark request 62 4.126893 192.168.1.150 204.48.30.216 RTSP 220 PLAY rtsp://204.48.30.216:8554/live/Corvo/trackID=0 RTSP/1.0 response 70 4.457005 204.48.30.216 192.168.1.150 RTSP 110 Reply: RTSP/1.0 400 Bad Request
WinTAK2_RTSP_comms.zip
yes