1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

177 Commits

Author SHA1 Message Date
Derek Buitenhuis
bc9a5965c8 Merge commit '9f61abc8111c7c43f49ca012e957a108b9cc7610'
This also deprecates our old duplicated callbacks.

* commit '9f61abc8111c7c43f49ca012e957a108b9cc7610':
  lavf: allow custom IO for all files

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-10 14:42:41 +00:00
Michael Niedermayer
fe3fed0b14 Update demuxers and protocols for protocol whitelist support
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 04:16:50 +01:00
Michael Niedermayer
af24b1c0cd Revert "avformat/hls: Require the file extension to be m3u / m3u8 for probing to succeed"
This can cause problems with urls that have arguments after the filename

This reverts commit b0c57206d5.

Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-01 15:06:34 +01:00
Michael Niedermayer
cde57eee98 avformat/hls: Check that filename is not "" in probe before checking its extension
Possibly the check as a whole causes more problems than it helps, if so dont
hesitate to remove it

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-25 00:18:57 +01:00
Anton Khirnov
81306fd4bd hls: eliminate ffurl_* usage
Now all IO should go through the IO callbacks and be interceptable by
the caller.
2016-01-24 16:50:13 +01:00
Anton Khirnov
9f61abc811 lavf: allow custom IO for all files
Some (de)muxers open additional files beyond the main IO context.
Currently, they call avio_open() directly, which prevents the caller
from using custom IO for such streams.

This commit adds callbacks to AVFormatContext that default to
avio_open2()/avio_close(), but can be overridden by the caller. All
muxers and demuxers using AVIO are switched to using those callbacks
instead of calling avio_open()/avio_close() directly.

(de)muxers that use the URLProtocol layer directly instead of AVIO
remain unconverted for now. This should be fixed in later commits.
2016-01-24 16:45:32 +01:00
Michael Niedermayer
b0c57206d5 avformat/hls: Require the file extension to be m3u / m3u8 for probing to succeed
If the filename isnt set by the user application then the code behaves like before

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-19 16:46:30 +01:00
Michael Niedermayer
cfda1bea4c avformat/hls: Even stricter URL checks
This fixes a null pointer dereference at least

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-15 15:29:22 +01:00
Michael Niedermayer
6ba42b6482 avformat/hls: More strict url checks
No case is known where these are needed

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-15 14:11:21 +01:00
Maxim Andreev
7145e80b4f avformat/hls: forbid all protocols except http(s) & file
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-14 00:18:00 +01:00
Joel Holdsworth
c48122d731 avformat/hls: Added http_proxy support
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-27 21:44:15 +01:00
Joel Holdsworth
9cdccd404b avformat/hls: Remember to free HLSContext::headers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-27 21:44:15 +01:00
Michael Niedermayer
676a93f2d8 avformat: Add av_program_add_stream_index()
This will be used by the subsequent commit(s)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-11 22:27:25 +01:00
Hendrik Leppkes
7f5af80ba4 Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'
* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457':
  avpacket: Replace av_free_packet with av_packet_unref

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-27 14:28:56 +01:00
Luca Barbato
ce70f28a17 avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.
2015-10-26 18:00:55 +01:00
Anssi Hannula
9099079488 avformat/hls: add support for EXT-X-MAP
Without EXT-X-MAP support we miss the first bytes of some streams.

These streams worked by luck before byte-ranged segment support was added in
da7759b357

Fixes ticket #4797.
2015-10-15 15:04:00 +03:00
Anssi Hannula
fd74d45d51 avformat/hls: fix segment selection regression on track changes of live streams
Commit ad701326b4 ("avformat/hls: open playlists immediately when
AVDISCARD_ALL is dropped") inadvertently caused first_packet to never be
cleared, causing select_cur_seq_no() to not use the specific code for
live streams.

In practice this means that when the user selects a different audio
track during live stream (i.e. non-VOD) playback, there may be some
additional delay as the code might select an incorrect segment at first,
and we have to wait for video to catch audio (if too late segment was
selected) or to download more following audio segments (if too early
segment was selected).

Fix that by restoring the zeroing of first_packet.
2015-10-15 15:04:00 +03:00
Rodger Combs
f00ec7eb1b lavf/hls: don't convert NULL options to empty strings; fixes HTTP CRLF warnings 2015-10-09 04:12:57 -05:00
Rodger Combs
14221b2dd9 lavf/hls: allow subtitles to be read despite incomplete handling
This will give incorrect results in some cases due to not parsing segments
separately, so it currently requires -strict experimental.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-03 12:54:44 +02:00
Luca Barbato
74942685cb hls: Check av_opt_set_dict return value as well
Bug-Id: CID 1320426
2015-10-01 13:51:13 +02:00
Ganesh Ajjanagadde
db9de9b954 avformat/hls: remove unused function
Fixes -Wunused-function from
http://fate.ffmpeg.org/report.cgi?time=20150820031140&slot=arm64-darwin-clang-apple-5.1

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-09-26 18:44:36 +02:00
Lucas de Andrade
770dd10504 avformat/hls: Update Cookies response with Setcookie
Context cookies must be updated when a playlist response return Setcookie header.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
2015-09-25 17:22:44 +02:00
Andreas Cadhalpun
f9f0b4c08e hls: only seek if there is an offset
If there is no #EXT-X-BYTERANGE specified, there is no need to seek.
Seeking fails anyway for rtmp, because this protocol does not support
url_seek.

This fixes CNN.m3u from trac ticket 4797 (i.e. Debian bug #798189).

Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-09-22 21:00:01 +02:00
wm4
26eb294007 avformat/hls: fix some cases of HLS streams which require cookies
Broken by commit ba12ba859a. This only
happens with HLS streams which use encryption and require preserving
cookies sent by the server.

Fixes trac issue #4846.
2015-09-22 17:41:01 +02:00
Michael Niedermayer
4eca1939ef avformat/hls: Check for av_opt_set_dict() failure
Fixes: CID1320426

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-05 14:28:08 +02:00
Ganesh Ajjanagadde
5edf8b118d avformat/hls: correct comment for ensure_playlist()
Comment was previously slightly incorrect.
Also, it was placed in the wrong location.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-21 14:21:10 +02:00
Ronald S. Bultje
6471040f56 FF_OPT_TYPE_* -> AV_OPT_TYPE_*. 2015-08-18 11:48:49 -04:00
Michael Niedermayer
ba12ba859a Merge commit '0c73a5a53cc97f4291bbe9e1e68226edf6161744'
* commit '0c73a5a53cc97f4291bbe9e1e68226edf6161744':
  hls: Save and forward avio options

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-30 17:52:23 +02:00
Luca Barbato
0c73a5a53c hls: Save and forward avio options
Make possible to send the custom headers and override the user agent.

Reported-by: BenWonder
2015-07-30 11:21:26 +02:00
Michael Niedermayer
29d147c94d Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'
* commit '059a934806d61f7af9ab3fd9f74994b838ea5eba':
  lavc: Consistently prefix input buffer defines

Conflicts:
	doc/examples/decoding_encoding.c
	libavcodec/4xm.c
	libavcodec/aac_adtstoasc_bsf.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.h
	libavcodec/asvenc.c
	libavcodec/avcodec.h
	libavcodec/avpacket.c
	libavcodec/dvdec.c
	libavcodec/ffv1enc.c
	libavcodec/g2meet.c
	libavcodec/gif.c
	libavcodec/h264.c
	libavcodec/h264_mp4toannexb_bsf.c
	libavcodec/huffyuvdec.c
	libavcodec/huffyuvenc.c
	libavcodec/jpeglsenc.c
	libavcodec/libxvid.c
	libavcodec/mdec.c
	libavcodec/motionpixels.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/noise_bsf.c
	libavcodec/nuv.c
	libavcodec/nvenc.c
	libavcodec/options.c
	libavcodec/parser.c
	libavcodec/pngenc.c
	libavcodec/proresenc_kostya.c
	libavcodec/qsvdec.c
	libavcodec/svq1enc.c
	libavcodec/tiffenc.c
	libavcodec/truemotion2.c
	libavcodec/utils.c
	libavcodec/utvideoenc.c
	libavcodec/vc1dec.c
	libavcodec/wmalosslessdec.c
	libavformat/adxdec.c
	libavformat/aiffdec.c
	libavformat/apc.c
	libavformat/apetag.c
	libavformat/avidec.c
	libavformat/bink.c
	libavformat/cafdec.c
	libavformat/flvdec.c
	libavformat/id3v2.c
	libavformat/isom.c
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/mpc.c
	libavformat/mpc8.c
	libavformat/mpegts.c
	libavformat/mvi.c
	libavformat/mxfdec.c
	libavformat/mxg.c
	libavformat/nutdec.c
	libavformat/oggdec.c
	libavformat/oggparsecelt.c
	libavformat/oggparseflac.c
	libavformat/oggparseopus.c
	libavformat/oggparsespeex.c
	libavformat/omadec.c
	libavformat/rawdec.c
	libavformat/riffdec.c
	libavformat/rl2.c
	libavformat/rmdec.c
	libavformat/rtpdec_latm.c
	libavformat/rtpdec_mpeg4.c
	libavformat/rtpdec_qdm2.c
	libavformat/rtpdec_svq3.c
	libavformat/sierravmd.c
	libavformat/smacker.c
	libavformat/smush.c
	libavformat/spdifenc.c
	libavformat/takdec.c
	libavformat/tta.c
	libavformat/utils.c
	libavformat/vqf.c
	libavformat/westwood_vqa.c
	libavformat/xmv.c
	libavformat/xwma.c
	libavformat/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 23:15:19 +02:00
schenk michael
b9161ef052 avformat/hls: do not iterate to next sequence number if interruption is requested
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-26 14:36:25 +02:00
Michael Niedermayer
7a27aa15ec avformat/hls: Handle read_buffer allocation failure
Fixes CID1297576

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-12 19:03:18 +02:00
wm4
e2691b8092 hls: skip to next segment if the current is unavailable
Apparently, some live streams can delete segments too early, maybe
because the client is too far behind. In this case, it's better to skip
the segment, instead of returning EOF. (Yes, the HLS demuxer actually
returns AVERROR_EOF if opening the segment returns a 404 HTTP error.)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-17 22:54:17 +02:00
Rodger Combs
bcf44c91c3 libavformat/hls: add an option to start from a given segment in a live stream
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 13:34:15 +02:00
Micah Galizia
fca0851879 avformat/hls: refactor repeated HLS option updates
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-16 13:01:39 +01:00
Micah Galizia
7859618aff avformat/hls: store cookies returned in HLS key response
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-16 01:57:01 +01:00
selsta
6c8a158989 hls: detect SAMPLE-AES encryption
SAMPLE-AES encryption is not commonly used yet, but without this patch
ffmpeg is thinking that the hls segments are not encrypted which
produces broken files.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-05 23:08:38 +01:00
wm4
4bf3fab281 hls: fix a null pointer dereference
Not allocating the pls->ctx will crash in libavformat/hls.c:1410, where
it tries to dereference the field.

Sample: http://ec24.rtp.pt/liverepeater/rtpn.smil/playlist.m3u8

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-16 19:59:04 +01:00
Michael Niedermayer
4641ae352e avformat: Add and use ff_copy_whitelists()
Fixes potential security issue in case of running out of memory

Found-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-24 19:23:23 +02:00
Michael Niedermayer
2c5ae57776 Merge commit '6df9d9b55d3f56ee7782639a7678eeeaf77f14ea'
* commit '6df9d9b55d3f56ee7782639a7678eeeaf77f14ea':
  lavf: Use av_gettime_relative

Conflicts:
	libavformat/hls.c

See: f78bc96b7c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-24 12:40:36 +02:00
Martin Storsjö
6df9d9b55d lavf: Use av_gettime_relative
The ones left using av_gettime are NTP timestamps (for RTCP,
which is specified to send the actual current realtime clock
in RTCP SR packets), and the NUT muxer timestamper, which is
documented as using wallclock time.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-24 09:53:45 +03:00
Michael Niedermayer
24cd4e5071 avformat/hls: forward whitelists to mpegts demuxer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-23 15:26:46 +02:00
Michael Niedermayer
0026c4ecfd avformat/hls: use av_freep(), do not leave stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-07 04:29:27 +02:00
Reimar Döffinger
a0941c8a2b Use new av_dict_set_int helper function.
Get rid of the many, slightly differing, implementations
of basically the same thing.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-08-16 14:31:41 +02:00
James Almer
d34ec64a22 replace calls to url_feof() with avio_feof()
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-08 00:48:38 +02:00
Michael Schenk
513a431e07 avformat/hls: reduce memory usage by using dynamically allocated url/key
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-12 03:14:52 +03:00
Anssi Hannula
39b192b8e1 avformat/hls: do not call ffurl_seek/ffurl_size on crypto protocol
ffurl_seek() will not work even when it should be a no-op, so do not
call it on crypto protocol.

Also replace use of ffurl_size() for the same reason.

Reported-by: Michael Schenk <Michael.Schenk@albistechnologies.com>
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-11 00:04:34 +03:00
Vladlen Y. Koshelev
cdbd9e218d avformat/hls: support for seeking on event playlists
This allows clients to seek between first played segment
and the last one in the live stream playlist with #EXT-X-PLAYLIST-TYPE:EVENT attribute.
2014-04-06 17:55:04 +03:00
Anssi Hannula
f29cb45bf2 avformat/hls: flush the subdemuxer when seeking
Since we are basically seeking the AVIOContext under the subdemuxer, we
need to flush the subdemuxer to avoid old packets from being read from
the packet queue after the seek.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:04 +03:00
Anssi Hannula
9aa0606e87 avformat/hls: properly take stream_index into account when seeking
Properly take stream_index into account so that a keyframe will be
looked for in the specified stream_index only.

Similarly, only check timestamp validity against the specified
stream_index.

Also remove code for stream_index == -1 case which does not actually
happen as it is handled by generic code.

This is based on an initial patch by James Deng.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:04 +03:00
Anssi Hannula
ad701326b4 avformat/hls: open playlists immediately when AVDISCARD_ALL is dropped
Do not try to delay opening newly required playlists until a segment
switch. Applications expect that newly selected undiscarded streams are
available immediately, especially with alternative rendition streams
(selectable audio/subtitle tracks).

One might think that delaying variant stream switch until a segment
switch would allow a "seamless" switch without us having to download a
specific segment from two different variant playlists. However, that is
not the case, since the application would have to keep the previous
stream available (undiscarded) until the first packet of the newly
selected stream arrives, but by that time the demuxer would have already
downloaded the next segment of both variants.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:04 +03:00
Anssi Hannula
05ce529a59 avformat/hls: factor identical playlist allocations out of parse_playlist
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
6b4b73e75d avformat/hls: do not use sequence numbers for packet ordering
As per spec 3.4.3 ("A client MUST NOT assume that segments with the same
sequence number in different Media Playlists contain matching content.")
we cannot use sequence numbers for packet ordering.

This can be seen e.g. in the subtitle streams of
bipbop_16x9_variant.m3u8 that have considerably longer segments and
therefore different numbering.

Since the code now exclusively syncs using timestamps that may wrap, add
some additional checking for that.

According to the HLS spec all the timestamps should be in 33-bit MPEG
format and synced together.

v2: cleaner wrap detection
v3: further wrap detection improvements

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
8fd6875c83 avformat/hls: do not care about stream start timestamps
While selecting a packet to return to caller in read_packet(), the code
corrects the timestamps for starting timestamps.

However, this is wrong, since for live streams the initial timestamps
might differ just because of the time delay between the retrieval of the
various Media Playlists.

Fortunately, spec 6.2.4 mandates that all variant streams must have
matching timestamps, so we do not need to correct for initial
timestamps.

Drop the correction code.

Note that ID3 timestamps were previously ignored, so this code was
previously actually needed.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
d549b0910c avformat/hls: avoid unnecessary segment retrievals
Check if the playlist is still needed just before requesting the next
segment instead of after exhausting the previous segment.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
4e85202bcc avformat/hls: improve segment selection when restarting list reception
Improve selection of the segment sequence number when restarting the
reception of a playlist after it was suspended due to being unneeded
(due to discard flags).

The current code assumes that each playlist contains matching data with
the same sequence number, while spec 3.4.3 specifically says that that
is not the case. Often subtitle playlists also have longer target
durations as well, causing the selection to be completely wrong.

Instead prefer using the playlist segment duration information for
non-live playlists, and other means if that is not possible.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
61e1a70278 avformat/hls: track seeking on a per-playlist basis
Seeking needs to be tracked on a per-playlist basis, since the resyncing
code in hls_read_packet() has to sync each playlist to the seek
timestamp instead of stopping after the first playlist has reached it.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
01b184e68d avformat/hls: parse ID3 timestamps for elementary audio streams
HLS provides MPEG TS timestamps via ID3 tags in the beginning of each
segment of elementary audio streams.

v2: fix issues with streams that have multiple ID3 tags

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
1cb8d986b8 avformat/hls: split read_from_url() out of read_data()
Useful for ID3 parsing.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:03 +03:00
Anssi Hannula
f7c7fc1369 avformat/hls: add some logging messages
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:02 +03:00
Anssi Hannula
da7759b357 avformat/hls: add support for byte-ranged segments
Add support for EXT-X-BYTERANGE added in HLS protocol v4.

v2: Better comment explaining ffurl_seek call and fix cur_seg_offset not
being updated.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:02 +03:00
Anssi Hannula
cc1162d775 avformat/hls: always return EOF for unneeded playlist streams
Even if we returned AVERROR_EOF previously due to playlist no longer
being needed, we may still be called again, and we do not want to
trigger a segment download in that case.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:02 +03:00
Anssi Hannula
edf4406c4d avformat/hls: add support for alternative renditions
HLS protocol version 4 added alternative renditions to the
specification (e.g. alternative audio tracks).

The EXT-X-MEDIA tags can also contain metadata for "renditions" (i.e.
tracks) of the main Media Playlist.

Add support for those.

Note that the same rendition (AVStream) may be associated with multiple
variants (AVPrograms).

Alternative subtitle tracks will require additional work and are
therefore not enabled yet.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-04-06 17:55:02 +03:00
Mikael Finstad
5846d8a91e avformat/hls: Fix cookies and user agent with encrypted HLS streams
Session data (cookies, user-agent) is not being sent on payload requests with
encrypted HLS streams This causes services like Akamai to give a 403 forbidden
when requesting the TS files, because they expect the same cookies
and user-agent on all requests
2014-01-28 18:50:58 +01:00
Anssi Hannula
9371d70bad avformat/hls: decouple playlists from variants
Not all "sub-playlists" are variant playlists (containing the same
content with a different bitrate, etc) in the current version of the HLS
specification. They can now also be alternative renditions, containing
e.g. alternative audio tracks etc.

Decouple playlists from variants to prepare for handling the new
features.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-01-03 15:05:48 +02:00
Michael Niedermayer
9c00f9ada6 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  hls: Avoid reading outside of the allocated array

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-22 18:15:12 +01:00
Michael Niedermayer
9440e47067 Merge commit '8c929098141ebc94ad3f303521c520bb3dc6d8f6'
* commit '8c929098141ebc94ad3f303521c520bb3dc6d8f6':
  hls: Check whether the AVIOContext contains a new redirected URL

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-22 18:08:53 +01:00
Martin Storsjö
56c2337004 hls: Avoid reading outside of the allocated array
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-11-22 14:27:10 +02:00
Martin Storsjö
8c92909814 hls: Check whether the AVIOContext contains a new redirected URL
This allows both the main playlist itself as well as the variant
playlists to handle redirects combined with relative URLs.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-11-22 14:27:08 +02:00
kowalsky
4684539c91 avformat/hls: fixed bug where custom http headers weren't kept for hls streams
See: https://trac.ffmpeg.org/ticket/3024
2013-11-07 12:29:45 +01:00
Michael Niedermayer
21a2b97365 avformat/hls: do not limit manifest lines to 1024 chars
Fixes Ticket2976
Debuged-by: jaimeMF
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-21 20:59:30 +02:00
Michael Niedermayer
95960027a5 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  hls: Call avformat_find_stream_info() on the chained demuxers

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-31 11:01:30 +02:00
Michael Niedermayer
9696740af7 hls: Call avformat_find_stream_info() on the chained demuxers
This allows the chained demuxer (or more precisely, the lavf
utility code) to better fill in timestamps on packets from
these, especially for cases where one stream is a raw ADTS
stream.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-30 12:31:08 +03:00
Michael Niedermayer
7dfe798d14 Merge commit '06205b5efdcf0bc4c5463bfdd02f09b5f79fc4cd'
* commit '06205b5efdcf0bc4c5463bfdd02f09b5f79fc4cd':
  hls: Free packets when skipping packets when seeking

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-30 10:26:04 +02:00
Michael Niedermayer
4971551fd2 Merge commit 'c44191039944526dd7eb6e536990b555837961f5'
* commit 'c44191039944526dd7eb6e536990b555837961f5':
  hls: Store all durations in AV_TIME_BASE

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-30 10:12:48 +02:00
Michael Niedermayer
5a270296cb Merge commit 'e1d5b244761cf69db655ad7ece1dbf2c13dd4fce'
* commit 'e1d5b244761cf69db655ad7ece1dbf2c13dd4fce':
  hls: Store first_timestamp in units of AV_TIME_BASE

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-30 10:03:02 +02:00
Martin Storsjö
06205b5efd hls: Free packets when skipping packets when seeking
This fixes memory leaks present since 2b3d041cdc.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 20:15:50 +03:00
Martin Storsjö
c441910399 hls: Store all durations in AV_TIME_BASE
Also parse segment durations as floating point, which is allowed
since HLS version 3.

This is based on a patch by Zhang Rui.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 20:15:50 +03:00
Martin Storsjö
e1d5b24476 hls: Store first_timestamp in units of AV_TIME_BASE
When first_timestamp was stored as-is, its actual time base
wasn't known later in the seek function.

Additionally, the logic (from 795d9594cf) for scaling it
based on stream_index is flawed - stream_index in the seek
function only specifies which stream the seek timestamp refers
to, but obviously doesn't say anything about which stream
first_timestamp belongs to.

In the cases where stream_index was >= 0 and all streams had the
same time base, this didn't matter in practice.

Seeking taking first_timestamp into account is problematic
when one variant is mpegts (with real timestamps) and one variant
is raw ADTS (with timestamps only being accumulated packet
duration), where the variants start at totally different timestamps.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 20:15:50 +03:00
Michael Niedermayer
994e09345e Merge remote-tracking branch 'qatar/master'
* qatar/master:
  hls: Create an AVProgram for each variant

Conflicts:
	libavformat/hls.c

See: 23db5418ed
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-29 14:35:40 +02:00
Michael Niedermayer
65dcb54493 Merge commit '9d64f236292ba28018dd9afd2d57f8f944b33f81'
* commit '9d64f236292ba28018dd9afd2d57f8f944b33f81':
  hls: Respect the different stream time bases when comparing dts

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-29 14:18:37 +02:00
Michael Niedermayer
2f9e97b32a Merge commit 'c11e33a3d9665dd1fc5dbdecdd03a4860ac6a622'
* commit 'c11e33a3d9665dd1fc5dbdecdd03a4860ac6a622':
  hls: Set stream offset before opening a chained demuxer

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-29 14:11:21 +02:00
Michael Niedermayer
d31c0fcfa5 Merge commit 'cdd2d73d315ecaf19ff49e64c91923275f1bda68'
* commit 'cdd2d73d315ecaf19ff49e64c91923275f1bda68':
  hls: Don't check discard flags until the parent demuxer's streams actually exist
  hls: Copy the time base from the chained demuxer

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-29 14:04:27 +02:00
Michael Niedermayer
07440c9380 Merge commit 'eb33ba04e03d9f36e23fffd442510c824be709c3'
* commit 'eb33ba04e03d9f36e23fffd442510c824be709c3':
  hls: Return all packets from a previous variant before moving on to the next one

Conflicts:
	libavformat/hls.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-29 13:59:27 +02:00
LYF
c110cbf6b5 hls: Create an AVProgram for each variant
Without the information, an application may choose audio from one
variant and video from another variant, which leads to fetching two
variants from the network. This enables av_find_best_stream() to find
matching audio and video streams, so that only one variant is fetched.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 09:50:09 +03:00
Michael Niedermayer
9d64f23629 hls: Respect the different stream time bases when comparing dts
Also adjust the streams timestamps according to their start
timestamp when comparing. This helps getting correctly interleaved
packets if one stream lacks timestamps (such as a plain ADTS
stream when the other variants are full mpegts) when the others
have timestamps that don't start from zero.

This probably doesn't work properly if such a stream is
temporarily disabled (via the discard flags) and then reenabled,
and such streams are hard to correctly sync against the other
streams as well - but this works better than before at least.

The segment number restriction makes sure all variants advance
roughly at the same pace as well.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 09:50:08 +03:00
Martin Storsjö
c11e33a3d9 hls: Set stream offset before opening a chained demuxer
This makes sure we don't accidentally check discard flags
for the wrong stream.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 09:50:06 +03:00
Michael Niedermayer
cdd2d73d31 hls: Don't check discard flags until the parent demuxer's streams actually exist
If passing the end of one segment while initializing the
chained demuxer, the parent demuxer's streams aren't set up
yet, so we can't recheck the discard flags.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 09:50:05 +03:00
Michael Niedermayer
82bf8c8783 hls: Copy the time base from the chained demuxer
When a variant stream isn't mpegts but e.g. raw adts, the
default time base (90k) isn't correct.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 09:50:03 +03:00
Martin Storsjö
eb33ba04e0 hls: Return all packets from a previous variant before moving on to the next one
This serves as a safeguard; normally we want to use the dts
comparison to interleave packets from all active variants. If that
dts comparison for some reason doesn't work as intended, make sure
that all packets in all variants for a certain sequence number have
been returned before moving on to the next one.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-29 09:50:02 +03:00
Michael Niedermayer
419a3d8a43 avformat/hls: avoid floating point arithmetic
Should make things more reproducable across platforms

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-22 19:36:33 +02:00
Zhang Rui
2a5891bb9d avformat/hls: parse EXTINF duration as floating-point number
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-22 19:34:47 +02:00
Timothy Gu
a9bbf59be7 cosmetics: Fix "dont" "wont" "doesnt" typos
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-29 02:31:16 +02:00
Reimar Döffinger
efa7f42020 Use the avstring.h locale-independent character type functions
Make sure the behavior does not change with the locale.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-03-07 15:16:36 +02:00
Michael Niedermayer
a12a618aa9 hls: fix timebase
Fixes Ticket1733

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-07 13:42:12 +01:00
Reimar Döffinger
88d55b827d Remove incorrect use of ctype.h functions.
As far as I can tell the code should not change behaviour
depending on locale in any of these places.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2013-03-03 21:44:10 +01:00
Reimar Döffinger
db6e2e848b hls: do not access pb->opaque for custom IO.
As the name indicates we can't just assume what the
"opaque" field contains.
This fixes a crash in third-party applications see e.g.:
http://bugzilla.mplayerhq.hu/show_bug.cgi?id=2126

This fixes also FFmpeg trac #2293, which is a different
third-party application.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2013-02-24 19:49:06 +01:00
Michael Niedermayer
665f2d432c hls: add missing checks for accessing avoption fields
Fixes null pointer exception and probably other things

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-23 22:22:53 +01:00
Micah Galizia
d4e5d8d4c2 lavf/hls: broker HTTP options
Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
2013-01-23 19:27:14 +01:00
Diego Biurrun
511cf612ac miscellaneous typo fixes 2012-12-21 00:18:34 +01:00