Commit Graph

710 Commits

Author SHA1 Message Date
Andriy Gelman 207658112b avformat/rtsp: set AV_OPT_FLAG_DEPRECATED on deprecated options
Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-12-18 16:14:17 -05:00
Limin Wang 95d12da559 avformat/rtsp: prefer to use MAX_URL_SIZE for url and command buffer
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-12-05 09:00:53 +08:00
Andriy Gelman 4fe9e2fc16 avformat/rtsp: don't forget to call ff_network_close() on error
In sdp_read_header() some ff_network_close() calls were missed.

Also in rtp_read_header() update comment to explain why a single
call to ff_network_close() is enough to cover all cases even if
sdp_read_header() returns an error.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-21 10:15:52 -05:00
Andriy Gelman 78537aa52f avformat/rtsp: set return variable in error path
In this error path ret still stores the number of bytes read in
ffurl_read().

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-21 10:15:46 -05:00
Limin Wang 5bb313e723 avformat/rtsp: av_rescale -> av_rescale_q
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-14 09:09:28 +08:00
Limin Wang aa1fab6934 avformat/rtsp: check return value of ffurl_read_complete
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-11 18:32:56 +08:00
Limin Wang 001ccbc5cc avformat/rtsp: prefer to use variable instead of type
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-11 18:32:56 +08:00
Limin Wang 33f6bb7828 avformat/rtsp: move SDP_MAX_SIZE macro definition to header file
move comments for the size of SDP_MAX_SIZE here:
Some SDP lines, particularly for Realmedia or ASF RTSP streams,
contain long SDP lines containing complete ASF Headers (several
kB) or arrays of MDPR (RM stream descriptor) headers plus
"rulebooks" describing their properties. Therefore, the SDP line
buffer is large.
The Vorbis FMTP line can be up to 16KB - see xiph_parse_sdp_line
in rtpdec_xiph.c.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-11 18:32:56 +08:00
Limin Wang 5439460016 avformat/rtsp: 16384 -> SDP_MAX_SIZE
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-11 18:32:56 +08:00
Limin Wang c8101aabee avformat/rtsp: support infinite initial_timeout for rtsp option
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-07 10:13:29 +08:00
Limin Wang 784ce1c294 avformat/rtsp: reuse POLLING_TIME and remove POLL_TIMEOUT_MS
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-22 20:53:56 +08:00
Limin Wang 92c40ef882 avformat/rtsp: support for listen_timeout option for sdp
Now the listen timeout is hardcoded(10s).
How to test(30s timeout):
./ffprobe  -listen_timeout 30 -protocol_whitelist rtp,udp,file -i test.sdp

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-22 20:53:56 +08:00
Andriy Gelman 0d156eb58a avformat/rtsp: allocate correct max number of pollfds
There is one general rtsp connection plus two connections per stream (rtp/rtcp).

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-10-08 23:18:18 -04:00
Zhao Zhili a191d4166f avformat/rtsp: fix parse_rtsp_message
1. Remove the assumption that the message method is TEARDOWN.
2. Don't ignore the error code of ff_rtsp_parse_streaming_commands.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-10-02 09:11:24 +03:00
Martin Storsjö 0b1d8468c4 rtsp: Fix infinite loop in listen mode with UDP transport
In listen mode with UDP transport, once the sender has sent
the TEARDOWN and closed the connection, poll will indicate that
one can read from the connection (indicating that the socket has
reached EOF and should be closed by the receiver as well). In this
case, parse_rtsp_message won't try to parse the command (because
it's no longer in state STREAMING), but previously just returned
zero.

Prior to f6161fccf8, this caused
udp_read_packet to return zero, which is treated as EOF by
read_packet. But after that commit, udp_read_packet would continue
if parse_rtsp_message didn't return an explicit error code.

To keep the original behaviour from before that commit, more
explicitly return an error in parse_rtsp_message when in the wrong
state.

Fixes: #8840
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-10-02 09:09:17 +03:00
Andreas Rheinhardt 82bf41f3ab avformat: Replace ffurl_close() by ffurl_closep() where appropriate
It avoids leaving dangling pointers behind in memory.

Also remove redundant checks for whether the URLContext to be closed is
already NULL.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-25 13:11:36 +02:00
Andreas Rheinhardt 4e254ec6be avformat/rtsp: Put strings instead of pointers to strings into array
In this example, the difference in length between the shortest and
longest string is three, so that not using pointers to strings saves
space even on 32bit systems.

Moreover, there is no need to use a sentinel here; it can be replaced
with FF_ARRAY_ELEMS.

Reviewed-by: Ross Nicholson <phunkyfish@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:21:39 +02:00
Andreas Rheinhardt 87b056e6af avformat/rtsp: Don't free uninitialized AVBPrint
Fixes Coverity ID 1462307.

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Ross Nicholson <phunkyfish@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:16:24 +02:00
Wolfgang Haupt 428a0987e4 libavformat/rtsp: pass protocol options for udp multicast
Protocol options like buffer_size need to be passed to the
underlying transport implementation for udp multicasts as well.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-19 23:27:45 +02:00
phunkyfish 2a322906b7 avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-19 13:18:01 +02:00
Carl Eugen Hoyos 8b1f07ef51 Revert "avformat/rtp: Pass sources and block filter addresses via sdp file for rtp"
This reverts commit b71685865f.

The commit lead to the use of an uninitialized variable.
Other issues were listed by Andreas Rheinhardt:
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259150.html
2020-04-05 11:58:02 +02:00
phunkyfish b71685865f avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Signed-off-by: Aman Gupta <aman@tmm1.net>
2020-03-27 10:39:15 -07:00
Martin Storsjö 29f8d4e947 rtsp: Use AVERROR() with errno.h error codes for error returns
This particular function is only required to return nonzero on
errors, but use the common AVERROR() pattern for consistency.

Signed-off-by: Martin Storsjö <martin@martin.st>
2019-12-12 11:28:31 +02:00
Ross Nicholson 460f74495f libavformat/rtsp: return error if rtsp_hd_out is null instead of crash
Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-27 10:54:28 -07:00
James Almer 3e076faf3b Merge commit '1e56173515826aa4d680d3b216d80a3879ed1c68'
* commit '1e56173515826aa4d680d3b216d80a3879ed1c68':
  rtsp: add pkt_size option

Merged-by: James Almer <jamrial@gmail.com>
2019-05-02 13:02:58 -03:00
Tristan Matthews 1e56173515 rtsp: add pkt_size option
This allows users to specify an upper limit on the size of outgoing packets
when publishing via RTSP.

Signed-off-by: Martin Storsjö <martin@martin.st>
2019-04-15 22:44:19 +03:00
Jun Li 32148b5ac9 lavf/rtsp.c: Fix stimeout option not applied on http tunnel
stimeout option is already used in tcp transport, since
http is based on tcp, pass the option to http for tunneling
case.

Reviewed-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: Jun Li <junli1026@gmail.com>
2019-04-15 19:46:20 +08:00
Steven Liu 7f78a1b1ca Revert "lavf/rtsp.c: Fix stimeout option not applied on http tunnel"
This reverts commit 1ae8a1073b.
2019-04-15 19:45:39 +08:00
Signed-off-by: Jun Li 1ae8a1073b lavf/rtsp.c: Fix stimeout option not applied on http tunnel
stimeout option is already used in tcp transport, since
http is based on tcp, pass the option to http for tunneling
case.

Reviewed-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: Jun Li <junli1026@gmail.com>
2019-04-15 19:44:11 +08:00
Steven Liu bbae8d08f5 Revert "lavf/rtsp.c: Fix stimeout option not applied on http tunnel"
This reverts commit f502bd5432.
2019-04-15 19:43:21 +08:00
Steven Liu f502bd5432 lavf/rtsp.c: Fix stimeout option not applied on http tunnel
stimeout option is already used in tcp transport, since
http is based on tcp, pass the option to http for tunneling
case.

Reviewed-by: Steven Liu <lq@onvideo.cn>
Signed-off-by: Jun Li <junli1026@gmail.com>
2019-04-15 15:24:56 +08:00
Jun Li 4f5e660e69 avformat/doc, http, icecast, rtsp: Add option to disable send-expect-100
Fix ticket #7297
The current setting for send-expect-100 option is either
enabled if applicable or forced enabled, no option to force
disable the header. This change is to expand the option setting
to provide more flexibility, which is useful for rstp case.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-03-31 23:23:52 +02:00
Jun Li c3b517dac2 avformat/rtsp: Add https tunneling support
Add https based tunneling for RTSP/RTP. Tested on Axis and Bosch cameras.
Https is widely used for security consideration.
2019-03-25 01:17:23 +01:00
Carl Eugen Hoyos 4d8875ec23 lavf: Constify the probe function argument.
Reviewed-by: Lauri Kasanen
Reviewed-by: Tomas Härdin
2019-03-21 11:42:17 +01:00
Michael Niedermayer 497c9b0cce avformat/rtsp: Check number of streams in sdp_parse_line()
Fixes: OOM

Found-by: Michael Hanselmann <public@hansmi.ch>
Reviewed-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 17:33:50 +01:00
Michael Niedermayer 0b50f27635 avformat/rtsp: Clear reply in every iteration in ff_rtsp_connect()
Fixes: Infinite loop

Found-by: Michael Hanselmann <public@hansmi.ch>
Reviewed-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-31 00:24:38 +01:00
Carl Eugen Hoyos dced1f6cdf lavf/rtpdec: Constify several pointers.
Fixes two warnings:
libavformat/rtpdec.c:155:20: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
libavformat/rtpdec.c:168:20: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
2018-02-11 20:03:33 +01:00
wm4 ff46124b0d rtsp: rename certain options after a deprecation period
The "timeout" option name inherently clashes with the meaning of the
HTTP libavformat protocol option with the same name. Rename it after a
deprecation period to make it compatible with the HTTP one.
2018-02-04 15:08:48 +01:00
Marton Balint 18ac642359 avformat: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-28 23:06:43 +01:00
James Almer dae6d27aa0 Merge commit 'f6161fccf8c5720ceac1ed1df8ba60ff8fed69f5'
* commit 'f6161fccf8c5720ceac1ed1df8ba60ff8fed69f5':
  rtsp: only break on parse_rtsp_message on error

Merged-by: James Almer <jamrial@gmail.com>
2017-12-10 20:44:26 -03:00
Tristan Matthews f6161fccf8 rtsp: only break on parse_rtsp_message on error
Fix suggested by Luca Barbato.

This was causing spurious EOFs when using -rtsp_transport udp, as
reported in https://bugzilla.libav.org/show_bug.cgi?id=1103

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2017-11-30 15:32:04 +01:00
Luca Barbato 1e27837265 rtsp: Move message parsing to a separate function
Make easier to handle the polling function before we implement
full threading support.

(cherry picked from libav commit ca960161f0)
Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-06 00:22:10 -03:00
James Almer 1e7b6e47d2 Merge commit '79331df362fb05a0d04ca9489c87e5b80077a3f4'
* commit '79331df362fb05a0d04ca9489c87e5b80077a3f4':
  rtsp: Lazily set up the pollfd array once

Merged-by: James Almer <jamrial@gmail.com>
2017-10-03 23:08:06 -03:00
James Almer c2916564d8 Merge commit '5263f464db5f2df74ddf712f6d1221b24475fa8e'
* commit '5263f464db5f2df74ddf712f6d1221b24475fa8e':
  rtsp: Lazily allocate the pollfd array

Merged-by: James Almer <jamrial@gmail.com>
2017-10-03 21:40:22 -03:00
James Almer 7c74efeaf8 Merge commit 'b9b82151a1aaa8bbf389853a6142c4e101d80b86'
* commit 'b9b82151a1aaa8bbf389853a6142c4e101d80b86':
  rtsp: Move the pollfd setup out of the for loop

Merged-by: James Almer <jamrial@gmail.com>
2017-10-03 21:37:37 -03:00
James Almer c244d4af43 Merge commit '150e99d694f33ab9ad678834964909aa315d14a1'
* commit '150e99d694f33ab9ad678834964909aa315d14a1':
  rtsp: Factor out packet reading

Merged-by: James Almer <jamrial@gmail.com>
2017-10-03 21:34:08 -03:00
wm4 5d76674756 lavf: make avio_read_partial() public
Main use-case is proxying avio through a foreign I/O layer and a custom
AVIO context, without losing latency and performance characteristics.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>

Merged from Libav commit 173b56218f.
2017-09-01 17:56:33 +02:00
wm4 173b56218f lavf: make avio_read_partial() public
Main use-case is proxying avio through a foreign I/O layer and a custom
AVIO context, without losing latency and performance characteristics.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2017-08-30 14:29:14 +02:00
Clément Bœsch e3287077ec Merge commit '67deba8a416d818f3d95aef0aa916589090396e2'
* commit '67deba8a416d818f3d95aef0aa916589090396e2':
  Use avpriv_report_missing_feature() where appropriate

Merged-by: Clément Bœsch <cboesch@gopro.com>
2017-03-31 10:40:34 +02:00
Luca Barbato ca960161f0 rtsp: Move message parsing to a separate function
Make easier to handle the polling function before we implement
full threading support.
2017-03-21 04:23:41 +01:00