Commit Graph

235 Commits

Author SHA1 Message Date
Bruno George Moraes acf6aef882 stream: change malloc+memset to calloc
Also removed some memset that were left on some calloc that was already in
the code.

Signed-off-by: wm4 <wm4@nowhere>
2014-09-27 16:01:49 +02:00
wm4 d6c27855d7 stream_bluray: allow opening BDMV directories directly
Similar as the previous commits.

Most of the code is actually copied from the stream_dvdnav.c code, but
I'd rather prefer to duplicate it, than to entangle them. The latter
would probably result in terrible things in a few years.
2014-09-26 00:30:21 +02:00
wm4 c3f7773138 stream_dvdnav: allow opening DVD directories directly
Same hack as with stream_dvd.c.

VIDEO_TS.IFO files are now opened via stream_dvdnav.c. Directories
containing a VIDEO_TS.IFO or VIDEO_TS/VIDEO_TS.IFO file are also
opened with it.
2014-09-26 00:30:21 +02:00
wm4 debbff76f9 Remove mpbswap.h
This was once central, but now it's almost unused. Only vf_divtc still
uses it for extremely weird and incomprehensible reasons. The use in
stream.c is trivial. Replace these, and remove mpbswap.h.
2014-09-25 21:32:55 +02:00
wm4 b6d8d5e05c stream: fix build with emulated atomics
This code was legal with C11 atomics, but it fails with our
compatibility wrapper.
2014-09-13 17:08:47 +02:00
wm4 2e91d44e20 stream: redo playback abort handling
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.
2014-09-13 16:09:51 +02:00
wm4 8c7a9b0cd0 stream: change cache return values
Basically a cosmetic change, because currently the player just continues
even if the cache fails initializing.
2014-09-07 20:45:39 +02:00
wm4 5ea84e17c0 player: don't allow remote playlists to load local files
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.
2014-09-01 00:13:22 +02:00
wm4 866e0e1670 player: always load playlists
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.
2014-08-31 19:49:39 +02:00
wm4 b7fa981899 stream: correctly propagate uncached stream type
This makes the ordered chapter code not think that a stream from the
local filesystem is not a local file (it checks uncached_type).
2014-08-30 19:05:57 +02:00
wm4 68ff8a0484 Move compat/ and bstr/ directory contents somewhere else
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.
2014-08-29 12:31:52 +02:00
wm4 ac2502141d stream: tweaks to network reconnection code
Don't reconnect to the cache (since the cached stream already handles
reconnection). This is necessary, because since commit 0b428e44 the
"streaming" field (which also controls whether attempting to reconnect
makes sense at all) is inherited to the cache stream wrapper.

Also, let the stream reset its own position on reconnect. This removes
some assumptions and messy handling from the reconnect function.

Make sure the cache is dropped on reconnect. This takes care of
readjusting the stream position if necessary. (Also drop the cache on
DVB channel switching commands.)
2014-08-29 11:58:49 +02:00
wm4 0b428e4482 player: redo how stream caching and pausing on low cache works
Add the --cache-secs option, which literally overrides the value of
--demuxer-readahead-secs if the stream cache is active. The default
value is very high (10 seconds), which means it can act as network
cache.

Remove the old behavior of trying to pause once the byte cache runs
low. Instead, do something similar wit the demuxer cache. The nice
thing is that we can guess how many seconds of video it has cached,
and we can make better decisions. But for now, apply a relatively
naive heuristic: if the cache is below 0.5 secs, pause, and wait
until at least 2 secs are available.

Note that due to timestamp reordering, the estimated cached duration
of video might be inaccurate, depending on the file format. If the
file format has DTS, it's easy, otherwise the duration will seemingly
jump back and forth.
2014-08-27 03:39:04 +02:00
wm4 23a7257cca Revert "Remove DVD and Bluray support"
This reverts commit 4b93210e0c.

*shrug*
2014-07-15 01:49:02 +02:00
wm4 4b93210e0c Remove DVD and Bluray support
It never worked well. Just remux your DVD and BD images to mkv.
2014-07-14 14:34:14 +02:00
wm4 c37956b364 stream: don't sleep for reconnecting network if playback is stopped
Also silences the bogus message if that happens.

CC: @mpv-player/stable
2014-07-12 19:19:04 +02:00
wm4 338004bcfc dvd, bluray, cdda: add demux_disc containing all related hacks
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.
2014-07-05 17:07:15 +02:00
Alessandro Ghedini ab241c05c8 options: add --list-protocols option 2014-06-30 23:20:10 +02:00
wm4 5b8298376b stream: add a file cache
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.
2014-06-22 05:04:05 +02:00
wm4 99f5fef0ea Add more const
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.
2014-06-11 00:39:14 +02:00
wm4 35e6d1abe0 stream_dvd, stream_dvdnav, stream_bluray: remove global option variables 2014-06-11 00:39:06 +02:00
wm4 77a7aa2c41 stream_cdda: remove global option variables 2014-06-11 00:34:46 +02:00
wm4 7689f5f7ce stream: add a generic way to setup stream priv defaults
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.)
2014-06-11 00:34:46 +02:00
wm4 a192f32a3a stream: remove VCD support
If a single person complains, I will readd it. But I don't expect that
this will happen.

The main reason for removing this is that it's some of the most unclean
code remaining, it's unmaintained, and I've never ever heard of someone
using it.
2014-06-01 17:22:21 +02:00
wm4 baaa32621e stream: unbreak writeable streams
So, basically this worked only with streams that were not local files,
because stream_dvd.c "intercepts" local files to check whether they
point to DVD images. This means if a stream is not writeable, we have to
try the next stream implementation.

Unbreaks 2-pass encoding.
2014-05-27 22:05:22 +02:00
wm4 aa87c143cb stream: remove chaos related to writeable streams
For some reason, we support writeable streams. (Only encoding uses that,
and the use of it looks messy enough that I want to replace it with FILE
or avio today.)

It's a chaos: most streams do not actually check the mode parameter like
they should. Simplify it, and let streams signal availability of write
mode by setting a flag in the stream info struct.
2014-05-24 16:17:52 +02:00
wm4 a4d487f5b2 stream: don't use end_pos
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.
2014-05-24 16:17:51 +02:00
wm4 e3c20bf350 stream: kill start_pos, remove --sb option
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).
2014-05-24 16:17:50 +02:00
wm4 4664f8b3b7 cache: redo options and default settings
Some options change from percentages to number of kilobytes; there are
no cache options using percentages anymore.

Raise the default values. The cache is now 25000 kilobytes, although if
your connection is slow enough, the maximum is probably never reached.
(Although all the memory will still be used as seekback-cache.)

Remove the separate --audio-file-cache option, and use the cache default
settings for it.
2014-05-20 02:40:22 +02:00
wm4 e0cf983e53 stream: remove interrupt callback global variables
This used global variables for the asynchronous interrupt callback.

Pick the simple and dumb solution and stuff the callback into
mpv_global. Do this because interrupt checking should also work in the
connect phase, and currently stream creation equates connecting.
Ideally, this would be passed to the stream on creation instead, or
connecting would be separated from creation. But since I don't know yet
which is better, and since moving stream/demuxer into their own thread
is something that will happen later, go with the mpv_global solution.
2014-04-25 19:12:24 +02:00
wm4 3d51ef3dc8 stream: use uninterruptible sleep on reconnecting
This is the only function which actually used the time argument of
stream_check_interrupt(). Considering that the whole player freezes
anyway, this is not worth the complication.

Also generally reduce the maximum wait time due to timeout. Introduce
exponential backoff, which makes the first reconnect retries faster, but
still waits up to 500ms in the later retries.
2014-04-25 19:11:58 +02:00
wm4 132f395aac Remove radio://
It was disabled by default, works only for analogue radio, and I bet
nobody uses it.
2014-04-13 18:51:43 +02:00
xylosper 8cee8279ad stream_bluray: implement navigation interface for Blu-ray stream
This commit introduces new stream protocols: bdnav(and others).
bdnav stream shares lots of codes with original bluray stream, so
it's not separated in different source file.

Major difference from bluray is that bdnav does not support longest
title because there is no way to query that information.
bdnav://menu and bdnav://first correspond to top menu title and
first play title respectively, though they often point same title.

Also, binary position based seeking has been removed, because it
didn't have no point.
2014-03-29 23:31:46 +09:00
wm4 ef006dcae6 stream: print stream_read_line warnings by default
This is probably ok. Probing could hit this case very often, since it'll
mean running this function on potentially binary data, but on the other
hand, probing usually uses a memory stream (to limit the amount of data
read), and memory streams have s->log silenced (details see
open_memory_stream()).
2014-01-19 21:15:55 +01:00
wm4 77e92bbb11 stream: treat embedded 0 bytes as error in stream_read_line
Text files should never contain these.
2014-01-19 21:15:54 +01:00
wm4 333a9491b7 stream: redo stream_read_line()
This simplifies the implementation and should make it more robust. For
example, we return an error if a line is longer than the provided buffer
(instead of splitting the line).

The code is much shorter, because now finding the new line and reading
characters is done in one go.
2014-01-19 21:15:54 +01:00
wm4 b04b48fc10 stream: always respect sector_size, fixes cdda://
Streams like CDDA have special requirements in what quantities data can
be read: you can only read a sector at once, not more and not less. The
stream_peek() function didn't respect that and set less (used internal
buffer size of 2048 bytes, instead of CD sector size of 2352 bytes), so
no data was read and EOF was accidentally set, making playback with
cdda:// fail.

This is a regression since commit 9a723f, but that commit merely exposed
the issue (the redundant seek would clear the EOF flag).
2014-01-02 00:39:14 +01:00
wm4 0335011f11 stream: mp_msg conversions
We also drop some slave mode stuff from stream_vcd.
2013-12-21 21:43:16 +01:00
wm4 d8d42b44fc m_option, m_config: mp_msg conversions
Always pass around mp_log contexts in the option parser code. This of
course affects all users of this API as well.

In stream.c, pass a mp_null_log, because we can't do it properly yet.
This will be fixed later.
2013-12-21 21:05:02 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
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.
2013-12-17 02:07:57 +01:00
wm4 7dc7b900c6 Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsg
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.
2013-12-16 20:41:08 +01:00
wm4 653980ac3a dvdnav, tv: force-disable caching
On dvdnav, caching kind of works but not really. (Not our fault, at
least not fully. It's due to libdvdnav being slightly misdesigned; see
previous commit for some explanations.)

The TV code is implemented in the demuxer, and the stream implementation
is just a wrapper, so caching makes no sense here.
2013-12-14 01:21:06 +01:00
wm4 9a723fc03b stream: don't seek when seeking to the same position
There was already something similar in the code that did the actual
seek,  but I think seeking to the same position could still trigger an
actual seek due to weid interaction with the buffer.
2013-12-14 00:52:39 +01:00
wm4 600bccdf2a stream: add function for dropping the buffer
And use it in demux_lavf.c. It looks like otherwise, some data might be
left over, depending on how the hell av_seek_frame() behaves.
2013-12-14 00:51:00 +01:00
wm4 0530447417 Add prelimimary (basic, possibly broken) dvdnav support
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 your DVD to proper video files?
2013-12-12 01:46:45 +01:00
wm4 0d255f07bf build: make pthreads mandatory
pthreads should be available anywhere. Even if not, for environment
without threads a pthread wrapper could be provided that can't actually
start threads, thus disabling features that require threads.

Make pthreads mandatory in order to simplify build dependencies and to
reduce ifdeffery. (Admittedly, there wasn't much complexity, but maybe
we will use pthreads more in the future, and then it'd become a real
bother.)
2013-11-28 19:28:38 +01:00
wm4 f99aff1b31 Reduce stheader.h includes, move stream types to mp_common.h 2013-11-23 22:08:42 +01:00
wm4 04bdd7af72 timeline: add edl:// URIs
Questionable change from user perspective, but internally needed to
implement the next commit. Also useful for testing timeline stuff.
2013-11-19 22:39:04 +01:00
wm4 f7b2d644ef Merge branch 'master' into have_configure
Conflicts:
	configure
2013-11-04 00:43:06 +01:00