Commit Graph

139 Commits

Author SHA1 Message Date
Christoph Heinrich c0807e98fb options: remove explicit initialization of integers to 0 2023-02-21 17:15:17 +00:00
Christoph Heinrich 91cc0d8cf6 options: transition options from OPT_FLAG to OPT_BOOL
c784820454 introduced a bool option type
as a replacement for the flag type, but didn't actually transition and
remove the flag type because it would have been too much mundane work.
2023-02-21 17:15:17 +00:00
sfan5 b6b8380518 stream/dvb: drop support for DVB API before 5.8
There is really no reason to keep the #ifdef mess around given
that version is available since December 2012 (Linux 3.7).
2023-01-12 22:02:07 +01:00
Oliver Freyermuth 3d9c0eae9e stream_dvb: add missing mutex unlock
This deadlock was not triggered in real use since configuration
validity does not change at runtime.

closes #9459
2021-11-16 22:24:14 +01:00
Oliver Freyermuth b4c1554f7a stream_dvb: Remove call to stream_drop_buffers in fill_buffer.
The call was hidden very well, via
dvb_streaming_read -> dvb_update_config
-> dvb_streaming_start -> dvb_set_channel,
and broke the stream buffering logic.
Dropping that call does not noticeably slow down channel switches.
2020-04-10 17:12:53 +02:00
wm4 26f4f18c06 options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with

   {"name", ...

followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.

I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.

Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.

Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.

In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-18 19:52:01 +01:00
Oliver Freyermuth 1571276d64 stream_dvb: Remove implicit fallthroughs and consistify debug messages.
The code is more explicit now and less confusing,
and debug messages for the channel parsing for the several delivery systems
are now more similar.
2019-12-28 19:16:07 +01:00
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 c26e80d0fd command: shuffle some crap around
This is preparation to get rid of the option-to-property bridge
(mp_on_set_option). This is a pretty insane thing that redirects
accesses to options to properties. It was needed in the ever ongoing
transition from something to... something else.

A good example for the need of this bridge is applying profiles at
runtime. This obviously goes through the config parser, but should also
make all changes effective, for which traditionally the property layer
is used.

There isn't much left that needs this bridge. This commit changes a
bunch of options (which also have a property implementation) to use
option change notifications instead. Many of the properties are still
left, but perform unrelated functions like OSD formatting.

This should be mostly compatible. There may be some subtle behavior
changes. For example, "hwdec" and "record-file" do not check for changes
anymore before applying them, so writing the current value to them
suddenly does something, while it was ignored before.

DVB changes untested, but should work.
2019-11-25 00:26:36 +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
Oliver Freyermuth 8c52cd4e4a stream_dvb: Remove now replaced stream-control code for good. 2019-10-02 01:25:45 +02:00
Oliver Freyermuth 12d74e4d95 stream_dvb: Allow actual zapping of channels again.
This is realized by dvbin-channel-switch-offset,
which is a numeric offset on the channel initially tuned to.
Since the channel list is kept in the stream alone
depending on detected hardware and chosen card,
and no available backchannel to the player, there's no direct
property which could be switched.

Using input.conf like:
H cycle dvbin-channel-switch-offset up
K cycle dvbin-channel-switch-offset down
Q set dvbin-prog "ZDF HD"
allow fast and reliable channel switching again.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth 9cd4638d2b stream_dvb: Add dvb_update_config to poll config parameters.
If any parameters have been updated, reinitiate streaming_start.
Throttle checks since we poll from streaming_read.
This also requires the player to re-initialize, since all video
and audio streams and even the transport format may change.
This is added in the next commit.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth 1768ea0d15 stream_dvb: Move stream->is_on initialization to state preparation.
Notably, this allows to call dvb_streaming_start more than once,
simplifying e.g. channel switching.
Also, get rid of unused timeout variable.
2019-10-02 01:25:45 +02:00
Oliver Freyermuth c15ec393dd stream_dvb: Factor out logic to determine program and card.
This is now treated in dvb_parse_path consistently
instead of logic scattered over various functions.
This is a requirement to sensibly re-evaluate config
after options have been changed, since we have two ways
to configure the stream (decorated URI and config parameters).
2019-10-02 01:25:45 +02:00
Oliver Freyermuth 76918be267 stream_dvb: Use separated out options struct.
This also allows the use of m_config_cache_alloc
which allows to watch config updates.
2019-10-02 01:25:45 +02:00
wm4 9280e6b322 stream_dvb: remove unused variable
(At first I left this intentionally, because the temporarily disabled
stream ctrl code used it, but there's actually no reason to annoy
everyone with the warning.)
2019-09-21 22:05:24 +02:00
wm4 ddcbe66768 stream: remove some more optical disc leftovers 2019-09-13 17:32:21 +02:00
wm4 b30e85508a Remove classic Linux analog TV support, and DVB runtime controls
Linux analog TV support (via tv://) was excessively complex, and
whenever I attempted to use it (cameras or loopback devices), it didn't
work well, or would have required some major work to update it. It's
very much stuck in the analog past (my favorite are the frequency tables
in frequencies.c for analog TV channels which don't exist anymore).

Especially cameras and such work fine with libavdevice and better than
tv://, for example:

  mpv av://v4l2:/dev/video0

(adding --profile=low-latency --untimed even makes it mostly realtime)

Adding a new input layer that targets such "modern" uses would be
acceptable, if anyone is interested in it. The old TV code is just too
focused on actual analog TV.

DVB is rather obscure, but has an active maintainer, so don't remove it.
However, the demux/stream ctrl layer must go, so remove controls for
channel switching. Most of these could be reimplemented by using the
normal method for option runtime changes.
2019-09-13 17:32:19 +02:00
Oliver Freyermuth c8424a3bee stream_dvb: Increase timeout of streaming read.
It seems some DVB-T2 cards take longer to push out data.
2019-09-02 01:19:33 +03:00
Oliver Freyermuth 66128dec82 stream_dvb: Adapt to VDR channel config format.
While they accept the frequency field with MHz for DVB-S,
for DVB-C and DVB-T, it may be in Hz, kHz or MHz.
The official rule is to multiply whatever is in the channels.conf
by 1000 until a value > 1000000 is reached to get correct units for tuning.
2019-09-02 01:19:33 +03:00
Jan Ekström 199aabddcc Merge branch 'master' into pr6360
Manual changes done:
  * Merged the interface-changes under the already master'd changes.
  * Moved the hwdec-related option changes to video/decode/vd_lavc.c.
2019-03-11 01:00:27 +02:00
Oliver Freyermuth d6d6da4711 stream_dvb: Correct range for dvbin-card option.
Adapt documentation accordingly and
also, fix an off-by-one check in the code.
closes #6371
2018-12-12 01:50:43 +02:00
wm4 559a400ac3 demux, stream: rip out the classic stream cache
The demuxer cache is the only cache now. Might need another change to
combat seeking failures in mp4 etc. The only bad thing is the loss of
cache-speed, which was sort of nice to have.
2018-08-31 12:55:22 +02:00
wm4 d7ca95c3ea command: whitelist some blocking accesses for certain demuxers/streams
The properties/commands touched in this commit are all for obscure
special inputs (BD/DVD/DVB/TV), and they all block on the demuxer/stream
layer. For network streams, this blocking is very unwelcome. They will
affect playback and probably introduce pauses and frame drops. The
player can even freeze fully, and the logic that tries to make playback
abortable even if frozen complicates the player.

Since the mentioned accesses are not needed for network streams, but
they will block on network streams even though they're going to fail,
add a flag that coarsely enables/disables these accesses. Essentially it
establishes a whitelist of demuxers/streams which support them.

In theory you could to access BD/DVD images over network (or add such
support, I don't think it's a thing in mpv). In these cases these
controls still can block and could even "freeze" the player completely.

Writing to the "program" and "cache-size" properties still can block
even for network streams. Just don't use them if you don't want freezes.
2018-05-24 19:56:35 +02:00
rim 04d04033e6 dvb: Add multiple frontends support: MAX_FRONTENDS now 8. 2017-12-16 23:24:55 -08: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
Oliver Freyermuth de0c1dd4f5 dvb: Skip channel if ATSC device does not support cable / terr.
This matches what is done for the other multi-delivery-system
cards.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth add0cbea2a dvb: Implement parsing of modulation for VDR-style channels config.
This is required for ATSC cable / terrestrial support.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth e46338c66a dvb: Fixes for ATSC tuning.
ATSC is a mix of terrestrial and cable,
and depending on modulation is actually using
DVBC_ANNEX_B. Thus, we need to override the delivery
system depending on the modulation, channel by channel.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth 20381a5f5a stream_dvb: Multiply frequency and sample rate by 1000 for VDR.
These values are kept with a different unit in VDR style config
for all delivery systems, not only for DVB-S / DVB-S2.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
ivan-83 e40c41de19 dvb: add support for DVB-T2
Probably does much more:

+ add support DVB-T2
* DVB params set to AUTO by default
* MAX_CARDS: 4 -> 16
* DMX_SET_BUFFER_SIZE: 64kb -> 256kb
+ add DTV_CLEAR call before tune
+ add logic from https://github.com/olifre/mpv/commits/dvb-mixed-api-scan
* rename type to delsys
* single playlist per adapter
* card -> adapter
* fix channels order in playlist
* update internal api
* auto fallback to old DVB API on tune
* fix DELSYS_SUPP_MASK value
* remove tone - unused
* add channel mem zeroize in config parser
+ add code from libdvbv5 for detect delivery systems
* SYS_DVBC_ANNEX_AC replaced to SYS_DVBC_ANNEX_A + SYS_DVBC_ANNEX_C

Signed-off-by: wm4 <wm4@nowhere>
2017-03-06 16:12:27 +01:00
wm4 05f63edc7b Revert "dvb: add support for DVB-T2"
This reverts commit df91e492fd.

Multiple issues such as weird code with undefined behavior (like
(like conf_file*). The PR wasn't properly reviewed anyway (my error),
so this commit should be reviewed and then merged again.
2017-02-14 13:31:06 +01:00
ivan-83 df91e492fd dvb: add support for DVB-T2
Probably does much more:

+ add support DVB-T2
* DVB params set to AUTO by default
* MAX_CARDS: 4 -> 16
* DMX_SET_BUFFER_SIZE: 64kb -> 256kb
+ add DTV_CLEAR call before tune
+ add logic from https://github.com/olifre/mpv/commits/dvb-mixed-api-scan
* rename type to delsys
* single playlist per adapter
* card -> adapter
* fix channels order in playlist
* update internal api
* auto fallback to old DVB API on tune
* fix DELSYS_SUPP_MASK value
* remove tone - unused
* add channel mem zeroize in config parser
+ add code from libdvbv5 for detect delivery systems
* SYS_DVBC_ANNEX_AC replaced to SYS_DVBC_ANNEX_A + SYS_DVBC_ANNEX_C

Signed-off-by: wm4 <wm4@nowhere>
2017-02-13 11:17:51 +01:00
Thomas V 1672204dc5 dvb: move priv allocation to dvb_open
This fixes a crash when changing channels; previously stream->priv would not
be initialized when dvb_get_state reused the existing state.

Signed-off-by: Thomas VanSelus <tvanselus@diospyros.us>
2017-02-10 08:19:28 +01:00
wm4 fb9a32977d stream: get rid of streamtype enum
Because it's kind of dumb. (But not sure if it was worth the trouble.)

For stream_file.c, we add new explicit fields. The rest are rather
special uses and can be killed by comparing the stream impl. name.

The changes to DVD/BD/CD/TV are entirely untested.
2017-02-02 18:26:58 +01:00
wm4 9213db0d49 stream_dvb: remove weird option parsing stuff
Mostly untested.
2016-09-09 17:54:35 +02:00
wm4 337ad4fef4 stream_dvb: fix minor resource leaks
Fixes CID 1350062 and 1350061.

Just for the sake of shutting up Coverity.
2016-02-12 15:51:49 +01:00
wm4 8e4eee9a9a stream_dvb: remove dead code
Fixes CID 1350063.
2016-02-12 15:47:25 +01:00
Oliver Freyermuth 3c4f13c23a dvb: fix segmentation fault in case no valid configuration is found.
This was introduced in c55b242 .
2016-01-24 20:38:51 +01:00
wm4 2df448b1f3 dvb: remove trailing whitespace 2016-01-22 11:55:47 +01:00
Oliver Freyermuth e904129b79 stream_dvb: support frontends with multiple delivery systems.
Most common case would be DVB-C / DVB-T combination cards.
Cards with multiple delivery systems are only supported
starting from DVBv5 API (Kernel 2.6.38).
In this case, we loop over all delivery systems and
just treat them as different cards would be treated:
They all get their own TUNER-type, channel-list parsing etc.
2016-01-21 00:34:02 +01:00
Oliver Freyermuth 62acd315ad player, stream_dvb: implement dvb-channel-name property.
On read, it returns the name of the current DVB program,
on write, it triggers a channel-switch to the program
if it is found in the channel list of the currently active card.
Compared to the dvb-channel property which already exists
and is a pair of integers (card + channel number) this has the limitation
of not switching the card, but is probably of much more common use.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth c55b242b4e stream_dvb: global protection mutex and usage bit for global_dvb_state.
The mutex is used in dvbin_open and dvbin_close only since these are
the only entry / exit points to the stream.
When opening, it is first checked (mutexed) whether the state already exists
and is in use, then a STREAM_ERROR is returned,
since there may be only one stream_dvb active at a time.
State-creation itself is also protected by mutex.
In dvbin_close, the usage-bit is set to false (mutexed) in case
of channel switch.
In case of stream-teardown, the state is destructed
(also protected by mutex).
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 1e46bda0f8 stream_dvb: implement GET_METADATA and return program name.
Now title will be the current channel name also after channel switch.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 16723d4bb1 stream_dvb: persist state-information across channel-switches.
The state-structure is kept in a static pointer and reused on
recreation of the stream.
To not leak the state and the FDs within upon mpv shutdown,
the state-structure is still destructed gracefully in dvbin_close(),
unless a channel switch has been initiated directly before.
This fixes channel-switching for DVB which was broken since a609877.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 4c3f95708f dvb: rename dvb_config_t to dvb_state_t, keep config and state there.
The state-struct now contains everything which can be kept after initial initialization.
This includes the channel-lists, configuration, device-fds and also information like
current channel and current card.
The dvb_priv_t is kept containing the mp-options, a pointer to the state and to the logger.
After this restructuring, the state-struct contains all information which can be persisted
across channel switching.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 2dd8982f73 dvb: cleanup dvb_params struct, remove some unneeded fds
One was just used as an alias, the other one (sec_fd) was not used at
all.

Signed-off-by: wm4 <wm4@nowhere>
2016-01-07 19:20:48 +01:00
Philip Sequeira 6172e843cd options: add M_OPT_FILE to new options that are missing it
Fixes shell completion.
2015-03-07 22:19:38 +01:00
wm4 616cfb90c1 stream_dvb: silence bogus compiler warning
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.
2015-01-19 17:58:37 +01:00