[Libav-user] RTSP client issues PAUSE, receives 200 and... throws back 501 Not Implemented
Michal Rybinski
michal.rybinski+ffmpeg at gmail.com
Fri Feb 22 17:28:11 EET 2019
Hi there,
Using ffmpeg to grab RTSP stream.
During one case, av_read_pause is used with intention to perform
av_read_play when the trigger for play comes to control flow.
In RTPS terms (confirmed with wireshark and RTSP server logs). (C)lient
here is ffmpeg.
C->S: PAUSE
CSeq: 5
Session: 423132DA
S->C: RTSP/1.0 200 OK
CSeq: 5
Session: 423132DA
C->S: RTSP/1.0 501 Not Implemented
AFAIK PAUSE is C->S only and client shouldn't issue anything after it.
Could anyone share any advise in which direction to continue with analysis?
Some more info below.
The flow is (in general)
avformat_open_input - opens rtsp stream
av_read_frame - to grab frames and put on them on queue for processing
and somewhere on the way - av_read_pause is issued
Curious observation is that the av_read_pause never returned several times
to the calling thread during this exercise (maybe I'm using it wrong?)
I'm trying to debug what's happening on the way in order to determine what
I'm doing wrong.
After browsing and chasing possible source, I found in /libavformat/rtsp.c
(FFMPEG) the int ff_rtsp_read_reply(...) and following parts:
in a parsing loop:
if (line_count == 0) {
/* get reply code */
get_word(buf1, sizeof(buf1), &p);
if (!strncmp(buf1, "RTSP/", 5)) {
get_word(buf1, sizeof(buf1), &p);
reply->status_code = atoi(buf1);
av_strlcpy(reply->reason, p, sizeof(reply->reason));
} else {
av_strlcpy(reply->reason, buf1, sizeof(reply->reason)); //
method
get_word(buf1, sizeof(buf1), &p); // object
request = 1;
}
}
So it seems a "RTSP/whatever" from Server triggers 'request =1' setting,
hence:
if (request) {
//(...)
if (!strcmp(reply->reason, "OPTIONS")) {
snprintf(buf, sizeof(buf), "RTSP/1.0 200 OK\r\n");
if (reply->seq)
av_strlcatf(buf, sizeof(buf), "CSeq: %d\r\n", reply->seq);
if (reply->session_id[0])
av_strlcatf(buf, sizeof(buf), "Session: %s\r\n",
reply->session_id);
} else {
snprintf(buf, sizeof(buf), "RTSP/1.0 501 Not Implemented\r\n");
}
// (...)
/* If method is set, this is called from ff_rtsp_send_cmd,
* where a reply to exactly this request is awaited. For
* callers from within packet receiving, we just want to
* return to the caller and go back to receiving packets. */
if (method)
goto start;
return 0;
}
So it seems in this case if S->C: OPTIONS, ffmpeg rtsp client creates 501
Not Implemented message and in any other case - it should end-up in mutual
Client-Serwer 200 OK. So in my scenario, if anything, RTSP/1.0 200 OK
should be seen, yet I still do get this 501 after PAUSE.
Which seems harmless, yet weird anyway as after succesful PAUSE client
shouldn't be issuing anything else. Still I may have missed logic blocking
issuing this C->S RTSP/1.0 200 in response to S->C RTSP/1.0 200 response.
I am using ffmpeg source from December's release, so possibly will re-check
on latest master.
Where else I could look to debug the issue properly? I am assuming it's the
usage of libav that's flawed and trying narrow down the problem.
Any tips would be much appreciated.
MichaĆ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190222/be88fbe9/attachment.html>
More information about the Libav-user
mailing list