Commit Graph

296 Commits

Author SHA1 Message Date
Alexander Drozdov
08ccc474b7 RTMP: fix FD leak in rtmp_open()
If we setup AVIO interrupt callback and it will be returns 1 on socket
timeouts and we try to connect to non-existing streams on some servers
(like nginx-rtmp) we got FD leak.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-30 11:26:25 +02:00
Michael Niedermayer
60dbed6067 Merge commit '4b1f5e5090abed6c618c8ba380cd7d28d140f867'
* commit '4b1f5e5090abed6c618c8ba380cd7d28d140f867':
  cosmetics: Write NULL pointer inequality checks more compactly

Conflicts:
	libavcodec/dvdsubdec.c
	libavcodec/h263dec.c
	libavcodec/libxvid.c
	libavcodec/rv10.c
	libavcodec/utils.c
	libavformat/format.c
	libavformat/matroskadec.c
	libavformat/segment.c
	libavutil/opt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-15 21:26:12 +02:00
Gabriel Dume
4b1f5e5090 cosmetics: Write NULL pointer inequality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 05:34:13 -07:00
Michael Niedermayer
e91f27cbbb Merge commit '59cb5747ec3c5cd842b94e574c37889521c97cc4'
* commit '59cb5747ec3c5cd842b94e574c37889521c97cc4':
  rtmpproto: read metadata to set correct FLV header

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-02 00:32:30 +02:00
Uwe L. Korn
59cb5747ec rtmpproto: read metadata to set correct FLV header
In the presence of no metadata, do not set any stream flag in the FLV
header but let the demuxer handle the detection and creation of streams
as data arrives.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-06-01 23:30:48 +03:00
Reynaldo H. Verdejo Pinochet
93cade4825 rtmpproto: info out for unsupported auth vars
Should aid debugging badly formatted URLs

Signed-off-by: Reynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>
2014-05-16 17:31:48 -04:00
Reynaldo H. Verdejo Pinochet
e83aae2839 rtmpproto: avoid setting auth var value if null
Use default values if parsed variable is found not to
have any value. Avoids crashing at strlen for salt/user
on the auth call afterwards and needless NULL assignments
for the rest (default is already NULL for those).

Should fix Coverity Scan issues #966644 and #966645

Signed-off-by: Reynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>
2014-05-16 17:31:48 -04:00
Michael Niedermayer
996fffbbb3 Merge commit '0bacfa8d37710b904897e7cbeb8d6f96fbf75e2e'
* commit '0bacfa8d37710b904897e7cbeb8d6f96fbf75e2e':
  rtmpproto: Check the buffer sizes when copying app/playpath strings

Conflicts:
	libavformat/rtmpproto.c

See: 0c2a6dabce
See: 02ac3398eb
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-08 22:44:58 +02:00
Michael Niedermayer
0c2a6dabce avformat/rtmpproto: add FFMIN() to av_strlcpy()
Suggested-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-08 18:19:38 +02:00
Martin Storsjö
0bacfa8d37 rtmpproto: Check the buffer sizes when copying app/playpath strings
As pointed out by Reimar Döffinger.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-05-08 19:02:43 +03:00
Michael Niedermayer
d68ed9f257 Merge commit '7ce3bd9614717e545af8fb8455032c807e389b78'
* commit '7ce3bd9614717e545af8fb8455032c807e389b78':
  rtmpproto: Support alternative slist parameter in rtmp URLs

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-07 00:39:54 +02:00
Uwe L. Korn
7ce3bd9614 rtmpproto: Support alternative slist parameter in rtmp URLs
Support the URL scheme where the playpath is in an RTMP URL is
passed as the slist argument and the app is given infront of the
query part of the URL:

rtmp://host[:port]/[app]?slist=[playpath]

(other arguments in the query part are stripped as they are not used)

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-05-06 23:41:56 +03:00
Stephan Soller
36b9c27dae avformat/rtmpproto: Added handling of an initial RTMP chunk size packet.
Fixes ticket #2911.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-14 14:28:22 +02:00
Michael Niedermayer
8e5f840472 Merge commit '6477139721f559b26eafd415e23e13ea2b0c27e1'
* commit '6477139721f559b26eafd415e23e13ea2b0c27e1':
  rtmpproto: Make sure to pass on the error code if read_connect failed

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-14 14:12:47 +02:00
Stephan Soller
4d40e073dc rtmpproto: Handle RTMP chunk size packets before the connect packet
In all other cases where ff_rtmp_packet_read is used, the packet returned
is passed to rtmp_parse_result more or less immediately. In this single
case, the content of the packet was required to be a connect packet.

Some clients, e.g. Open Broadcaster Software, send a chunk size packet
before the connect packet. If the first packet is a chunk size packet,
handle it and read another one, requiring this to be a connect packet
instead.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-04-14 11:09:26 +03:00
Martin Storsjö
6477139721 rtmpproto: Make sure to pass on the error code if read_connect failed
Previously, if read_connect failed, the ret variable was unmodified
and had the value 0, indicating success, which then was returned from
the rtmp_open function, even though it actually failed.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-04-14 11:09:20 +03:00
Michael Niedermayer
ca9d7c57f4 Merge commit '24eb3c791606fe98a1591c13a8b2ba6c342bb3b5'
* commit '24eb3c791606fe98a1591c13a8b2ba6c342bb3b5':
  rtmpproto: Avoid using uninitialized memory

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-21 04:13:57 +01:00
Martin Storsjö
24eb3c7916 rtmpproto: Avoid using uninitialized memory
If the url ends with .flv, we stripped it but didn't initialize
rt->playpath, doing av_strlcat on an uninitialized buffer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-01-20 21:56:57 +02:00
Vittorio Giovara
d763978583 rtmpproto: Reorder conditions to help dead code elimination
This makes sure that these branches are eliminated properly
with clang with optimizations disabled.
2013-11-03 11:51:41 +01:00
Michael Niedermayer
953dd72321 Merge commit '84a125c4c28f3e3e215d2e6c32f7f0ec43bbc04c'
* commit '84a125c4c28f3e3e215d2e6c32f7f0ec43bbc04c':
  rtmp: Allocate the prev_pkt arrays dynamically

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-14 15:31:11 +02:00
Martin Storsjö
84a125c4c2 rtmp: Allocate the prev_pkt arrays dynamically
Normally, all channel ids are between 0 and 10, while they in
uncommon cases can have values up to 64k.

This avoids allocating two arrays for up to 64k entries (at a total
of over 6 MB in size) each when most of them aren't used at all.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-14 14:27:35 +03:00
Michael Niedermayer
74b2b0ed9f Merge commit 'cd818b3a5709b9b08bd5901cb8863a8b61be265e'
* commit 'cd818b3a5709b9b08bd5901cb8863a8b61be265e':
  rtmpproto: Validate the embedded flv packet size before copying

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 14:30:05 +02:00
Michael Niedermayer
5bb3ef3b36 Merge commit '8921e32f730c191543b84e61338bc9d549aa05a3'
* commit '8921e32f730c191543b84e61338bc9d549aa05a3':
  rtmpproto: Readjust the end of the flv buffer if handle_metadata exited early

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 14:25:03 +02:00
Michael Niedermayer
b8e44118b1 Merge commit '24fee95321c1463360ba7042d026dae021854360'
* commit '24fee95321c1463360ba7042d026dae021854360':
  rtmpproto: Move the flv header/trailer addition to append_flv_data

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 14:18:32 +02:00
Michael Niedermayer
205b602135 Merge commit '72540e514ceaaed8ecb97ed63637b2a2a4447ab8'
* commit '72540e514ceaaed8ecb97ed63637b2a2a4447ab8':
  rtmpproto: Clear the flv allocation size on reallocp failures

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 14:17:53 +02:00
Michael Niedermayer
d32eec3359 Merge commit '4d6d70292e91a7ef027824d731b6b6570ceabf2f'
* commit '4d6d70292e91a7ef027824d731b6b6570ceabf2f':
  rtmpproto: Pass the 'live' parameter in the right unit

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 13:53:17 +02:00
Michael Niedermayer
373d15525d Merge commit 'a6b361325f2bfc8d9d4e5f761d6c1a07b209c4fb'
* commit 'a6b361325f2bfc8d9d4e5f761d6c1a07b209c4fb':
  rtmpproto: Print the error code string if there's no description

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-04 13:47:06 +02:00
Martin Storsjö
cd818b3a57 rtmpproto: Validate the embedded flv packet size before copying
This wasn't an issue prior to 58404738, when the whole RTMP packet
was copied at once and the length of the individual embedded flv
packets only were validated by the flv demuxer.

Prior to this patch, this could lead to reads and writes out of bound.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-04 09:25:10 +03:00
Martin Storsjö
8921e32f73 rtmpproto: Readjust the end of the flv buffer if handle_metadata exited early
If the embedded flv packets were incomplete and we aborted the
copying loop early, make sure the flv buffer is trimmed to
only contain full packets.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-04 09:25:08 +03:00
Martin Storsjö
24fee95321 rtmpproto: Move the flv header/trailer addition to append_flv_data
update_offset is also called from handle_metadata, where the
packet header sizes is already included in the size.

Previously this lead to flv_data/flv_size including 15 uninitialized
bytes at the end after each call to handle_metadata, making the
flv demuxer lose sync with the stream.

Also remove leftover copying in handle_metadata. This is a leftover
from the refactoring in 5840473. (Previously this final mempcy was
the one that copied all the packets at once, while this is done
within the loop right now.) After making sure flv_size is set to
the right size, this write was out of bounds.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-04 09:25:07 +03:00
Martin Storsjö
72540e514c rtmpproto: Clear the flv allocation size on reallocp failures
This was overlooked in d872fb0f7 since I assumed all the realloc
issues in the rtmp code was fixed already.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-04 09:25:06 +03:00
Martin Storsjö
4d6d70292e rtmpproto: Pass the 'live' parameter in the right unit
The current magic numbers passed are values in seconds, while the
parameter itself should be passed over the wire in milliseconds.

This makes (some/all?) live streams from Red5 work correctly, that
previously returned StreamNotFound even with "-rtmp_live live". After
this commit, the default 'any' also works on these streams.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-04 09:25:05 +03:00
Martin Storsjö
a6b361325f rtmpproto: Print the error code string if there's no description
On (certain streams/setups at least on) Red5, the description string
actually is present, but empty. Therefore, first try loading the
description, but if not found or empty, load the code string instead.
The code string is quite understandable in most cases anyway (like
"NetStream.Play.StreamNotFound").

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-04 09:25:04 +03:00
Michael Niedermayer
5e253fdfc1 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  rtmp: alias rtmp_listen to listen

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-02 14:59:42 +02:00
Luca Barbato
628a17d78a rtmp: alias rtmp_listen to listen
Make it uniform with the other protocols.
2013-10-01 15:42:06 +02:00
Michael Niedermayer
72eddc10fa Merge commit 'd872fb0f7ff2ff0ba87f5ccf6a1a55ca2be472c9'
* commit 'd872fb0f7ff2ff0ba87f5ccf6a1a55ca2be472c9':
  lavf: Reset the entry count and allocation size variables on av_reallocp failures

Conflicts:
	libavformat/avienc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-27 12:13:41 +02:00
Martin Storsjö
d872fb0f7f lavf: Reset the entry count and allocation size variables on av_reallocp failures
When av_reallocp fails, the associated variables that keep track of
the number of elements in the array (and in some cases, the
separate number of allocated elements) need to be reset.

Not all of these might technically be needed, but it's better to
reset them if in doubt, to make sure variables don't end up
conflicting.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-26 23:14:03 +03:00
Michael Niedermayer
eaa20afa76 Merge commit 'ba77757a7efafe38924b6b423acfca8c1e1c62d6'
* commit 'ba77757a7efafe38924b6b423acfca8c1e1c62d6':
  rtmp: Replace a magic number with a macro

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-23 11:45:38 +02:00
Michael Niedermayer
c70e647a15 Merge commit '5840473890440dbe0bd2cce530ebb3d93e187ae6'
* commit '5840473890440dbe0bd2cce530ebb3d93e187ae6':
  rtmp: Rewrite embedded flv handling

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-23 11:40:15 +02:00
Michael Niedermayer
eee8cb42d0 Merge commit 'e40a0e822801d2485e4e555909d7a82713fa86a5'
* commit 'e40a0e822801d2485e4e555909d7a82713fa86a5':
  rtmp: Refactor get_packet

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-23 11:36:06 +02:00
Luca Barbato
ba77757a7e rtmp: Replace a magic number with a macro
11 is the RTMP header size.
2013-09-22 01:09:33 +02:00
Luca Barbato
5840473890 rtmp: Rewrite embedded flv handling
Use update_offset() as done for rtmp audio, video and notifications and
read update and write the fields instead of replacing them in the rtmp
packet and then memcpying it to the output buffer.
2013-09-22 01:09:33 +02:00
Luca Barbato
e40a0e8228 rtmp: Refactor get_packet 2013-09-22 01:09:33 +02:00
Michael Niedermayer
dda7bd13b3 Merge commit '5532ee6d7d554bb54d4374d0b69f72bc9ab9fd91'
* commit '5532ee6d7d554bb54d4374d0b69f72bc9ab9fd91':
  rtmp: Unbreak get_packet

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-20 15:45:04 +02:00
Michael Niedermayer
391e272c16 Merge commit 'b97b1adb3f807e1acd00d56319ee6cb41cc727e4'
* commit 'b97b1adb3f807e1acd00d56319ee6cb41cc727e4':
  rtmpproto: Add a comment explaining the logic in handle_notify

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-20 15:30:51 +02:00
Luca Barbato
5532ee6d7d rtmp: Unbreak get_packet
Commit 5626f994f2 broke it.
2013-09-20 13:38:22 +02:00
Martin Storsjö
b97b1adb3f rtmpproto: Add a comment explaining the logic in handle_notify
This explains why the cleanup in 5626f994f was wrong and why
ae0f316a was needed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-20 10:47:15 +03:00
Luca Barbato
fbd54827b1 rtmp: Unbreak handle_notify
Commit 5626f994f2 broke it.
2013-09-19 11:27:21 +02:00
Michael Niedermayer
20dfab33f5 Merge commit '5626f994f273af80fb100d4743b963304de9e05c'
* commit '5626f994f273af80fb100d4743b963304de9e05c':
  avformat: Use av_reallocp() where suitable

Conflicts:
	libavformat/avidec.c
	libavformat/avienc.c
	libavformat/aviobuf.c
	libavformat/oggparsevorbis.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-19 11:01:26 +02:00
Luca Barbato
ae0f316a47 rtmp: Unbreak handle_notify
Commit 5626f994f2 broke it.
2013-09-19 09:13:04 +02:00