Commit Graph

323 Commits

Author SHA1 Message Date
Michael Niedermayer 03b84f2fb2 avformat/rtmpproto: Use av_freep() to avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-22 12:03:36 +01:00
Michael Niedermayer 27897d2ef6 Merge commit '491805636cef50d3f582bd345e1460eeb739ea48'
* commit '491805636cef50d3f582bd345e1460eeb739ea48':
  rtmpproto: Fix a typo in a comment

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-28 22:01:45 +01:00
Martin Storsjö 491805636c rtmpproto: Fix a typo in a comment
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-28 20:56:45 +02:00
Michael Niedermayer 21ff626ce0 Merge commit '01eac895ab350027467ffbe7278740f89ae8be75'
* commit '01eac895ab350027467ffbe7278740f89ae8be75':
  rtmpproto: Only prepend @setDataFrame for onMetaData and |RtmpSampleAccess

Conflicts:
	libavformat/rtmpproto.c

See: 60fd790f38
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-28 12:31:59 +01:00
Michael Niedermayer 42a095d095 Merge commit '3c3b8003a13d9c3668c0bb6d79d2376da3b2b352'
* commit '3c3b8003a13d9c3668c0bb6d79d2376da3b2b352':
  rtmpproto: Simplify code for copying data into the output packet

Conflicts:
	libavformat/rtmpproto.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-28 11:57:33 +01:00
Michael Niedermayer a105c1f204 Merge commit '857e6667f9061ae261c0b951113e4efc4329b05e'
* commit '857e6667f9061ae261c0b951113e4efc4329b05e':
  rtmpproto: Clarify a comment

Conflicts:
	libavformat/rtmpproto.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-28 11:35:08 +01:00
Martin Storsjö 01eac895ab rtmpproto: Only prepend @setDataFrame for onMetaData and |RtmpSampleAccess
Currently, when streaming to an RTMP server, any time a packet of type
RTMP_PT_NOTIFY is encountered, the packet is prepended with @setDataFrame
before it gets sent to the server. This is incorrect; only packets for
onMetaData and |RtmpSampleAccess should invoke @setDataFrame on the RTMP
server. Specifically, the current bug manifests itself when trying to
stream onTextData or onCuePoint invocations.

This fix addresses that problem and ensures that the @setDataFrame is
only prepended for onMetaData and |RtmpSampleAccess.

Since data is fed to the rtmp_write function in smaller pieces (depending
on the calling IO buffer size), we can't generally assume that the
whole packet (or even the whole command string) is available at once,
therefore we can only check the command string once the full packet
has been transferred to us for sending.

Based on a patch by Jeffrey Wescott.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-28 09:59:29 +02:00
Martin Storsjö 3c3b8003a1 rtmpproto: Simplify code for copying data into the output packet
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-28 09:59:27 +02:00
Martin Storsjö 857e6667f9 rtmpproto: Clarify a comment
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-28 09:59:25 +02:00
Jeffrey Wescott 60fd790f38 avformat/rtmpproto: only prepend @setMetaData for onMetaData and |RtmpSampleAccess
In current versions of ffmpeg, when streaming to an RTMP server, anytime a packet of type
RTMP_PT_NOTIFY is encountered, the packet is prepended with @setDataFrame before it gets sent
to the server. This is incorrect; only packets for onMetaData and |RtmpSampleAccess should
invoke @setDataFrame on the RTMP server. Specifically, the current bug manifests
itself when trying to stream onTextData or onCuePoint invocations.

This fix addresses that problem and ensures that the @setDataFrame is only prepended
for onMetaData and |RtmpSampleAccess.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-24 00:15:48 +01:00
Michael Niedermayer 513d57cc4d Merge commit 'a490391157dcf4dc6b65352ec3eea2781dd0a404'
* commit 'a490391157dcf4dc6b65352ec3eea2781dd0a404':
  rtmpproto: Ignore errors from the getStreamLength method

Conflicts:
	libavformat/rtmpproto.c

See: 09711545f5
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-05 10:17:07 +01:00
Martin Storsjö a490391157 rtmpproto: Ignore errors from the getStreamLength method
It is never an error if this method failed. If rt->live was
explicitly set to 0 (known to be a recorded file), print it
as a warning, otherwise print it as a debug message.

Based on a patch by Michael Niedermayer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-05 09:18:22 +02:00
Michael Niedermayer 09711545f5 avformat/rtmpproto: Do not fail when the length cannot be determined for live streams
Fixes Ticket4071

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-04 00:35:32 +01:00
Vittorio Giovara 322b571d55 rtmpproto: remove dead code
Expression already evaluated before, redundant since
0533868642.

Bug-Id: CID 732199
2014-10-20 10:44:22 +01:00
Kacper Michajłow f22cf88fd3 rtmpproto: Don't mistake app for playpath.
For URLs "rtmp://server[:port]/foo" determine what `foo` refers to. If
application name has been defined by the user assume that `foo` is a
playpath, otherwise assume application name.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-19 18:52:30 +02:00
Michael Niedermayer 52bf4ad674 Merge commit '0034314a69e76a53534a74cceef865cfcb7b42cc'
* commit '0034314a69e76a53534a74cceef865cfcb7b42cc':
  rtmp: Always call rtmp_close() on rtmp_open() failure

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-18 23:48:21 +02:00
Alexander Drozdov 0034314a69 rtmp: Always call rtmp_close() on rtmp_open() failure
Prevent possible memory leaks.

Connect to nginx and request a non-existent resource to
trigger the issue.

CC: libav-stable@libav.org

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Uwe L. Korn <uwelk@xhochy.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-10-18 17:37:11 +02:00
Michael Niedermayer 7891b4fa59 Merge commit '9bec3ca2b878c83d2337bc6095bd51c3e3f8eef0'
* commit '9bec3ca2b878c83d2337bc6095bd51c3e3f8eef0':
  rtmpproto: Add pause support

Conflicts:
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-18 03:12:10 +02:00
Michael Niedermayer 178764e833 Merge commit 'f4cd8b80b9cb2a9a4112d8abb1d3b93cd3b4e467'
* commit 'f4cd8b80b9cb2a9a4112d8abb1d3b93cd3b4e467':
  rtmpproto: Track last received timestamp

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-18 03:01:35 +02:00
Uwe L. Korn 9bec3ca2b8 rtmpproto: Add pause support
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-17 23:13:51 +03:00
Uwe L. Korn f4cd8b80b9 rtmpproto: Track last received timestamp
Some RTMP commands need the most recent timestamp as their parameter, so
keep track of it. This must be the most recent one and not e.g. the max
received timestamp as it can decrease again through seeking.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-17 23:13:37 +03:00
Michael Niedermayer 3dda0bbe42 Merge commit 'e65c776d18dc14df8a279e017760862f9fc8763b'
* commit 'e65c776d18dc14df8a279e017760862f9fc8763b':
  rtmpproto: Add getStreamLength call to query duration

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 15:34:27 +02:00
Michael Niedermayer 6cf9d02cea Merge commit '324b23dde1bc8638959eb32419c95a93906db272'
* commit '324b23dde1bc8638959eb32419c95a93906db272':
  rtmpproto: Add function to read a number response

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 15:21:40 +02:00
Uwe L. Korn e65c776d18 rtmpproto: Add getStreamLength call to query duration
In (non-live) streams with no metadata, the duration of a stream can
be retrieved by calling the RTMP function getStreamLength with the
playpath. The server will return a positive duration upon the request if
the duration is known, otherwise either no response or a duration of 0
will be returned.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-17 12:07:19 +03:00
Uwe L. Korn 324b23dde1 rtmpproto: Add function to read a number response
Packets that contain a number as a result to a rtmp function call are
structured the same way (String, Number, Null, Number). This new method
also includes more bounds checks to better handle packets that are not
structured as expected.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-17 12:07:19 +03:00
Michael Niedermayer 917f86f479 Merge commit '79dd756e143a54efc25d64e90505f0dca6cbc4ec'
* commit '79dd756e143a54efc25d64e90505f0dca6cbc4ec':
  rtmpproto: Fix a typo

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-16 00:02:54 +02:00
Martin Storsjö 79dd756e14 rtmpproto: Fix a typo
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-15 21:00:39 +03:00
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