summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
Commit message (Collapse)AuthorAgeFilesLines
* demux: reduce log spam if threading is disabledwm42014-08-111-3/+11
|
* demux: fix playback abort if --demuxer-thread is not usedwm42014-08-071-9/+9
| | | | | | | | | | | | Switching tracks caused cached_demux_control() to catch the command to switch tracks, even if no thread was running. Thus, the tracks were never really switched, and EOF happened immediately on playback start. Fix it by not using the cache at all if the demuxer thread is disabled. The cache code still has to be called somewhere, though, because it handles stream metadata update. Regression from today.
* demux: make track switching asynchronouswm42014-08-061-0/+21
| | | | | | | | | | | | | Because why not. This can lead to reordering of operations between seeking and track switching (happens when the demuxer wakes up after seek and track switching operations were queued). Do the track switching strictly before seeks if there is a chance of reordering, which guarantees that the seek position will always start with key frames. The reverse (seeking, then switching) does not really have any advantages. (Not sure if the player relies on this behavior.)
* demux: asynchronous seekingwm42014-07-211-9/+43
| | | | | | | | | | | | | | | | | This tells the demuxer thread that it should seek, instead of waiting until the demuxer thread is ready. Care has to be taken about the state between seek request and actual seeking: newly demuxed packets have to be discarded. We can't just flush when doing the actual seek, because the user thread could read these packets. I'm wondering if this could lead to issues due to relaxed ordering of operations. But it should be fine, since seeking influences packet reading only, and seeking is always strictly done before that. Currently, this will have no advantages; unless audio is disabled. Then seeking as well as normal playback can be non-blocking.
* demux: don't start reading if no packets were requested yetwm42014-07-201-1/+1
| | | | | | | | | | | Instead of starting to fill the packet queue if at least 1 stream is selected, wait until there is at least 1 stream had new packets requested. In theory this is cleaner, because it allows you to e.g. do a seek and then reselect streams without losing packets. Seeking marks all streams as inactive, and without this new logic, the thread would read new packets anyway right after seek.
* demux: make the cache refresh cached STREAM_CTRLswm42014-07-201-0/+1
| | | | | | | This fixes the same symptom as the previous commit, but when the demuxer thread is enabled. In this case, if nothing was read from the demuxer, the STREAM_CTRLs weren't updated either. To the player, this looked like the stream cache was never making progress, so playback was kept paused.
* demux: fix a corner case (2)wm42014-07-191-2/+4
| | | | | | | | | It can happen that read_packet() doesn't read a packet, even if it succeeds. Typically this is because a packet was read, but then thrown away, because it's not part of a selected stream. The result would be a bogus EOF condition. Fix by explicitly checking for EOF.
* demux: ensure demux_read_packet_async() always readswm42014-07-191-2/+3
| | | | | | | | | | | | | In corner cases, it might be possible that a demux_read_packet_async() call fails to make the demuxer thread to read more packets. If a packet is queued, the function will simply return a packet, without marking the stream as active. As a consequence, read_packet() might decide not to read any further packets, and the demuxer will never read a packet and wake up the playback thread. This was originally done to align it with demux_read_packet() semantics; just drop this.
* demux: fix a corner casewm42014-07-191-2/+4
| | | | | | | | | | | | demux_read_any_packet() attempts to call read_packet(), but if no stream is active, it can decide not to read anything. The function will return NULL, which implies EOF. Fix this by explicitly setting demux_stream->active if needed. Also use dequeue_packet() instead of demux_read_packet(), because it's cleaner. (Shouldn't change behavior.) Possibly fixes #938.
* demux: fix opening pipes with demux_lavfwm42014-07-181-0/+5
| | | | | | | | | | | | | | | | | | | | We told the demuxer that a pipe (if stream cache is enabled) is seekable. This is because the stream cache is technically seekable, it's just that seeking may fail at runtime if a non-cached byte range is requested. This caused libavformat to issue seeks on initialization (at least when piping mp4 youtube videos). Initialization failed completely after spamming tons of error messages. So, if an unseekable stream is cached, tell the demuxer that the file is not seekable. This gets reversed later (when printing a message about caching an unseekable stream), so the user can still try his luck by issuing a seek command. The important part is that libavformat initialization will not take code paths that will unnecessarily seek for whatever reasons. CC: @mpv-player/stable: regression from 0.3.x
* demux: fix problems with EOFwm42014-07-181-5/+14
| | | | | | | | | | | | | | | | | | | | It was easy to get into a wakeup feedback loop on EOF. The reason that EOF is complicated is that we try to retry reading when EOF is reached, in case the EOF state actually disappears (e.g. when watching a currently downloaded file). This feature is probably worthless, since in practice you have to do a seek to "unstuck" it anyway, but since the old code also did this, we want to keep this behavior for now. Avoid the feedback loop by introducing another EOF flag (last_eof), that contains the actual previous EOF state, and is not overwritten when retrying reading. Wakeup is skipped if the EOF state didn't change. Also, actually call the wakeup callback when EOF is detected. The line that adds "ds->active = false;" actually does nothing, but in theory it's cleaner.
* demux: add function to read packets asychronouslywm42014-07-181-14/+50
|
* demux: fix debug log outputwm42014-07-171-1/+1
| | | | It printed the PTS instead of the DTS.
* demux: add a demuxer threadwm42014-07-161-162/+548
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-151-0/+2
| | | | | | This reverts commit 4b93210e0c244a65ef10a566abed2ad25ecaf9a1. *shrug*
* Remove DVD and Bluray supportwm42014-07-141-2/+0
| | | | It never worked well. Just remux your DVD and BD images to mkv.
* demux: remove accurate_seek fieldwm42014-07-081-1/+0
| | | | It's unused now. (Only the dvd code used it until recently.)
* demux: print initial metadatawm42014-07-071-0/+1
| | | | | This was accidentally broken in 7e209185, and metadata was printed only when it changed.
* Remove stream_pts stuffwm42014-07-061-3/+0
| | | | | This was used by DVD/BD, but its usage was removed with one of the previous commits.
* demux: fix a corner case related to demux_discwm42014-07-061-5/+8
| | | | | | It can happen that demux_fill_buffer() adds more than 1 packet, and then the packets would add up. Affects demux_disc.c only (nothing else uses this function).
* dvd: fix first subtitle with delayed subtitle streamswm42014-07-061-0/+1
| | | | | | This was accidentally broken with moving the DVD code to demux_disc.c. Also remove an abort() call meant for debugging.
* demux: minor simplificationwm42014-07-061-1/+1
| | | | Oops, should have been part of commit 37085788.
* demux: minor simplification to internal APIwm42014-07-051-19/+11
| | | | Also some other unrelated minor changes.
* dvd: move angle switching codewm42014-07-051-39/+0
| | | | | No need to provide a "nice" API for it; just do this stuff directly in the command code.
* dvd, bluray, cdda: add demux_disc containing all related hackswm42014-07-051-71/+15
| | | | | | | | | | | | 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: set filepos field when dequeuing a packetwm42014-07-051-3/+2
| | | | Otherwise the position can be too far ahead.
* demux: cosmetics: minimize codewm42014-07-051-16/+3
|
* demux: make start time a simple fieldwm42014-07-051-10/+0
| | | | Simpler, especially for later changes.
* demux, stream: change metadata notificationwm42014-07-051-21/+12
| | | | | | | | | | | | (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.
* demux: make replaygain per-trackwm42014-07-051-3/+6
| | | | | | It's unlikely that files with multiple audio tracks and with replaygain actually happen, but this change might help avoid minor corner cases with later changes.
* demux: move packet functions to a separate source filewm42014-07-051-100/+0
|
* demux: move packet list functionswm42014-07-051-66/+0
| | | | Move them to the only place where they are used, demux_subreader.c.
* demux: drop AVI special codewm42014-07-021-8/+0
| | | | | | | I'm pretty sure libavformat does this automatically, and we don't have other demuxers where this could happen. Still, slightly "risky" - so let's see.
* demux: minor cleanupswm42014-07-011-6/+0
|
* demux: use position as signed integerwm42014-06-141-1/+1
| | | | Seeing (uint64_t)-1 as value when position was unset was annoying.
* demux: use av_malloc for packetswm42014-06-131-2/+2
| | | | | | | | Probably "needed" to get the correct alignment, although I'm not aware of actual breakages or performance issues. In fact we should probably always just allocate AVPackets, but for now use the simple fix.
* demux: simplify packet resizingwm42014-06-131-13/+3
| | | | | Actually we don't need to resize packets; we just need to make them shorter.
* demux: fix compilation with FFmpeg gitwm42014-06-121-8/+4
| | | | | | | | | FFmpeg requires a bullshit padding after each input buffer, and they just increased that padding without warning and without ABI or API bump. We need this only in one file (although mp_image hardcodes something similar, for which no FFmpeg API define is available), so drop our own define.
* player: hide audio/video codec and file format messageswm42014-05-311-3/+3
| | | | | None of these are very important usually. For error analysis, the plain log is useless anyway, and this information is still printed with "-v".
* stream: don't use end_poswm42014-05-241-2/+1
| | | | | | | | | | | | | | | | | | | Stop using it in most places, and prefer STREAM_CTRL_GET_SIZE. The advantage is that always the correct size will be used. There can be no doubt anymore whether the end_pos value is outdated (as it happens often with files that are being downloaded). Some streams still use end_pos. They don't change size, and it's easier to emulate STREAM_CTRL_GET_SIZE using end_pos, instead of adding a STREAM_CTRL_GET_SIZE implementation to these streams. Make sure int64_t is always used for STREAM_CTRL_GET_SIZE (it was uint64_t before). Remove the seek flags mess, and replace them with a seekable flag. Every stream must set it consistently now, and an assertion in stream.c checks this. Don't distinguish between streams that can only be forward or backwards seeked, since we have no such stream types.
* stream: kill start_pos, remove --sb optionwm42014-05-241-1/+2
| | | | | | | | | | | | | | | | | | | | stream.start_pos was needed for optical media only, and (apparently) not for very good reasons. Just get rid of it. For stream_dvd, we don't need to do anything. Byte seeking was already removed from it earlier. For stream_cdda and stream_vcd, emulate the start_pos by offsetting the stream pos as seen by the rest of mpv. The bits in discnav.c and loadfile.c were for dealing with the code seeking back to the start in demux.c. Handle this differently by assuming the demuxer is always initialized with the stream at start position, and instead seek back if initializing the demuxer fails. Remove the --sb option, which worked by modifying stream.start_pos. If someone really wants this option, it could be added back by creating a "slice" stream (actually ffmpeg already has such a thing).
* options: remove deprecated --identifyMartin Herkt2014-05-041-5/+0
| | | | | | | Also remove MSGL_SMODE and friends. Note: The indent in options.rst was added to work around a bug in ReportLab that causes the PDF manual build to fail.
* mp_tags: move generic mp_tags stuff into its own .c/.h files in common/Kevin Mitchell2014-04-131-42/+0
| | | | | | rename add_metadata to the more genera/descriptive mp_tags_copy_items_from_av_dictionary Signed-off-by: wm4 <wm4@nowhere>
* demux: move metadata-based replaygain decoding out of af_volumeAlessandro Ghedini2014-04-041-0/+78
|
* player: remove demuxer chapoter API wrapperswm42014-03-251-64/+5
| | | | | | Instead, always use the mpctx->chapters array. Before this commit, this array was used only for ordered chapters and such, but now it's always populated if there are chapters.
* stream: remove old chapter handling codewm42014-03-251-33/+10
| | | | | | | | Stream-level chapters (like DVD etc.) did potentially not have timestamps for each chapter, so STREAM_CTRL_SEEK_TO_CHAPTER and STREAM_CTRL_GET_CURRENT_CHAPTER were needed to navigate chapters. We've switched everything to use timestamps and that seems to work, so we can simplify the code and remove this old mechanism.
* demux: use av_packet_ref()wm42014-03-161-4/+1
| | | | | av_copy_packet() was FFmpeg specific, av_packet_ref() is now available on all supported libavcodec releases.
* client API: add event for metadata changeswm42014-02-191-1/+3
|
* demux: expose stream_type_name() functionwm42014-02-161-1/+1
|
* demux: fix some newlines in output messageswm42014-02-091-2/+2
|
* demux: reword "Clip info:" line to "File tags:"wm42014-02-061-1/+1
|
* demux: fill metadata directly, instead of using wrapper functionswm42014-02-061-24/+1
| | | | | | Get rid of demux_info_add[_bstr] and demuxer_add_chapter_info. Make demuxer_add_chapter_info return the chapter index for convenience.
* demux_lavf: clear metadata on update, instead of merging itwm42014-02-061-0/+6
| | | | | Assume a metadata update is a full update. Clear the previous metadata, so that tags which existed only in the previous metadata are removed.
* demux: handle tag updates differentlywm42014-02-061-11/+18
| | | | | | | | | | | | | | | | Instead of printing lines like: Demuxer info GENRE changed to Alternative Rock Just output all tags once they change. The assumption is that individual tags rarely change, while all tags change in the common case. This changes tag updates to use polling. This could be fixed later, although the ICY stuff makes it a bit painful, so maybe it will remain this way. Also remove DEMUXER_CTRL_UPDATE_INFO. This was intended to check for tag updates, but now we use a different approach.
* demux: don't prefix tag output with demuxer namewm42013-12-211-8/+11
| | | | Add a separate mp_log instance for this purpose.
* demux: mp_msg conversionswm42013-12-211-46/+50
| | | | | | | The TV code pretends to be part of stream/, but it's actually demuxer code too. The audio_in code is shared between the TV code and stream_radio.c, so stream_radio.c needs a small hack until stream.c is converted.
* demux: use fprintf() for printing fatal errorswm42013-12-211-6/+4
| | | | | We print these before calling abort(), which is deadly unclean anyway. Avoids having to add log contexts.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-1/+1
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-9/+9
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* demux: revert accidentally included change from previous commitwm42013-12-121-1/+1
| | | | Oops.
* Add prelimimary (basic, possibly broken) dvdnav supportwm42013-12-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This readds a more or less completely new dvdnav implementation, though it's based on the code from before commit 41fbcee. Note that this is rather basic, and might be broken or not quite usable in many cases. Most importantly, navigation highlights are not correctly implemented. This would require changes in the FFmpeg dvdsub decoder (to apply a different internal CLUT), so supporting it is not really possible right now. And in fact, I don't think I ever want to support it, because it's a very small gain for a lot of work. Instead, mpv will display fake highlights, which are an approximate bounding box around the real highlights. Some things like mouse input or switching audio/subtitles stream using the dvdnav VM are not supported. Might be quite fragile on transitions: if dvdnav initiates a transition, and doesn't give us enough mpeg data to initialize video playback, the player will just quit. This is added only because some users seem to want it. I don't intend to make mpv a good DVD player, so the very basic minimum will have to do. How about you just convert yo