Commit Graph

55 Commits

Author SHA1 Message Date
wm4 1cb9e7efb8 stream, demux: redo origin policy thing
mpv has a very weak and very annoying policy that determines whether a
playlist should be used or not. For example, if you play a remote
playlist, you usually don't want it to be able to read local filesystem
entries. (Although for a media player the impact is small I guess.)

It's weak and annoying as in that it does not prevent certain cases
which could be interpreted as bad in some cases, such as allowing
playlists on the local filesystem to reference remote URLs. It probably
barely makes sense, but we just want to exclude some other "definitely
not a good idea" things, all while playlists generally just work, so
whatever.

The policy is:
- from the command line anything is played
- local playlists can reference anything except "unsafe" streams
  ("unsafe" means special stream inputs like libavfilter graphs)
- remote playlists can reference only remote URLs
- things like "memory://" and archives are "transparent" to this

This commit does... something. It replaces the weird stream flags with a
slightly clearer "origin" value, which is now consequently passed down
and used everywhere. It fixes some deviations from the described policy.

I wanted to force archives to reference only content within them, but
this would probably have been more complicated (or required different
abstractions), and I'm too lazy to figure it out, so archives are now
"transparent" (playlists within archives behave the same outside).

There may be a lot of bugs in this.

This is unfortunately a very noisy commit because:
- every stream open call now needs to pass the origin
- so does every demuxer open call (=> params param. gets mandatory)
- most stream were changed to provide the "origin" value
- the origin value needed to be passed along in a lot of places
- I was too lazy to split the commit

Fixes: #7274
2019-12-20 13:00:39 +01:00
wm4 6487abde79 stream: remove unused read_chunk field
It was set, but its value was never used. The stream cache used to use
it, but it was removed. It controlled how much data it tried to read
from the underlying stream at once.

The user can now control the buffer size with --stream-buffer-size,
which achieves a similar effect, because the stream will in the common
case read half of the buffer size at once. In fact, the new default size
is 128KB, i.e. 64KB read size, which is as much as stream_file and
stream_cb requested by default. stream_memory requested more, but it
doesn't matter anyway. Only stream_smb set a larger size with 128KB.
2019-11-07 22:53:13 +01:00
wm4 e5a9b792ec stream: replace STREAM_CTRL_GET_SIZE with a proper entrypoint
This is overlay convoluted as a stream control, and important enough to
warrant "first class" functionality.
2019-11-07 22:53:13 +01:00
wm4 d3479018db stream: change buffer argument types from char* to void*
This is slightly better, although not much, and ultimately doesn't
matter.

The public API in stream_cb.h also uses char*, but can't change that.
2019-11-07 22:53:13 +01:00
wm4 116ab73566 stream_smb: remove unnecessary short write logic
See previous commit. It compiles, but 100% untested.
2019-09-14 13:00:43 +02:00
pavelxdd bdec4421e6 stream_smb: make sure the string is NULL-terminated after strncpy
strncpy does not guarantee that the string will be NULL-terminated.
2018-10-25 13:49:49 +02:00
Yclept Nemo 5532a3da1e stream_smb/stream_file: fix `write_buffer`
Functions `write` and `smbc_write` are given a diminishing buffer of
incorrect constant size. After partial writes, the code would do another
write of the full original length, failing to subtract the amount
already written.
2018-07-29 12:54:56 +03:00
Yclept Nemo 112b3fa922 stream_smb: locking to bypass libsmbclient issues
Thread-unsafe libsmbclient is likely to crash when used simultaneously
across threads. For example, by:

    mpv "smb://...mkv" --sub-file "smb://...srt"

Work around this by locking all calls to this library under a single
global mutex. This is a temporary solution. When the libsmbclient bug
[1] is fixed, switch to the code from branch [2] which uses a new api to
create per-thread smb contexts. Fixes [3].

[1] https://bugzilla.samba.org/show_bug.cgi?id=11413
[2] https://github.com/orbisvicis/mpv/tree/smbclient_threaded_api
[3] https://github.com/mpv-player/mpv/issues/5936
2018-07-29 12:54:56 +03:00
wm4 14541ae258 Add checks for HAVE_GPL to various GPL-only source files
This should actually cover all of them, if you take into account that
some unchanged GPL source files include header files with such checks.
Also this was done already for the libaf derived code.

This is only for "safety" and to avoid misunderstandings.
2017-10-10 15:51:16 +02:00
wm4 f38bd0f25a stream_smb: disable by default, mark as GPLv3
It seems libsmbclient has been GPLv3 for years. Also, it's certainly not
LGPL (unlike some of its support libs like talloc). Thus, mpv built with
Samba support is GPLv3.

Disable it by default, so we don't have to go through the trouble to
indicate the correct license in our output, and we don't trick people
into distributing stuff under the wrong license.
2017-05-11 08:19:02 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
Kevin Mitchell 3efbc1a9a3 stream/smb: mark as network stream for --cache=auto
This causes the cache to be enabled with --cache=auto. It was not done
previously because the small cache size 320k actually led to worse
performance. However, with the current default cache size of 25000kb,
caching notably improves performance.
2015-03-09 03:38:01 -07: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 e47e818356 stream_smb: fix compilation
Accidentally forgotten in commit a4d487.
2014-05-24 17:00:30 +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
Kevin Mitchell a6762dbc16 stream_smb: increase to 128k read_chuuk from default 8k
Previous to this commit, read_chunk was not set in stream_smb. The
cache was therefore filled in small 8K chunks. This resulted in poor
performance when compared to, for example, smbnetfs on the same
network.

The value of 128k is chosen both because it is emperically
the "levelling off point" for throughput into mpv's cache, and because
it is the value chosen by smbnetfs when serving smb shares to
mpv.

Note that this change has no effect unless --cache is explicitly
specified as smb:// streams do not activate cache by default. This is
because the default cache size of 320K is so small it actually makes
smb:// perfomance worse. For best results use at least --cache=1024.
2014-05-12 15:09:38 -07:00
wm4 78128bddda Kill all tabs
I hate tabs.

This replaces all tabs in all source files with spaces. The only
exception is old-makefile. The replacement was made by running the
GNU coreutils "expand" command on every file. Since the replacement was
automatic, it's possible that some formatting was destroyed (but perhaps
only if it was assuming that the end of a tab does not correspond to
aligning the end to multiples of 8 spaces).
2014-04-13 18:03:01 +02:00
wm4 a2bc1c28a5 stream_smb: remove dead code
Yep, smb_username/password were unused since forever, even in MPlayer.
Removal untested. (Does anyone even use smb://?)
2013-12-22 23:42:58 +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 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 971e8456fc stream: fix url_options field, make protocols field not fixed length
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.
2013-08-26 10:09:45 +02:00
wm4 f806e268c6 stream: don't require streams to set s->pos in seek callback
Instead, set s->pos depending on the success of the seek callback.
2013-08-22 19:14:26 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
wm4 bc1d61cf42 stream: redo URL parsing, replace m_struct usage with m_config
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.)
2013-08-02 17:02:34 +02:00
wm4 f406482d84 stream: remove useless author/comment fields
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.
2013-07-12 22:16:27 +02:00
wm4 f63193f58f stream: remove fd member
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.
2013-07-12 22:16:26 +02:00
wm4 5c1b8d4aa1 stream: don't require streams to set a type
Set the type only for streams that have special treatment in other parts
of the code.
2013-07-12 22:16:26 +02:00
wm4 52c3eb6976 core: change open_stream and demux_open signature
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.
2013-07-12 21:56:40 +02:00
wm4 0d5e6084ae stream: don't set EOF flag in stream implementations
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.
2013-06-16 22:05:10 +02:00
wm4 ddffcce678 stream, demux: replace off_t with int64_t
On reasonable systems, these types were the same anyway. Even on
unreasonable systems (seriously, which?), this may reduce potential
breakage.
2012-11-20 18:00:15 +01:00
reimar 51dac4e070 stream: change STREAM_CTRL_GET_SIZE argument type to uint64_t
Update endpos each time libavformat asks for it.

Fixes playback of still downloading files to not stop before we
really reached the end.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35107 b3059339-0415-0410-9bf9-f77b7e298cf2

Conflicts:
	libmpdemux/demux_lavf.c

Change STREAM_CTRL_GET_SIZE argument type from off_t to
uint64_t.
Also fix the incorrect type of the uint64_res variable.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35360 b3059339-0415-0410-9bf9-f77b7e298cf2

Conflicts:
	libmpdemux/demux_lavf.c
	libmpdemux/muxer_lavf.c

Note: also merges the "forgotten" cache support from r35107.
2012-11-20 18:00:14 +01:00
wm4 4873b32c59 Rename directories, move files (step 2 of 2)
Finish renaming directories and moving files. Adjust all include
statements to make the previous commit compile.

The two commits are separate, because git is bad at tracking renames
and content changes at the same time.

Also take this as an opportunity to remove the separation between
"common" and "mplayer" sources in the Makefile. ("common" used to be
shared between mplayer and mencoder.)
2012-11-12 20:08:18 +01:00
Uoti Urpala 7e65428712 Merge branch 'mplayer1_changes' 2011-05-02 00:46:03 +03:00
Clément Bœsch 52743acba3 cleanup: avoid various GCC warnings 2011-04-20 04:22:53 +03:00
ranma f8c32fc953 stream: Make stream_write_buffer() check for short writes
None of the calling sites to stream_write_buffer were checking the
return value to see if all bytes got written (nothing in current code
actually calls it any more after MEncoder was removed).

This was causing (very occasionally) problems with mencoder when using
output pipes AND running under a sandbox or when being straced (ptrace
is the culprit). Theoretically this problem can happen without pipes
or ptrace.

Only stream_file, stream_smb and stream_ffmpeg implement
write_buffer and ffmpeg already handles this internally.

Original patch by Sang-Uok Kum.

Signed-off-by: Tobias Diedrich <ranma@google.com>

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32881 b3059339-0415-0410-9bf9-f77b7e298cf2
2011-04-12 18:23:43 +03:00
Uoti Urpala 00323c06e2 Delete things related to old translation system
Remove the help/ subdirectory, configure code to create toplevel
help_mp.h, and all the '#include "help_mp.h"' lines from .c files.
2010-03-10 03:47:14 +02:00
Uoti Urpala 12d3caebc7 Merge svn changes up to r30475 2010-03-09 19:18:43 +02:00
diego 59e26907b6 Add license header to all files missing it in the stream subdirectory.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30468 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-01-30 22:26:47 +00:00
Uoti Urpala 5995bc175a Merge svn changes up to r29962 2009-11-23 01:56:21 +02:00
reimar af2988cbce Finally rename the STREAM_SEEK define to MP_STREAM_SEEK, there are just too many
name clashes, in particular with Windows headers (which define STREAM_SEEK as an enum type).


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29962 b3059339-0415-0410-9bf9-f77b7e298cf2
2009-11-22 15:18:21 +00:00
Uoti Urpala 0eb321bf2c Remove trailing whitespace from most files 2009-07-07 02:34:35 +03:00
Amar Takhar e306174952 Translation system changes part 2: replace macros by strings
Replace all MSGTR_ macros in the source by the corresponding English
string.
2009-07-07 01:38:20 +03:00
Amar Takhar b5972d6f14 Translation system changes part 1: wrap translated strings
Replace mp_msg() calls which have a translated string as the format
argument with mp_tmsg and add _() around all other translated strings.
2009-07-07 01:28:07 +03:00
diego 6e9cbdc104 whitespace cosmetics: Remove all trailing whitespace.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
2009-05-13 02:58:57 +00:00
reimar 6f616c316d stream_opts should be const
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25719 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-01-13 12:34:42 +00:00
reimar dd2fcb4370 stream_opts arrays should be const
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25270 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-12-02 21:37:08 +00:00
reimar cd3d3369e1 Mark all stream_info_t as const
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25239 b3059339-0415-0410-9bf9-f77b7e298cf2
2007-12-02 13:22:53 +00:00