summaryrefslogtreecommitdiffstats
path: root/stream
Commit message (Collapse)AuthorAgeFilesLines
* demux: change signature of open functions, cleanupswm42013-07-111-19/+15
| | | | Preparation for redoing the open functions.
* video: eliminate frametime variablewm42013-07-111-2/+0
|
* core: don't access demux_stream outside of demux.c, make it privatewm42013-07-111-1/+1
| | | | | | | | | | | | | | | | | | | Generally remove all accesses to demux_stream from all the code, except inside of demux.c. Make it completely private to demux.c. This simplifies the code because it removes an extra concept. In demux.c it is reduced to a simple packet queue. There were other uses of demux_stream, but they were removed or are removed with this commit. Remove the extra "ds" argument to demux fill_buffer callback. It was used by demux_avi and the TV pseudo-demuxer only. Remove usage of d_video->last_pts from the no-correct-pts code. This field contains the last PTS retrieved after a packet that is not NOPTS. We can easily get this value manually because we read the packets ourselves. Reuse sh_video->last_pts to store the packet PTS values. It was used only by the correct-pts code before, and like d_video->last_pts, it is reset on seek. The behavior should be exactly the same.
* tv: add hack in preparation of demux_stream removalwm42013-07-111-4/+17
| | | | | | | | | | Currently, all demuxer fill_buffer functions have a demux_stream parameter. We want to remove that, but the TV code still depends on it. Add a hack to remove that dependency. The problem with the TV code is that reading video and audio frames blocks, so in order to avoid a deadlock, you should read either of them only if the decoder actually requests new data.
* mplayer: fix incorrect audio sync after format changeswm42013-07-111-1/+1
| | | | | | | | | | | This is not directly related to the handling of format changes itself, but playing audio normally after the change. This was broken: the output byte rate was not recalculated, so audio-video sync was simply broken. Fix this by calculating the byte rate on the fly, instead of storing it in sh_audio. Format changes are relatively common (switches between stereo and 5.1 in TV recordings), so this fixes a somewhat critical bug.
* Merge branch 'master' into remove_old_demuxerswm42013-07-084-26/+6
|\ | | | | | | | | | | Conflicts: DOCS/man/en/changes.rst DOCS/man/en/options.rst
| * cache: fix compilation without posix timersStefano Pigozzi2013-07-081-0/+1
| | | | | | | | | | | | This is a regression caused by 854303a. This commit removed the include of `sys/time.h` which was included in `cache.c` through a chain of recurvive includes.
| * stream/tv: remove unused dshow-specific optionsMartin Herkt2013-07-082-26/+1
| |
| * stream_radio: fix buildwm42013-07-081-0/+4
| | | | | | | | | | | | | | This was accidentally broken with 37c5c11 and has been nroken for 5 months. Does anyone (want to) use this at all?
* | demux: remove separate arrays for audio/video/sub streams, simplifywm42013-07-081-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | These separate arrays were used by the old demuxers and are not needed anymore. We can simplify track switching as well. One interesting thing is that stream/tv.c (which is a demuxer) won't respect --no-audio anymore. It will probably work as expected, but it will still open an audio device etc. - this is because track selection is now always done with the runtime track switching mechanism. Maybe the TV code could be updated to do proper runtime switching, but I can't test this stuff.
* | demux: remove some old stream header functionswm42013-07-081-2/+4
| |
* | Remove old demuxerswm42013-07-072-2/+2
|/ | | | | | | | | | Delete demux_avi, demux_asf, demux_mpg, demux_ts. libavformat does better than them (except in rare corner cases), and the demuxers have a bad influence on the rest of the code. Often they don't output proper packets, and require additional audio and video parsing. Most work only in --no-correct-pts mode. Remove them to facilitate further cleanups.
* stream: unbreak streams with large sector sizes (stream_cdda)wm42013-07-071-1/+2
| | | | | | | Commit 7b16d4b changed some stream implementations to check the buffer size passed to them. This made stream_cdda stop working, because the default buffer size is smaller than the CDIO frame size. So pass the sector size instead of the (arbitrary) default buffer size.
* stream: don't treat position 0 speciallywm42013-07-071-7/+6
| | | | | | | | | Seeking to position 0 meant to try reconnecting with some streams, actually just the internal http implementation. This has been removed, so we don't need the special handling anymore. This means we don't have to be stuck in a retry loop if the stream doesn't even support reconnect.
* Remove some leftovers from network removalwm42013-07-073-182/+1
| | | | | | | | stream_vstream.c in particular was actually dependent on the network code, and didn't compile anymore. Cleanup the protocol list in mpv.rst, and add some missing ones supported by libavformat to stream_lavf.c.
* stream: remove weird STREAMTYPE_STREAM special handlingwm42013-07-076-50/+27
| | | | | | | | | 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.
* stream: re-add accidentally removed seek callwm42013-07-071-0/+7
| | | | | | | This was under CONFIG_NETWORKING, so in theory it should have been save to remove. But actually this disables forward skipping when reading from a pipe. (Still a questionable feature, because it doesn't behave well with libavformat - but it was not supposed to be changed.)
* Remove internal network supportwm42013-07-0722-5996/+9
| | | | | | | | | | | 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: make network options available even if old net code is disabledwm42013-07-075-23/+3
| | | | Preparation for removing the old network code.
* stream: make eof flag more consistentwm42013-07-041-1/+6
| | | | | | When reading something successfully, the eof flag should never be 1, so clear it in these situations. The eof flag will be set properly on the next read call.
* stream_lavf: request and read streamcast/ICY metadatawm42013-07-021-4/+89
| | | | Requires recent ffmpeg git, otherwise will do nothing.
* core: update metadata during playback, allow streams to export metadatawm42013-07-022-1/+23
| | | | | | | 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.)
* cache: fix per-block metadata memory leakwm42013-07-021-0/+1
|
* stream: redo memory streamswm42013-06-283-8/+91
| | | | | Make memory streams actual streams. This causes fewer weird corner cases and actually allows using demuxers with them.
* Merge branch 'sub_mess2'wm42013-06-252-46/+77
|\ | | | | | | ...the return.
| * stream: remove stream_unread_buffer()wm42013-06-252-21/+0
| | | | | | | | Replaced with stream_peek().
| * stream: add stream_peek functionwm42013-06-252-0/+35
| | | | | | | | | | Makes probing easier, and this is perhaps a simpler interface than stream_unread_buffer().
| * stream: never let read functions return values < 0wm42013-06-251-3/+5
| | | | | | | | | | | | | | | | | | | | stream_read_unbuffered() can sometimes return negative values on error. Change that to return 0 - the negative values are nowhere used anyway. If distinguishing errors and EOF is really needed, a flag could be added instead. This also fixes the stream_read_partial() call in cache.c, which assumes the return values is always >= 0.
| * stream: readd memory streamswm42013-06-252-5/+21
| |
| * stream: remove padding parameter from stream_read_complete()wm42013-06-232-18/+17
| | | | | | | | | | | | | | | | 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.
* | cache: cache number of chapterswm42013-06-241-0/+10
| | | | | | | | | | | | | | | | | | Querying this caused the cache to block and wait. Some parts of the frontend (like progress bar) call this very often, so cache performance was ruined in these cases. Also print a message in -v mode when the cache is blocked for a STREAM_CTRL. This should make debugging similar issues easier.
* | cache: fix stream_pts cachingwm42013-06-181-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Or rather, keep hacking it until it somehow works. The problem here was that trying to avoid calling STREAM_CTRL_GET_CURRENT_TIME too often didn't really work, so the cache sometimes returned incorrect times. Also try to avoid the situation that looking up the time with an advanced read position doesn't really work, as well as when trying to look it up when EOF or cache end has been reached. In that case we have read_filepos == max_filepos, which is "outside" of the cache, but querying the time is still valid. Should also fix the issue that demuxing streams with demux_lavf and if STREAM_CTRL_GET_CURRENT_TIME is not supported messed up the reported playback position. This stuff is still not sane, but the way the player tries to fix the playback time and how the DVD/BD stream inputs return the current time based on the current byte position isn't sane to begin with. So, let's leave it at bad hacks. The two changes that touch s->eof are unrelated and basically of cosmetic nature (separate commit would be too noisy.)
* | osdep: remove shmem wrapperwm42013-06-181-1/+0
| | | | | | | | This is unused now that the cache is always threaded.
* | cache: actually use time instead of retry count for slow cache warningwm42013-06-181-9/+11
|/ | | | | There's actually no reason to maintain a retry count, and this is more robust against spurious wakeups.
* cache: fix build on OSX (again)wm42013-06-161-0/+7
| | | | | | | | | | | | | OSX doesn't support the POSIX API we were using. We check for _POSIX_TIMERS. 0 or -1 means unsupported. See: http://pubs.opengroup.org/onlinepubs/009696699/functions/clock_getres.html http://pubs.opengroup.org/onlinepubs/009696699/basedefs/unistd.h.html The workaround of using gettimeofday() is suggested by Apple: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/pthread_cond_timedwait.3.html Thanks to AStorm for providing help here.
* cache: fix compilation on Libavwm42013-06-161-1/+8
| | | | Appears Libav doesn't have av_clip64(). So implement our own.
* cache: use correct header for clock_gettimewm42013-06-161-0/+1
| | | | Fixes compilation on OSX.
* stream: don't set sector size on cachewm42013-06-161-3/+1
| | | | | | | | | This is useless on the cache side. The sector is needed only to deal with stream implementations which are not byte addressable, and the cache is always byte addressable. Also set a default read_chunk value. (This value is never used unless you chain multiple caches, but it's cleaner.)
* cache: attempt to improve slow cache warningwm42013-06-161-26/+35
| | | | | Still sucks. The old cache behavior (before removing the fork code) wasn't great either, though.
* cache: report more precise stream timewm42013-06-161-9/+39
| | | | | | | | | | | | | | | | | | | | | | | | DVD and bluray packet streams carry (essentially) random timestamps, which don't start at 0, can wrap, etc. libdvdread and libbluray provide a linear timestamp additionally. This timestamp can be retrieved with STREAM_CTRL_GET_CURRENT_TIME. The problem is that this timestamp is bound to the current raw file position, and the stream cache can be ahead of playback by an arbitrary amount. This is a big problem for the user, because the displayed playback time and actual time don't match (depending on cache size), and relative seeking is broken completely. Attempt to fix this by saving the linear timestamp all N bytes (where N = BYTE_META_CHUNK_SIZE = 16 KB). This is a rather crappy hack, but also very effective. A proper solution would probably try to offset the playback time with the packet PTS, but that would require at least knowing how the PTS can wrap (e.g. how many bits is the PTS comprised of, and what are the maximum and reset values). Another solution would be putting the cache between libdvdread and the filesystem/DVD device, but that can't be done currently. (Also isn't that the operating system's responsibility?)
* stream: don't align stream position if not neededwm42013-06-161-3/+1
| | | | | This is pointless, and just increases latency on seeking. For streams that have a sector size set, this is still needed, though.
* stream: don't adjust stream position if seek succeeds, but read failswm42013-06-161-3/+2
| | | | | | | This was probably done this way to ensure that after a successful seek, the reported stream position is the same as the requested seek position. But it doesn't make too much sense, since both stream->pos and the stream implementation's internal position will go out of sync.
* stream: fix some aspects of EOF handlingwm42013-06-161-10/+22
| | | | | | | | | | | | | The stream EOF flag should only be set when trying to read past the end of the file (relatively similar to unix files). Always clear the EOF flag on seeking. Trying to set it "properly" (depending whether data is available at seek destination or not) might be an ok idea, but would require attention to too many special cases. I suspect before this commit (and in MPlayer etc. too), the EOF flag wasn't handled consistently when the stream position was at the end of the file. Fix one special case in ebml.c and stream_skip(): this function couldn't distinguish between at-EOF and past-EOF either.
* stream: don't set EOF flag in stream implementationswm42013-06-167-13/+1
| | | | | | | | | | EOF should be set when reading more data fails. The stream implementations have nothing to say here and should behave correctly when trying to read when EOF was actually read. Even when seeking, a correct EOF flag should be guaranteed. stream_seek() (or actually stream_seek_long()) calls stream_fill_buffer() at least once, which also updates the EOF flag.
* stream: remove stream_reset()wm42013-06-162-12/+3
| | | | | | | | | 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: check for interruption when trying to reconnect streamwm42013-06-161-3/+3
| | | | | | | This happens with something like "mpv https://www.youtube.com/watch". The URL is obviously not valid, but the stream layer tries to reconnect. This commit at least allows to use the terminal to abort gracefully. (Other than killing the process.)
* stream: cosmeticswm42013-06-162-26/+12
|
* stream: reset buffer even on EOF/errorwm42013-06-161-4/+2
| | | | This probably didn't matter anywhere, but it's more proper.
* cache: use threads instead of fork()wm42013-06-163-542/+403
| | | | | | | | | | | | | | | | | | | 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-162-17/+28
| | | | | 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-162-4/+33
| | | | | | | | | | | | | | | | | | | | | | 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-165-331/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 pointless checkwm42013-06-091-7/+3
|
* stream: remove unused functionwm42013-06-091-9/+0
|
* stream: move VCD specific stuff to stream_vcdwm42013-06-093-5/+4
| | | | I don't even know what VCDs are. A prehistoric version of the DVD or so.
* stream_cdda, stream_vcd: check read buffer sizewm42013-06-092-0/+5