Commit Graph

144 Commits

Author SHA1 Message Date
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt b800327f4c avformat/avformat: Add FFInputFormat, hide internals of AVInputFormat
This commit does for AVInputFormat what commit
59c9dc82f4 did for AVOutputFormat:
It adds a new type FFInputFormat, moves all the internals
of AVInputFormat to it and adds a now reduced AVInputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for demuxers (it is still a mess due to lavd).

This is possible since 50f34172e0
(which removed the last usage of an internal field of AVInputFormat
in fftools).

(Hint: tools/probetest.c accesses the internals of FFInputFormat
as well, but given that it is a testing tool this is not considered
a problem.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Paul Orlyk de8305e097
avformat/rtsp: Send mode=record instead of mode=receive in Transport header
Fixes server compatibility issues with rtspclientsink GStreamer plugin.

>From specification:
RFC 7826 "Real-Time Streaming Protocol Version 2.0" (https://datatracker.ietf.org/doc/html/rfc7826), section 18.54:
   mode: The mode parameter indicates the methods to be supported for
         this session.  The currently defined valid value is "PLAY".  If
         not provided, the default is "PLAY".  The "RECORD" value was
         defined in RFC 2326; in this specification, it is unspecified
         but reserved.  RECORD and other values may be specified in the
         future.
RFC 2326 "Real Time Streaming Protocol (RTSP)" (https://datatracker.ietf.org/doc/html/rfc2326), section 12.39:
   mode:
          The mode parameter indicates the methods to be supported for
          this session. Valid values are PLAY and RECORD. If not
          provided, the default is PLAY.

mode=receive was always like this, from the initial commit 'a8ad6ffa rtsp: Add listen mode'.

For comparison, Wowza was used to push RTSP stream to. Both GStreamer and FFmpeg had no issues.
Here is the capture of Wowza responding to SETUP request:
200 OK
CSeq: 3
Server: Wowza Streaming Engine 4.8.26+4 build20231212155517
Cache-Control: no-cache
Expires: Mon, 15 Jan 2024 19:40:31 GMT
Transport: RTP/AVP/UDP;unicast;client_port=11640-11641;mode=record;source=172.17.0.2;server_port=6976-6977
Date: Mon, 15 Jan 2024 19:40:31 GMT
Session: 1401457689;timeout=60

Test setup:
    Server: ffmpeg -loglevel trace -y -rtsp_flags listen -i rtsp://0.0.0.0:30800/live.stream t.mp4
    FFmpeg client: ffmpeg -re -i "Big Buck Bunny - FULL HD 30FPS.mp4" -c:v libx264 -f rtsp rtsp://127.0.0.1:30800/live.stream
    GStreamer client: gst-launch-1.0 videotestsrc is-live=true pattern=smpte ! queue ! videorate ! videoscale ! video/x-raw,width=640,height=360,framerate=60/1 ! timeoverlay font-desc="Sans, 84" halignment=center valignment=center ! queue ! videoconvert ! tee name=t t. ! x264enc bitrate=9000 pass=cbr speed-preset=ultrafast byte-stream=false key-int-max=15 threads=1 ! video/x-h264,profile=baseline ! queue ! rsink. audiotestsrc ! voaacenc ! queue ! rsink. t. ! queue ! autovideosink rtspclientsink name=rsink location=rtsp://localhost:30800/live.stream

Test results:
modified FFmpeg client -> stock server    : ok
stock FFmpeg client    -> modified server : ok
modified FFmpeg client -> modified server : ok
GStreamer client       -> modified server : ok

Signed-off-by: Paul Orlyk <paul.orlyk@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-01-16 01:34:58 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Martin Storsjö a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Martin Storsjö 4eb9232c6e libavformat: Split version.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:05:26 +02:00
Limin Wang d782c746a0 avformat/rtspdec: get rid of the hardcoded max size for sdp
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-04 08:26:30 +08:00
Andreas Rheinhardt 1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02: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
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
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 f3891430fc avformat/rtspdec: fix potential mem leak in listen mode
Currently a repeating setup request (with the same stream id) will
simply overwrite rtp_handle/transport_priv without freeing the
resources first. This is fixed by closing the previous setup request.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-28 12:27:53 -05:00
Andriy Gelman b0019b909b avformat/rtspdec: show method request in log
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-28 12:26:59 -05:00
Andriy Gelman 9a70b6f5b8 avformat/rtspdec: cosmetics
Make error check style consistent with rest of function.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-21 10:13:36 -05:00
Andriy Gelman 122fcf1f40 avformat/rtspdec: fix mem leaks in connect mode if init fails
Fixes #6334

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-21 10:13:28 -05:00
Andriy Gelman 38bc4ba142 avformat/rtspdec: fix mem leaks in listen mode if init fails
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-21 10:13:16 -05:00
Andriy Gelman 423d06e0e2 avformat/rtspdec: add network init to listen mode
As per the docs network initialization is required before ff_url_join().
Furthermore, because the ff_network_init() was skipped, this makes
one additional call to ff_network_close() if the stream exits without
errors.

The was forgotten in the origin commit of the listen mode:
a8ad6ffafe

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-11-21 10:11:38 -05:00
Limin Wang 89429cf2f2 avformat/rtspdec: return proper error code
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-11 18:32:56 +08:00
Limin Wang 9e2872bc67 avformat/rtspdec: use SDP_MAX_SIZE for sdp array
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-11-11 18:32:56 +08:00
Andriy Gelman b4103e0eb6 avformat/rtspdec: add newline in log message
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-10-08 23:18:18 -04:00
Limin Wang cb14c6ff8f avformat/rtspdec: av_dict_set() -> av_dict_set_int()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-06-02 22:25:11 +08: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
Marton Balint 18ac642359 avformat: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-28 23:06:43 +01:00
Derek Buitenhuis 5ca063799c rtspdec: Fix return error
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-07-10 15:02:29 -04:00
Clément Bœsch 03f5e80bdb Merge commit '67351924fa91dea4339109100a4c0689f006581f'
* commit '67351924fa91dea4339109100a4c0689f006581f':
  Drop unreachable break and return statements

Merged-by: Clément Bœsch <cboesch@gopro.com>
2017-03-30 10:26:29 +02:00
Diego Biurrun 67351924fa Drop unreachable break and return statements 2016-11-03 20:17:12 +01:00
Derek Buitenhuis f8e89d8a29 Merge commit 'fab8156b2f30666adabe227b3d7712fd193873b1'
* commit 'fab8156b2f30666adabe227b3d7712fd193873b1':
  avio: Copy URLContext generic options into child URLContexts

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-21 15:55:09 +01:00
Martin Storsjö fab8156b2f avio: Copy URLContext generic options into child URLContexts
Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.

This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).

Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-03-24 10:34:19 +02:00
Derek Buitenhuis 93629735d7 avformat: Add a protocol blacklisting API
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-03-04 16:13:42 +00:00
Anton Khirnov ec4c483976 lavf: add a protocol whitelist/blacklist for file opened internally
Should make the default behaviour safer for careless callers that open
random untrusted files.

Bug-Id: CVE-2016-1897
Bug-Id: CVE-2016-1898
2016-02-22 11:48:30 +01:00
Anton Khirnov 8c0ceafb0f urlprotocol: receive a list of protocols from the caller
This way, the decisions about which protocols are available for use in
any given situations can be delegated to the caller.
2016-02-22 11:45:31 +01:00
Michael Niedermayer fe3fed0b14 Update demuxers and protocols for protocol whitelist support
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 04:16:50 +01:00
Hendrik Leppkes f62fe535d5 Merge commit '2c17fb61ced2059034856a6c6cd303014aed01fe'
* commit '2c17fb61ced2059034856a6c6cd303014aed01fe':
  rtsp: Log getaddrinfo failures

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-29 16:13:24 +01:00
Luca Barbato 2c17fb61ce rtsp: Log getaddrinfo failures
And forward the logging contexts when needed.
2015-11-25 09:01:25 +01:00
wm4 4a006b9eb7 lavf: split tls.c
Move the OpenSSL and GnuTLS implementations to their own files. Other
than the connection code (including options) and some boilerplate, no
code is actually shared.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-27 21:48:47 +02:00
wm4 d8ffb2055f lavf: split tls.c
Move the OpenSSL and GnuTLS implementations to their own files. Other
than the connection code (including options) and some boilerplate, no
code is actually shared.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-05-26 21:48:32 +03:00
Michael Niedermayer 40d552dae6 Merge commit '1a3eb042c704dea190c644def5b32c9cee8832b8'
* commit '1a3eb042c704dea190c644def5b32c9cee8832b8':
  Replace av_dlog with normal av_log at trace level

Conflicts:
	ffplay.c
	libavdevice/fbdev_dec.c
	libavfilter/avfilter.c
	libavfilter/internal.h
	libavfilter/setpts.c
	libavfilter/src_movie.c
	libavfilter/vf_crop.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fieldorder.c
	libavformat/assdec.c
	libavformat/avidec.c
	libavformat/flvdec.c
	libavformat/http.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/mov.c
	libavformat/mpegenc.c
	libavformat/mpegts.c
	libavformat/mpegtsenc.c
	libavformat/mux.c
	libavformat/mxfdec.c
	libavformat/nsvdec.c
	libavformat/oggdec.c
	libavformat/r3d.c
	libavformat/rtspdec.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 03:19:47 +02:00
Vittorio Giovara 1a3eb042c7 Replace av_dlog with normal av_log at trace level
This applies to every library where performance is not critical.
2015-04-19 12:41:59 +01:00
Michael Niedermayer 53bf6b155c Merge commit 'e3ec6fe7bb2a622a863e3912181717a659eb1bad'
* commit 'e3ec6fe7bb2a622a863e3912181717a659eb1bad':
  rtsp: Add a buffer_size option

Conflicts:
	libavformat/rtsp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-01 21:34:20 +02:00
Luca Barbato e3ec6fe7bb rtsp: Add a buffer_size option
And forward it to rtp and udp.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-04-01 14:26:35 +02:00
Michael Niedermayer 83f18410bd Merge commit 'cdcc370293a159c321e41af7f0eef141c62d698d'
* commit 'cdcc370293a159c321e41af7f0eef141c62d698d':
  rtsp: punch holes again after pause

See: 22bb5bd7a3
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-23 21:43:18 +01:00
Gilles Chanteperdrix cdcc370293 rtsp: punch holes again after pause
When a client behind a NAT issues a pause command, and stay paused for a
long time, the router may stop the RTP/RTCP port redirection. Resend the
hole punching packets before each PLAY command to cause the router to
restart the port redirection in that case.

Move the existing code for sending the packets from the SETUP phase
to the PLAY phase.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-23 16:55:56 +02:00
Gilles Chanteperdrix 22bb5bd7a3 avformat/rtsp: punch holes again after pause
When a client behind a NAT issues a pause command, and stay paused for a
long time, the router may stop the RTP/RTCP port redirection. Resend the
hole punching packets after each PLAY command to cause the router to
restart the port redirection in that case.

Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-22 14:09:26 +01:00
Michael Niedermayer 0982077be5 Merge commit '9108967513fcaff3d55514a7bca4c9fbba128c71'
* commit '9108967513fcaff3d55514a7bca4c9fbba128c71':
  rtspdec: Consistently use rtsp_hd_out for writing

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-23 12:26:47 +01:00
Martin Storsjö 9108967513 rtspdec: Consistently use rtsp_hd_out for writing
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-23 10:33:00 +02:00
Michael Niedermayer 2c5ae57776 Merge commit '6df9d9b55d3f56ee7782639a7678eeeaf77f14ea'
* commit '6df9d9b55d3f56ee7782639a7678eeeaf77f14ea':
  lavf: Use av_gettime_relative

Conflicts:
	libavformat/hls.c

See: f78bc96b7c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-24 12:40:36 +02:00
Martin Storsjö 6df9d9b55d lavf: Use av_gettime_relative
The ones left using av_gettime are NTP timestamps (for RTCP,
which is specified to send the actual current realtime clock
in RTCP SR packets), and the NUT muxer timestamper, which is
documented as using wallclock time.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-24 09:53:45 +03:00
Andrey Utkin 282c9354f1 avformat/rtsp: Use ff_rtsp_averror()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-21 03:52:27 +02:00
Michael Niedermayer 76d1ffffd0 Merge commit '3df8d52fcdc9036b4074fdc612d487ece8bb5b7f'
* commit '3df8d52fcdc9036b4074fdc612d487ece8bb5b7f':
  rtsp: Add rtsps to the probe

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-10 21:36:27 +02:00