aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtmpproto.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/rtmpproto: fix rmtp packet leak in gen_connect()Lidong Yan2025-06-161-0/+2
| | | | | | | | | | | In libavformat/rtmpproto.c:gen_connect(), if check on string length or check on codec fourcc failed, ff_rtmp_packet_create() allocated data in pkt would leak. Add ff_rtmp_packet_destory before return error code. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Reviewed-by: Zhao Zhili <quinkblack@foxmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* rtmp: Set correct message stream id when writing as serverJonathan Murray2025-02-261-1/+6
| | | | | | | | | | | | | rtmp_write is used both for writing outputs as a server. The rt->listen flag determines which mode we're running in. Previously, when running as a server, the message stream id would always be set to 0 for media/metadata messages. This is surprising given that we have both responded to "createStream()" with a value of 1 and sent a "Stream Begin 1" to the client. Furthermore, some client libraries (Red5) seem to trip up on receiving "@setDataFrame" on stream 0 (and may be correct to assume that this message would be sent on stream 1).
* rtmpproto: Avoid rare crashes in the fail: codepath in rtmp_openMartin Storsjö2025-01-281-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running the cleanup in rtmp_close on failures in rtmp_open, we can in rare cases end up using rt->playpath, assuming that it is still set. The crash could happen if we hit the fail codepath in rtmp_open while publishing (rt->is_input == 0) with rt->state set to a value > STATE_FCPUBLISH. This would normally not happen while publishing; either we have an error (and rt->state <= STATE_FCPUBLISH) or we reach rt->state = STATE_PUBLISHING, and then we also return successfully from rtmp_open. The unexpected combination of states could happen if the server responds with e.g. "NetStream.Play.Stop" while expecting "NetStream.Publish.Start"; this sets rt->state to STATE_STOPPED, which also fulfills the condition "> STATE_FCPUBLISH". We don't need to free the rt->playpath/tcurl/flashver strings here; they're handled via AVOption, and thus are freed automatically when the protocol instance is freed (that's why they aren't freed manually within the rtmp_close function either). We also don't need to free the AVDictionary with options; it's owned by the caller. A smaller fix would be to just call rtmp_close before freeing the strings and dictionary, but as we don't need to free them at all, let's remove that redundant code. Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/rtmpproto: reserve enough space for statusmsgTimo Rothenpieler2024-12-271-1/+1
|
* avformat/rtmpproto: add more enhanced rtmp codecsTimo Rothenpieler2024-12-271-1/+8
|
* avformat/rtmpproto: Use AV_DICT_MATCH_CASE instead of litteral numberMichael Niedermayer2024-07-121-1/+1
| | | | | | | Found by reviewing: CID1530166 Free of array-typed value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-0/+1
| | | | | | | | | | | 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>
* avformat/avio: Avoid function pointer castsAndreas Rheinhardt2024-03-051-2/+4
| | | | | | | 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>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "avformat/rtmpproto: Pass rw_timeout to underlying transport protocol"Zhao Zhili2023-11-251-3/+0
| | | | | | | | | This reverts commit bec6dfcd5c0b59dd6d947ec3074986aeffd525aa. The patch is NOP since ffurl_open_whitelist copy options from parent automatically. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/rtmpproto: Pass rw_timeout to underlying transport protocolZhao Zhili2023-11-221-0/+3
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/rtmpproto: support enhanced rtmpSteven Liu2023-09-051-0/+34
| | | | | | | | 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>
* avformat/rtmpproto: send proper status for response to play commandMarton Balint2022-04-221-9/+10
| | | | | | | | This fixes referencing the uninitialized filename variable. Fixes ticket #9711. Signed-off-by: Marton Balint <cus@passwd.hu>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-161-0/+2
| | | | | | | | 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>
* libavformat: Split version.hMartin Storsjö2022-03-161-0/+1
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/utils: Make ff_data_to_hex() zero-terminate the stringAndreas Rheinhardt2021-12-081-2/+0
| | | | | | Most callers want it that way anyway. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf/rtmp: Add option to set TCP_NODELAY for rtmpNick Ruff2021-06-201-3/+5
| | | | Suggested-By: ffmpeg@fb.com
* avformat/rtmpproto: Only include RTMP protocols that are enabledAndreas Rheinhardt2021-02-021-9/+15
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat: Replace ffurl_close() by ffurl_closep() where appropriateAndreas Rheinhardt2020-05-251-3/+2
| | | | | | | | | | 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>
* avformat/rtmpproto: use av_reallocp_array()Limin Wang2020-05-061-1/+1
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* lavf/rtmpproto: Don't unref uninitialized buffersJun Zhao2019-12-071-1/+1
| | | | | | This happens if ffurl_open_whitelist fails and stream is unset. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/rtmpproto: fix the playpath truncation if the len > 512Jun Zhao2019-11-171-3/+5
| | | | | | | | 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>
* avformat/rtmpproto: fix memleak when open rtmp failedSteven Liu2019-10-281-0/+3
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/rtmpptoto: add logging context to logSteven Liu2019-10-081-1/+1
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* libavformat/rtmpproto: Plug leak if sending bytes read report fails.Josh Allmann2018-01-251-1/+3
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit 'b864230c49089b087eef56988a3d6a784f6f9827'James Almer2017-10-211-36/+0
|\ | | | | | | | | | | | | * commit 'b864230c49089b087eef56988a3d6a784f6f9827': rtmp: Move RTMP digest calculation to a separate file Merged-by: James Almer <jamrial@gmail.com>
| * rtmp: Move RTMP digest calculation to a separate fileDiego Biurrun2017-03-201-36/+0
| | | | | | | | The rtmpcrypt protocol requires it.
* | Merge commit '15a92e0c402c830b607f905d6bf203b6cfb4fa8c'James Almer2017-09-261-18/+29
|\| | | | | | | | | | | | | * commit '15a92e0c402c830b607f905d6bf203b6cfb4fa8c': rtmp: Correctly handle the Window Acknowledgement Size packets Merged-by: James Almer <jamrial@gmail.com>
| * rtmp: Correctly handle the Window Acknowledgement Size packetsMartin Storsjö2017-02-031-18/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge commit 'a1a143adb0fd11c474221431417cff25db7d920f'James Almer2017-09-261-39/+39
|\| | | | | | | | | | | | | * commit 'a1a143adb0fd11c474221431417cff25db7d920f': rtmp: Rename packet types to closer match the spec Merged-by: James Almer <jamrial@gmail.com>
| * rtmp: Rename packet types to closer match the specMartin Storsjö2017-02-031-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * rtmp: Account for bytes_read wraparoundLuca Barbato2017-01-291-1/+1
| | | | | | | | | | | | | | 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.
* | rtmpproto: Fix error returnDerek Buitenhuis2017-07-071-1/+1
| | | | | | | | | | | | Mistake was added in 5840473890440dbe0bd2cce530ebb3d93e187ae6. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* | rtmpproto: send swfverify value as swfurl if latter is unusedRicardo Constantino2017-05-071-2/+5
| | | | | | | | | | | | | | | | | | 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>
* | Merge commit 'f4ca8ea92a8b36fe723412aefafc1b2fa89f8dc6'Clément Bœsch2017-03-291-4/+5
|\| | | | | | | | | | | | | * commit 'f4ca8ea92a8b36fe723412aefafc1b2fa89f8dc6': rtmpproto: Restructure zlib code to avoid unreachable code warning Merged-by: Clément Bœsch <u@pkh.me>
| * rtmpproto: Restructure zlib code to avoid unreachable code warningDiego Biurrun2016-11-021-4/+5
| | | | | | | | libavformat\rtmpproto.c(1165) : warning C4702: unreachable code
* | Merge commit 'c541a44e029e8a4f21db028c34fee3ad1c10a409'Clément Bœsch2017-03-271-1/+4
|\| | | | | | | | | | | | | * commit 'c541a44e029e8a4f21db028c34fee3ad1c10a409': Revert "rtmpproto: Don't include a client version in the unencrypted C1 handshake" Merged-by: Clément Bœsch <u@pkh.me>
| * Revert "rtmpproto: Don't include a client version in the unencrypted C1 ↵Luca Barbato2016-10-301-1/+4
| | | | | | | | | | | | handshake" This reverts commit 7d8d726be7dc46343ab1c98c339c1ed44bcb07c1.
* | Merge commit '7d8d726be7dc46343ab1c98c339c1ed44bcb07c1'Clément Bœsch2017-03-231-4/+1
|\| | | | | | | | | | | | | * commit '7d8d726be7dc46343ab1c98c339c1ed44bcb07c1': rtmpproto: Don't include a client version in the unencrypted C1 handshake Merged-by: Clément Bœsch <u@pkh.me>
| * rtmpproto: Don't include a client version in the unencrypted C1 handshakeMartin Storsjö2016-10-141-4/+1
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge commit '9f23f77a532ca9c2b7dc4b5328bc413e4f6f5b56'Clément Bœsch2017-03-231-3/+0
|\| | | | | | | | | | | | | * commit '9f23f77a532ca9c2b7dc4b5328bc413e4f6f5b56': rtmpproto: Don't include the libavformat version as "clientid" Merged-by: Clément Bœsch <u@pkh.me>
| * rtmpproto: Don't include the libavformat version as "clientid"Martin Storsjö2016-10-141-3/+0
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge commit '8b5e0d17e70400eaf5dc3845b5c1df8b2b88d830'Clément Bœsch2017-03-231-1/+1
|\| | | | | | | | | | | | | * commit '8b5e0d17e70400eaf5dc3845b5c1df8b2b88d830': rtmpproto: Send chunk size on the network channel Merged-by: Clément Bœsch <u@pkh.me>
| * rtmpproto: Send chunk size on the network channelMartin Storsjö2016-10-141-1/+1
| | | | | | | | | | | | | | | | 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>
* | Merge commit 'd6ded94036e43a04889f4ff2813a7f7dd60b82fe'Clément Bœsch2017-03-231-1/+1
|\| | | | | | | | | | | | | * commit 'd6ded94036e43a04889f4ff2813a7f7dd60b82fe': rtmpproto: Lengthen the filename buffer when receiving streams Merged-by: Clément Bœsch <u@pkh.me>
| * rtmpproto: Lengthen the filename buffer when receiving streamsMartin Storsjö2016-10-141-1/+1
| | | | | | | | | | | | | | 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>
* | Merge commit '7395784ba72742b6daa62d35db4028e09f3fdf06'Clément Bœsch2017-03-231-0/+7
|\| | | | | | | | | | | | | * commit '7395784ba72742b6daa62d35db4028e09f3fdf06': rtmpproto: Check the return from ff_amf_read_string Merged-by: Clément Bœsch <u@pkh.me>
| * rtmpproto: Check the return from ff_amf_read_stringMartin Storsjö2016-10-141-0/+7
| | | | | | | | | | | | | | | | 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>