1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-04 07:21:31 +02:00
Commit Graph

726 Commits

Author SHA1 Message Date
Andreas Rheinhardt
6c8f96f18b avformat/rtsp: Use av_dict_set_int()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:40:13 +02:00
Andreas Rheinhardt
40bdd8cc05 avformat: Avoid allocation for AVStreamInternal
Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:22:25 +02:00
Andreas Rheinhardt
45bfe8b838 avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext.
This commit moves them into a new structure in avio_internal.h instead.
Said structure contains the public AVIOContext as its first element
in order to avoid having to allocate a separate AVIOContextInternal
which is costly for those use cases where one just wants to access
an already existing buffer via the AVIOContext-API.
For these cases ffio_init_context() can't fail and always returned zero,
which was typically not checked. Therefore it has been made to not
return anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Hayden Myers
9b4b0df470 libavformat/rtsp.c: Reply to GET_PARAMETER requests
Some encoders send GET_PARAMETER requests as a keep-alive mechanism.
If the client doesn't reply with an OK message, the encoder will close
the session.  This was encountered with the impath i5110 encoder, when
the RTSP Keep-Alive checkbox is enabled under streaming settings.
Alternatively one may set the X-No-Keepalive: 1 header, but this is more
of a workaround.  It's better practice to respond to an encoder's
keep-alive request, than disable the mechanism which may be manufacturer
specific.

Signed-off-by: Hayden Myers <hmyers@skylinenet.net>
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-07-12 16:00:48 +03:00
Andriy Gelman
6df4bcf1d0 avformat/rtsp: Include rtcp in port range check
Currently it is only checked that the rtp port does not exceed rtp_port_max.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-07-05 13:37:39 -04:00
Andriy Gelman
d1f78067a6 avformat/rtsp: Reindent after previous commit
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-07-05 13:37:26 -04:00
Andriy Gelman
02387de90e avformat/rtsp: Set port_off to zero for low min/max port range
Fixes:
$ ffmpeg -min_port 32000 -max_port 32001 -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov -f null -
[1]    303871 floating point exception (core dumped)

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-07-05 13:36:22 -04:00
Andriy Gelman
8257d6dda6 avformat/rtsp: Fix timeout option
92c40ef882 added a listen_timeout option
for sdp. This allowed a user to set variable timeout which was
originally hard coded to 10 seconds.

The commit used the initial_timeout variable to store the value. But
this variable is shared with rtsp where it's used to infer a "listen"
mode. Thus, the timeout value could not be set in rtsp, and the default
value (initial_timeout = -1) would give 100ms timeout.

This was attempted to be fixed in c8101aabee,
which changed the meaning of initial_timeout = -1 to be an infinite
timeout. However, it did not address the issue that the timeout could
still not be set. Being able to set the timeout is useful because it
allows to automatically reconfigure from a udp to tcp connection in the
lower transport.

In this commit this is fixed by using the stimeout variable to
store the timeout value.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-07-05 12:49:55 -04:00
James Almer
b9c5fdf602 avformat: move AVStream.{parser,need_parsing} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-05-07 09:27:21 -03:00
Andreas Rheinhardt
bc70684e74 avformat: Constify all muxer/demuxers
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:06 -03:00
Andreas Rheinhardt
6f34f03190 avformat/rtsp: Remove deprecated old options, rename stimeout->timeout
Deprecated in ff46124b0d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:09 -03:00
Jiangjie Gao
3e9284fccb avformat/rtsp: support buffer_size and pkt_size options for RTP
And forward it to the underlying UDP protocol.

Fixes ticket #7517.

Signed-off-by: Jiangjie Gao <gaojiangjie@live.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-03-19 23:13:26 +01:00
Andreas Rheinhardt
e9513052b5 avformat/rtsp: Fix build failure when RTP demuxers are disabled
rtsp.c uses a check of the form "if (CONFIG_RTSP_DEMUXER && ...) {}"
with the intent to make the code compilable even though the part guarded
by this check contains calls to functions that don't exist when the RTSP
demuxer is disabled. Yet even then compilers still need a declaration of
all the functions in the dead code block and error out if not (due to
our usage of -Werror=implicit-function-declaration) and no such
declaration exists for a static function in rtsp.c. Simply adding a
declaration leads to a "used but never defined" warning, therefore this
commit resorts to an #if.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-03 21:36:47 +01:00
tpol
71ce5c32f0 avformat/rtsp: correctly set media control uri with mpegts
Fixes #1941

Currently the media control uri is not correctly assigned when mpegts is
signalled in the media description.

The code checks whether at least one AVStream has been setup before
assigning to the media's uri. With mpegts the AVStreams are setup when
parsing packets and so the media's uri is skipped. This is fixed by
using rt->nb_rtsp_streams in the check which counts all medias in the
sdp.

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2021-01-17 21:36:16 -05:00
Aman Karmani
d20f059fb9 avformat/rtsp: add satip_raw flag to receive raw mpegts stream
This can be used to receive the raw mpegts stream from a SAT>IP
server, by letting avformat handle the RTSP/RTP/UDP negotiation
and setup, but then simply passing the MP2T stream through
instead of demuxing it further.

For example, this command would demux/remux the mpegts stream:

    SATIP_URL='satip://192.168.1.99:554/?src=1&freq=12188&pol=h&ro=0.35&msys=dvbs&mtype=qpsk&plts=off&sr=27500&fec=34&pids=0,17,18,167,136,47,71'
    ffmpeg -i $SATIP_URL -map 0 -c copy -f mpegts -y remux.ts

Whereas this command will simply write out the raw stream, with
the original PAT/PMT/PIDs intact:

    ffmpeg -rtsp_flags satip_raw -i $SATIP_URL -map 0 -c copy -f data -y raw.ts

Signed-off-by: Aman Karmani <aman@tmm1.net>
2020-12-28 14:08:44 -08:00
Aman Karmani
98b76bb11f avformat/rtsp: add support for satip://
The SAT>IP protocol[1] is similar to RTSP. However SAT>IP servers
are assumed to speak only MP2T, so DESCRIBE is not used in the same
way. When no streams are active, DESCRIBE will return 404 according
to the spec (see section 3.5.7). When streams are active, DESCRIBE
will return a list of all current streams along with information
about their signal strengths.

Previously, attemping to use ffmpeg with a rtsp:// url that points
to a SAT>IP server would work with some devices, but fail due to 404
response on others. Further, if the SAT>IP server was already
streaming, ffmpeg would incorrectly consume the DESCRIBE SDP response
and join an existing tuner instead of requesting a new session with
the URL provided by the user. These issues have been noted by many
users across the internet[2][3][4].

This commit adds proper spec-compliant support for SAT>IP, including:

- support for the satip:// psuedo-protocol[5]
- avoiding the use of DESCRIBE
- parsing and consuming the com.ses.streamID response header
- using "Transport: RTP/AVP;unicast" because the optional "/UDP"
  suffix confuses some servers

This patch has been validated against multiple SAT>IP vendor devices:

- Telestar Digibit R2
  (https://telestar.de/en/produkt/digibit-r1-2/)
- Kathrein EXIP 418
  (https://www.kathrein-ds.com/en/produkte/sat-zf-verteiltechnik/sat-ip/227/exip-418)
- Kathrein EXIP 4124
  (https://www.kathrein-ds.com/en/products/sat-if-signal-distribution/sat-ip/226/exip-4124)
- Megasat MEG-8000
  (https://www.megasat.tv/produkt/sat-ip-server-3/)
- Megasat Twin
  (https://www.megasat.tv/en/produkt/sat-ip-server-twin/)
- Triax TSS 400
  (https://www.conrad.com/p/triax-tss-400-mkii-sat-ip-server-595256)

[1] https://www.satip.info/sites/satip/files/resource/satip_specification_version_1_2_2.pdf
[2] https://stackoverflow.com/questions/61194344/does-ffmpeg-violate-the-satip-specification-describe-syntax
[3] https://github.com/kodi-pvr/pvr.iptvsimple/issues/196
[4] https://forum.kodi.tv/showthread.php?tid=359072&pid=2995884#pid2995884
[5] https://www.satip.info/resources/channel-lists/
2020-12-28 14:08:44 -08:00
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