[FFmpeg-trac] #6471(avformat:new): RTMPS stream does not work
FFmpeg
trac at avcodec.org
Fri May 10 07:02:40 EEST 2019
#6471: RTMPS stream does not work
-------------------------------------+-------------------------------------
Reporter: | Owner:
rubensanchez |
Type: defect | Status: new
Priority: important | Component: avformat
Version: git-master | Resolution:
Keywords: rtmps, | Blocked By:
facebook |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by Adion):
I encountered the same problem, it appears to still exist in FFmpeg v4.1.3
and I think I found the underlying reason for this failure.
The full code is:
[code]
/* set stream into nonblocking mode */
rt->stream->flags |= AVIO_FLAG_NONBLOCK;
/* try to read one byte from the stream */
ret = ffurl_read(rt->stream, &c, 1);
/* switch the stream back into blocking mode */
rt->stream->flags &= ~AVIO_FLAG_NONBLOCK;
[/code]
The problem is that the non-blocking stream flag is not passed down to
underlying protocols.
In the case of rtmp, this is not a problem since the protocol is tcp
directly.
In the case of rtmps, the protocol is one of the tls implementations, and
(at least for securetransport on mac and schannel on windows) they both
use a secondary URLProtocol to make the call to tcp.
On this secondary URLProtocol, the flag is not updated however.
Instead of commenting out the lines, I've fixed it in tls_read instead,
but to fix it anywhere might require deeper changes (a function to update
URLProtocol flags so that protocols know they have to change the flags in
the protocols they use perhaps?)
Anyway, here are the changes I've made to temporarily fix this:
In tls_schannel.c tls_read function, change the ffurl_read function to:
[code]
set_flag_nonblock = 1;
if (h->flags&AVIO_FLAG_NONBLOCK &&
!(s->tcp->flags&AVIO_FLAG_NONBLOCK)) {
s->tcp->flags |= AVIO_FLAG_NONBLOCK;
set_flag_nonblock = 1;
}
ret = ffurl_read(s->tcp, c->enc_buf + c->enc_buf_offset,
c->enc_buf_size - c->enc_buf_offset);
if (set_flag_nonblock)
s->tcp->flags &= ~AVIO_FLAG_NONBLOCK;
[/code]
In tls_securetransport.c I did something similar for tls_read_cb.
I don't use openssl, but at first sight it seems to use a similar way so
probably is affected as well.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/6471#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list