summaryrefslogtreecommitdiff
path: root/libavformat/rtmpproto.c
Commit message (Collapse)AuthorAge
* cosmetics: Fix spelling mistakesVittorio Giovara2016-05-04
| | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* avio: Copy URLContext generic options into child URLContextsMartin Storsjö2016-03-24
| | | | | | | | | | | | | | | 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>
* urlprotocol: receive a list of protocols from the callerAnton Khirnov2016-02-22
| | | | | This way, the decisions about which protocols are available for use in any given situations can be delegated to the caller.
* lavf: reorganize URLProtocolsAnton Khirnov2016-02-22
| | | | | | | | | | Instead of a linked list constructed at av_register_all(), store them in a constant array of pointers. Since no registration is necessary now, this removes some global state from lavf. This will also allow the urlprotocol layer caller to limit the available protocols in a simple and flexible way in the following commits.
* rtmpproto: Include the full path as app when "slist=" is foundMartin Storsjö2015-12-13
| | | | | | | This matches what librtmp does. This fixes automatic url parsing of crunchyroll urls. Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Write correct flv packet sizes at the end of packetsMichael Niedermayer2015-10-14
| | | | | | | In one case it was written as zero, one case left it uninitialized, missed the 11 bytes for the flv header. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* rtmpproto: free hmac context properlyJames Almer2015-07-30
| | | | | Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: use AVHMAC instead of a custom implementationJames Almer2015-07-29
| | | | | Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* Replace av_dlog with normal av_log at trace levelVittorio Giovara2015-04-19
| | | | This applies to every library where performance is not critical.
* rtmpproto: Fix a typo in a commentMartin Storsjö2014-11-28
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Only prepend @setDataFrame for onMetaData and |RtmpSampleAccessMartin Storsjö2014-11-28
| | | | | | | | | | | | | | | | | | | | | | 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>
* rtmpproto: Simplify code for copying data into the output packetMartin Storsjö2014-11-28
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Clarify a commentMartin Storsjö2014-11-28
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Ignore errors from the getStreamLength methodMartin Storsjö2014-11-05
| | | | | | | | | | 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>
* rtmpproto: remove dead codeVittorio Giovara2014-10-20
| | | | | | | Expression already evaluated before, redundant since 053386864219eccbcca1886c55f902f9555428a5. Bug-Id: CID 732199
* rtmp: Always call rtmp_close() on rtmp_open() failureAlexander Drozdov2014-10-18
| | | | | | | | | | | | | 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>
* rtmpproto: Add pause supportUwe L. Korn2014-10-17
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Track last received timestampUwe L. Korn2014-10-17
| | | | | | | | 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>
* rtmpproto: Add getStreamLength call to query durationUwe L. Korn2014-10-17
| | | | | | | | | | 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>
* rtmpproto: Add function to read a number responseUwe L. Korn2014-10-17
| | | | | | | | | 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>
* rtmpproto: Fix a typoMartin Storsjö2014-10-15
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* cosmetics: Write NULL pointer inequality checks more compactlyGabriel Dume2014-08-15
| | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* rtmpproto: read metadata to set correct FLV headerUwe L. Korn2014-06-01
| | | | | | | | 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>
* rtmpproto: Check the buffer sizes when copying app/playpath stringsMartin Storsjö2014-05-08
| | | | | | | As pointed out by Reimar Döffinger. CC: libav-stable@libav.org Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Support alternative slist parameter in rtmp URLsUwe L. Korn2014-05-06
| | | | | | | | | | | | 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>
* rtmpproto: Handle RTMP chunk size packets before the connect packetStephan Soller2014-04-14
| | | | | | | | | | | | | 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>
* rtmpproto: Make sure to pass on the error code if read_connect failedMartin Storsjö2014-04-14
| | | | | | | | | 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>
* rtmpproto: Avoid using uninitialized memoryMartin Storsjö2014-01-20
| | | | | | | 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>
* rtmpproto: Reorder conditions to help dead code eliminationVittorio Giovara2013-11-03
| | | | | This makes sure that these branches are eliminated properly with clang with optimizations disabled.
* rtmp: Allocate the prev_pkt arrays dynamicallyMartin Storsjö2013-10-14
| | | | | | | | | | 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>
* rtmpproto: Validate the embedded flv packet size before copyingMartin Storsjö2013-10-04
| | | | | | | | | | 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>
* rtmpproto: Readjust the end of the flv buffer if handle_metadata exited earlyMartin Storsjö2013-10-04
| | | | | | | | 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>
* rtmpproto: Move the flv header/trailer addition to append_flv_dataMartin Storsjö2013-10-04
| | | | | | | | | | | | | | | | | 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>
* rtmpproto: Clear the flv allocation size on reallocp failuresMartin Storsjö2013-10-04
| | | | | | | 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>
* rtmpproto: Pass the 'live' parameter in the right unitMartin Storsjö2013-10-04
| | | | | | | | | | | 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>
* rtmpproto: Print the error code string if there's no descriptionMartin Storsjö2013-10-04
| | | | | | | | | | 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>
* rtmp: alias rtmp_listen to listenLuca Barbato2013-10-01
| | | | Make it uniform with the other protocols.
* lavf: Reset the entry count and allocation size variables on av_reallocp ↵Martin Storsjö2013-09-26
| | | | | | | | | | | | | | 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>
* rtmp: Replace a magic number with a macroLuca Barbato2013-09-22
| | | | 11 is the RTMP header size.
* rtmp: Rewrite embedded flv handlingLuca Barbato2013-09-22
| | | | | | 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.
* rtmp: Refactor get_packetLuca Barbato2013-09-22
|
* rtmp: Unbreak get_packetLuca Barbato2013-09-20
| | | | Commit 5626f994f273af80fb100d4743b963304de9e05c broke it.
* rtmpproto: Add a comment explaining the logic in handle_notifyMartin Storsjö2013-09-20
| | | | | | | This explains why the cleanup in 5626f994f was wrong and why ae0f316a was needed. Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmp: Unbreak handle_notifyLuca Barbato2013-09-19
| | | | Commit 5626f994f273af80fb100d4743b963304de9e05c broke it.
* avformat: Use av_reallocp() where suitableAlexandra Khirnova2013-09-18
| | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>
* rtmp: Support reading interleaved chunks.Josh Allmann2013-09-17
| | | | | | | | | | | | | | | A given packet won't always come in contiguously; sometimes they may be broken up on chunk boundaries by packets of another channel. This support primarily involves tracking information about the data that's been read, so the reader can pick up where it left off for a given channel. As a side effect, we no longer over-report the bytes read if (toread = MIN(size, chunk_size)) == size Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Extend a comment to explain the prev_pkt arrays rolesMartin Storsjö2013-09-17
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Consistently use the right prev_pkt arrayMartin Storsjö2013-09-17
| | | | | | | prev_pkt[0] is used for input packets, while prev_pkt[1] is used for output. Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmpproto: Check for the right return codeMartin Storsjö2013-09-17
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* rtmp: rename main_channel_id to stream_id.Josh Allmann2013-09-17
| | | | | | | This more closely corresponds to the usage of the field. Its usage here is unrelated to the channel ID. Signed-off-by: Martin Storsjö <martin@martin.st>