summaryrefslogtreecommitdiffstats
path: root/stream
Commit message (Collapse)AuthorAgeFilesLines
* stream: don't drop buffers on failed seekswm42014-09-291-6/+2
| | | | | | | | | | | Might matter when libavformat tries to do tiny seekbacks in an unseekable stream, and the seekback buffer isn't large enough. In this case, seeking would fail, and would drop the current buffer. The seekback would end up dropping future data. This change probably doesn't have any observable effects. libavformat normally has its own stream buffer, and demux_mkv.c tries carefully never to seek back.
* cache_file: refuse to cache unseekable streamswm42014-09-291-0/+5
| | | | | | | | | This makes no sense to use with DVD/BD/DVB and some others, and these streams happen to be unseekable. Also, other kinds of unseekable streams (like reading from pipe) should work, but will exhibit sketchy behavior if they need to seek. So just disable it, and leave these problems to the memory cache (cache.c).
* stream_bluray: autodetect AVCHD directorieswm42014-09-271-3/+4
| | | | Fixes #1127.
* stream: change malloc+memset to callocBruno George Moraes2014-09-273-8/+2
| | | | | | | Also removed some memset that were left on some calloc that was already in the code. Signed-off-by: wm4 <wm4@nowhere>
* stream_bluray: allow opening BDMV directories directlywm42014-09-262-0/+88
| | | | | | | | Similar as the previous commits. Most of the code is actually copied from the stream_dvdnav.c code, but I'd rather prefer to duplicate it, than to entangle them. The latter would probably result in terrible things in a few years.
* stream_dvdnav: allow opening DVD directories directlywm42014-09-262-0/+54
| | | | | | | | Same hack as with stream_dvd.c. VIDEO_TS.IFO files are now opened via stream_dvdnav.c. Directories containing a VIDEO_TS.IFO or VIDEO_TS/VIDEO_TS.IFO file are also opened with it.
* stream_dvd: better .ifo probingwm42014-09-255-21/+66
| | | | | | | | | | | | | | | stream_dvd.c includes a pseudo-protocol that recognizes .IFO files, and plays them using libdvdread. This was relatively lazy, and could perhaps easily trigger with files that just had the .ifo extension. Make the checks stricter, and even probe the file header. Apparently the first bytes in an .ifo file are always "DVDVIDEO-VTS", so check for this. Refuse to load the main "video_ts.ifo". The plan is to use stream_dvdnav for it. This also removes at least 1 memory leak.
* Remove mpbswap.hwm42014-09-251-2/+1
| | | | | | This was once central, but now it's almost unused. Only vf_divtc still uses it for extremely weird and incomprehensible reasons. The use in stream.c is trivial. Replace these, and remove mpbswap.h.
* stream_cdda, demux_raw: always use s16lewm42014-09-251-8/+0
| | | | | | | | | | | | | stream_cdda's output format is linked to demux_raw's default audio format, and at least we don't care enough to provide a separate mechanism to let stream_cdda explicitly set the format, so they must match. Judging from the existing code, it looks like CDDA always outputs little endian. stream_cdda.c changed this back to native endian (what demux_raw expects). Just make them both little endian. This requires less code, and also having a raw demuxer's behavior depend on the endianness of the machine isn't very sane anyway.
* audio: drop swapped-endian audio formatswm42014-09-234-6/+6
| | | | | | | | | | | | | | | | | | | | Until now, the audio chain could handle both little endian and big endian formats. This actually doesn't make much sense, since the audio API and the HW will most likely prefer native formats. Or at the very least, it should be trivial for audio drivers to do the byte swapping themselves. From now on, the audio chain contains native-endian formats only. All AOs and some filters are adjusted. af_convertsignendian.c is now wrongly named, but the filter name is adjusted. In some cases, the audio infrastructure was reused on the demuxer side, but that is relatively easy to rectify. This is a quite intrusive and radical change. It's possible that it will break some things (especially if they're obscure or not Linux), so watch out for regressions. It's probably still better to do it the bulldozer way, since slow transition and researching foreign platforms would take a lot of time and effort.
* stream: fix build with emulated atomicswm42014-09-131-3/+3
| | | | | This code was legal with C11 atomics, but it fails with our compatibility wrapper.
* stream: redo playback abort handlingwm42014-09-137-26/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mechanism originates from MPlayer's way of dealing with blocking network, but it's still useful. On opening and closing, mpv waits for network synchronously, and also some obscure commands and use-cases can lead to such blocking. In these situations, the stream is asynchronously forced to stop by "interrupting" it. The old design interrupting I/O was a bit broken: polling with a callback, instead of actively interrupting it. Change the direction of this. There is no callback anymore, and the player calls mp_cancel_trigger() to force the stream to return. libavformat (via stream_lavf.c) has the old broken design, and fixing it would require fixing libavformat, which won't happen so quickly. So we have to keep that part. But everything above the stream layer is prepared for a better design, and more sophisticated methods than mp_cancel_test() could be easily introduced. There's still one problem: commands are still run in the central playback loop, which we assume can block on I/O in the worst case. That's not a problem yet, because we simply mark some commands as being able to stop playback of the current file ("quit" etc.), so input.c could abort playback as soon as such a command is queued. But there are also commands abort playback only conditionally, and the logic for that is in the playback core and thus "unreachable". For example, "playlist_next" aborts playback only if there's a next file. We don't want it to always abort playback. As a quite ugly hack, abort playback only if at least 2 abort commands are queued - this pretty much happens only if the core is frozen and doesn't react to input.
* stream: change cache return valueswm42014-09-072-7/+7
| | | | | Basically a cosmetic change, because currently the player just continues even if the cache fails initializing.
* stream_lavf: assume icy title data is terminated with ';'wm42014-09-061-1/+1
| | | | Should fix #1071.
* player: don't allow remote playlists to load local fileswm42014-09-013-4/+11
| | | | | | | | Because that might be a bad idea. Note that remote playlists still can use any protocol marked with is_safe and is_network, because the case of http-hosted playlists containing URLs using other streaming protocols is not unusual.
* player: always load playlistswm42014-08-314-3/+37
| | | | | | | | | Until now, you had to use --load-unsafe-playlists or --playlist to get playlists loaded. Change this and always load playlists by default. This still attempts to reject unsafe URLs. For example, trying to invoke libavdevice pseudo-demuxer is explicitly prevented. Local paths and any http links (and some more) are always allowed.
* cache_file: add a mode that creates a temporary filewm42014-08-301-1/+2
| | | | | | | Since we have to be portable, our options for creating temporary files are somewhat limited. tmpfile() happens to be available everywhere, so use that. This function doesn't allow having a "visible" filename or location, so we use the magic string "TMP" for this.
* stream: correctly propagate uncached stream typewm42014-08-301-1/+1
| | | | | This makes the ordered chapter code not think that a stream from the local filesystem is not a local file (it checks uncached_type).
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-294-5/+5
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* stream: tweaks to network reconnection codewm42014-08-293-3/+6
| | | | | | | | | | | | | | Don't reconnect to the cache (since the cached stream already handles reconnection). This is necessary, because since commit 0b428e44 the "streaming" field (which also controls whether attempting to reconnect makes sense at all) is inherited to the cache stream wrapper. Also, let the stream reset its own position on reconnect. This removes some assumptions and messy handling from the reconnect function. Make sure the cache is dropped on reconnect. This takes care of readjusting the stream position if necessary. (Also drop the cache on DVB channel switching commands.)
* tv: initialize frequencies to 0Ben Boeckel2014-08-281-2/+2
|
* player: redo how stream caching and pausing on low cache workswm42014-08-271-0/+1
| | | | | | | | | | | | | | | | | | | Add the --cache-secs option, which literally overrides the value of --demuxer-readahead-secs if the stream cache is active. The default value is very high (10 seconds), which means it can act as network cache. Remove the old behavior of trying to pause once the byte cache runs low. Instead, do something similar wit the demuxer cache. The nice thing is that we can guess how many seconds of video it has cached, and we can make better decisions. But for now, apply a relatively naive heuristic: if the cache is below 0.5 secs, pause, and wait until at least 2 secs are available. Note that due to timestamp reordering, the estimated cached duration of video might be inaccurate, depending on the file format. If the file format has DTS, it's easy, otherwise the duration will seemingly jump back and forth.
* stream_dvb: restore --dvbin-file optionwm42014-08-062-7/+15
| | | | | | | Got lost some time ago. Although I'm not sure if it actually does anything on MPlayer (it exists there, but might broken, not sure). Fixes #988 (untested).
* stream_dvb: fix channels.conf preference orderwm42014-08-061-3/+4
| | | | | | | | channels.conf was never used (even though its config path was resolved). Also remove the non-sense with the access() call. Fixes #987 (untested).
* Improve setting AVOptionswm42014-08-021-5/+1
| | | | | | | | Use OPT_KEYVALUELIST() for all places where AVOptions are directly set from mpv command line options. This allows escaping values, better diagnostics (also no more "pal"), and somehow reduces code size. Remove the old crappy option parser (av_opts.c).
* stream: hack-fix rtmp-level seekingwm42014-07-303-7/+15
| | | | | | | | | | | | | This didn't work, because the timebase was wrong. According to the ffmpeg doxygen, if the stream index is -1 (which is what we used), the timebase is AV_TIME_BASE. But this didn't work, and it really expected the stream's timebase. Quite "surprising", since this feature (avio_seek_time) is used by rtmp only. Fixing this properly is too hard, so hack-fix our way around it. STREAM_CTRL_SEEK_TO_TIME is also used by DVD/BD, so a new STREAM_CTRL_AVSEEK is added. We simply pass-through the request verbatim.
* stream_lavf: allow setting AVOptions with --stream-lavf-owm42014-07-301-0/+17
| | | | | This commit also creates a private option struct for stream_lavf.c, but since I'm lazy, I'm not moving any existing options to it.
* demux: add a demuxer threadwm42014-07-161-23/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a thread to the demuxer which reads packets asynchronously. It will do so until a configurable minimum packet queue size is reached. (See options.rst additions.) For now, the thread is disabled by default. There are some corner cases that have to be fixed, such as fixing cache behavior with webradios. Note that most interaction with the demuxer is still blocking, so if e.g. network dies, the player will still freeze. But this change will make it possible to remove most causes for freezing. Most of the new code in demux.c actually consists of weird caches to compensate for thread-safety issues (with the previously single-threaded design), or to avoid blocking by having to wait on the demuxer thread. Most of the changes in the player are due to the fact that we must not access the source stream directly. the demuxer thread already accesses it, and the stream stuff is not thread-safe. For timeline stuff (like ordered chapters), we enable the thread for the current segment only. We also clear its packet queue on seek, so that the remaining (unconsumed) readahead buffer doesn't waste memory. Keep in mind that insane subtitles (such as ASS typesetting muxed into mkv files) will practically disable the readahead, because the total queue size is considered when checking whether the minimum queue size was reached.
* Revert "Remove DVD and Bluray support"wm42014-07-156-0/+2608
| | | | | | This reverts commit 4b93210e0c244a65ef10a566abed2ad25ecaf9a1. *shrug*
* Remove DVD and Bluray supportwm42014-07-146-2608/+0
| | | | It never worked well. Just remux your DVD and BD images to mkv.
* stream_dvdnav: suspend read on vts change even if the requested title is not ↵Alessandro Ghedini2014-07-131-1/+0
| | | | found
* stream: don't sleep for reconnecting network if playback is stoppedwm42014-07-121-0/+2
| | | | | | Also silences the bogus message if that happens. CC: @mpv-player/stable
* cache_file: fix operation if stream size is unknownwm42014-07-121-2/+3
| | | | | | | | | | | | | Happens when playing from a pipe. Note that seeking forward doesn't work. It would be possible to create a workaround for that by reading and skipping data until the target position is reached (and writing the skipped data into the cache file), but I'm not sure about that. Fixes #928. CC: @mpv-player/stable
* Revert "build: avoid defining _GNU_SOURCE"wm42014-07-101-3/+0
| | | | | | This reverts commit 2e6a8f260ca169e2e1a5646eecfc322de6f77307. Too many problems for now, such as with OSX and asprintf().
* build: include <strings.h> for strcasecmp()wm42014-07-104-0/+4
| | | | | | | It happens to work without strings.h on glibc or with _GNU_SOURCE, but the POSIX standard requires including <strings.h>. Hopefully fixes OSX build.
* build: deal with endian messwm42014-07-101-1/+2
| | | | | | | | | | | | | | | | | | | | There is no standard mechanism for detecting endianess. Doing it at compile time in a portable way is probably hard. Doing it properly with a configure check is probably hard too. Using the endian definitions in <sys/types.h> (usually includes <endian.h>, which is not available everywhere) works under circumstances, but the previous commit broke it on OSX. Ideally all code should be endian dependent, but that is not possible due to the dependencies (such as FFmpeg, some video output APIs, some audio output APIs). Create a header osdep/endian.h, which contains various fallbacks. Note that the last fallback uses libavutil; however, it's not clear whether AV_HAVE_BIGENDIAN is a public symbol, or whether including <libavutil/bswap.h> really makes it visible. And in fact we don't want to pollute the namespace with libavutil definitions either. Thus it's only the last fallback.
* build: avoid defining _GNU_SOURCEwm42014-07-091-0/+3
| | | | | | | | | _GNU_SOURCE defines the kitchen sink, and also prefers glibc definitions where glibc and POSIX conflict. Even though POSIX is worth less than toilet paper, we still prefer the POSIX definitions. rar.c needs asprintf(), which is _GNU_SOURCE-only. So we define _GNU_SOURCE too specifically for this file.
* cache, dvd, bluray: simplify stream time handlingwm42014-07-071-42/+16
| | | | | | | | | | | | | | | | | | We used a complicated and approximate method to cache the stream timestamp, which is basically per-byte. (To reduce overhead, it was only cached per 8KB-block, so it was approximate.) Simplify this, and read/keep the timestamp only on discontinuities. This is when demux_disc.c actually needs the timestamp. Note that caching is currently disabled for dvdnav, but we still read the timestamp only after some data is read. libdvdread behaves well, but I don't know about libbluray, and the previous code also read the timestamp only after reading data, so try to keep it safe. Also drop the start_time offset. It wouldn't be correct anymore if used with the cache, and the idea behind it wasn't very sane either (making the player to offset the initial playback time to 0).
* stream_dvdnav: more debugging outputwm42014-07-061-2/+5
|
* stream: remove now unused STREAM_CTRL_GET_START_TIMEwm42014-07-064-19/+0
| | | | demux_disc.c takes care of this now.
* tv: move demuxer parts to separate filewm42014-07-052-250/+13
| | | | | Now all demuxer implementations (at least demuxer API-wise) are in the demux directory.
* demux: minor simplification to internal APIwm42014-07-051-3/+3
| | | | Also some other unrelated minor changes.
* dvd, bluray, cdda: add demux_disc containing all related hackswm42014-07-058-24/+7
| | | | | | | | | | | | DVD and Bluray (and to some extent cdda) require awful hacks all over the codebase to make them work. The main reason is that they act like container, but are entirely implemented on the stream layer. The raw mpeg data resulting from these streams must be "extended" with the container-like metadata transported via STREAM_CTRLs. The result were hacks all over demux.c and some higher-level parts. Add a "disc" pseudo-demuxer, and move all these hacks and special-cases to it.
* demux, stream: change metadata notificationwm42014-07-052-41/+28
| | | | | | | | | | | | (Again.) This time, we simply make it event-based, as it should be. This is done for both demuxer metadata and stream metadata. For some ogg-over-icy streams, 2 updates are reported on stream start. This is because libavformat reports an update right on start, while including the same info in the "static" metadata. I don't know if that's a bug or a feature.
* stream_dvdnav: check the length of all titles with dvdnav://longesttholin2014-07-041-1/+1
| | | | | | | | The last title was ignored before. CC: @mpv-player/stable Signed-off-by: wm4 <wm4@nowhere>
* stream_dvdnav: free pointer to priv->filename on closetholin2014-07-041-0/+2
| | | | | | CC: @mpv-player/stable Signed-off-by: wm4 <wm4@nowhere>
* stream_dvdnav: make sure seeking bounds are within rangetholin2014-07-041-1/+5
| | | | | | | | libdvdnav returns an error is the seek position is out of range. CC: @mpv-player/stable Signed-off-by: wm4 <wm4@nowhere>
* cache_file: use unicode on windowswm42014-07-021-0/+2
| | | | This enables the MinGW Windows crap wrapper for fopen().
* cache: clear DVD timestampswm42014-07-021-0/+3
| | | | | | | | | | | | When resizing the cache, the buffer for the DVD timestamps is initialized with 0. This causes the player to always return playback position 0 with any file format (not just DVD), and also makes all relative seeks relative to position 0. Fix this by clearing the timestamps explicitly. Closes #899. CC: @mpv-player/stable
* Audit and replace all ctype.h useswm42014-07-015-7/+4
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* options: add --list-protocols optionAlessandro Ghedini2014-06-302-0/+24
|
* Basic xdg directory implementationKenneth Zhou2014-06-261-12/+7
| | | | | | | | | | Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file() Closes #864, #109. Signed-off-by: wm4 <wm4@nowhere>
* stream: add a file cachewm42014-06-223-16/+183
| | | | | | | | | For remarks, pretty much see the manpage additions. Could help with network streams that require too much seeking (maybe), or might be extended to help with the use case of watching and downloading a file at the same time. In general, it might be a useless feature and could be removed again.
* stream: minor cleanupswm42014-06-223-10/+7
| | | | | Remove unused stream type constants. Move some now DVD specific crap to stream_dvd.c.
* stream_dvd, stream_dvdnav: map dvd:// to dvdnavwm42014-06-202-3/+3
| | | | The old stream_dvd.c implementation is still available under dvdread://.
* stream_dvd: fix potential endless loop on seekingwm42014-06-201-1/+2
| | | | | Attempt to fix a reported freeze with some DVDs. Unknown if this helps, and it still might read the whole DVD before terminating.
* cache: avoid race condition between cache wakeup and idlingwm42014-06-161-0/+1
| | | | | | | | |