summaryrefslogtreecommitdiffstats
path: root/stream
Commit message (Collapse)AuthorAgeFilesLines
* cache: use MPCLAMP() macrowm42015-02-261-9/+2
| | | | (cherry picked from commit e85bcc12233ee08b7609382372dd80482fd016f2)
* cache: limit to file sizewm42015-02-261-1/+8
| | | | | | | Saves some memory. Should be especially helpful if many small files are loaded, like when mass-loading subtitle files and the cache is enabled. (cherry picked from commit 899f0cd51eaadf6d0249d854efc3d0d1029045bd)
* stream_file: open pipes non-blockingwm42015-02-211-4/+33
| | | | | | | Now the player can actually be quit if a pipe was opened, but nobody is writing to it. (cherry picked from commit 3c9344a1a9de335925b81058b7699fccd187626b)
* cache: silence "EOF reached" messagewm42015-02-191-1/+1
| | | | | | | | | | | | | | | This message will be printed relatively often once EOF is reached. In some cases this is rather annoying, for example when playing HLS. (With HLS, the stream is just a playlist file, while libavformat opens actual media files without mpv's knowledge, so the cache is completely useless and hits EOF instantly.) That it retries reading is apparently a good thing: at least local files can grow, and even after the player got the EOF, playback _could_ be resumed by basically polling and detecting that there is more data. So I'm not changing this behavior yet. (cherry picked from commit 3f5b5b758dac511f500fdfd9ae85089cbfc31fde)
* dvb_tune: fix invalid syntaxwm42015-02-111-1/+1
| | | | Oops.
* stream: get rid of remaining uses of the end_pos fieldwm42015-02-067-26/+25
| | | | | | | | 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-064-88/+64
| | | | | | | | | | | | | | | | 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-062-18/+29
| | | | | Wait for a longer time between reconnects. Introdeuce and use mp_cancel_wait(), so that quitting is still immediate.
* stream_lavf: fix build with Libavwm42015-02-061-2/+5
| | | | | | The API function used is FFmpeg-only. Sigh...
* options: add --network-timeoutwm42015-02-061-0/+3
| | | | | | Not quite sure if this actually works as intended. Fixes #1566.
* stream_cdda: fix bugs in chapter time retrievalwm42015-02-041-2/+2
| | | | | | | | | | | | | | | | | | Looks like a bunch of off-by-one errors. The track number was mistakenly offset by 1 - this shifted all chapters by one, and make the first chapter start on the second track (so the "chapter" property returned -1 in the first track since it was before the first chapter). Also, the calculation of the sector destination was messed up. This comes from commit 32d818f0, where I apparently attempted to calculate the position to one byte before the section, but unfortunately math doesn't work this way and it was nonsense. Just drop this idea; while it may help with seeking (probably...), it also returns slightly different times. The user shall use hr-seeks if accurate seeking is required. Hopefully fixes #1560.
* 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).
* stream: reject overly long URLswm42015-01-211-0/+4
|
* stream_lavf: escape disallowed characters in http URLswm42015-01-212-5/+24
| | | | | | | | | | | | | | | | | In my opinion, libavformat should be doing this. But a patch handling a very safe case rejected, so I suppose we have to do it manually. (This patch was only escaping spaces, which can never work because they break the basic syntax of the HTTP protocol.) This commit attempts to do 2 things: - Try to guess whether libavformat will use the URL for http. This is not always trivial, because some protocols will recursively pass part of the user URL to http in some way. - Try to fix invalid URLs. We fix only the simplest case: only characters that are never valid are escaped. This excludes invalid escape codes, which happen with freestanding '%' characters. Fixes #1495.
* dvd: try to improve seekingwm42015-01-191-3/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | libdvdnav is garbage. Seeking by time is incredibly inexact, which is in part due to the fact that it does not use the DVD seek tables. Instead, it assumes CBR for certain ranges within the DVD, which makes especially small seeks unreliable. I have no good fix for this, other than hacking libdvdnav (I'd rather prefer to remove mpv DVD support completely than doing this). So here's a shitty hack that tries to workaround these problems. A basic observation is that seeking in VLC seems to work quite well; however it seems to be based on seeking by blocks (unless there is a subtle "trick" I didn't see in the source code). mpv usually seeks by timestamps, so this is not an option for us. However, we can pretend we are doing this in the DVD layer. The previous commit added a way to pass through relative seeks. This commit uses the relative seek. STREAM_CTRL_SEEK_TO_TIME is backwards compatible (there's still dvdread and bluray), so most code is about extracing the relative seek information and turning it into a block seek. (Another way would have been using SEEK_FACTOR stuff, but that would probably make for a less reliable way to handle this situation.) Additionally, if a hr-seek is done, add an offset by 10 seconds. As long as the error done by libdvdnav is not worse, this should help with hr- seeks - although it makes them much slower.
* stream_dvb: silence bogus compiler warningwm42015-01-191-1/+1
| | | | | | This complains within dvb_strtok_r() that savePtr is uninitialized. There doesn't seem to be any code path where this can happen though, so it's probably a false positive. Silence it anyway.
* cache: cache-position needs to be int64_tOliver Freyermuth2015-01-131-1/+1
| | | | | | Both max_filepos and offset are int64_t, so pos can overflow, e.g. causing endless loops in stream implementation.
* stream_dvb: Add MP_ERR if polling worked, but read fails.Oliver Freyermuth2015-01-131-0/+4
| | | | Read can still fail, e.g. if the buffer is invalid.
* stream_pvr: uncrustifywm42015-01-061-1306/+1188
| | | | Mostly automatic, with some manual changes.
* dvb: uncrustifywm42015-01-063-1272/+1261
| | | | Mostly automatic, some manual changes.
* stream_dvb: Enable streaming mode, activates cache.Oliver Freyermuth2015-01-061-0/+1
| | | | | | | | | This causes more constant reading from the DVB device, and seems not to hurt the stream-controls. As the device cache seems to fill up when not reading from it for several seconds, reading into the cache fixes desync-issues after the initial analyzeduration of the demuxer.
* stream_dvb: Do not add special PIDs if we anyways record the full TP.Oliver Freyermuth2015-01-061-23/+22
| | | | | | This just exchanges two blocks of code: If we record the full transponder, no need to explicitly add some PIDs to the filter list.
* stream_dvb: Add possibility to dump a full transponder.Oliver Freyermuth2015-01-062-4/+11
| | | | | | | | | | | | Was already possible before by injecting the magic PID 8192 into channels.conf, the flag makes this much more useable and we also have it documented. Useful not only for debugging, but also for incomplete channels.conf (mplayer format...), multi-channel recording, or channels which do dynamic PID switchng. full-transponder is also useful for channels which switch PIDs on-the-fly. ffmpeg can handle this, but it needs the full stream with all PIDs.
* stream_dvb: Record PIDs with human-readable content, bump max demuxer count.Oliver Freyermuth2015-01-062-1/+15
| | | | | | | | | | | There is the STD which contains service-names (ffmpeg can understand it), and the EIT which contains the EPG (ffmpeg does not parse it, but e.g. VLC does). As we now have more PIDs in general, increase the maximum number of demuxers we can open. ffmpeg has an internal limit of 64 PIDs, we are still far from that.
* stream_dvb: Also demux PMT if possible, reactivate TPID parsing.Oliver Freyermuth2015-01-064-12/+113
| | | | | | | | | | | | If VDR-channel-config is used, we know the service_id. Using that, PMT can be extracted from PAT (code for that inspired by szap-s2 again). For this, we need to demux PAT with a special filter-setup, and once PMT was found it can be added to the PID-list. PMT is only resolved the first time one tunes to a channel, then stored in the channel-list in memory. With PMT available, ffmpeg can safely decode the teletext-pids.
* stream_dvb: Extend token-list for pid-parsing, magically allows to parse ↵Oliver Freyermuth2015-01-061-3/+33
| | | | | | | | | | | VDR-style PID-lists. I also added a comment explaining the potentially occuring structures for future reference. For tokenization, a custom strtok_r implementation is used, inspired by strtok_r as implemented in musl and ffmpeg, hopefully slightly more readable (av_strtok_r is not available in libav, and strtok_r is not available everywhere).
* stream_dvb: Move out PID-parsing, disable TPID parsing.Oliver Freyermuth2015-01-061-26/+38
| | | | | | | Move PID-string parsing into a separate function, reduces code-duplication. Drop TPID-parsing again since teletext-stream seems not really correctly identified (ffmpeg guessed mp3 in my test...). Parsing now done using strtok + sscanf instead of sscanfs with fixed numbers of expected fields - gives more correct checking of PID-overflow, will allow VDR-style PID-field parsing.
* stream_dvb: Add TPID (teletext-pid) parsing from VDR-style channel-lists.Oliver Freyermuth2015-01-061-23/+28
| | | | | The PID-parsing is not really nicely done and also does not yet handle the special VDR-style syntax. A later commit will move the parsing to a separate function handling that which also checks that the maximum PID-count is not exceeded.
* stream_dvb: Handle VDR-config location-field as DISEQc-field.Oliver Freyermuth2015-01-061-6/+26
| | | | | | | In mplayer-style channels-config, we had a LNB-field used for that. In old VDR times, the location-field was also containing DISEQc information, now it does that only indirectly (location => LNB => vdr knows from lnb-config). We only accept it as this if the field is fully numeric.
* dvb: Extend understanding of VDR channel config: stream_id, inversion.Oliver Freyermuth2015-01-064-9/+33
| | | | | | | Now also "stream ID" (for DVB-S2) and "inversion" are understood. The parameter-string can also provide information on FEC, rolloff etc. For DVB-S, "auto" which mpv uses by default should be fine, I can also confirm it works. For non-DVB-S cards, it might be useful to also parse this information in case of a vdr-channel list. As I have no such hardware and thus would have to do it blindly, I added a FIXME. Mostly complete vdr-channels.conf format documentation is at http://www.vdr-wiki.de/wiki/index.php/Channels.conf (german only).
* stream_dvb: Very basic vdr-type channels.conf support.Oliver Freyermuth2015-01-061-24/+80
| | | | | | | | | | | Still incomplete. Initialize is_dvb_s2 boolean in channel-struct. We first check whether the channels.conf-line at hand is sscanf'able with a vdr-style pattern. If yes, we assume it is a vdr-channel-config (we check whether sscanf consumed the full line). The vdr-style config also contains a parameter-string which contains information about polarization + delivery type (e.g. DVB-S2). With this change, S2-tuning works with a VDR-channel list. Missing (later commits): - vdr-parameter-string also contains other information, e.g. invert-flag, needs to be parsed. - Diseqc-lnb-number is not present in VDR-config (I believe it is handled via the location-parameter + lnb-config there). For backwards compatibility, the location-parameter can be the lnb-number - we should test whether it is an int and assume this in this case. - VID, AID and TID-lists are extremely ugly in their syntax for VDR. At the moment, only the first number is parsed (and TID fully ignored), needs to be fixed.
* dvb: Extend dvb_channel struct, needs to know whether channel is S2.Oliver Freyermuth2015-01-063-11/+19
| | | | | | It contains now also a boolean which tells whether this is an DVB-S2 channel (not initialized yet - tbd in next commit). We could also pass through the type of the delivery system (would be more flexible), but the delivery-system-enum is only available with S2API, so this is more backwards-compatible. If someone has DVB-T2 / DVB-C2 hardware and extends the code to deal with it, this should be changed.
* dvb_tune: (DVB-S) Initial S2API support.Oliver Freyermuth2015-01-061-13/+79
| | | | | | | | | | | Also allows demuxers to buffer, and we explicitly discard stale QPSK events. Inspiration taken from the szap-s2 implementation. S2API is only used if available and for DVB-S cards - it might also be useful to have that for DVB-T2 / DVB-C2 tuning later, but I do not have the HW / no DVB-T2 broadcasting station nearby to test functionality. This should do no functional changes, only usage of the different API. The S2API is more extensible and a requirement for all the HD-deliveries (e.g. DVB-S2) and since 2.6.28 is the successor of the old API. Tuning to DVB-S2 channels actually already "works" like this if the delivery is hardcoded in - for a fully working implementation, the channels.conf.sat would need an additional field indicating the delivery type (VDR-type channels.conf have that). This commit also: - Cleans up some debug output. - Moves an unneeded usleep(100000) (only needed for diseqc switching for SAT) into the DVB-S-only part of the implementation.
* dvbin: Prepare S2API-implementation, support different DVB-API versions.Oliver Freyermuth2015-01-061-1/+17
| | | | | | | | | | Define a new macro "DVB_USE_S2API" to be used to switch to S2API if available, also document what is the main difference in the new S2API. StreamID-handling is only supported since API 5.2, and some macros were renamed or only added later with 5.8 (somewhere around kernel 3.6), so some define-fixups are needed to support these intermediate kernel header versions.
* stream_pvr: sort channel list by --tv-channels orderwm42014-12-281-2/+25
| | | | | | | | | | Apparently this is what users would expect. Going the way of least resistance (in terms of messing with this old, rarely used code), sorting them by some kind of addition timestamp (called priority in the patch) is the easiest. Fixes #1390.
* stream: always make stream dumping/capturing append to output filewm42014-12-271-1/+1
| | | | Partially fixes #1393 (but not really).
* stream_pvr: remove redundant log prefixeswm42014-12-261-103/+82
|
* stream_pvr: increase timeout, slightly better error reportingwm42014-12-261-5/+10
| | | | | | | An attempt to find out what's wrong with issue #1382. I don't even know why a timeout would be needed; for robustness with broken devices maybe?
* stream: always disable cache for pseudo-streamswm42014-12-242-1/+3
| | | | | Streams which don't have a full_buffer function never return any actual data. Slight improvement over commit 5640c195.
* stream_edl: disable cachingwm42014-12-231-0/+1
| | | | | | | | | | | stream_edl merely makes demux_edl act "special", which checks for the stream type explicitly and then does something with its URL. If a cache is added before the stream, it'll try to use the cache's URL (i.e. an empty string), and will then obviously fail to parse the URL. While this is slightly stupid, just disabling the entirely useless cache is the most effective solution. Fixes #1378.
* dvd: add the last chapterwm42014-12-161-1/+1
| | | | | | | | | | | | As suggested in issue #1251. I think the main point is that it acts as a hack to return to the DVD menu when jumping past the last chapter, because it will reach title-EOF, instead of explicitly jumping to the next file (which usually exits the player). This basically reverts commit 8b7418d, except it doesn't include an off-by-1 error (apparently). Closes #1251.
* command, dvd: add property which returns list of DVD titleswm42014-12-133-22/+63
| | | | | | | | | 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_cdda: don't return number of tracks as number of titleswm42014-12-131-5/+0
| | | | | | Apparently, we treat different tracks as titles, so returning the number of titles (which is user-visible as "disc-titles" property) is completely misguided.
* dvd: drop last chapterwm42014-12-131-2/+2
| | | | | | | Apparently, libdvdnav always reports a last chapter that points to the exact end of the title. This is useless for us. Again, same possible caveats as with the previous commit.
* dvd: add an extra chapter at position 0wm42014-12-131-2/+2
| | | | | | | This way, chapter 0 will always point to the start of the title. At least this is the intention; it's likely that DVDs as well as libdvdnav do random things that lead to random results.
* dvd, bd: don't unnecessarily block on demuxer/stream all the timewm42014-12-041-2/+2
| | | | | | | | | | | | | | | | | | This was completely breaking any low-level caching. Change it so that at least demuxer caching will work. Do this by using the metadata cache mechanism to funnel through the menu commands. For some incomprehensible reason, I had to reorder the events (which affects their delivery priority), or they would be ignored. Probably some crap about the event state being cleared before it could be delivered. I don't give a shit. All this code sucks. It would probably be better to let discnav.c access the menu event "queue" directly, and to synchronize access with a mutex, instead of going through all the caching layers, making things complicated and slow.
* Do not call strerror()wm42014-11-268-75/+81
| | | | | | | | | | | | | | | | | | | | | | | | | ...because everything is terrible. strerror() is not documented as having to be thread-safe by POSIX and C11. (Which is pretty much bullshit, because both mandate threads and some form of thread-local storage - so there's no excuse why implementation couldn't implement this in a thread-safe way. Especially with C11 this is ridiculous, because there is no way to use threads and convert error numbers to strings at the same time!) Since we heavily use threads now, we should avoid unsafe functions like strerror(). strerror_r() is in POSIX, but GNU/glibc deliberately fucks it up and gives the function different semantics than the POSIX one. It's a bit of work to convince this piece of shit to expose the POSIX standard function, and not the messed up GNU one. strerror_l() is also in POSIX, but only since the 2008 standard, and thus is not widespread. The solution is using avlibc (libavutil, by its official name), which handles the unportable details for us, mostly. We avoid some pain.
* Silence some Coverity warningswm42014-11-211-0/+1
| | | | None of this really matters.
* Remove some unneeded NULL checkswm42014-11-211-3/+2
| | | | Found by Coverity; also see commit 85fb2af3.
* stream: fix endian swappingwm42014-11-211-2/+2
| | | | | | | | | | In addition to the messed-up expression, the endianness was also inverted. The code reads big endian by default. It "worked" by coincidence, but for little endian, codepoints outside of latin1 were broken. The broken expression was found by Coverity.
* stream: reduce ifdeffery for win32 somewhatwm42014-11-182-16/+8
| | | | Remove the ones which are not strictly needed.
* stream: signal a Windows event object on cancelJames Ross-Gowan2014-11-182-0/+35
| | | | | This will be used in the following commit to cancel subprocesses started by Lua.
* cache: don't relay STREAM_CTRL_AVSEEK if it's unsupportedwm42014-11-011-0/+4
| | | | | | | | Thanks to STREAM_CTRL_HAS_AVSEEK, we actually know whether CTRL_AVSEEK is implemented at all, and we can avoid a blocking wait on the cache if demux_lavf sends CTRL_AVSEEK even if it won't wait. I'm hoping this can't currently happen, but why hope if we can explicitly prevent it. It'll make us more robust against future changes in libavformat.
* demux_lavf, stream_lavf: drop local buffers on time-seekswm42014-10-301-1/+3
| | | | | There was chance that some data was left in various local buffers after time-seeks. Probably doesn't actually matter.
* demux_lavf: mark as seekable if protocol supports seeking by timewm42014-10-303-0/+9
| | | | | | | | | | | | 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.
* Drop libquvi supportwm42014-10-253-334/+0
| | | | | | | | | | | No development activity (or even any sign of life) for almost a year. A replacement based on youtube-dl will probably be provided before the next mpv release. Ask on the IRC channel if you want to test. Simplify the Lua check too: libquvi linking against a different Lua version than mpv was a frequent issue, but with libquvi gone, no direct dependency uses Lua, and such a clash is rather unlikely.
* tv: remove some differences between immediate/normal modewm42014-10-251-38/+23
| | | | |