summaryrefslogtreecommitdiffstats
path: root/stream
Commit message (Collapse)AuthorAgeFilesLines
* 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
| | | | | | | | | | When the reader is out of data, it tries to wake up the cache thread to get more data. In theory, there's a small race condition, which could cause the cache to miss the wakeup and idle before reaction. Most certainly didn't cause real issues, because even if this extremely unlikely race condition happens, the cache won't idle for longer than 1 second (the hardcoded cache idle time).
* tv: if timestamp is unset, return NOPTSwm42014-06-141-4/+4
| | | | | | Well, not sure if this really improves anything, but at least it's less of a WTF to the playback core than always returning the same timestamp for every frame.
* tv: remove some non-sensewm42014-06-141-2/+2
| | | | | | There's really no need to convert this to float and then back. This is mostly of cosmetic nature, double precision was probably enough to avoid rounding.
* tv: fix compilation without clock_gettime, don't claim to be MPlayerwm42014-06-141-1/+1
| | | | mp_msg() doesn't exist anymore in this form. Oops.
* tv: add missing header for clock_gettimewm42014-06-131-0/+1
| | | | | | | Not sure how this symbol becomes visible in glibc (probably accidental or mandatory recursive inclusion via the other standard or Linux- specific headers), but normally this include file is needed to get the symbol.
* cache: print cache size only in verbose modewm42014-06-121-2/+2
| | | | Seems pretty useless in general, so this reduces output noise.
* tv: fix a hidden static variablewm42014-06-121-9/+9
|
* stream_bluray: fix some const declarationswm42014-06-121-6/+6
| | | | Like in commit 99f5fe.
* tv: use correct timestampsiive2014-06-121-12/+48
| | | | | | | | | | | | | | | | | | Squashed from the following mplayer-svn commits. The '#' is removed from the bug ID to prevent github from doing something stupid. Instead of adding the mplayer configure check for clock_gettime(), the POSIX identifiers are used for checking presence of the function. Use correct type of timestamps when recording from v4l2. Fix 2176 Patch by Jarek Czekalski <jarekczek at poczta onet pl>. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37222 b3059339-0415-0410-9bf9-f77b7e298cf2 Allow building of v4l2 without clock_gettime(). Add overly verbose message in case monotone timestamps are required by the kernel. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37223 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add more constwm42014-06-1119-31/+31
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* stream_dvd: minor cleanupswm42014-06-113-141/+44
| | | | | We don't need a separate stream_dvd.h header file anymore. Some dead functions become apparent; remove them.
* stream_dvd, stream_dvdnav, stream_bluray: remove global option variableswm42014-06-117-67/+61
|
* stream_dvb: remove global option variableswm42014-06-112-20/+22
|
* stream_cdda: remove global option variableswm42014-06-113-33/+37
|
* stream: add a generic way to setup stream priv defaultswm42014-06-112-0/+3
| | | | | | | | | | | | | | | Usually, each stream driver declares the size and option list of its private data. This was pretty natural for when most streams still used global variables to setup their defaults. They did by pointing priv_defaults to the (mutable) struct containing the option values. But falls short when storing the option values in MPOpts. So provide a somewhat inelegant but simple way to let the stream implementation setup the priv struct at initialization time. This is done with the get_defaults callback. It should return a copy of the struct used in MPOpts. (A copy, because if MPOpts is changed, string fields might be deallocated, and if that field is not described by stream_info.options, it won't be copied on init.)
* stream_pvr: remove global option variableswm42014-06-114-188/+84
|
* tv: remove printing of useless comment informationwm42014-06-114-14/+3
|
* tv: remove global option variableswm42014-06-115-194/+244
| | | | | | Pretty much nothing changes, but using -tv-scan with suboptions doesn't work anymore (instead of "-tv-scan x" it's "-tv scan-x" now). Flat options ("-tv-scan-x") stay compatible.
* command: redo ancient TV/DVB/PVR commandswm42014-06-115-10/+113
| | | | | | | | | | | | | | | | | | Convert all these commands to properties. (Except tv_last_channel, not sure what to do with this.) Also, internally, don't access stream details directly, but dispatch commands with stream ctrls. Many of the new properties are a bit strange, because they're write- only. Also remove some OSD output these commands produced, because I couldn't be bothered to port these. In general, this makes everything much cleaner, and will also make it easier to e.g. move the demuxer to its own thread. Don't bother updating input.conf, but changes.rst documents how old commands map to the new ones. Mostly untested, due to lack of hardware.
* stream/cache: handle failure of seeking underlying streamwm42014-06-051-1/+4
| | | | | | | | | | | | This could for example happen when serving an incomplete file from http, and the demuxer tries reading data from the end of the file when opening it (e.g. with avi). Seeking past EOF fails with http, so the file could never be opened, and the cache would get stuck trying to seek to the position. We can't really make the cache report seek failure directly (it would suck for various reasons), so just make the cache report EOF if seeking fails.
* stream: remove VCD supportwm42014-06-016-989/+0
| | | | | | | | | If a single person complains, I will readd it. But I don't expect that this will happen. The main reason for removing this is that it's some of the most unclean code remaining, it's unmaintained, and I've never ever heard of someone using it.
* tv: remove sysinfo() usagewm42014-05-301-10/+0
| | | | | | This call was used limited the buffer size if installed RAM was below 16 MB. This stopped being useful a decade ago. The check could also overflow on 32 bit systems. Just get rid of it.
* af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriateMarcoen Hirschberg2014-05-281-1/+1
| | | | | | In most places where af_fmt2bits is called to get the bits/sample, the result is immediately converted to bytes/sample. Avoid this by getting bytes/sample directly by introducing af_fmt2bps.
* audio: rename i_