summaryrefslogtreecommitdiffstats
path: root/stream/stream.h
Commit message (Collapse)AuthorAgeFilesLines
* timeline: add edl:// URIswm42013-11-191-0/+1
| | | | | Questionable change from user perspective, but internally needed to implement the next commit. Also useful for testing timeline stuff.
* cosmetics: replace "CTRL" defines by enumswm42013-10-021-25/+27
| | | | Because why not.
* mplayer: attempt to make playback resume work with DVD/BDwm42013-09-221-0/+3
| | | | | | | | | | | | | | | | The problem with DVD/BD and playback resume is that most often, the filename is just "dvd://", while the actual path to the DVD disk image is given with --dvd-device. But playback resume works on the filename only. Add a pretty bad hack that includes the path to the disk image if the filename starts with dvd://, and the same for BD respectively. (It's a bad hack, but I want to go to bed, so here we go. I might revert or improve it later, depending on user feedback.) We have to cleanup the global variable mess around the dvd_device. Ideally, this should go into MPOpts, but it isn't yet. Make the code paths in mplayer.c take MPOpts anyway.
* stream: add uncompressed rar supportwm42013-08-261-0/+1
| | | | | | | | | | | | | | | | | Apparently, it is popular to store large files in uncompressed rar archives. Extracting files is not practical, and some media players suport playing directly from uncompressed rar (at least VLC and some DirectShow components). Storing or accessing files this way is completely idiotic, but it is a common practice, and the ones subjected to this practice can't do much to change this (at least that's what I assume/hope). Also, it's a feature request, so we say yes. This code is mostly taken from VLC (commit f6e7240 from their git tree). We also copy the way this is done: opening a rar file by itself yields a playlist, which contains URLs to the actual entries in the rar file. Compressed entries are simply skipped.
* stream: change open code, add stream filter conceptwm42013-08-261-1/+8
| | | | | | | | | | Add a stream filter concept, in which streams can be opened on top of an underlying "source" stream. Change the open code to make this easier, and also to account for some mechanisms that will be needed for this. The following commit will add stream_rar, which contains such a stream filter.
* stream: fix url_options field, make protocols field not fixed lengthwm42013-08-261-2/+2
| | | | | | | | | | | | | | | | | | | | The way the url_options field was handled was not entirely sane: it's actually a flexible array member, so it points to garbage for streams which do not initialize this member (it just points to the data right after the struct, which is garbage in theory and practice). This was not actually a problem, since the field is only used if priv_size is set (due to how this stuff is used). But it doesn't allow setting priv_size only, which might be useful in some cases. Also, make the protocols array not a fixed size array. Most stream implementations have only 1 protocol prefix, but stream_lavf.c has over 10 (whitelists ffmpeg protocols). The high size of the fixed size protocol array wastes space, and it is _still_ annoying to add new prefixes to stream_lavf (have to bump the maximum length), so make it arbitrary length. The two changes (plus some more cosmetic changes) arte conflated into one, because it was annoying going over all the stream implementations.
* core: add a playlist demuxerwm42013-08-261-0/+2
| | | | | | | | | Modeled after the old playlist_parser.c, but actually new code, and it works a bit differently. Demuxers (and sometimes streams) are the component that should be used to open files and to determine the file format. This was already done for subtitles, but playlists still use a separate code path.
* stream: move file forward skipping to common stream implementationwm42013-08-221-0/+1
| | | | | | | | | | | stream_file.c contains some code meant for forward seeking with pipes. This simply reads data until the seek position is reached. Move this code to stream.c. This stops stream_file from doing strange things (messing with stream internals), and removes the code duplication too. We also make stream_seek_long() use the new skip code. This is shorter and much easier to follow than the old code, which basically did strange things.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-2/+2
| | | | Followup commit. Fixes all the files references.
* stream: parse URL escapes for file://wm42013-08-021-0/+2
| | | | | | | | | | | | | | | | | So for example "file:///file%20name.mkv" will open "file name.mkv". I'm not sure whether we want/need this. The old code didn't do it. Also, it's not really clear whether this is handled correctly. It seems the corresponding freedesktop.org "standard" allows a (useless) hostname part, which we should skip in theory. The number of slashes is not really clear either. We can open relative filenames (by removing one of the slashes from the example above), which is perhaps an unneeded feature. How does this even work with Windows paths? This issues can probably be corrected later. The URL unescape code is based on code from m_option.c removed with a recent commit.
* stream: redo URL parsing, replace m_struct usage with m_configwm42013-08-021-6/+9
| | | | | | | | | | | | | Move the URL parsing code from m_option.c to stream.c, and simplify it dramatically. This code originates from times when http code used this, but now it's just relict from other stream implementations reusing this code. Remove the unused bits and simplify the rest. stream_vcd is insane, and the priv struct is different on every platform, so drop the URL parsing. This means you can't specify a track anymore, only the device. (Does anyone use stream_vcd? Not like this couldn't be fixed, but it doesn't seem worth the effort, especially because it'd require potentially touching platform specific code.)
* Merge branch 'remove_old_demuxers'wm42013-07-141-65/+16
|\ | | | | | | | | | | | | | | The merged branch doesn't actually just remove old demuxers, but also includes a branch of cleanups and some refactoring. Conflicts: stream/stream.c
| * stream: remove useless author/comment fieldswm42013-07-121-3/+0
| | | | | | | | | | | | | | | | | | These were printed only with -v. Most streams had them set to useless or redundant values, so it's just badly maintained bloat. Since we remove the "author" field too, and since this may have copyright implications, we add the contents of the author fields to the file headers, except if the name is already part of the file header.
| * stream: remove unused functionswm42013-07-121-36/+0
| | | | | | | | These were used by old demuxers.
| * stream: remove fd memberwm42013-07-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stream implementations could set this to a unix file descriptor. The generic stream code could use it as fallback for a few things. This was confusing and insane. In most cases, the stream implementations defined all callbacks, so setting the fd member didn't have any advantages, other than avoiding defining a private struct to store it. It appears that even if the stream implementation used close() on the fd (or something equivalent), stream.c would close() it a second time (and on windows, even would call closesocket()), which should be proof for the insanity of this code. For stream_file.c, additionally make sure we don't close stdin or stdout if "-" is used as filename. For stream_vcd.c, remove the control() code. This code most likely didn't make the slightest sense, because it used a different type for stream->priv. It also leaked memory. Maybe it worked, but it's incorrect and insignificant anyway, so kill it. This code was added with commit 9521c19 (svn commit 31019). Untested for all protocols other than stream_file.c.
| * stream: don't require streams to set a typewm42013-07-121-21/+13
| | | | | | | | | | Set the type only for streams that have special treatment in other parts of the code.
| * core: change open_stream and demux_open signaturewm42013-07-121-4/+3
| | | | | | | | | | | | | | | | | | | | | | This removes the dependency on DEMUXER_TYPE_* and the file_format parameter from the stream open functions. Remove some of the playlist handling code. It looks like this was needed only for loading linked mov files with demux_mov (which was removed long ago). Delete a minor bit of dead network-related code from stream.c as well.
* | options: add --cache-default optionwm42013-07-101-3/+1
|/ | | | | | | | | | | | Add this option, which lets users set the cache size without forcing it even when playing from the local filesystem. Also document the default value explicitly. The Matroska linked segments case is slightly simplified: they can never come from network (mostly because it'd be insane, and we can't even list files from network sources), so the cache will never be enabled automatically.
* stream: remove weird STREAMTYPE_STREAM special handlingwm42013-07-071-1/+0
| | | | | | | | | This was an old leftover from an earlier cleanup (which happened in 2003), and which used "special" stuff for streams that could be only forward-seeked. Also, don't add mode flags to s->flags; they're supposed to be in s->mode instead.
* Remove internal network supportwm42013-07-071-29/+0
| | | | | | | | | | | This commit removes the "old" networking code in favor of libavformat's code. The code was still used for mp_http, udp, ftp, cddb. http has been mapped to libavformat's http support since approximately 6 months ago. udp and ftp have support in ffmpeg (though ftp was added only last month). cddb support is removed with this commit - it's probably not important and rarely used if at all, so we don't care about it.
* core: update metadata during playback, allow streams to export metadatawm42013-07-021-0/+1
| | | | | | | STREAM_CTRL_GET_METADATA will be used to poll for streamcast metadata. Also add DEMUXER_CTRL_UPDATE_INFO, which could in theory be used by demux_lavf.c. (Unfortunately, libavformat is too crappy to read metadata mid-stream for mp3 or ogg, so we don't implement it.)
* stream: redo memory streamswm42013-06-281-0/+2
| | | | | Make memory streams actual streams. This causes fewer weird corner cases and actually allows using demuxers with them.
* stream: remove stream_unread_buffer()wm42013-06-251-1/+0
| | | | Replaced with stream_peek().
* stream: add stream_peek functionwm42013-06-251-0/+1
| | | | | Makes probing easier, and this is perhaps a simpler interface than stream_unread_buffer().
* stream: readd memory streamswm42013-06-251-0/+1
|
* stream: remove padding parameter from stream_read_complete()wm42013-06-231-7/+2
| | | | | | | | Seems like a completely unnecessary complication. Instead, always add a 1 byte padding (could be extended if a caller needs it), and clear it. Also add some documentation. There was some, but it was outdated and incomplete.
* stream: remove stream_reset()wm42013-06-161-1/+0
| | | | | | | | | This function was called in various places. Most time, it was used before a seek. In other cases, the purpose was apparently resetting the EOF flag. As far as I can see, this makes no sense anymore. At least the stream_reset() calls paired with stream_seek() are completely pointless. A seek will either seek inside the buffer (and reset the EOF flag), or do an actual seek and reset all state.
* stream: cosmeticswm42013-06-161-10/+6
|
* cache: use threads instead of fork()wm42013-06-161-5/+1
| | | | | | | | | | | | | | | | | | | Basically rewrite all the code supporting the cache (i.e. anything other than the ringbuffer logic). The underlying design is untouched. Note that the old cache2.c (on which this code is based) already had a threading implementation. This was mostly unused on Linux, and had some problems, such as using shared volatile variables for communication and uninterruptible timeouts, instead of using locks for synchronization. This commit does use proper locking, while still retaining the way the old cache worked. It's basically a big refactor. Simplify the code too. Since we don't need to copy stream ctrl args anymore (we're always guaranteed a shared address space now), lots of annoying code just goes away. Likewise, we don't need to care about sector sizes. The cache uses the high-level stream API to read from other streams, and sector sizes are handled transparently.
* stream: add partial read functionwm42013-06-161-0/+1
| | | | | This is a nice way to avoid an additional copy of the data when reading with stream_read().
* stream: add stream_unread_buffer()wm42013-06-161-3/+7
| | | | | | | | | | | | | | | | | | | | | | demux_lavf probes up to 2 MB of data in the worst case. When the ffmpeg demuxer is actually opened, the stream is seeked back to 0, and the previously read data is thrown away. This wasn't a problem for playback of local files, but it's less than ideal for playing from slow media (like web streams), and breaks completely if the media is not seekable (pipes, some web streams). This new function is intended to allow fixing this. demux_lavf will use it to put the read probe data back into the buffer. The simplest way of implementing this function is by making it transparently extend the normal stream buffer. This makes sure no existing code is broken by new weird special cases. For simplicity and to avoid possible performance loss due to extra dereferencing when accessing the buffer, we just extend the static buffer from 8 KB to 2 MB. Normally, most of these 2 MB will stay uncommitted, so there's no associated waste of memory. If demux_lavf really reads all 2 MB, the memory will be committed and stay unused, though.
* cache: make the stream cache a proper stream that wraps other streamswm42013-06-161-27/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, the cache was franken-hacked on top of the stream API. You had to use special functions (like cache_stream_fill_buffer() instead of stream_fill_buffer()), which would access the stream in a cached manner. The whole idea about the previous design was that the cache runs in a thread or in a forked process, while the cache awa functions made sure the stream instance looked consistent to the user. If you used the normal functions instead of the special ones while the cache was running, you were out of luck. Make it a bit more reasonable by turning the cache into a stream on its own. This makes it behave exactly like a normal stream. The stream callbacks call into the original (uncached) stream to do work. No special cache functions or redirections are needed. The only different thing about cache streams is that they are created by special functions, instead of being part of the auto_open_streams[] array. To make things simpler, remove the threading implementation, which was messed into the code. The threading code could perhaps be kept, but I don't really want to have to worry about this special case. A proper threaded implementation will be added later. Remove the cache enabling code from stream_radio.c. Since enabling the cache involves replacing the old stream with a new one, the code as-is can't be kept. It would be easily possible to enable the cache by requesting a cache size (which is also much simpler). But nobody uses stream_radio.c and I can't even test this thing, and the cache is probably not really important for it either.
* stream: remove unused functionwm42013-06-091-9/+0
|
* stream: move VCD specific stuff to stream_vcdwm42013-06-091-4/+0
| | | | I don't even know what VCDs are. A prehistoric version of the DVD or so.
* core: use STREAM_CTRL instead of accessing stream_dvd internalswm42013-06-091-0/+6
| | | | | | | | | | | | Some code in mplayer.c did stuff like accessing (dvd_priv_t *)st->priv. Do this indirectly by introducing STREAM_CTRL_GET_DVD_INFO. This is extremely specific to DVD, so it's not worth abstracting this further. This is a preparation for turning the cache into an actual stream, which simply wraps the cached stream. There are other streams which are accessed in the way DVD was, at least TV/radio/DVB. We assume these can't be used with the cache. The code doesn't look thread-safe or fork aware.
* stream: kill STREAM_CTRL_RESETwm42013-05-261-1/+0
| | | | Was unused.
* stream: kill memory streamswm42013-05-261-3/+0
| | | | | These are unused by now, and it relied on some assumptions that have been broken by now.
* stream: de-inline some larger functionswm42013-05-261-70/+3
| | | | | | | | | | | | | | | | Tests with demux_mkv show that the speed doesn't change (or actually, it seems to be faster after this change). In any case, there is not the slightest reason why these should be inline. Functions for which this will (probably) actually matter, like stream_read_char, are still left inline. This was tested with demux_mkv's indexing. For broken files without index, demux_mkv creates an on-the-fly index. If you seek to a later part of the file, all data has to be read and parsed until the wanted position is found. This means demux_mkv will do mostly I/O, calling stream_read_char() and stream_read(). This should be the most I/O intensive non-deprecated part of mpv that uses the stream interface. (demux_lavf has its own buffering.)
* core: add --stream-capturewm42013-05-121-0/+6
| | | | | | This is a partial revert of commit 7059c15, and basically re-adds --capture, just with different option names and slightly different semantics.
* stream: report chapter times, use time seeks for DVD chapterswm42013-05-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Allow the stream layer to report chapter times. Extend stream_dvd to do this. I'm not 100% sure whether the re-used code is bug-free (because it was used for slave-mode and/or debugging only). MAke the frontend do time-based seeks when switching DVD chapters. I'm not sure if there's a real reason STREAM_CTRL_SEEK_TO_CHAPTER exists (maybe/hopefully not), but we will see. Note that querying chapter times in demuxer_chapter_time() with the new STREAM_CTRL_GET_CHAPTER_TIME could be excessively slow, especially with the cache enabled. The frontend likes to query chapter times very often. Additionally, stream_dvd uses some sort of quadratic algorithm to list times for all chapters. For this reason, we try to query all chapters on start (after the demuxer is opened), and add the chapters to the demuxer chapter list. demuxer_chapter_time() will get the time from that list, instead of asking the stream layer over and over again. This assumes stream_dvd knows the list of chapters at the start, and also that the list of chapters never changes during playback. This seems to be true, and the only exception, switching DVD titles, is not supported at runtime (and doesn't need to be supported).
* stream: add start time reportingwm42013-05-051-0/+1
| | | | | | Will be needed to override the demuxer's start time reporting. We could be lazy and special-case it since the result is always 0 for the streams that care, but doing it properly is better.
* core: don't report byte-based playback position with dvdwm42013-05-051-0/+4
| | | | | | | | | | DVD playback uses a demuxer that signals to the frontend that timestamp resets are possible. This made the frontend calculate the OSD playback position based on the byte position and the total size of the stream. This actually broke DVD playback position display. Since DVD reports a a linear playback position, we don't have to rely on the demuxer reported position, so disable this functionality in case of DVD playback. This reverts the OSD behavior with DVD to the old behavior.
* stream: remove unused new_ds_stream()wm42013-05-031-2/+0
|
* stream_bluray: remove the broken -bluray-chapter optionreimar2013-04-271-2/+1
| | | | | | | | | | Remove the broken -bluray-chapter option. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36175 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: DOCS/man/en/mplayer.1 cfg-common.h
* stream: fix reconnecting on broken network connectionswm42013-01-241-0/+1
| | | | | | | | | | | | | | | | This didn't work properly for HTTP with libavformat. The builtin HTTP implementation reconnects automatically on its own, while libavformat doesn't. Fix this by adding explicit reconnection support to stream_lavf.c, which simply destroys and recreates the AVIO context. It mostly works, though sometimes it mysteriously fails, spamming crap all over the terminal and feeding broken data to the decoders. This is probably due to itneractions with the cache. Also, reconnecting to unseekable HTTP streams will make it read the entire stream until the previous playback position is reached again. It's not known whether this change makes behavior with "strange" protocols like RTP better or worse.
* stream: uncrustify stream.c/.hwm42013-01-241-173/+203
| | | | The formatting almost made me break out in tears.
* stream_lavf/demux_lavf: export/use HTTP MIME typewm42012-12-111-0/+1
| | | | | | | | | | | | | | | | | This is a fix for web radio streams that send raw AAC [1]. libavformat's AAC demuxer probe is picky enough to request hundreds of KBs data, which makes for a slow startup. To speed up stream startup, try use the HTTP MIME type to identify the format. The webstream in question sends an AAC specific MIME type, for which demux_lavf will force the AAC demuxer, without probing anything. ffmpeg/ffplay do the same thing. Note that as of ffmpeg commit 76d851b, av_probe_input_buffer() does the mapping from MIME type to demuxer. The actual mapping is not publicly accessible, and can only be used by calling that function. This will hopefully be rectified, and ideally ffmpeg would provide a function like find_demuxer_from_mime_type(). [1] http://lr2mp0.latvijasradio.lv:8000
* stream: handle mms streaming with ffmpegwm42012-12-111-1/+1
| | | | | | | | | | | | | | | | | | | | Use ffmpeg (stream_lavf) instead of internal mms support (asf_streaming.c) for mms://, mmsh://, mmst:// URLs. The old implementation is available under mp_mms:// etc. There are some caveats with this: - mms:// now always maps to mmsh://. It won't try mmst://. (I'm not sure if mms:// URLs really can use the mmst protocol, though.) - MMS streams under the http:// prefix are not handled. (ffmpeg ticket #2001.) (Was already broken in mpv since c02f25.) - It downloads all video streams now. MMS streams often have redundant video streams, which encode the main stream at different quality. The client is supposed to select one according to its bandwidth requirements. (Explicit MMS stream selection has been broken in mpv for a while, because MPOpts.vid maps to the stream number, not the demuxer's stream ID - but the old logic doesn't work anyway when using demuxer_lavf as opposed to demux_asf.)
* core: automatically pause on low cachewm42012-12-031-0/+1
| | | | |