summaryrefslogtreecommitdiffstats
path: root/stream/stream.h
Commit message (Collapse)AuthorAgeFilesLines
* stream: use native libavformat reconnection featurewm42018-01-041-1/+0
| | | | | | | | | | | | | | | | | | Remove our own hacky reconnection code, and use libavformat's feature for that. It's disabled by default, and until recently it did not work too well. This has been fixed in recent ffmpeg git master[1], so there's no reason to keep our own code. [1] FFmpeg/FFmpeg@8a108bdea06fac43af9f44b6d2538f357451167a We set "reconnect_delay_max" to 7, which limits the maximum time it waits. Since libavformat doubles the wait time on each reconnect attempt (starting with 1), and stops trying to reconnect once the wait time is over the reconnect_delay_max value, this allows for 4 reconnection attempts which should add to 11 seconds maximum wait time. The default is 120, which seems too high for normal playback use. (The user can still override these parameters with --stream-lavf-o.)
* stream: change license to LGPLwm42017-06-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All relevant authors have agreed. There are two exceptions, patches by authors who could not be reached. This commit tries to remove their copyright. a0f08fbe: messes with the seeking code corner cases. The EOF flag logic was changed at some point, and always had a flaky history (see e.g. 347cf972 50274ca3 70411f27 5999efb9 0d5e6084 ff08d0c3 2e2f77e3 de5566f0 9554a844, all which happened after that patch, MPlayer ones without that patch). I claim that all of the copyright the patch might have added is gone. Except the message in stream_seek(), which this commit removes. The other code removed/changed in stream_seek() is probably not from that patch, but it doesn't hurt to be sure, and also makes it more readable. (It might change the behavior so that sometimes the eof flag is set after a seek, but it doesn't matter here.) 2aa6acd9: it looks like the seek_forward() modified by this patch was later moved to stream.c and renamed to stream_skip_read() in a790f2133. (Looking closer at it, it was actually modified again a bunch of times, fixing the logic.) I rewrote it in this commit. The code ended up rather similar, which probably could lead to doubts whether this was done properly, but I guess the reader of this will just have to believe me. I knew what stream_skip_read() was supposed to do (which was reinforced when I tried to replace it on the caller side), without reading the pre-existing code in detail. I had to "relearn" the logic how buf_pos and bug_len work - it was actually easy to see from stream_read_char() how to skip the data, essentially by generalizing its logic from 1 byte to N bytes. From the old code I only "used" the fact that it's obviously a while(len>0) look, that has to call stream_fill_buffer repeatedly to make progress. At first I actually didn't use stream_fill_buffer_by(), but the variant without _by, but readded it when I checked why the old code used it (see cd7ec016e7). This has to be good enough. In the end, it's hard to argue that this could be implemented in a way not using such a loop. Other than this, I could add the usual remarks about how this code was not modularized in the past, and how stream.c contained DVD code, and how this was later modularized, moving the copyright to other files, and so on. Also, if someone wrote a stream module, and was not asked about LGPL relicensing, we don't consider the entry in stream_list[] copyrightable.
* stream: get rid of streamtype enumwm42017-02-021-16/+2
| | | | | | | | | Because it's kind of dumb. (But not sure if it was worth the trouble.) For stream_file.c, we add new explicit fields. The rest are rather special uses and can be killed by comparing the stream impl. name. The changes to DVD/BD/CD/TV are entirely untested.
* stream: better method signal caching, rename weird uncached_stream fieldwm42017-02-021-1/+2
| | | | | | | | "uncached_stream" is a pretty bad name. It could be mistaken for a boolean, and then its meaning would be inverted. Rename it. Also add a "caching" field, which signals that the stream is a cache or reads from a cache. This is easier to understand and more flexible.
* player: remove --stream-capture option/propertywm42017-01-211-5/+0
| | | | | | | | | | | | | | | This was excessively useless, and I want my time back that was needed to explain users why they don't want to use it. It captured the byte stream only, and even for types of streams it was designed for (like transport streams), it was rather questionable. As part of the removal, un-inline demux_run_on_thread() (which has only 1 call-site now), and sort of reimplement --stream-dump to write the data directly instead of using the removed capture code. (--stream-dump is also very useless, and I struggled coming up with an explanation for it in the manpage.)
* demux, stream: add option to prevent opening referenced fileswm42016-12-041-0/+1
| | | | Quite irresponsibly hacked together. Sue me.
* stream, demux, config: remove some dead/unneeded option-related codewm42016-09-091-13/+0
| | | | | | | | | | This has all been made unnecessary recently. The change not to copy the global option struct in particular can be made because now nothing accesses the global options anymore in the demux and stream layers. Some code that was accidentally added/changed in commit 5e30e7a0 is also removed, because it was simply committed accidentally, and was never used.
* stream_dvd, stream_dvdnav: remove weird option parsing stuffwm42016-09-081-0/+7
| | | | | | Same deal as with stream_bluray. Untested because I don't give a fuck about your shitty DVDs.
* demux: do not access global optionswm42016-09-061-3/+2
| | | | | | | | | | | | | | | | | Don't access MPOpts directly, and always use the new m_config.h functions for accessing them in a thread-safe way. The goal is eventually removing the mpv_global.opts field, and the demuxer/stream-layer specific hack that copies MPOpts to deal with thread-safety issues. This moves around a lot of options. For one, we often change the physical storage location of options to make them more localized, but these changes are not user-visible (or should not be). For shared options on the other hand it's better to do messy direct access, which is worrying as in that somehow renaming an option or changing its type would break code reading them manually, without causing a compilation error.
* client API: add stream_cb API for user-defined stream implementationsAman Gupta2016-08-071-0/+1
| | | | | | Based on #2630. Some heavy changes by committer. Signed-off-by: wm4 <wm4@nowhere>
* cache: use a single STREAM_CTRL for various cache infowm42016-03-291-4/+9
| | | | | | | | Instead of having a separate for each, which also requires separate additional caching in the demuxer. (The demuxer adds an indirection, since STREAM_CTRLs are not thread-safe.) Since this includes the cache speed, this should fix #3003.
* command: add cache-speed propertywm42016-03-201-0/+1
| | | | | | | Should reflect I/O speed. This could go into the terminal status line. But I'm not sure how to put it there, since it already uses too much space, so it's not there yet.
* cache: remove unused STREAM_CTRL_RESUME_CACHEwm42016-03-031-1/+0
| | | | Went way with DVD/BD menu support.
* cache: add mechanism for disabling readaheadwm42016-01-181-0/+1
| | | | Will be used in a following commit.
* player, stream_dvb: implement dvb-channel-name property.Oliver Freyermuth2016-01-141-0/+2
| | | | | | | | | On read, it returns the name of the current DVB program, on write, it triggers a channel-switch to the program if it is found in the channel list of the currently active card. Compared to the dvb-channel property which already exists and is a pair of integers (card + channel number) this has the limitation of not switching the card, but is probably of much more common use.
* stream: provide a stream_get_size() convenience functionwm42015-08-181-0/+1
| | | | | And use it everywhere, instead of retrieving the size manually. Slight simplification.
* stream: remove remaining DVD/BD menu definitionswm42015-08-031-2/+0
|
* vo_opengl: add support for custom shadersNiklas Haas2015-05-271-0/+2
|
* command: add protocol-list propertywm42015-05-231-0/+1
| | | | Fixes #1972.
* player: allow playing directorieswm42015-04-171-0/+1
| | | | | | | | | | | If a directory is encountered, replace it with its contents in the internal playlist. This is messed into demux_playlist.c, because why not. STREAMTYPE_DIR could be avoided by unconditonally trying opendir() in demux_playlist.c, but it seems nicer not to do weird things like calling it on real files. This does not work on Windows, because msvcrt is retarded.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* player: refine rar:// playlist-safety handlingwm42015-03-021-1/+0
| | | | | | | | | | | | It was possible to make the player play local files by putting rar:// links into remote playlists, and some other potentially unsafe things. Redo the handling of it. Now the rar-redirector (the thing in demux_playlist.c) sets disable_safety, which makes the player open any playlist entries returned. This is fine, because it redirects to the same file anyway (just with different selection/interpretation of the contents). On the other hand, rar:// itself is now considered fully unsafe, which means that it is ignored if found in normal playlists.
* stream: remove stream filter conceptwm42015-02-271-3/+0
| | | | Unused since the previous commit. (Apparently it was a stupid idea.)
* stream: get rid of remaining uses of the end_pos fieldwm42015-02-061-2/+1
| | | | | | | | Most things stopped using this field for better support of growing files. Go through the trouble to repalce the remaining uses, so it can be removed. Also move the "streaming" field; saves 4 bytes (wow!).
* stream: minor cleanupswm42015-02-061-2/+2
| | | | | | | | | | | | | | | | Fix return types and return values to make them more consistent. Some reformatting and making code more concise. In stream_reconnect(), avoid the additional mp_cancel_test() call by moving the "connection lost" message below the mp_cancel_wait() call, which effectively leads to the same behavior when the stream was already canceled. (The goal is not to show the message in this case.) Merge stream_seek_long() into stream_seek(). It was the only caller. Always clear the eof flag on seeks. Reduce access to stream internals in cache.c and stream_lavf.c.
* stream: slightly improve reconnect behaviorwm42015-02-061-0/+1
| | | | | Wait for a longer time between reconnects. Introdeuce and use mp_cancel_wait(), so that quitting is still immediate.
* command: add dummy get implementation for tv-channel propertywm42015-02-021-0/+1
| | | | | A small cosmetic change with the effect that pressing 'k' shows "unavailable" instead of "error" (even if no TV code is active).
* command, dvd: add property which returns list of DVD titleswm42014-12-131-22/+35
| | | | | | | | | This was requested. It seems libdvdread can't get the duration for titlesets other than the currently opened title. The data structures contain dangling pointers for these, and MPlayer works this around by opening every title separately for the purpose of dumping the title list.
* stream: reduce ifdeffery for win32 somewhatwm42014-11-181-4/+1
| | | | Remove the ones which are not strictly needed.
* stream: signal a Windows event object on cancelJames Ross-Gowan2014-11-181-0/+4
| | | | | This will be used in the following commit to cancel subprocesses started by Lua.
* demux_lavf: mark as seekable if protocol supports seeking by timewm42014-10-301-0/+1
| | | | | | | | | | | | Basically, this will mark the demuxer as seekable with rtmp* and mmsh protocols. These protocols have network-level time seeking, and whether you can seek on the byte level does not matter. Until now, seeking was typically only enabled because of the cache, and a (nonsensical) warning was shown accordingly. It still could happen that the server doesn't actually support thse requests (or simply rejects them), so this is somewhat imperfect.
* lua: add an utility function for starting processeswm42014-10-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because 1) Lua is terrible, and 2) popen() is terrible. Unfortunately, since Unix is also terrible, this turned out more complicated than I hoped. As a consequence and to avoid that this code has to be maintained forever, add a disclaimer that any function in Lua's utils module can disappear any time. The complexity seems a bit ridiculous, especially for a feature so far removed from actual video playback, so if it turns out that we don't really need this function, it will be dropped again. The motivation for this commit is the same as with 8e4fa5fc. Note that there is an "#ifndef __GLIBC__". The GNU people are very special people and thought it'd be convenient to actually declare "environ", even though the POSIX people, which are also very special people, state that no header declares this and that the user has to declare this manually. Since the GNU people overtook the Unix world with their very clever "embrace, extend, extinguish" strategy, but not 100%, and trying to build without _GNU_SOURCE is hopeless; but since there might be Unix environments which support _GNU_SOURCE features partially, this means that in practice "environ" will be randomly declared or not declared by system headers. Also, gcc was written by very clever people too, and prints a warning if an external variable is declared twice (I didn't check, but I suppose redeclaring is legal C, and not even the gcc people are clever enough to only warn against a definitely not legal C construct, although sometimes they do this), ...and since we at mpv hate compiler warnings, we seek to silence them all. Adding a configure test just for a warning seems too radical, so we special-case this against __GLIBC__, which is hopefully not defined on other libcs, especially not libcs which don't implement all aspects of _GNU_SOURCE, and redefine "environ" on systems even if the headers define it already (because they support _GNU_SOURCE - as I mentioned before, the clever GNU people wrote software THAT portable that other libcs just gave up and implemented parts of _GNU_SOURCE, although probably not all), which means that compiling mpv will print a warning about "environ" being redefined, but at least this won't happen on my system, so all is fine. However, should someone complain about this warning, I will force whoever complained about this warning to read this ENTIRE commit message, and if possible, will also force them to eat a printed-out copy of the GNU Manifesto, and if that is not enough, maybe this person could even be forced to convince the very clever POSIX people of not doing crap like this: having the user to manually declare somewhat central symbols - but I doubt it's possible, because the POSIX people are too far gone and only care about maintaining compatibility with old versions of AIX and HP-UX. Oh, also, this code contains some subtle and obvious issues, but writing about this is not fun.
* demux_lavf: set stream network options if applicablewm42014-10-141-0/+7
| | | | | | | | | | | Normally, we pass libavformat demuxers a wrapped mpv stream. But in some cases, such as HLS and RTSP, we let libavformat open the stream itself. In these cases, set typical network properties like useragent according to the mpv options. (We still don't set it for the cases where libavformat opens other streams on its own, e.g. when opening the companion .sub file for .idx files - not sure if we maybe should always set these options.)
* stream_dvd: better .ifo probingwm42014-09-251-0/+1
| | | | | | | | | | | | | | | 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.
* stream: redo playback abort handlingwm42014-09-131-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* player: don't allow remote playlists to load local fileswm42014-09-011-2/+5
| | | | | | | | 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-311-0/+3
| | | | | | | | | 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.
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | 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: hack-fix rtmp-level seekingwm42014-07-301-0/+8
| | | | | | | | | | | | | 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.
* Revert "Remove DVD and Bluray support"wm42014-07-151-0/+9
| | | | | | This reverts commit 4b93210e0c244a65ef10a566abed2ad25ecaf9a1. *shrug*
* Remove DVD and Bluray supportwm42014-07-141-9/+0
| | | | It never worked well. Just remux your DVD and BD images to mkv.
* stream: remove now unused STREAM_CTRL_GET_START_TIMEwm42014-07-061-1/+0
| | | | demux_disc.c takes care of this now.
* dvd, bluray, cdda: add demux_disc containing all related hackswm42014-07-051-4/+1
| | | | | | | | | | | | 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.
* options: add --list-protocols optionAlessandro Ghedini2014-06-301-0/+2
|
* stream: add a file cachewm42014-06-221-0/+2
| | | | | | | | | 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-221-9/+0
| | | | | Remove unused stream type constants. Move some now DVD specific crap to stream_dvd.c.
* Add more constwm42014-06-111-2/+2
| | | | | | | 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, stream_dvdnav, stream_bluray: remove global option variableswm42014-06-111-9/+0
|
* stream_cdda: remove global option variableswm42014-06-111-1/+1
|
* stream: add a generic way to setup stream priv defaultswm42014-06-111-0/+1
| | | | | | | | | | | | | | | 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.)
* command: redo ancient TV/DVB/PVR commandswm42014-06-111-1/+19
| | | | | | | | | | | | | | | | | | 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: remove chaos related to writeable streamswm42014-05-241-1/+2