Commit Graph

392 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 57e20dd6b6 avformat/avio: Avoid function pointer casts
It is undefined behaviour to use a different type for a call
than the actual type of the function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01: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
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
Zhao Zhili bbdedd9663 Revert "avformat/rtmpproto: Pass rw_timeout to underlying transport protocol"
This reverts commit bec6dfcd5c.

The patch is NOP since ffurl_open_whitelist copy options from parent
automatically.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-11-25 10:56:00 +08:00
Zhao Zhili bec6dfcd5c avformat/rtmpproto: Pass rw_timeout to underlying transport protocol
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-11-22 21:02:04 +08:00
Steven Liu 637c761be1 avformat/rtmpproto: support enhanced rtmp
add option named rtmp_enhanced_codec,
it would support hvc1,av01,vp09 now,
the fourcc is using Array of strings.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2023-09-05 09:14:18 +08:00
Marton Balint 58454749a7 avformat/rtmpproto: send proper status for response to play command
This fixes referencing the uninitialized filename variable.

Fixes ticket #9711.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-04-22 22:06:04 +02: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
Andreas Rheinhardt e38eaf4749 avformat/utils: Make ff_data_to_hex() zero-terminate the string
Most callers want it that way anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 00:42:48 +01:00
Nick Ruff ea24781a9b lavf/rtmp: Add option to set TCP_NODELAY for rtmp
Suggested-By: ffmpeg@fb.com
2021-06-20 22:45:35 +02:00
Andreas Rheinhardt 5cad6c6e85 avformat/rtmpproto: Only include RTMP protocols that are enabled
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-02 23:53:29 +01: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
Limin Wang fa21df2bd4 avformat/rtmpproto: use av_reallocp_array()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-06 23:02:00 +08:00
Jun Zhao 70e292becf lavf/rtmpproto: Don't unref uninitialized buffers
This happens if ffurl_open_whitelist fails and stream is unset.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-12-07 14:09:12 +08:00
Jun Zhao 487e7e9670 lavf/rtmpproto: fix the playpath truncation if the len > 512
fix the playpath truncation if the len > 512

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Found-by: liuwenhuang <liuwenhuang@tencent.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-11-17 09:09:38 +08:00
Steven Liu 991cf95fde avformat/rtmpproto: fix memleak when open rtmp failed
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-28 14:26:14 +08:00
Steven Liu 35236fd729 avformat/rtmpptoto: add logging context to log
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-08 13:46:53 +08:00
Josh Allmann ee88f31d34 libavformat/rtmpproto: Plug leak if sending bytes read report fails.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-01-25 20:42:39 +01:00
James Almer 5f84ad3ecc Merge commit 'b864230c49089b087eef56988a3d6a784f6f9827'
* commit 'b864230c49089b087eef56988a3d6a784f6f9827':
  rtmp: Move RTMP digest calculation to a separate file

Merged-by: James Almer <jamrial@gmail.com>
2017-10-21 13:32:13 -03:00
James Almer 4ea63d2cdd Merge commit '15a92e0c402c830b607f905d6bf203b6cfb4fa8c'
* commit '15a92e0c402c830b607f905d6bf203b6cfb4fa8c':
  rtmp: Correctly handle the Window Acknowledgement Size packets

Merged-by: James Almer <jamrial@gmail.com>
2017-09-26 18:34:25 -03:00
James Almer f858a6e278 Merge commit 'a1a143adb0fd11c474221431417cff25db7d920f'
* commit 'a1a143adb0fd11c474221431417cff25db7d920f':
  rtmp: Rename packet types to closer match the spec

Merged-by: James Almer <jamrial@gmail.com>
2017-09-26 18:29:05 -03:00
Derek Buitenhuis c27d7c027c rtmpproto: Fix error return
Mistake was added in 5840473890.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-07-07 15:30:57 -04:00
Ricardo Constantino c0b3781bf2 rtmpproto: send swfverify value as swfurl if latter is unused
Replicates lavf/librtmp.c behavior in L149-156 and rtmpdump's
behavior with "--swfVfy <url>" passing the url to swfUrl.

Fixes trac ticket #5549.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-07 00:57:08 +02:00
Clément Bœsch 72dbfe42ef Merge commit 'f4ca8ea92a8b36fe723412aefafc1b2fa89f8dc6'
* commit 'f4ca8ea92a8b36fe723412aefafc1b2fa89f8dc6':
  rtmpproto: Restructure zlib code to avoid unreachable code warning

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-29 15:17:59 +02:00
Clément Bœsch 4e43c6df54 Merge commit 'c541a44e029e8a4f21db028c34fee3ad1c10a409'
* commit 'c541a44e029e8a4f21db028c34fee3ad1c10a409':
  Revert "rtmpproto: Don't include a client version in the unencrypted C1 handshake"

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-27 22:21:18 +02:00
Clément Bœsch 8892739a16 Merge commit '7d8d726be7dc46343ab1c98c339c1ed44bcb07c1'
* commit '7d8d726be7dc46343ab1c98c339c1ed44bcb07c1':
  rtmpproto: Don't include a client version in the unencrypted C1 handshake

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:37:58 +01:00
Clément Bœsch ddcd396075 Merge commit '9f23f77a532ca9c2b7dc4b5328bc413e4f6f5b56'
* commit '9f23f77a532ca9c2b7dc4b5328bc413e4f6f5b56':
  rtmpproto: Don't include the libavformat version as "clientid"

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:37:31 +01:00
Clément Bœsch d1c341f77b Merge commit '8b5e0d17e70400eaf5dc3845b5c1df8b2b88d830'
* commit '8b5e0d17e70400eaf5dc3845b5c1df8b2b88d830':
  rtmpproto: Send chunk size on the network channel

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:36:05 +01:00
Clément Bœsch a106b7e8b9 Merge commit 'd6ded94036e43a04889f4ff2813a7f7dd60b82fe'
* commit 'd6ded94036e43a04889f4ff2813a7f7dd60b82fe':
  rtmpproto: Lengthen the filename buffer when receiving streams

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:35:17 +01:00
Clément Bœsch 36fcbc0076 Merge commit '7395784ba72742b6daa62d35db4028e09f3fdf06'
* commit '7395784ba72742b6daa62d35db4028e09f3fdf06':
  rtmpproto: Check the return from ff_amf_read_string

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:34:19 +01:00
Steven Liu 8ddadf56f6 avformat/rtmpproto: change rtmp_open from url_open to url_open2
use the option set by user

Reported-by: Lancelot Lai <laihy23@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2017-03-22 18:06:14 +08:00
Diego Biurrun b864230c49 rtmp: Move RTMP digest calculation to a separate file
The rtmpcrypt protocol requires it.
2017-03-20 13:16:51 +01:00
Martin Storsjö 15a92e0c40 rtmp: Correctly handle the Window Acknowledgement Size packets
This swaps which field is set when the Window Acknowledgement Size
and Set Peer BW packets are received, renames the fields in
order to clarify their role further and adds verbose comments
explaining their respective roles and how well the code currently
does what it is supposed to.

The Set Peer BW packet tells the receiver of the packet (which
can be either client or server) that it should not send more data
if it already has sent more data than the specified number of bytes,
without receiving acknowledgement for them. Actually checking this
limit is currently not implemented.

In order to be able to check that properly, one can send the
Window Acknowledgement Size packet, which tells the receiver of the
packet that it needs to send Acknowledgement packets
(RTMP_PT_BYTES_READ) at least after receiving a given number of bytes
since the last Acknowledgement.

Therefore, when we receive a Window Acknowledgement Size packet,
this sets the maximum number of bytes we can receive without sending
an Acknowledgement; therefore when handling this packet we should set
the receive_report_size field (previously client_report_size).

Signed-off-by: Martin Storsjö <martin@martin.st>
2017-02-03 09:27:41 +02:00
Martin Storsjö a1a143adb0 rtmp: Rename packet types to closer match the spec
Also rename comments and log messages accordingly,
and add clarifying comments for some hardcoded values.

The previous names were taken from older, reverse engineered
references.

These names match the official public rtmp specification, and
matches the names used by wirecast in annotating captured
streams. These names also avoid hardcoding the roles of server
and client, since the handling of them is irrelevant of whether
we act as server or client.

The RTMP_PT_PING type maps to RTMP_PT_USER_CONTROL.

The SERVER_BW and CLIENT_BW types are a bit more intertwined;
RTMP_PT_SERVER_BW maps to RTMP_PT_WINDOW_ACK_SIZE and
RTMP_PT_CLIENT_BW maps to RTMP_PT_SET_PEER_BW.

Signed-off-by: Martin Storsjö <martin@martin.st>
2017-02-03 09:26:46 +02:00
Luca Barbato 11e225db31 rtmp: Account for bytes_read wraparound
Servers seem to be happy to receive the wrapped-around value as long
as they receive a report, otherwise they timeout.

Initially reported and analyzed by Thomas Bernhard.
2017-01-29 18:10:44 +01:00
Carl Eugen Hoyos 75bd4ea024 lavf/rtmpproto: Make bytes_read variables 64bit.
When bytes_read overflowed, last_bytes_read did not yet overflow
and no bytes-read report was created leading to a timeout.

Analyzed-by: Thomas Bernhard

Fixes ticket #5836.
2017-01-25 00:39:13 +01:00
Diego Biurrun f4ca8ea92a rtmpproto: Restructure zlib code to avoid unreachable code warning
libavformat\rtmpproto.c(1165) : warning C4702: unreachable code
2016-11-02 10:33:39 +01:00
Luca Barbato c541a44e02 Revert "rtmpproto: Don't include a client version in the unencrypted C1 handshake"
This reverts commit 7d8d726be7.
2016-10-30 21:55:03 +01:00
Hiroyuki OYAMA 47f74df29c avformat/rtmpproto: Fix RTMP control message handling error in listen mode.
Fix problem to fail by a RTMP Control Message except "Set Chunk Size (1)" after an RTMP handshake. When 'nginx-rtmp-module' relays an RTMP, it sends not only control message 'Set Chunk Size (1)' but also 'Window Acknowledgement Size (5)'.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-21 16:16:32 +02:00
Martin Storsjö 7d8d726be7 rtmpproto: Don't include a client version in the unencrypted C1 handshake
According to the public RTMP specification, these 4 bytes should
be zero.

librtmp in server mode assumes that the RTMPE (FP9) handshake is
used if these bytes are nonzero.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-10-14 23:11:19 +03:00
Martin Storsjö 9f23f77a53 rtmpproto: Don't include the libavformat version as "clientid"
When acting as server, the server can include a "clientid" property
in some status messages. But this should be a unique number
identifying the client session, not identifying the server itself.
In practice, omitting it works just as well as including this
incorrect field.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-10-14 23:11:17 +03:00
Martin Storsjö 8b5e0d17e7 rtmpproto: Send chunk size on the network channel
This makes sure that e.g. Adobe FME actually reacts to it. As long
as the value we've been sending is the default one (128), the bug
hasn't been noticed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-10-14 23:11:15 +03:00
Martin Storsjö d6ded94036 rtmpproto: Lengthen the filename buffer when receiving streams
Some applications such as Adobe FME append lots of parameters
here, making it easily overflow the current limit.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-10-14 23:11:12 +03:00
Martin Storsjö 7395784ba7 rtmpproto: Check the return from ff_amf_read_string
If this failed, we used to continue with an uninitialized
filename buffer.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-10-14 23:11:08 +03:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02: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