Commit Graph

60 Commits

Author SHA1 Message Date
wm4 1d2a111337 player: strip 'file://' from filenames on playback start
This fixes two things:

1. Dropping files on the VO window will auto-load subtitles (since most
   drag & drop code prefixes the filenames with 'file://', and the
   subtitle auto-load code considers 'file://' non-local)
2. Fix behavior of the %x screenshot filename template (similar problem)

One could force all that code to special-case 'file://' URLs, but just
replacing the filename on playback start is simpler.
2014-01-08 21:46:42 +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
Stefano Pigozzi e4f35516fb stream: fix clang warning
Good clang catches programming errors. `open(2)` takes `int` not `mode_t`.
2013-12-07 17:14:20 +01:00
wm4 95cfe58e3d Use O_CLOEXEC when creating FDs
This is needed so that new processes (created with fork+exec) don't
inherit open files, which can be important for a number of reasons.

Since O_CLOEXEC is relatively new (POSIX.1-2008, before that Linux
specific), we #define it to 0 in io.h to prevent compilation errors on
older/crappy systems. At least this is the plan.

input.c creates a pipe. For that, add a mp_set_cloexec() function (which
is based on Weston's code in vo_wayland.c, but more correct). We could
use pipe2() instead, but that is Linux specific. Technically, we have a
race condition, but it won't matter.
2013-11-30 22:40:51 +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
wm4 a790f2133b stream: move file forward skipping to common stream implementation
stream_file.c contains some code meant for forward seeking with pipes.
This simply reads data until the seek position is reached. Move this
code to stream.c. This stops stream_file from doing strange things
(messing with stream internals), and removes the code duplication too.

We also make stream_seek_long() use the new skip code. This is shorter
and much easier to follow than the old code, which basically did strange
things.
2013-08-22 18:33:19 +02:00
wm4 974250b60c stream_file: uncrustify 2013-08-22 18:20:49 +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 44d6ac06ae stream: parse URL escapes for file://
So for example "file:///file%20name.mkv" will open "file name.mkv".

I'm not sure whether we want/need this. The old code didn't do it.
Also, it's not really clear whether this is handled correctly. It
seems the corresponding freedesktop.org "standard" allows a (useless)
hostname part, which we should skip in theory. The number of slashes
is not really clear either. We can open relative filenames (by removing
one of the slashes from the example above), which is perhaps an
unneeded feature. How does this even work with Windows paths?

This issues can probably be corrected later.

The URL unescape code is based on code from m_option.c removed with
a recent commit.
2013-08-02 17:05:26 +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 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 c4f83ac6e9 stream: remove weird STREAMTYPE_STREAM special handling
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.
2013-07-07 21:10:44 +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
reimar ff08d0c34a stream_file: explicitly signal EOF
Explicitly signal EOF when reaching the end of a file/pipe.

Fixes a 4 second delay due to stream_reconnect for e.g.
echo | mplayer -

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35112 b3059339-0415-0410-9bf9-f77b7e298cf2
2012-10-30 19:50:18 +01:00
Uoti Urpala 202ea8214e stream_file: print strerror() when failing to open a file
stream_file always printed "File not found" if it could not open a
file, even though this could be due to other reasons such as
permission problems. Print strerror() information instead. This
changes the output for "mplayer /etc/shadow" from
File not found: '/etc/shadow'
to
Cannot open file '/etc/shadow': Permission denied
2012-08-16 17:16:32 +02:00
wm4 6de8120822 Merge remote-tracking branch 'origin/master' into my_master
Conflicts:
	command.c
	mp_core.h
	mplayer.c
	screenshot.c
2012-03-16 19:14:44 +01:00
wm4 a1244111a7 windows support: unicode filenames
Windows uses a legacy codepage for char* / runtime functions accepting
char *. Using UTF-8 as the codepage with setlocale() is explicitly
forbidden.

Work this around by overriding the MSVCRT functions with wrapper
macros, that assume UTF-8 and use "proper" API calls like _wopen etc.
to deal with unicode filenames. All code that uses standard functions
that take or return filenames must now include osdep/io.h. stat()
can't be overridden, because MinGW-w64 itself defines "stat" as a
macro. Change code to use use mp_stat() instead.

This is not perfectly clean, but still somewhat sane, and much better
than littering the rest of the mplayer code with MinGW specific hacks.
It's also a bit fragile, but that's actually little different from the
previous situation. Also, MinGW is unlikely to ever include a nice way
of dealing with this.
2012-03-09 20:48:54 +02:00
wm4 912e268931 stream: refuse to open directories
It's pointless.
2012-02-19 17:33:36 +01: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
reimar 0792847d4a cache: read up to 64 KiB at once from stream_file
Make the file protocol read up to 64 KiB at once when the cache is used,
assuming that files will generally be readable with high bandwidth.
This should improve performance when playing e.g. from high-latency
network shares.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32616 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-11-14 12:24:11 +02:00
reimar 112d8dd2fd stream_file: Simplify and document MinGW stdin hack
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31964 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-11-02 04:15:48 +02: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 0269d22d32 Merge svn changes up to r30876 2010-03-10 03:18:42 +02:00
Uoti Urpala 240550bbb9 Merge svn changes up to r30848 2010-03-10 03:00:14 +02:00
Uoti Urpala 13221a7165 Merge svn changes up to r30663
Conflicts:
	gui/cfg.c
	libmpcodecs/vd_dmo.c
	mplayer.c
2010-03-10 00:13:11 +02:00
Uoti Urpala 12d3caebc7 Merge svn changes up to r30475 2010-03-09 19:18:43 +02:00
komh dd491c0d28 Define O_BINARY in stream/stream.h unless it is defined yet, and use it
in other places.

This removes platform specific checks and prevents repeated definitions
of O_BINARY.



git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30850 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-03-06 07:24:41 +00:00
komh b10a6917f4 Define HAVE_SETMODE conditionally, and use it in stream/stream_file.c instead
of platform specific predefined macros.



git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30829 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-03-04 14:46:44 +00:00
komh 316e05b877 Replace platform preprocessor check by HAVE_DOS_PATHS.
This is both more elegant and more portable.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30650 b3059339-0415-0410-9bf9-f77b7e298cf2
2010-02-19 09:14:01 +00: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 a2037a2eff Merge svn changes up to r29412 2009-07-07 02:56:01 +03: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 bf67bb10a1 Files should be opened in binary mode on OS/2.
patch by KO Myung-Hun, komh chollian net


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29346 b3059339-0415-0410-9bf9-f77b7e298cf2
2009-06-03 14:06:10 +00: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
diego 4d644f513c Replace preprocessor check for WIN32 with checks for __MINGW32__ and __CYGWIN__.
This avoids a pointless indirection that only obscures what is really done.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27761 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-10-13 16:23:55 +00:00
reimar bafdcd542d Avoid a pointless special-case for opening a file
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26083 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-02-24 11:21:27 +00:00
diego b4558a3738 Add support for DOS-style file:///x:/path paths.
patch by KO Myung-Hun, komh chollian net


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26037 b3059339-0415-0410-9bf9-f77b7e298cf2
2008-02-20 08:20:49 +00:00