2010-01-30 23:24:23 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 23:24:23 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
player: change license of most core files to LGPL
These files have all in common that they were fully or mostly taken from
mplayer.c. (mplayer.c was a huge file that contains almost all of the
playback core, until it was split into multiple parts.) This was
probably the hardest part to relicense, because so much code was moved
around all the time.
player/audio.c still does not compile. We'll have to redo audio
filtering. Once that is done, we can probably actually provide an
actual LGPL configure switch.
Here is a relatively detailed list of potential issues:
8d190244: author did not reply, parts were made GPL-only in a previous
commit.
7882ea9b: author could not be reached, but the code is gone. wscript
still has --datadir switch, but I don't think this is relevant to
copyright.
f197efd5: unclear origin, but I consider the code gone anyway (replaced
with generic OSD mechanisms).
8337d9c2: author did not reply, but only the option still exists (under
a different name), other code was removed.
d8fd7131: did not reply. Disabled in a previous commit.
05258251: same author as above. Both fields actually seem to have
vanished (even when tracking renames), so no action taken.
d459e644, 268b2c1a: author did not reply, but we reuse only the options
(with different names and slightly or fully different semantics, and
completely different implementations), so I don't think this is relevant
for copyright.
09e742fe, 17c39c4e: same as above.
e8a173de, bff4b3ee: author could not be reached. The commands were
reworked to properties, and the code outside of the TV code were moved
back to the TV code. So I don't think copyright applies to the current
command.c parts (mp_property_tv_color, mp_property_tv_freq,
mp_property_tv_scan). The TV parts remain GPL.
0810e427: could not be reached. Disabled in a previous commit.
43744a2d: unknown author, but this was replaced by dynamic alloc (if the
change is even copyrightable).
116ca0c7: unknown author; reasoning see input.c relicensing commit.
e7e4d1d8: these semantics still exist, but as generic code, and this
code was fully removed.
f1175cd9: the author of the cited patch is unknown, and upon inspection
it turns out that I was only using the idea to pause the player on EOF,
so I claim it's not copyright relevant.
25affdcc: author could not be reached (yet) - but it's only a function
rename, not copyrightable.
5728504c was committed by Arpi (who agreed), but hints that it might be
by a different author. In fact it seems to be mostly this patch:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2001-November/002041.html
The author did not respond, but it all seems to have been removed later.
It's a terrible mess though. Arpi reverted the A-V sync code at first,
but left the RTC code for a while. The following commits remove these
changes 100%: 14b35442, 7181a091, 31482783, 614f8475, df58e822.
cehoyos did explicitly not agree to LGPL, but was involved in the
following changes:
c99d8fc8: applied a patch and didn't modify it, the original author
agreed.
40ac0d31: author could not be reached, but all code is gone anyway. The
"af" command has a similar function, but works completely different and
actually reuses a mechanism older than this patch.
54350436: applied a patch, but didn't modify it, except for adding a
German translation, which was removed later.
a2dda036: same situation as above
240b743e: this was made GPL-only in a previous commit
7b25afd7: same as above (for now)
kirijua could not be reached, but was a regular patch contributor:
c2c997fd: video equalizer code move; probably not copyrightable. Is GPL
due to Nick anyway.
be54f481: technically, this became the audio track property later. But
all what is left is the fact that you pass a track ID to it, so consider
the original coypright non-relevant.
2f376d1b: this was rewritten in b7052b43, but for now we can afford to
be careful, so this was marked as GPL only in a previous commit.
43844d09: remaining parts in main.c were reverted in a previous commit.
anders has mostly disagreed with the LGPL relicensing. Does not want
libaf to become LGPL, but made some concessions. In particular, he
granted us permission to relicense 4943e9c52c and 242aa6ebd4. We also
consider some of his changes remaining in mpv not relevant for copyright
(such as 735de602 - we won't remove the this option completely). We will
completely remove his other contributions, including the entire audio
filter chain. For now, this stuff is marked as GPL only. The remaining
question is how much code in player/audio.c (based on the former
mplayer.c and dec_audio.c) is under his copyright. I made claims about
this in a previous commit.
Nick(ols) Kurshev, svn username "nick" and "nickols_k", could not be
reached. He had a lot of changes in early MPlayer. It seems all of that
was removed, at least in mpv. His main work, like VIDIX or libswscale
work, does not exist in mpv anymore, but the changes to mplayer.c and
other core parts still deserve attention:
a4119f6b, fb927549, ad3529b8, e11b23dc, 5f2178be, 93c371d5: removed in
b43d67e0, d1628d12, 24ed01fe, df58e822.
0a83c6ec, 104c125e, 4e067f62, aec5dcc8, b587a3d6, f3de6e6b: DR, VAA, and
"tune" stuff was fully removed later on or replaced with other
mechanisms.
340183b0: screenshots were redone later (the VOCTRL was even removed,
with an independent implementation using the same VOCTRL a few years
later), so not relevant anymore. Basically only the 's' shortcut remains
(but not its implementation).
92c5c274, bffd4007, 555c6766: for now marked as GPL only in a previous
commit.
Might contain some trace amounts of "michael"'s copyright, who agreed to
LGPL only once the core is relicensed. This will still be respected, but
I don't think it matters at this in this case. (Some code touched by him
was merged into mplayer.c, and then disappeared after heavy
refactoring.)
I tried to be as careful and as complete as possible. It can't be
excluded that amends to this will be made later.
This does not make the player LGPL yet.
2017-06-23 13:53:41 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 23:24:23 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-13 15:49:39 +00:00
|
|
|
#include <float.h>
|
2007-02-21 00:49:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <unistd.h>
|
2007-03-09 14:04:07 +00:00
|
|
|
#include <string.h>
|
2008-11-29 06:09:57 +00:00
|
|
|
#include <stdbool.h>
|
2012-02-10 18:03:24 +00:00
|
|
|
#include <assert.h>
|
2013-06-04 11:33:01 +00:00
|
|
|
#include <time.h>
|
2014-11-28 23:34:53 +00:00
|
|
|
#include <math.h>
|
2014-04-05 21:54:21 +00:00
|
|
|
#include <pthread.h>
|
2013-11-30 21:47:17 +00:00
|
|
|
#include <sys/types.h>
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2020-03-18 21:45:59 +00:00
|
|
|
#include <ass/ass.h>
|
2013-06-27 16:21:07 +00:00
|
|
|
#include <libavutil/avstring.h>
|
|
|
|
#include <libavutil/common.h>
|
|
|
|
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2014-02-10 20:01:35 +00:00
|
|
|
#include "client.h"
|
2016-03-01 20:46:49 +00:00
|
|
|
#include "common/av_common.h"
|
2016-02-29 19:57:31 +00:00
|
|
|
#include "common/codecs.h"
|
2014-01-16 20:24:39 +00:00
|
|
|
#include "common/msg.h"
|
|
|
|
#include "common/msg_control.h"
|
stats: some more performance graphs
Add an infrastructure for collecting performance-related data, use it in
some places. Add rendering of them to stats.lua.
There were two main goals: minimal impact on the normal code and normal
playback. So all these stats_* function calls either happen only during
initialization, or return immediately if no stats collection is going
on. That's why it does this lazily adding of stats entries etc. (a first
iteration made each stats entry an API thing, instead of just a single
stats_ctx, but I thought that was getting too intrusive in the "normal"
code, even if everything gets worse inside of stats.c).
You could get most of this information from various profilers (including
the extremely primitive --dump-stats thing in mpv), but this makes it
easier to see the most important information at once (at least in
theory), partially because we know best about the context of various
things.
Not very happy with this. It's all pretty primitive and dumb. At this
point I just wanted to get over with it, without necessarily having to
revisit it later, but with having my stupid statistics.
Somehow the code feels terrible. There are a lot of meh decisions in
there that could be better or worse (but mostly could be better), and it
just sucks but it's also trivial and uninteresting and does the job. I
guess I hate programming. It's so tedious and the result is always shit.
Anyway, enjoy.
2020-04-08 22:27:54 +00:00
|
|
|
#include "common/stats.h"
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
#include "filters/f_decoder_wrapper.h"
|
2008-03-28 01:07:59 +00:00
|
|
|
#include "command.h"
|
2013-12-01 01:07:32 +00:00
|
|
|
#include "osdep/timer.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
2013-12-17 00:23:09 +00:00
|
|
|
#include "input/input.h"
|
2015-01-23 20:45:13 +00:00
|
|
|
#include "input/keycodes.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/stream.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "demux/demux.h"
|
|
|
|
#include "demux/stheader.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/playlist.h"
|
2013-11-24 11:58:06 +00:00
|
|
|
#include "sub/osd.h"
|
2011-01-16 18:03:08 +00:00
|
|
|
#include "sub/dec_sub.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
|
|
|
#include "options/m_property.h"
|
2020-03-12 22:07:05 +00:00
|
|
|
#include "options/m_config_frontend.h"
|
2021-05-01 12:26:50 +00:00
|
|
|
#include "osdep/getpid.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/out/vo.h"
|
|
|
|
#include "video/csputils.h"
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
#include "video/hwdec.h"
|
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).
The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.
Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.
For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.
Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 19:00:20 +00:00
|
|
|
#include "audio/aframe.h"
|
2017-09-21 10:48:30 +00:00
|
|
|
#include "audio/format.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/out/ao.h"
|
2016-07-01 17:39:04 +00:00
|
|
|
#include "video/out/bitmap_packer.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/path.h"
|
2011-10-06 18:46:01 +00:00
|
|
|
#include "screenshot.h"
|
2018-05-06 16:27:18 +00:00
|
|
|
#include "misc/dispatch.h"
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
#include "misc/node.h"
|
2018-05-06 16:27:18 +00:00
|
|
|
#include "misc/thread_pool.h"
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
#include "misc/thread_tools.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-11-30 21:40:51 +00:00
|
|
|
#include "osdep/io.h"
|
2015-01-01 19:37:49 +00:00
|
|
|
#include "osdep/subprocess.h"
|
2013-11-30 21:40:51 +00:00
|
|
|
|
2013-12-17 00:08:53 +00:00
|
|
|
#include "core.h"
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
2016-09-28 11:47:30 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
struct command_ctx {
|
2016-09-01 18:00:43 +00:00
|
|
|
// All properties, terminated with a {0} item.
|
|
|
|
struct m_property *properties;
|
|
|
|
|
2013-12-01 01:07:32 +00:00
|
|
|
double last_seek_time;
|
|
|
|
double last_seek_pts;
|
2014-12-17 21:56:45 +00:00
|
|
|
double marked_pts;
|
2020-07-17 12:21:42 +00:00
|
|
|
bool marked_permanent;
|
2013-12-01 01:07:32 +00:00
|
|
|
|
2015-05-22 18:01:12 +00:00
|
|
|
char **warned_deprecated;
|
|
|
|
int num_warned_deprecated;
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
struct overlay *overlays;
|
2014-07-25 12:22:40 +00:00
|
|
|
int num_overlays;
|
|
|
|
// One of these is in use by the OSD; the other one exists so that the
|
|
|
|
// bitmap list can be manipulated without additional synchronization.
|
|
|
|
struct sub_bitmaps overlay_osd[2];
|
2016-07-01 17:39:04 +00:00
|
|
|
int overlay_osd_current;
|
|
|
|
struct bitmap_packer *overlay_packer;
|
2014-10-10 17:46:21 +00:00
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
struct hook_handler **hooks;
|
|
|
|
int num_hooks;
|
|
|
|
int64_t hook_seq; // for hook_handler.seq
|
|
|
|
|
2015-02-12 15:53:56 +00:00
|
|
|
struct ao_hotplug *hotplug;
|
2016-09-21 13:56:54 +00:00
|
|
|
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
struct mp_cmd_ctx *cache_dump_cmd; // in progress cache dumping
|
2019-12-18 07:58:49 +00:00
|
|
|
|
|
|
|
char **script_props;
|
2022-12-16 01:20:43 +00:00
|
|
|
mpv_node udata;
|
2020-01-08 01:16:45 +00:00
|
|
|
|
|
|
|
double cached_window_scale;
|
2019-12-18 07:58:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct m_option script_props_type = {
|
|
|
|
.type = &m_option_type_keyvalue_list
|
2013-09-30 20:27:37 +00:00
|
|
|
};
|
|
|
|
|
2022-12-16 01:20:43 +00:00
|
|
|
static const struct m_option udata_type = {
|
|
|
|
.type = CONF_TYPE_NODE
|
|
|
|
};
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
struct overlay {
|
2016-07-01 17:39:04 +00:00
|
|
|
struct mp_image *source;
|
|
|
|
int x, y;
|
2014-10-02 23:22:07 +00:00
|
|
|
};
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
struct hook_handler {
|
2020-03-26 22:40:25 +00:00
|
|
|
char *client; // client mpv_handle name (for logging)
|
|
|
|
int64_t client_id; // client mpv_handle ID
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
char *type; // kind of hook, e.g. "on_load"
|
2018-03-23 15:24:49 +00:00
|
|
|
uint64_t user_id; // user-chosen ID
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
int priority; // priority for global hook order
|
2018-03-23 15:24:49 +00:00
|
|
|
int64_t seq; // unique ID, != 0, also for fixed order on equal priorities
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
bool active; // hook is currently in progress (only 1 at a time for now)
|
|
|
|
};
|
|
|
|
|
2016-05-03 20:41:53 +00:00
|
|
|
// U+279C HEAVY ROUND-TIPPED RIGHTWARDS ARROW
|
2016-05-04 19:51:35 +00:00
|
|
|
// U+00A0 NO-BREAK SPACE
|
|
|
|
#define ARROW_SP "\342\236\234\302\240"
|
2016-05-03 20:41:53 +00:00
|
|
|
|
|
|
|
const char list_current[] = OSD_ASS_0 ARROW_SP OSD_ASS_1;
|
|
|
|
const char list_normal[] = OSD_ASS_0 "{\\alpha&HFF}" ARROW_SP "{\\r}" OSD_ASS_1;
|
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
|
|
|
|
enum stream_type mediatype,
|
2013-09-20 13:09:29 +00:00
|
|
|
const char *cmd, const char *arg);
|
2013-08-03 11:41:38 +00:00
|
|
|
static int set_filters(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
struct m_obj_settings *new_chain);
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
|
2019-10-01 21:49:40 +00:00
|
|
|
static bool is_property_set(int action, void *val);
|
|
|
|
|
2018-03-23 15:24:49 +00:00
|
|
|
static void hook_remove(struct MPContext *mpctx, struct hook_handler *h)
|
2014-10-24 19:52:16 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2018-03-23 15:24:49 +00:00
|
|
|
for (int n = 0; n < cmd->num_hooks; n++) {
|
|
|
|
if (cmd->hooks[n] == h) {
|
|
|
|
talloc_free(cmd->hooks[n]);
|
|
|
|
MP_TARRAY_REMOVE_AT(cmd->hooks, cmd->num_hooks, n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-11-03 14:15:20 +00:00
|
|
|
MP_ASSERT_UNREACHABLE();
|
2014-10-24 19:52:16 +00:00
|
|
|
}
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
bool mp_hook_test_completion(struct MPContext *mpctx, char *type)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
for (int n = 0; n < cmd->num_hooks; n++) {
|
|
|
|
struct hook_handler *h = cmd->hooks[n];
|
2014-10-24 19:52:16 +00:00
|
|
|
if (h->active && strcmp(h->type, type) == 0) {
|
2020-03-26 22:40:25 +00:00
|
|
|
if (!mp_client_id_exists(mpctx, h->client_id)) {
|
2018-03-23 15:24:49 +00:00
|
|
|
MP_WARN(mpctx, "client removed during hook handling\n");
|
|
|
|
hook_remove(mpctx, h);
|
2014-10-24 19:52:16 +00:00
|
|
|
break;
|
|
|
|
}
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
return false;
|
2014-10-24 19:52:16 +00:00
|
|
|
}
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-23 15:24:49 +00:00
|
|
|
static int invoke_hook_handler(struct MPContext *mpctx, struct hook_handler *h)
|
|
|
|
{
|
|
|
|
MP_VERBOSE(mpctx, "Running hook: %s/%s\n", h->client, h->type);
|
|
|
|
h->active = true;
|
|
|
|
|
|
|
|
uint64_t reply_id = 0;
|
2020-03-06 18:23:14 +00:00
|
|
|
mpv_event_hook *m = talloc_ptrtype(NULL, m);
|
|
|
|
*m = (mpv_event_hook){
|
|
|
|
.name = talloc_strdup(m, h->type),
|
|
|
|
.id = h->seq,
|
|
|
|
},
|
|
|
|
reply_id = h->user_id;
|
2020-03-26 22:40:25 +00:00
|
|
|
char *name = mp_tprintf(22, "@%"PRIi64, h->client_id);
|
|
|
|
int r = mp_client_send_event(mpctx, name, reply_id, MPV_EVENT_HOOK, m);
|
2018-03-23 15:24:49 +00:00
|
|
|
if (r < 0) {
|
|
|
|
MP_WARN(mpctx, "Sending hook command failed. Removing hook.\n");
|
|
|
|
hook_remove(mpctx, h);
|
|
|
|
mp_wakeup_core(mpctx); // repeat next iteration to finish
|
|
|
|
}
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-03-23 15:24:49 +00:00
|
|
|
static int run_next_hook_handler(struct MPContext *mpctx, char *type, int index)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
|
|
|
|
for (int n = index; n < cmd->num_hooks; n++) {
|
|
|
|
struct hook_handler *h = cmd->hooks[n];
|
|
|
|
if (strcmp(h->type, type) == 0)
|
|
|
|
return invoke_hook_handler(mpctx, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
mp_wakeup_core(mpctx); // finished hook
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-23 19:54:04 +00:00
|
|
|
// Start processing script/client API hooks. This is asynchronous, and the
|
|
|
|
// caller needs to use mp_hook_test_completion() to check whether they're done.
|
|
|
|
void mp_hook_start(struct MPContext *mpctx, char *type)
|
2018-03-23 15:24:49 +00:00
|
|
|
{
|
|
|
|
while (run_next_hook_handler(mpctx, type, 0) < 0) {
|
|
|
|
// We can repeat this until all broken clients have been removed, and
|
|
|
|
// hook processing is successfully started.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:40:25 +00:00
|
|
|
int mp_hook_continue(struct MPContext *mpctx, int64_t client_id, uint64_t id)
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2018-03-23 15:24:49 +00:00
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
for (int n = 0; n < cmd->num_hooks; n++) {
|
|
|
|
struct hook_handler *h = cmd->hooks[n];
|
2020-03-26 22:40:25 +00:00
|
|
|
if (h->client_id == client_id && h->seq == id) {
|
2018-03-23 15:24:49 +00:00
|
|
|
if (!h->active)
|
|
|
|
break;
|
|
|
|
h->active = false;
|
|
|
|
return run_next_hook_handler(mpctx, h->type, n + 1);
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-23 15:24:49 +00:00
|
|
|
|
|
|
|
MP_ERR(mpctx, "invalid hook API usage\n");
|
|
|
|
return MPV_ERROR_INVALID_PARAMETER;
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int compare_hook(const void *pa, const void *pb)
|
|
|
|
{
|
|
|
|
struct hook_handler **h1 = (void *)pa;
|
|
|
|
struct hook_handler **h2 = (void *)pb;
|
|
|
|
if ((*h1)->priority != (*h2)->priority)
|
|
|
|
return (*h1)->priority - (*h2)->priority;
|
|
|
|
return (*h1)->seq - (*h2)->seq;
|
|
|
|
}
|
|
|
|
|
2020-03-26 22:40:25 +00:00
|
|
|
void mp_hook_add(struct MPContext *mpctx, char *client, int64_t client_id,
|
|
|
|
const char *name, uint64_t user_id, int pri)
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
struct hook_handler *h = talloc_ptrtype(cmd, h);
|
2018-03-23 15:24:49 +00:00
|
|
|
int64_t seq = ++cmd->hook_seq;
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
*h = (struct hook_handler){
|
|
|
|
.client = talloc_strdup(h, client),
|
2020-03-26 22:40:25 +00:00
|
|
|
.client_id = client_id,
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
.type = talloc_strdup(h, name),
|
2018-03-23 15:24:49 +00:00
|
|
|
.user_id = user_id,
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
.priority = pri,
|
|
|
|
.seq = seq,
|
|
|
|
};
|
|
|
|
MP_TARRAY_APPEND(cmd, cmd->hooks, cmd->num_hooks, h);
|
|
|
|
qsort(cmd->hooks, cmd->num_hooks, sizeof(cmd->hooks[0]), compare_hook);
|
|
|
|
}
|
|
|
|
|
2016-07-14 18:04:59 +00:00
|
|
|
// Call before a seek, in order to allow revert-seek to undo the seek.
|
2016-08-18 18:40:23 +00:00
|
|
|
void mark_seek(struct MPContext *mpctx)
|
2013-12-01 01:07:32 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
double now = mp_time_sec();
|
|
|
|
if (now > cmd->last_seek_time + 2.0 || cmd->last_seek_pts == MP_NOPTS_VALUE)
|
|
|
|
cmd->last_seek_pts = get_current_time(mpctx);
|
|
|
|
cmd->last_seek_time = now;
|
|
|
|
}
|
|
|
|
|
2017-01-26 17:24:53 +00:00
|
|
|
static char *skip_n_lines(char *text, int lines)
|
|
|
|
{
|
|
|
|
while (text && lines > 0) {
|
|
|
|
char *next = strchr(text, '\n');
|
|
|
|
text = next ? next + 1 : NULL;
|
|
|
|
lines--;
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int count_lines(char *text)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
while (text) {
|
|
|
|
char *next = strchr(text, '\n');
|
|
|
|
if (!next || (next[0] == '\n' && !next[1]))
|
|
|
|
break;
|
|
|
|
text = next + 1;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Given a huge string separated by new lines, attempts to cut off text above
|
|
|
|
// the current line to keep the line visible, and below to keep rendering
|
|
|
|
// performance up. pos gives the current line (0 for the first line).
|
|
|
|
// "text" might be returned as is, or it can be freed and a new allocation is
|
|
|
|
// returned.
|
|
|
|
// This is only a heuristic - we can't deal with line breaking.
|
|
|
|
static char *cut_osd_list(struct MPContext *mpctx, char *text, int pos)
|
|
|
|
{
|
|
|
|
int screen_h, font_h;
|
|
|
|
osd_get_text_size(mpctx->osd, &screen_h, &font_h);
|
|
|
|
int max_lines = screen_h / MPMAX(font_h, 1) - 1;
|
|
|
|
|
|
|
|
if (!text || max_lines < 5)
|
|
|
|
return text;
|
|
|
|
|
|
|
|
int count = count_lines(text);
|
|
|
|
if (count <= max_lines)
|
|
|
|
return text;
|
|
|
|
|
|
|
|
char *new = talloc_strdup(NULL, "");
|
|
|
|
|
2019-06-02 14:41:38 +00:00
|
|
|
int start = MPMAX(pos - max_lines / 2, 0);
|
2017-01-26 17:24:53 +00:00
|
|
|
if (start == 1)
|
|
|
|
start = 0; // avoid weird transition when pad_h becomes visible
|
|
|
|
int pad_h = start > 0;
|
|
|
|
|
|
|
|
int space = max_lines - pad_h - 1;
|
|
|
|
int pad_t = count - start > space;
|
|
|
|
if (!pad_t)
|
|
|
|
start = count - space;
|
|
|
|
|
2019-06-02 14:41:38 +00:00
|
|
|
if (pad_h) {
|
|
|
|
new = talloc_asprintf_append_buffer(new, "\342\206\221 (%d hidden items)\n",
|
|
|
|
start);
|
|
|
|
}
|
|
|
|
|
2017-01-26 17:24:53 +00:00
|
|
|
char *head = skip_n_lines(text, start);
|
|
|
|
if (!head) {
|
|
|
|
talloc_free(new);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2019-06-02 14:41:38 +00:00
|
|
|
int lines_shown = max_lines - pad_h - pad_t;
|
|
|
|
char *tail = skip_n_lines(head, lines_shown);
|
2017-01-26 17:24:53 +00:00
|
|
|
new = talloc_asprintf_append_buffer(new, "%.*s",
|
|
|
|
(int)(tail ? tail - head : strlen(head)), head);
|
2019-06-02 14:41:38 +00:00
|
|
|
if (pad_t) {
|
|
|
|
new = talloc_asprintf_append_buffer(new, "\342\206\223 (%d hidden items)\n",
|
|
|
|
count - start - lines_shown + 1);
|
|
|
|
}
|
2017-01-26 17:24:53 +00:00
|
|
|
|
|
|
|
talloc_free(text);
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
static char *format_delay(double time)
|
|
|
|
{
|
2015-12-26 17:36:45 +00:00
|
|
|
return talloc_asprintf(NULL, "%d ms", (int)lrint(time * 1000));
|
2012-09-18 13:31:46 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
// Property-option bridge. (Maps the property to the option with the same name.)
|
2016-09-22 18:35:38 +00:00
|
|
|
static int mp_property_generic_option(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2010-12-18 06:02:48 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2019-11-29 23:50:31 +00:00
|
|
|
struct m_config_option *opt =
|
|
|
|
m_config_get_co(mpctx->mconfig, bstr0(prop->name));
|
2014-09-21 14:00:03 +00:00
|
|
|
|
|
|
|
if (!opt)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
2010-12-18 06:02:48 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
2012-09-21 12:05:52 +00:00
|
|
|
*(struct m_option *)arg = *(opt->opt);
|
2010-12-18 06:02:48 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
2017-06-15 13:22:06 +00:00
|
|
|
if (!opt->data)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
m_option_copy(opt->opt, arg, opt->data);
|
2010-12-18 06:02:48 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_SET:
|
2019-11-25 19:25:20 +00:00
|
|
|
if (m_config_set_option_raw(mpctx->mconfig, opt, arg, 0) < 0)
|
2016-09-01 18:00:43 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
2010-12-18 06:02:48 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Playback speed (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playback_speed(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2019-11-24 23:26:36 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
double speed = mpctx->opts->playback_speed;
|
2014-10-02 00:49:05 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.2f", speed);
|
2012-09-25 01:24:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 16:40:16 +00:00
|
|
|
static int mp_property_av_speed_correction(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
char *type = prop->priv;
|
2015-08-10 16:43:25 +00:00
|
|
|
double val = 0;
|
2015-08-10 16:40:16 +00:00
|
|
|
switch (type[0]) {
|
2015-08-10 16:43:25 +00:00
|
|
|
case 'a': val = mpctx->speed_factor_a; break;
|
|
|
|
case 'v': val = mpctx->speed_factor_v; break;
|
2023-01-10 18:26:51 +00:00
|
|
|
default: MP_ASSERT_UNREACHABLE();
|
2015-08-10 16:40:16 +00:00
|
|
|
}
|
2015-08-10 16:43:25 +00:00
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%+.05f%%", (val - 1) * 100);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_display_sync_active(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, mpctx->display_sync_active);
|
2015-08-10 16:40:16 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 12:26:50 +00:00
|
|
|
static int mp_property_pid(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
// 32 bit on linux/windows - which C99 `int' is not guaranteed to hold
|
|
|
|
return m_property_int64_ro(action, arg, mp_getpid());
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// filename with path (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_path(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-10-13 15:09:35 +00:00
|
|
|
if (!mpctx->filename)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, mpctx->filename);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_filename(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-10-30 18:32:57 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-10-30 18:32:57 +00:00
|
|
|
if (!mpctx->filename)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-09-04 12:31:08 +00:00
|
|
|
char *filename = talloc_strdup(NULL, mpctx->filename);
|
|
|
|
if (mp_is_url(bstr0(filename)))
|
|
|
|
mp_url_unescape_inplace(filename);
|
|
|
|
char *f = (char *)mp_basename(filename);
|
2016-08-11 20:40:00 +00:00
|
|
|
if (!f[0])
|
|
|
|
f = filename;
|
|
|
|
if (action == M_PROPERTY_KEY_ACTION) {
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
if (strcmp(ka->key, "no-ext") == 0) {
|
|
|
|
action = ka->action;
|
|
|
|
arg = ka->arg;
|
|
|
|
bstr root;
|
|
|
|
if (mp_splitext(f, &root))
|
|
|
|
f = bstrto0(filename, root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int r = m_property_strdup_ro(action, arg, f);
|
2013-09-04 12:31:08 +00:00
|
|
|
talloc_free(filename);
|
|
|
|
return r;
|
2012-10-30 18:32:57 +00:00
|
|
|
}
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
static int mp_property_stream_open_filename(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->stream_open_filename || !mpctx->playing)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
2016-02-23 21:15:10 +00:00
|
|
|
if (mpctx->demuxer)
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
mpctx->stream_open_filename =
|
|
|
|
talloc_strdup(mpctx->stream_open_filename, *(char **)arg);
|
2019-11-30 00:07:24 +00:00
|
|
|
mp_notify_property(mpctx, prop->name);
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
return m_property_strdup_ro(action, arg, mpctx->stream_open_filename);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_file_size(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-05-05 21:52:50 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!mpctx->demuxer)
|
2014-05-05 21:52:50 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2018-09-07 19:58:46 +00:00
|
|
|
int64_t size = mpctx->demuxer->filesize;
|
2018-09-15 17:09:53 +00:00
|
|
|
if (size < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-05-05 21:52:50 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2014-05-05 21:52:50 +00:00
|
|
|
*(char **)arg = format_file_size(size);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int64_ro(action, arg, size);
|
2014-05-05 21:52:50 +00:00
|
|
|
}
|
|
|
|
|
2023-03-06 19:22:03 +00:00
|
|
|
static const char *find_non_filename_media_title(MPContext *mpctx)
|
2012-10-13 15:09:35 +00:00
|
|
|
{
|
2023-03-06 19:22:03 +00:00
|
|
|
const char *name = mpctx->opts->media_title;
|
2022-07-26 16:05:36 +00:00
|
|
|
if (name && name[0])
|
2023-03-06 19:22:03 +00:00
|
|
|
return name;
|
2023-03-06 19:18:06 +00:00
|
|
|
if (mpctx->demuxer) {
|
|
|
|
name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
|
|
|
|
if (name && name[0])
|
2023-03-06 19:22:03 +00:00
|
|
|
return name;
|
2023-03-06 19:18:06 +00:00
|
|
|
name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
|
|
|
|
if (name && name[0])
|
2023-03-06 19:22:03 +00:00
|
|
|
return name;
|
2023-03-06 19:18:06 +00:00
|
|
|
name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
|
|
|
|
if (name && name[0])
|
2023-03-06 19:22:03 +00:00
|
|
|
return name;
|
2023-03-06 19:18:06 +00:00
|
|
|
}
|
|
|
|
if (mpctx->playing && mpctx->playing->title)
|
2023-03-06 19:22:03 +00:00
|
|
|
return mpctx->playing->title;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_media_title(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
const char *name = find_non_filename_media_title(mpctx);
|
|
|
|
if (name && name[0])
|
|
|
|
return m_property_strdup_ro(action, arg, name);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_filename(ctx, prop, action, arg);
|
2012-10-13 15:09:35 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_path(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-10-13 15:09:35 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-08-26 10:31:09 +00:00
|
|
|
if (!mpctx->demuxer || !mpctx->demuxer->filename)
|
2012-10-13 15:09:35 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2016-08-26 10:31:09 +00:00
|
|
|
return m_property_strdup_ro(action, arg, mpctx->demuxer->filename);
|
2012-10-13 15:09:35 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Demuxer name (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_demuxer(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2012-08-19 16:07:06 +00:00
|
|
|
if (!demuxer)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, demuxer->desc->name);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-23 14:59:06 +00:00
|
|
|
static int mp_property_file_format(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2015-01-23 14:59:06 +00:00
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
const char *name = demuxer->filetype ? demuxer->filetype : demuxer->desc->name;
|
|
|
|
return m_property_strdup_ro(action, arg, name);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2016-03-09 22:34:04 +00:00
|
|
|
if (!demuxer || demuxer->filepos < 0)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2016-03-09 22:34:04 +00:00
|
|
|
return m_property_int64_ro(action, arg, demuxer->filepos);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Stream end offset (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_end(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_file_size(ctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-25 22:18:05 +00:00
|
|
|
// Does some magic to handle "<name>/full" as time formatted with milliseconds.
|
|
|
|
// Assumes prop is the type of the actual property.
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_time(int action, void *arg, double time)
|
2013-07-25 22:18:05 +00:00
|
|
|
{
|
2015-10-16 14:16:10 +00:00
|
|
|
if (time == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
const struct m_option time_type = {.type = CONF_TYPE_TIME};
|
2013-07-25 22:18:05 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(double *)arg = time;
|
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = time_type;
|
|
|
|
return M_PROPERTY_OK;
|
2013-07-25 22:18:05 +00:00
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
|
|
|
|
if (strcmp(ka->key, "full") != 0)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
|
|
|
switch (ka->action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(double *)ka->arg = time;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_PRINT:
|
|
|
|
*(char **)ka->arg = mp_format_time(time, true);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
*(struct m_option *)ka->arg = time_type;
|
2013-07-25 22:18:05 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-05-22 18:02:47 +00:00
|
|
|
static int mp_property_duration(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-10-29 20:54:59 +00:00
|
|
|
double len = get_time_length(mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2014-10-29 20:54:59 +00:00
|
|
|
if (len < 0)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, len);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_avsync(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-11-16 19:10:05 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-21 21:24:20 +00:00
|
|
|
if (!mpctx->ao_chain || !mpctx->vo_chain)
|
2012-11-16 19:10:05 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-12-16 04:07:38 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%7.3f", mpctx->last_av_difference);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_double_ro(action, arg, mpctx->last_av_difference);
|
2012-11-16 19:10:05 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_total_avsync_change(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-12 18:26:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-21 21:24:20 +00:00
|
|
|
if (!mpctx->ao_chain || !mpctx->vo_chain)
|
2014-04-12 18:26:28 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (mpctx->total_avsync_change == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_double_ro(action, arg, mpctx->total_avsync_change);
|
2014-04-12 18:26:28 +00:00
|
|
|
}
|
|
|
|
|
2017-01-20 16:01:29 +00:00
|
|
|
static int mp_property_frame_drop_dec(void *ctx, struct m_property *prop,
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
int action, void *arg)
|
2014-04-12 18:26:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
struct mp_decoder_wrapper *dec = mpctx->vo_chain && mpctx->vo_chain->track
|
|
|
|
? mpctx->vo_chain->track->dec : NULL;
|
|
|
|
if (!dec)
|
2014-04-12 18:26:28 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
f_decoder_wrapper: replace most public fields with setters/getters
I may (optionally) move decoding to a separate thread in a future
change. It's a bit attractive to move the entire decoder wrapper to
there, so if the demuxer has a new packet, it doesn't have to wake up
the main thread, and can directly wake up the decoder. (Although that's
bullshit, since there's a queue in between, and libavcodec's
multi-threaded decoding plays cross-threads ping pong with packets
anyway. On the other hand, the main thread would still have to shuffle
the packets around, so whatever, just seems like better design.)
As preparation, there shouldn't be any mutable state exposed by the
wrapper. But there's still a large number of corner-caseish crap, so
just use setters/getters for them. This recorder thing will inherently
not work, so it'll have to be disabled if threads are used.
This is a bit painful, but probably still the right thing. Like
speculatively pulling teeth.
2020-02-28 20:17:55 +00:00
|
|
|
return m_property_int_ro(action, arg,
|
|
|
|
mp_decoder_wrapper_get_frames_dropped(dec));
|
2014-04-12 18:26:28 +00:00
|
|
|
}
|
|
|
|
|
2015-10-30 13:05:41 +00:00
|
|
|
static int mp_property_mistimed_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
if (!mpctx->vo_chain || !mpctx->display_sync_active)
|
2015-10-30 13:05:41 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_int_ro(action, arg, mpctx->mistimed_frames_total);
|
|
|
|
}
|
|
|
|
|
2015-11-13 21:48:32 +00:00
|
|
|
static int mp_property_vsync_ratio(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
if (!mpctx->vo_chain || !mpctx->display_sync_active)
|
2015-11-13 21:48:32 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int vsyncs = 0, frames = 0;
|
|
|
|
for (int n = 0; n < mpctx->num_past_frames; n++) {
|
|
|
|
int vsync = mpctx->past_frames[n].num_vsyncs;
|
|
|
|
if (vsync < 0)
|
|
|
|
break;
|
|
|
|
vsyncs += vsync;
|
|
|
|
frames += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!frames)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, vsyncs / (double)frames);
|
|
|
|
}
|
|
|
|
|
2017-01-20 16:01:29 +00:00
|
|
|
static int mp_property_frame_drop_vo(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
if (!mpctx->vo_chain)
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_int_ro(action, arg, vo_get_drop_count(mpctx->video_out));
|
|
|
|
}
|
|
|
|
|
2015-11-13 21:41:41 +00:00
|
|
|
static int mp_property_vo_delayed_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2015-08-10 16:43:25 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
if (!mpctx->vo_chain)
|
2015-08-10 16:43:25 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-11-13 21:41:41 +00:00
|
|
|
return m_property_int_ro(action, arg, vo_get_delayed_count(mpctx->video_out));
|
2015-08-10 16:43:25 +00:00
|
|
|
}
|
|
|
|
|
2007-05-31 13:07:52 +00:00
|
|
|
/// Current position in percent (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_percent_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-05-31 13:07:52 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (action) {
|
2014-01-15 21:24:56 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2013-06-28 20:28:21 +00:00
|
|
|
double pos = *(double *)arg;
|
2016-08-15 19:07:32 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, MPSEEK_DEFAULT, 0);
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2014-01-15 21:24:56 +00:00
|
|
|
}
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
double pos = get_current_pos_ratio(mpctx, false) * 100.0;
|
|
|
|
if (pos < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(double *)arg = pos;
|
2013-06-28 20:28:21 +00:00
|
|
|
return M_PROPERTY_OK;
|
2014-01-15 21:24:56 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_DOUBLE,
|
|
|
|
.min = 0,
|
|
|
|
.max = 100,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2014-12-20 16:31:58 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
int pos = get_percent_pos(mpctx);
|
|
|
|
if (pos < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d", pos);
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
2014-12-20 16:31:58 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_time_start(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-02-28 14:04:10 +00:00
|
|
|
{
|
2015-11-16 21:47:17 +00:00
|
|
|
// minor backwards-compat.
|
|
|
|
return property_time(action, arg, 0);
|
2014-02-28 14:04:10 +00:00
|
|
|
}
|
|
|
|
|
2007-05-31 13:07:52 +00:00
|
|
|
/// Current position in seconds (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_time_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2007-05-31 13:07:52 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2013-07-25 22:18:05 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2016-08-15 19:07:32 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, 0);
|
2007-05-31 13:07:52 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, get_current_time(mpctx));
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
|
|
|
|
2016-09-19 17:11:14 +00:00
|
|
|
/// Current audio pts in seconds (R)
|
|
|
|
static int mp_property_audio_pts(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->playback_initialized || mpctx->audio_status < STATUS_PLAYING ||
|
|
|
|
mpctx->audio_status >= STATUS_EOF)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return property_time(action, arg, playing_audio_pts(mpctx));
|
|
|
|
}
|
|
|
|
|
2013-12-16 19:12:53 +00:00
|
|
|
static bool time_remaining(MPContext *mpctx, double *remaining)
|
2013-05-10 13:20:40 +00:00
|
|
|
{
|
2013-12-16 19:12:53 +00:00
|
|
|
double len = get_time_length(mpctx);
|
2014-06-29 17:27:46 +00:00
|
|
|
double playback = get_playback_time(mpctx);
|
2013-05-10 13:20:40 +00:00
|
|
|
|
2017-11-24 12:58:57 +00:00
|
|
|
if (playback == MP_NOPTS_VALUE || len <= 0)
|
2015-10-16 14:16:10 +00:00
|
|
|
return false;
|
|
|
|
|
2014-06-29 17:27:46 +00:00
|
|
|
*remaining = len - playback;
|
2013-12-16 19:12:53 +00:00
|
|
|
|
2014-10-29 20:54:59 +00:00
|
|
|
return len >= 0;
|
2013-12-16 14:55:36 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_remaining(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-12-16 14:55:36 +00:00
|
|
|
{
|
2013-12-16 19:12:53 +00:00
|
|
|
double remaining;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
if (!time_remaining(ctx, &remaining))
|
2013-12-16 14:55:36 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, remaining);
|
2013-12-16 14:55:36 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playtime_remaining(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-12-16 14:55:36 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-12-16 19:12:53 +00:00
|
|
|
double remaining;
|
|
|
|
if (!time_remaining(mpctx, &remaining))
|
2013-05-10 13:20:40 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-08-10 16:40:16 +00:00
|
|
|
double speed = mpctx->video_speed;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, remaining / speed);
|
2013-05-10 13:20:40 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 17:27:46 +00:00
|
|
|
static int mp_property_playback_time(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-06-29 17:27:46 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-08-21 13:51:50 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2016-08-15 19:07:32 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, 0);
|
2015-08-21 13:51:50 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-06-29 17:27:46 +00:00
|
|
|
return property_time(action, arg, get_playback_time(mpctx));
|
|
|
|
}
|
|
|
|
|
2007-12-14 08:33:11 +00:00
|
|
|
/// Current chapter (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_chapter(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-12-14 08:33:11 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-09-01 18:57:33 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
player: more option/property consistency fixes
Some properties had a different type from their equivalent options (such
as mute, volume, deinterlace, edition). This wasn't really sane, as raw
option values should be always within their bounds. On the other hand,
these properties use a different type to reflect runtime limits (such as
range of available editions), or simply to improve the "UI" (you don't
want to cycle throuhg the completely useless "auto" value when cycling
the "mute" property).
Handle this by making them always return the option type, but also
allowing them to provide a "constricted" type, which is used for UI
purposes. All M_PROPERTY_GET_CONSTRICTED_TYPE changes are related to
this.
One consequence is that you can set the volume property to arbitrary
high values just like with the --volume option, but using the "add"
command it still restricts it to the --volume-max range.
Also deprecate --chapter, as it is grossly incompatible to the chapter
property. We pondered renaming it to --chapters, or introducing a more
powerful --range option, but concluded that --start --end is actually
enough.
These changes appear to take care of the last gross property/option
incompatibilities, although there might still be a few lurking.
2016-09-18 14:06:12 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2016-09-01 18:57:33 +00:00
|
|
|
|
2012-08-19 16:07:06 +00:00
|
|
|
int chapter = get_current_chapter(mpctx);
|
2015-01-05 05:34:25 +00:00
|
|
|
int num = get_chapter_count(mpctx);
|
2010-04-24 17:46:54 +00:00
|
|
|
if (chapter < -1)
|
2007-12-22 06:20:48 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2007-12-14 08:33:11 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2007-12-17 03:42:54 +00:00
|
|
|
*(int *) arg = chapter;
|
2007-12-14 08:33:11 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.min = -1,
|
2015-01-05 05:34:25 +00:00
|
|
|
.max = num - 1,
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2007-12-14 08:33:11 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
2013-09-07 17:59:39 +00:00
|
|
|
*(char **) arg = chapter_display_name(mpctx, chapter);
|
2007-12-14 08:33:11 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2013-08-14 01:25:50 +00:00
|
|
|
case M_PROPERTY_SWITCH:
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_SET: ;
|
2013-12-01 01:07:32 +00:00
|
|
|
mark_seek(mpctx);
|
2013-08-14 01:25:50 +00:00
|
|
|
int step_all;
|
|
|
|
if (action == M_PROPERTY_SWITCH) {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
2015-12-26 17:36:45 +00:00
|
|
|
step_all = lrint(sarg->inc);
|
2013-08-14 01:25:50 +00:00
|
|
|
// Check threshold for relative backward seeks
|
|
|
|
if (mpctx->opts->chapter_seek_threshold >= 0 && step_all < 0) {
|
|
|
|
double current_chapter_start =
|
|
|
|
chapter_start_time(mpctx, chapter);
|
|
|
|
// If we are far enough into a chapter, seek back to the
|
|
|
|
// beginning of current chapter instead of previous one
|
2014-03-25 01:18:12 +00:00
|
|
|
if (current_chapter_start != MP_NOPTS_VALUE &&
|
2013-08-14 01:25:50 +00:00
|
|
|
get_current_time(mpctx) - current_chapter_start >
|
|
|
|
mpctx->opts->chapter_seek_threshold)
|
2016-10-01 18:51:17 +00:00
|
|
|
{
|
2013-08-14 01:25:50 +00:00
|
|
|
step_all++;
|
2016-10-01 18:51:17 +00:00
|
|
|
}
|
2013-08-14 01:25:50 +00:00
|
|
|
}
|
|
|
|
} else // Absolute set
|
|
|
|
step_all = *(int *)arg - chapter;
|
2007-12-14 08:33:11 +00:00
|
|
|
chapter += step_all;
|
2013-08-14 01:25:50 +00:00
|
|
|
if (chapter < -1)
|
|
|
|
chapter = -1;
|
2015-01-05 05:34:25 +00:00
|
|
|
if (chapter >= num && step_all > 0) {
|
2014-12-08 16:27:07 +00:00
|
|
|
if (mpctx->opts->keep_open) {
|
|
|
|
seek_to_last_frame(mpctx);
|
|
|
|
} else {
|
2015-12-25 12:58:50 +00:00
|
|
|
// semi-broken file; ignore for user convenience
|
|
|
|
if (action == M_PROPERTY_SWITCH && num < 2)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2015-07-08 19:31:31 +00:00
|
|
|
if (!mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2014-12-08 16:27:07 +00:00
|
|
|
}
|
2013-05-03 22:36:53 +00:00
|
|
|
} else {
|
2015-07-10 10:11:14 +00:00
|
|
|
double pts = chapter_start_time(mpctx, chapter);
|
|
|
|
if (pts != MP_NOPTS_VALUE) {
|
2016-08-15 19:07:32 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, pts, MPSEEK_DEFAULT, 0);
|
2015-07-10 10:11:14 +00:00
|
|
|
mpctx->last_chapter_seek = chapter;
|
|
|
|
mpctx->last_chapter_pts = pts;
|
|
|
|
}
|
2013-05-03 22:36:53 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-12-14 08:33:11 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-12-14 08:33:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 15:55:40 +00:00
|
|
|
static int get_chapter_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
char *name = chapter_name(mpctx, item);
|
|
|
|
double time = chapter_start_time(mpctx, item);
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"title", SUB_PROP_STR(name)},
|
2014-11-13 16:25:59 +00:00
|
|
|
{"time", {.type = CONF_TYPE_TIME}, {.time = time}},
|
2014-02-15 15:55:40 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
int r = m_property_read_sub(props, action, arg);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2016-09-24 15:27:19 +00:00
|
|
|
static int parse_node_chapters(struct MPContext *mpctx,
|
|
|
|
struct mpv_node *given_chapters)
|
2016-09-23 21:54:44 +00:00
|
|
|
{
|
2016-09-24 15:27:19 +00:00
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2016-09-23 21:54:44 +00:00
|
|
|
if (given_chapters->format != MPV_FORMAT_NODE_ARRAY)
|
2016-09-24 15:27:19 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
2016-09-23 21:54:44 +00:00
|
|
|
|
|
|
|
double len = get_time_length(mpctx);
|
|
|
|
|
|
|
|
talloc_free(mpctx->chapters);
|
|
|
|
mpctx->num_chapters = 0;
|
2016-09-24 15:27:19 +00:00
|
|
|
mpctx->chapters = talloc_array(NULL, struct demux_chapter, 0);
|
2016-09-23 21:54:44 +00:00
|
|
|
|
2016-09-24 15:27:19 +00:00
|
|
|
for (int n = 0; n < given_chapters->u.list->num; n++) {
|
2016-09-23 21:54:44 +00:00
|
|
|
struct mpv_node *chapter_data = &given_chapters->u.list->values[n];
|
2016-09-24 15:27:19 +00:00
|
|
|
|
2016-09-23 21:54:44 +00:00
|
|
|
if (chapter_data->format != MPV_FORMAT_NODE_MAP)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mpv_node_list *chapter_data_elements = chapter_data->u.list;
|
|
|
|
|
|
|
|
double time = -1;
|
|
|
|
char *title = 0;
|
|
|
|
|
2016-09-24 15:27:19 +00:00
|
|
|
for (int e = 0; e < chapter_data_elements->num; e++) {
|
|
|
|
struct mpv_node *chapter_data_element =
|
|
|
|
&chapter_data_elements->values[e];
|
2016-09-23 21:54:44 +00:00
|
|
|
char *key = chapter_data_elements->keys[e];
|
|
|
|
switch (chapter_data_element->format) {
|
|
|
|
case MPV_FORMAT_INT64:
|
|
|
|
if (strcmp(key, "time") == 0)
|
|
|
|
time = (double)chapter_data_element->u.int64;
|
|
|
|
break;
|
|
|
|
case MPV_FORMAT_DOUBLE:
|
|
|
|
if (strcmp(key, "time") == 0)
|
|
|
|
time = chapter_data_element->u.double_;
|
|
|
|
break;
|
|
|
|
case MPV_FORMAT_STRING:
|
|
|
|
if (strcmp(key, "title") == 0)
|
|
|
|
title = chapter_data_element->u.string;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-24 15:27:19 +00:00
|
|
|
if (time >= 0 && time < len) {
|
2016-09-23 21:54:44 +00:00
|
|
|
struct demux_chapter new = {
|
|
|
|
.pts = time,
|
2016-09-24 15:27:19 +00:00
|
|
|
.metadata = talloc_zero(mpctx->chapters, struct mp_tags),
|
2016-09-23 21:54:44 +00:00
|
|
|
};
|
2016-09-24 15:27:19 +00:00
|
|
|
if (title)
|
|
|
|
mp_tags_set_str(new.metadata, "title", title);
|
2016-09-23 21:54:44 +00:00
|
|
|
MP_TARRAY_APPEND(NULL, mpctx->chapters, mpctx->num_chapters, new);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-02 16:19:39 +00:00
|
|
|
mp_notify(mpctx, MP_EVENT_CHAPTER_CHANGE, NULL);
|
2019-11-30 00:07:24 +00:00
|
|
|
mp_notify_property(mpctx, "chapter-list");
|
2016-09-24 15:27:19 +00:00
|
|
|
|
2016-09-23 21:54:44 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_list_chapters(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:55:40 +00:00
|
|
|
int count = get_chapter_count(mpctx);
|
2016-09-23 21:54:44 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_PRINT: {
|
2015-05-26 19:42:34 +00:00
|
|
|
int cur = mpctx->playback_initialized ? get_current_chapter(mpctx) : -1;
|
2013-05-15 00:17:47 +00:00
|
|
|
char *res = NULL;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (count < 1) {
|
|
|
|
res = talloc_asprintf_append(res, "No chapters.");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < count; n++) {
|
|
|
|
char *name = chapter_display_name(mpctx, n);
|
|
|
|
double t = chapter_start_time(mpctx, n);
|
|
|
|
char* time = mp_format_time(t, false);
|
|
|
|
res = talloc_asprintf_append(res, "%s", time);
|
|
|
|
talloc_free(time);
|
2016-05-03 20:41:53 +00:00
|
|
|
const char *m = n == cur ? list_current : list_normal;
|
|
|
|
res = talloc_asprintf_append(res, " %s%s\n", m, name);
|
2013-05-15 00:17:47 +00:00
|
|
|
talloc_free(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2016-09-23 21:54:44 +00:00
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
struct mpv_node *given_chapters = arg;
|
2016-09-24 15:27:19 +00:00
|
|
|
return parse_node_chapters(mpctx, given_chapters);
|
2016-09-23 21:54:44 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-15 15:55:40 +00:00
|
|
|
return m_property_read_list(action, arg, count, get_chapter_entry, mpctx);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 00:47:06 +00:00
|
|
|
static int mp_property_current_edition(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer || demuxer->num_editions <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_int_ro(action, arg, demuxer->edition);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_edition(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-08-25 23:19:42 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2020-04-12 22:18:04 +00:00
|
|
|
char *name = NULL;
|
2012-08-25 23:19:42 +00:00
|
|
|
|
2020-04-12 22:18:04 +00:00
|
|
|
if (!demuxer)
|
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
|
|
|
|
int ed = demuxer->edition;
|
|
|
|
|
|
|
|
if (demuxer->num_editions <= 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_CONSTRICTED_TYPE: {
|
2019-12-16 00:47:06 +00:00
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.min = 0,
|
|
|
|
.max = demuxer->num_editions - 1,
|
|
|
|
};
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
2020-04-12 22:18:04 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
if (ed < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
name = mp_tags_get_str(demuxer->editions[ed].metadata, "title");
|
|
|
|
if (name) {
|
|
|
|
*(char **) arg = talloc_strdup(NULL, name);
|
|
|
|
} else {
|
|
|
|
*(char **) arg = talloc_asprintf(NULL, "%d", ed + 1);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
}
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 23:41:12 +00:00
|
|
|
static int get_edition_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2014-02-18 23:41:12 +00:00
|
|
|
struct demux_edition *ed = &demuxer->editions[item];
|
|
|
|
|
|
|
|
char *title = mp_tags_get_str(ed->metadata, "title");
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"id", SUB_PROP_INT(item)},
|
|
|
|
{"title", SUB_PROP_STR(title),
|
|
|
|
.unavailable = !title},
|
2023-02-20 05:53:09 +00:00
|
|
|
{"default", SUB_PROP_BOOL(ed->default_edition)},
|
2014-02-18 23:41:12 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_list_editions(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-02-18 23:41:12 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2014-02-18 23:41:12 +00:00
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
char *res = NULL;
|
|
|
|
|
|
|
|
struct demux_edition *editions = demuxer->editions;
|
|
|
|
int num_editions = demuxer->num_editions;
|
|
|
|
int current = demuxer->edition;
|
|
|
|
|
|
|
|
if (!num_editions)
|
|
|
|
res = talloc_asprintf_append(res, "No editions.");
|
|
|
|
|
|
|
|
for (int n = 0; n < num_editions; n++) {
|
|
|
|
struct demux_edition *ed = &editions[n];
|
|
|
|
|
2016-05-03 20:41:53 +00:00
|
|
|
res = talloc_strdup_append(res, n == current ? list_current
|
|
|
|
: list_normal);
|
2014-02-18 23:41:12 +00:00
|
|
|
res = talloc_asprintf_append(res, "%d: ", n);
|
|
|
|
char *title = mp_tags_get_str(ed->metadata, "title");
|
|
|
|
if (!title)
|
|
|
|
title = "unnamed";
|
2016-05-03 20:41:53 +00:00
|
|
|
res = talloc_asprintf_append(res, "'%s'\n", title);
|
2014-02-18 23:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return m_property_read_list(action, arg, demuxer->num_editions,
|
|
|
|
get_edition_entry, mpctx);
|
|
|
|
}
|
|
|
|
|
2008-09-26 21:17:01 +00:00
|
|
|
/// Number of chapters in file
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_chapters(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2008-09-26 21:17:01 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2008-09-26 21:17:01 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2011-10-23 02:51:44 +00:00
|
|
|
int count = get_chapter_count(mpctx);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int_ro(action, arg, count);
|
2008-09-26 21:17:01 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_editions(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-08-25 23:19:42 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2012-08-25 23:19:42 +00:00
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (demuxer->num_editions <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int_ro(action, arg, demuxer->num_editions);
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
2014-02-19 15:29:04 +00:00
|
|
|
static int get_tag_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct mp_tags *tags = ctx;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"key", SUB_PROP_STR(tags->keys[item])},
|
|
|
|
{"value", SUB_PROP_STR(tags->values[item])},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2019-07-15 01:10:51 +00:00
|
|
|
// tags can be NULL for M_PROPERTY_GET_TYPE. (In all other cases, tags must be
|
|
|
|
// provided, even for M_PROPERTY_KEY_ACTION GET_TYPE sub-actions.)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int tag_property(int action, void *arg, struct mp_tags *tags)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
2019-07-15 01:10:51 +00:00
|
|
|
case M_PROPERTY_GET_NODE: // same as GET, because type==mpv_node
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET: {
|
2014-03-30 17:09:31 +00:00
|
|
|
mpv_node_list *list = talloc_zero(NULL, mpv_node_list);
|
|
|
|
mpv_node node = {
|
|
|
|
.format = MPV_FORMAT_NODE_MAP,
|
|
|
|
.u.list = list,
|
|
|
|
};
|
|
|
|
list->num = tags->num_keys;
|
|
|
|
list->values = talloc_array(list, mpv_node, list->num);
|
|
|
|
list->keys = talloc_array(list, char*, list->num);
|
2013-09-08 04:32:48 +00:00
|
|
|
for (int n = 0; n < tags->num_keys; n++) {
|
2014-03-30 17:09:31 +00:00
|
|
|
list->keys[n] = talloc_strdup(list, tags->keys[n]);
|
|
|
|
list->values[n] = (struct mpv_node){
|
|
|
|
.format = MPV_FORMAT_STRING,
|
|
|
|
.u.string = talloc_strdup(list, tags->values[n]),
|
|
|
|
};
|
2013-09-08 04:32:48 +00:00
|
|
|
}
|
2014-03-30 17:09:31 +00:00
|
|
|
*(mpv_node*)arg = node;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
}
|
2013-06-07 15:31:30 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
char *res = NULL;
|
2013-09-08 04:32:48 +00:00
|
|
|
for (int n = 0; n < tags->num_keys; n++) {
|
2013-06-07 15:31:30 +00:00
|
|
|
res = talloc_asprintf_append_buffer(res, "%s: %s\n",
|
2013-09-08 04:32:48 +00:00
|
|
|
tags->keys[n], tags->values[n]);
|
2013-06-07 15:31:30 +00:00
|
|
|
}
|
2014-12-30 13:04:53 +00:00
|
|
|
if (!res)
|
|
|
|
res = talloc_strdup(NULL, "(empty)");
|
2013-06-07 15:31:30 +00:00
|
|
|
*(char **)arg = res;
|
2014-12-30 13:04:53 +00:00
|
|
|
return M_PROPERTY_OK;
|
2013-06-07 15:31:30 +00:00
|
|
|
}
|
2012-09-21 10:19:59 +00:00
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
2012-09-22 04:15:36 +00:00
|
|
|
struct m_property_action_arg *ka = arg;
|
2014-03-30 11:41:03 +00:00
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
|
|
|
if (bstr_equals0(key, "list")) {
|
2014-02-19 15:29:04 +00:00
|
|
|
struct m_property_action_arg nka = *ka;
|
2014-03-30 11:41:03 +00:00
|
|
|
nka.key = rem;
|
2014-02-19 15:29:04 +00:00
|
|
|
return m_property_read_list(action, &nka, tags->num_keys,
|
|
|
|
get_tag_entry, tags);
|
|
|
|
}
|
2014-02-19 15:16:42 +00:00
|
|
|
// Direct access without this prefix is allowed for compatibility.
|
2014-03-30 11:41:03 +00:00
|
|
|
bstr k = bstr0(ka->key);
|
|
|
|
bstr_eatstart0(&k, "by-key/");
|
|
|
|
char *meta = mp_tags_get_bstr(tags, k);
|
2012-09-21 10:19:59 +00:00
|
|
|
if (!meta)
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_UNKNOWN;
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (ka->action) {
|
2007-05-29 22:14:41 +00:00
|
|
|
case M_PROPERTY_GET:
|
2012-09-18 18:07:24 +00:00
|
|
|
*(char **)ka->arg = talloc_strdup(NULL, meta);
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
2014-03-30 16:50:35 +00:00
|
|
|
*(struct m_option *)ka->arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_STRING,
|
|
|
|
};
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
2012-09-21 10:19:59 +00:00
|
|
|
}
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-09-08 04:32:48 +00:00
|
|
|
/// Demuxer meta data
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-08 04:32:48 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2013-09-08 04:32:48 +00:00
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return tag_property(action, arg, demuxer->metadata);
|
2013-09-08 04:32:48 +00:00
|
|
|
}
|
|
|
|
|
2014-12-29 22:03:39 +00:00
|
|
|
static int mp_property_filtered_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->filtered_tags)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return tag_property(action, arg, mpctx->filtered_tags);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_chapter_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-08 05:42:05 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-09-08 05:42:05 +00:00
|
|
|
int chapter = get_current_chapter(mpctx);
|
2015-08-12 09:10:45 +00:00
|
|
|
if (chapter < 0)
|
2014-11-02 16:20:04 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return tag_property(action, arg, mpctx->chapters[chapter].metadata);
|
2013-09-08 05:42:05 +00:00
|
|
|
}
|
|
|
|
|
2015-09-11 21:04:02 +00:00
|
|
|
static int mp_property_filter_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-13 14:08:58 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-09-11 21:04:02 +00:00
|
|
|
const char *type = prop->priv;
|
2014-04-13 14:08:58 +00:00
|
|
|
|
2014-12-30 13:04:53 +00:00
|
|
|
if (action == M_PROPERTY_KEY_ACTION) {
|
2014-04-13 14:08:58 +00:00
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
2018-01-18 13:44:20 +00:00
|
|
|
struct mp_tags *metadata = NULL;
|
|
|
|
struct mp_output_chain *chain = NULL;
|
2015-09-11 21:04:02 +00:00
|
|
|
if (strcmp(type, "vf") == 0) {
|
2018-01-18 13:44:20 +00:00
|
|
|
chain = mpctx->vo_chain ? mpctx->vo_chain->filter : NULL;
|
2015-09-11 21:04:02 +00:00
|
|
|
} else if (strcmp(type, "af") == 0) {
|
2018-01-18 13:44:20 +00:00
|
|
|
chain = mpctx->ao_chain ? mpctx->ao_chain->filter : NULL;
|
2015-09-11 21:04:02 +00:00
|
|
|
}
|
2018-01-18 13:44:20 +00:00
|
|
|
if (!chain)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2019-07-15 01:10:51 +00:00
|
|
|
if (ka->action != M_PROPERTY_GET_TYPE) {
|
|
|
|
struct mp_filter_command cmd = {
|
|
|
|
.type = MP_FILTER_COMMAND_GET_META,
|
|
|
|
.res = &metadata,
|
|
|
|
};
|
|
|
|
mp_output_chain_command(chain, mp_tprintf(80, "%.*s", BSTR_P(key)),
|
|
|
|
&cmd);
|
2018-01-18 13:44:20 +00:00
|
|
|
|
2019-07-15 01:10:51 +00:00
|
|
|
if (!metadata)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
}
|
2018-02-14 22:15:32 +00:00
|
|
|
|
|
|
|
int res;
|
|
|
|
if (strlen(rem)) {
|
|
|
|
struct m_property_action_arg next_ka = *ka;
|
|
|
|
next_ka.key = rem;
|
|
|
|
res = tag_property(M_PROPERTY_KEY_ACTION, &next_ka, metadata);
|
|
|
|
} else {
|
|
|
|
res = tag_property(ka->action, ka->arg, metadata);
|
2014-04-13 14:08:58 +00:00
|
|
|
}
|
2018-02-14 22:15:32 +00:00
|
|
|
talloc_free(metadata);
|
|
|
|
return res;
|
2014-04-13 14:08:58 +00:00
|
|
|
}
|
2014-04-14 00:45:45 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2014-04-13 14:08:58 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_core_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-14 20:03:43 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, !mpctx->playback_active);
|
2014-04-14 20:03:43 +00:00
|
|
|
}
|
|
|
|
|
2014-12-10 13:42:57 +00:00
|
|
|
static int mp_property_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, mpctx->stop_play == PT_STOP);
|
2014-12-10 13:42:57 +00:00
|
|
|
}
|
|
|
|
|
2022-11-22 15:42:30 +00:00
|
|
|
static int mp_property_window_id(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
int64_t wid;
|
|
|
|
if (!vo || vo_control(vo, VOCTRL_GET_WINDOW_ID, &wid) <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_int64_ro(action, arg, wid);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_eof_reached(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-14 20:19:07 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-07-29 22:22:25 +00:00
|
|
|
bool eof = mpctx->video_status == STATUS_EOF &&
|
|
|
|
mpctx->audio_status == STATUS_EOF;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, eof);
|
2014-04-14 20:19:07 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 22:13:27 +00:00
|
|
|
static int mp_property_seeking(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, !mpctx->restart_complete);
|
2014-08-07 22:13:27 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 11:32:30 +00:00
|
|
|
static int mp_property_playback_abort(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, !mpctx->playing || mpctx->stop_play);
|
2014-10-21 11:32:30 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 11:04:45 +00:00
|
|
|
static int mp_property_cache_speed(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2018-09-07 20:26:48 +00:00
|
|
|
struct demux_reader_state s;
|
|
|
|
demux_get_reader_state(mpctx->demuxer, &s);
|
2018-09-01 11:04:45 +00:00
|
|
|
|
|
|
|
uint64_t val = s.bytes_per_second;
|
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = talloc_strdup_append(format_file_size(val), "/s");
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return m_property_int64_ro(action, arg, val);
|
|
|
|
}
|
|
|
|
|
2014-08-28 15:48:31 +00:00
|
|
|
static int mp_property_demuxer_cache_duration(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2018-09-07 20:26:48 +00:00
|
|
|
struct demux_reader_state s;
|
|
|
|
demux_get_reader_state(mpctx->demuxer, &s);
|
2014-08-28 15:48:31 +00:00
|
|
|
|
|
|
|
if (s.ts_duration < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, s.ts_duration);
|
|
|
|
}
|
|
|
|
|
2015-04-20 21:47:13 +00:00
|
|
|
static int mp_property_demuxer_cache_time(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2018-09-07 20:26:48 +00:00
|
|
|
struct demux_reader_state s;
|
|
|
|
demux_get_reader_state(mpctx->demuxer, &s);
|
2015-04-20 21:47:13 +00:00
|
|
|
|
2017-10-30 13:26:54 +00:00
|
|
|
if (s.ts_end == MP_NOPTS_VALUE)
|
2015-04-20 21:47:13 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2017-10-30 13:26:54 +00:00
|
|
|
return m_property_double_ro(action, arg, s.ts_end);
|
2015-04-20 21:47:13 +00:00
|
|
|
}
|
|
|
|
|
2014-08-28 15:48:31 +00:00
|
|
|
static int mp_property_demuxer_cache_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2018-09-07 20:26:48 +00:00
|
|
|
struct demux_reader_state s;
|
|
|
|
demux_get_reader_state(mpctx->demuxer, &s);
|
2014-08-28 15:48:31 +00:00
|
|
|
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, s.idle);
|
2014-08-28 15:48:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-21 19:13:53 +00:00
|
|
|
static int mp_property_demuxer_cache_state(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2017-10-26 20:26:43 +00:00
|
|
|
if (action == M_PROPERTY_GET_TYPE) {
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
if (action != M_PROPERTY_GET)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
2018-09-07 20:26:48 +00:00
|
|
|
struct demux_reader_state s;
|
|
|
|
demux_get_reader_state(mpctx->demuxer, &s);
|
2017-10-21 19:13:53 +00:00
|
|
|
|
2017-10-26 20:26:43 +00:00
|
|
|
struct mpv_node *r = (struct mpv_node *)arg;
|
|
|
|
node_init(r, MPV_FORMAT_NODE_MAP, NULL);
|
2017-10-21 19:13:53 +00:00
|
|
|
|
2017-10-30 13:26:54 +00:00
|
|
|
if (s.ts_end != MP_NOPTS_VALUE)
|
|
|
|
node_map_add_double(r, "cache-end", s.ts_end);
|
2017-10-26 20:26:43 +00:00
|
|
|
|
|
|
|
if (s.ts_reader != MP_NOPTS_VALUE)
|
|
|
|
node_map_add_double(r, "reader-pts", s.ts_reader);
|
|
|
|
|
2020-02-07 15:15:55 +00:00
|
|
|
if (s.ts_duration >= 0)
|
|
|
|
node_map_add_double(r, "cache-duration", s.ts_duration);
|
|
|
|
|
2017-10-26 20:26:43 +00:00
|
|
|
node_map_add_flag(r, "eof", s.eof);
|
|
|
|
node_map_add_flag(r, "underrun", s.underrun);
|
|
|
|
node_map_add_flag(r, "idle", s.idle);
|
2017-11-10 15:43:09 +00:00
|
|
|
node_map_add_int64(r, "total-bytes", s.total_bytes);
|
|
|
|
node_map_add_int64(r, "fw-bytes", s.fw_bytes);
|
demux: add a on-disk cache
Somewhat similar to the old --cache-file, except for the demuxer cache.
Instead of keeping packet data in memory, it's written to disk and read
back when needed.
The idea is to reduce main memory usage, while allowing fast seeking in
large cached network streams (especially live streams). Keeping the
packet metadata on disk would be rather hard (would use mmap or so, or
rewrite the entire demux.c packet queue handling), and since it's
relatively small, just keep it in memory.
Also for simplicity, the disk cache is append-only. If you're watching
really long livestreams, and need pruning, you're probably out of luck.
This still could be improved by trying to free unused blocks with
fallocate(), but since we're writing multiple streams in an interleaved
manner, this is slightly hard.
Some rather gross ugliness in packet.h: we want to store the file
position of the cached data somewhere, but on 32 bit architectures, we
don't have any usable 64 bit members for this, just the buf/len fields,
which add up to 64 bit - so the shitty union aliases this memory.
Error paths untested. Side data (the complicated part of trying to
serialize ffmpeg packets) untested.
Stream recording had to be adjusted. Some minor details change due to
this, but probably nothing important.
The change in attempt_range_joining() is because packets in cache
have no valid len field. It was a useful check (heuristically
finding broken cases), but not a necessary one.
Various other approaches were tried. It would be interesting to list
them and to mention the pros and cons, but I don't feel like it.
2019-06-13 17:10:32 +00:00
|
|
|
if (s.file_cache_bytes >= 0)
|
|
|
|
node_map_add_int64(r, "file-cache-bytes", s.file_cache_bytes);
|
2020-04-03 11:20:21 +00:00
|
|
|
if (s.bytes_per_second > 0)
|
|
|
|
node_map_add_int64(r, "raw-input-rate", s.bytes_per_second);
|
2018-01-05 15:41:16 +00:00
|
|
|
if (s.seeking != MP_NOPTS_VALUE)
|
|
|
|
node_map_add_double(r, "debug-seeking", s.seeking);
|
|
|
|
node_map_add_int64(r, "debug-low-level-seeks", s.low_level_seeks);
|
2019-11-07 15:05:27 +00:00
|
|
|
node_map_add_int64(r, "debug-byte-level-seeks", s.byte_level_seeks);
|
2018-01-05 15:41:16 +00:00
|
|
|
if (s.ts_last != MP_NOPTS_VALUE)
|
|
|
|
node_map_add_double(r, "debug-ts-last", s.ts_last);
|
2017-10-26 20:26:43 +00:00
|
|
|
|
2019-05-17 20:40:01 +00:00
|
|
|
node_map_add_flag(r, "bof-cached", s.bof_cached);
|
|
|
|
node_map_add_flag(r, "eof-cached", s.eof_cached);
|
|
|
|
|
|
|
|
struct mpv_node *ranges =
|
|
|
|
node_map_add(r, "seekable-ranges", MPV_FORMAT_NODE_ARRAY);
|
|
|
|
for (int n = s.num_seek_ranges - 1; n >= 0; n--) {
|
|
|
|
struct demux_seek_range *range = &s.seek_ranges[n];
|
|
|
|
struct mpv_node *sub = node_array_add(ranges, MPV_FORMAT_NODE_MAP);
|
|
|
|
node_map_add_double(sub, "start", range->start);
|
|
|
|
node_map_add_double(sub, "end", range->end);
|
|
|
|
}
|
|
|
|
|
2017-10-26 20:26:43 +00:00
|
|
|
return M_PROPERTY_OK;
|
2017-10-21 19:13:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-10 00:44:55 +00:00
|
|
|
static int mp_property_demuxer_start_time(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, mpctx->demuxer->start_time);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_paused_for_cache(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-12 18:26:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, mpctx->paused_for_cache);
|
2014-04-12 18:26:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 20:07:07 +00:00
|
|
|
static int mp_property_cache_buffering(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-04-19 20:01:30 +00:00
|
|
|
int state = get_cache_buffering_percentage(mpctx);
|
2014-10-07 20:07:07 +00:00
|
|
|
if (state < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2016-04-19 20:01:30 +00:00
|
|
|
return m_property_int_ro(action, arg, state);
|
2014-10-07 20:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-24 14:31:01 +00:00
|
|
|
static int mp_property_demuxer_is_network(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, mpctx->demuxer->is_network);
|
2017-03-24 14:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_clock(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-06-04 11:33:01 +00:00
|
|
|
{
|
|
|
|
char outstr[6];
|
|
|
|
time_t t = time(NULL);
|
|
|
|
struct tm *tmp = localtime(&t);
|
|
|
|
|
2013-06-13 22:46:28 +00:00
|
|
|
if ((tmp != NULL) && (strftime(outstr, sizeof(outstr), "%H:%M", tmp) == 5))
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, outstr);
|
2013-06-04 11:33:01 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_seekable(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-02-28 14:04:10 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-28 14:04:10 +00:00
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, mpctx->demuxer->seekable);
|
2014-02-28 14:04:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 12:46:33 +00:00
|
|
|
static int mp_property_partially_seekable(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, mpctx->demuxer->partially_seekable);
|
2015-01-26 12:46:33 +00:00
|
|
|
}
|
|
|
|
|
2016-01-26 14:12:42 +00:00
|
|
|
static int mp_property_mixer_active(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, !!mpctx->ao);
|
2016-01-26 14:12:42 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Volume (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_volume(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-07-09 16:31:18 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
player: more option/property consistency fixes
Some properties had a different type from their equivalent options (such
as mute, volume, deinterlace, edition). This wasn't really sane, as raw
option values should be always within their bounds. On the other hand,
these properties use a different type to reflect runtime limits (such as
range of available editions), or simply to improve the "UI" (you don't
want to cycle throuhg the completely useless "auto" value when cycling
the "mute" property).
Handle this by making them always return the option type, but also
allowing them to provide a "constricted" type, which is used for UI
purposes. All M_PROPERTY_GET_CONSTRICTED_TYPE changes are related to
this.
One consequence is that you can set the volume property to arbitrary
high values just like with the --volume option, but using the "add"
command it still restricts it to the --volume-max range.
Also deprecate --chapter, as it is grossly incompatible to the chapter
property. We pondered renaming it to --chapters, or introducing a more
powerful --range option, but concluded that --start --end is actually
enough.
These changes appear to take care of the last gross property/option
incompatibilities, although there might still be a few lurking.
2016-09-18 14:06:12 +00:00
|
|
|
case M_PROPERTY_GET_CONSTRICTED_TYPE:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_FLOAT,
|
|
|
|
.min = 0,
|
2016-07-09 16:31:18 +00:00
|
|
|
.max = opts->softvol_max,
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2016-07-09 16:31:18 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%i", (int)opts->softvol_volume);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2017-04-26 19:45:50 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2016-01-26 14:12:42 +00:00
|
|
|
}
|
|
|
|
|
2016-07-09 16:31:18 +00:00
|
|
|
static int mp_property_ao_volume(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct ao *ao = mpctx->ao;
|
|
|
|
if (!ao)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
2016-07-09 16:31:18 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2022-12-31 03:46:44 +00:00
|
|
|
float vol = *(float *)arg;
|
2016-07-09 16:31:18 +00:00
|
|
|
if (ao_control(ao, AOCONTROL_SET_VOLUME, &vol) != CONTROL_OK)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2016-07-09 16:31:18 +00:00
|
|
|
}
|
|
|
|
case M_PROPERTY_GET: {
|
2022-12-31 03:46:44 +00:00
|
|
|
if (ao_control(ao, AOCONTROL_GET_VOLUME, arg) != CONTROL_OK)
|
2016-07-09 16:31:18 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2016-07-09 16:31:18 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
2016-07-10 10:50:58 +00:00
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_FLOAT,
|
|
|
|
.min = 0,
|
|
|
|
.max = 100,
|
|
|
|
};
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return M_PROPERTY_OK;
|
2016-07-10 10:50:58 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
2022-12-31 03:46:44 +00:00
|
|
|
float vol = 0;
|
2016-07-10 10:50:58 +00:00
|
|
|
if (ao_control(ao, AOCONTROL_GET_VOLUME, &vol) != CONTROL_OK)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2022-12-31 03:46:44 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.f", vol);
|
2016-07-10 10:50:58 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2016-07-09 16:31:18 +00:00
|
|
|
|
|
|
|
static int mp_property_ao_mute(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-19 12:32:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-07-09 16:31:18 +00:00
|
|
|
struct ao *ao = mpctx->ao;
|
|
|
|
if (!ao)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
2013-09-19 12:32:47 +00:00
|
|
|
switch (action) {
|
2016-07-09 16:31:18 +00:00
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
bool value = *(int *)arg;
|
|
|
|
if (ao_control(ao, AOCONTROL_SET_MUTE, &value) != CONTROL_OK)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2013-09-19 12:32:47 +00:00
|
|
|
case M_PROPERTY_GET: {
|
2016-07-09 16:31:18 +00:00
|
|
|
bool value = false;
|
|
|
|
if (ao_control(ao, AOCONTROL_GET_MUTE, &value) != CONTROL_OK)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(int *)arg = value;
|
|
|
|
return M_PROPERTY_OK;
|
2013-09-19 12:32:47 +00:00
|
|
|
}
|
2016-07-09 16:31:18 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
2023-02-20 05:53:09 +00:00
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_BOOL};
|
2016-07-09 16:31:18 +00:00
|
|
|
return M_PROPERTY_OK;
|
2013-09-19 12:32:47 +00:00
|
|
|
}
|
2016-07-09 16:31:18 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2013-09-19 12:32:47 +00:00
|
|
|
}
|
|
|
|
|
2014-10-10 17:46:21 +00:00
|
|
|
static int get_device_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct ao_device_list *list = ctx;
|
|
|
|
struct ao_device_desc *entry = &list->devices[item];
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"name", SUB_PROP_STR(entry->name)},
|
|
|
|
{"description", SUB_PROP_STR(entry->desc)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2016-09-16 12:23:54 +00:00
|
|
|
static void create_hotplug(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
|
|
|
|
if (!cmd->hotplug) {
|
|
|
|
cmd->hotplug = ao_hotplug_create(mpctx->global, mp_wakeup_core_cb,
|
|
|
|
mpctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-27 11:16:32 +00:00
|
|
|
static int mp_property_audio_device(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
2015-02-16 20:35:13 +00:00
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2016-09-16 12:23:54 +00:00
|
|
|
create_hotplug(mpctx);
|
|
|
|
|
2018-05-21 13:11:19 +00:00
|
|
|
char *name = NULL;
|
|
|
|
if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &name) < 1)
|
|
|
|
name = NULL;
|
|
|
|
|
2022-08-29 18:52:02 +00:00
|
|
|
struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug, mpctx->ao);
|
2015-02-16 20:35:13 +00:00
|
|
|
for (int n = 0; n < list->num_devices; n++) {
|
|
|
|
struct ao_device_desc *dev = &list->devices[n];
|
2018-05-21 13:11:19 +00:00
|
|
|
if (dev->name && name && strcmp(dev->name, name) == 0) {
|
2015-02-16 20:35:13 +00:00
|
|
|
*(char **)arg = talloc_strdup(NULL, dev->desc ? dev->desc : "?");
|
2018-05-21 13:11:19 +00:00
|
|
|
talloc_free(name);
|
2015-02-16 20:35:13 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
2018-05-21 13:11:19 +00:00
|
|
|
|
|
|
|
talloc_free(name);
|
2015-02-16 20:35:13 +00:00
|
|
|
}
|
2016-10-05 14:45:04 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2014-10-27 11:16:32 +00:00
|
|
|
}
|
|
|
|
|
2014-10-10 17:46:21 +00:00
|
|
|
static int mp_property_audio_devices(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2016-09-16 12:23:54 +00:00
|
|
|
create_hotplug(mpctx);
|
2014-10-10 17:46:21 +00:00
|
|
|
|
2022-08-29 18:52:02 +00:00
|
|
|
struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug, mpctx->ao);
|
2015-02-12 15:53:56 +00:00
|
|
|
return m_property_read_list(action, arg, list->num_devices,
|
|
|
|
get_device_entry, list);
|
2014-10-10 17:46:21 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 16:35:31 +00:00
|
|
|
static int mp_property_ao(void *ctx, struct m_property *p, int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_strdup_ro(action, arg,
|
|
|
|
mpctx->ao ? ao_get_name(mpctx->ao) : NULL);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Audio delay (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_audio_delay(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2019-11-24 23:26:36 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = format_delay(mpctx->opts->audio_delay);
|
2012-09-18 13:31:46 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Audio codec tag (RO)
|
2015-05-22 18:05:04 +00:00
|
|
|
static int mp_property_audio_codec_name(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-21 21:24:20 +00:00
|
|
|
struct track *track = mpctx->current_track[0][STREAM_AUDIO];
|
|
|
|
const char *c = track && track->stream ? track->stream->codec->codec : NULL;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, c);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Audio codec name (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_audio_codec(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-05-29 22:14:41 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-21 21:24:20 +00:00
|
|
|
struct track *track = mpctx->current_track[0][STREAM_AUDIO];
|
f_decoder_wrapper: replace most public fields with setters/getters
I may (optionally) move decoding to a separate thread in a future
change. It's a bit attractive to move the entire decoder wrapper to
there, so if the demuxer has a new packet, it doesn't have to wake up
the main thread, and can directly wake up the decoder. (Although that's
bullshit, since there's a queue in between, and libavcodec's
multi-threaded decoding plays cross-threads ping pong with packets
anyway. On the other hand, the main thread would still have to shuffle
the packets around, so whatever, just seems like better design.)
As preparation, there shouldn't be any mutable state exposed by the
wrapper. But there's still a large number of corner-caseish crap, so
just use setters/getters for them. This recorder thing will inherently
not work, so it'll have to be disabled if threads are used.
This is a bit painful, but probably still the right thing. Like
speculatively pulling teeth.
2020-02-28 20:17:55 +00:00
|
|
|
char desc[256] = "";
|
|
|
|
if (track && track->dec)
|
|
|
|
mp_decoder_wrapper_get_desc(track->dec, desc, sizeof(desc));
|
|
|
|
return m_property_strdup_ro(action, arg, desc[0] ? desc : NULL);
|
2007-05-29 22:14:41 +00:00
|
|
|
}
|
|
|
|
|
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).
The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.
Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.
For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.
Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 19:00:20 +00:00
|
|
|
static int property_audiofmt(struct mp_aframe *fmt, int action, void *arg)
|
2015-05-22 18:23:47 +00:00
|
|
|
{
|
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).
The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.
Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.
For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.
Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 19:00:20 +00:00
|
|
|
if (!fmt || !mp_aframe_config_is_valid(fmt))
|
2015-05-22 18:23:47 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).
The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.
Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.
For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.
Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 19:00:20 +00:00
|
|
|
struct mp_chmap chmap = {0};
|
|
|
|
mp_aframe_get_chmap(fmt, &chmap);
|
|
|
|
|
2015-05-22 18:23:47 +00:00
|
|
|
struct m_sub_property props[] = {
|
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).
The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.
Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.
For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.
Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 19:00:20 +00:00
|
|
|
{"samplerate", SUB_PROP_INT(mp_aframe_get_rate(fmt))},
|
|
|
|
{"channel-count", SUB_PROP_INT(chmap.num)},
|
|
|
|
{"channels", SUB_PROP_STR(mp_chmap_to_str(&chmap))},
|
|
|
|
{"hr-channels", SUB_PROP_STR(mp_chmap_to_str_hr(&chmap))},
|
|
|
|
{"format", SUB_PROP_STR(af_fmt_to_str(mp_aframe_get_format(fmt)))},
|
2015-05-22 18:23:47 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_audio_params(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2018-01-18 13:44:20 +00:00
|
|
|
return property_audiofmt(mpctx->ao_chain ?
|
|
|
|
mpctx->ao_chain->filter->input_aformat : NULL, action, arg);
|
2015-05-22 18:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_audio_out_params(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
audio: introduce a new type to hold audio frames
This is pretty pointless, but I believe it allows us to claim that the
new code is not affected by the copyright of the old code. This is
needed, because the original mp_audio struct was written by someone who
has disagreed with LGPL relicensing (it was called af_data at the time,
and was defined in af.h).
The "GPL'ed" struct contents that surive are pretty trivial: just the
data pointer, and some metadata like the format, samplerate, etc. - but
at least in this case, any new code would be extremely similar anyway,
and I'm not really sure whether it's OK to claim different copyright. So
what we do is we just use AVFrame (which of course is LGPL with 100%
certainty), and add some accessors around it to adapt it to mpv
conventions.
Also, this gets rid of some annoying conventions of mp_audio, like the
struct fields that require using an accessor to write to them anyway.
For the most part, this change is only dumb replacements of mp_audio
related functions and fields. One minor actual change is that you can't
allocate the new type on the stack anymore.
Some code still uses mp_audio. All audio filter code will be deleted, so
it makes no sense to convert this code. (Audio filters which are LGPL
and which we keep will have to be ported to a new filter infrastructure
anyway.) player/audio.c uses it because it interacts with the old filter
code. push.c has some complex use of mp_audio and mp_audio_buffer, but
this and pull.c will most likely be rewritten to do something else.
2017-08-16 19:00:20 +00:00
|
|
|
struct mp_aframe *frame = NULL;
|
|
|
|
if (mpctx->ao) {
|
|
|
|
frame = mp_aframe_create();
|
|
|
|
int samplerate;
|
|
|
|
int format;
|
|
|
|
struct mp_chmap channels;
|
|
|
|
ao_get_format(mpctx->ao, &samplerate, &format, &channels);
|
|
|
|
mp_aframe_set_rate(frame, samplerate);
|
|
|
|
mp_aframe_set_format(frame, format);
|
|
|
|
mp_aframe_set_chmap(frame, &channels);
|
|
|
|
}
|
|
|
|
int r = property_audiofmt(frame, action, arg);
|
|
|
|
talloc_free(frame);
|
|
|
|
return r;
|
2015-05-22 18:23:47 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 08:05:05 +00:00
|
|
|
static struct track* track_next(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
int direction, struct track *track)
|
2012-08-19 16:01:30 +00:00
|
|
|
{
|
|
|
|
assert(direction == -1 || direction == +1);
|
|
|
|
struct track *prev = NULL, *next = NULL;
|
|
|
|
bool seen = track == NULL;
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *cur = mpctx->tracks[n];
|
|
|
|
if (cur->type == type) {
|
|
|
|
if (cur == track) {
|
|
|
|
seen = true;
|
2016-02-03 08:05:05 +00:00
|
|
|
} else if (!cur->selected) {
|
2012-08-19 16:01:30 +00:00
|
|
|
if (seen && !next) {
|
|
|
|
next = cur;
|
2013-07-21 16:06:52 +00:00
|
|
|
}
|
|
|
|
if (!seen || !track) {
|
2012-08-19 16:01:30 +00:00
|
|
|
prev = cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return direction > 0 ? next : prev;
|
|
|
|
}
|
|
|
|
|
2019-11-25 18:49:09 +00:00
|
|
|
static int property_switch_track(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2019-11-25 18:49:09 +00:00
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
const int *def = prop->priv;
|
|
|
|
int order = def[0];
|
|
|
|
enum stream_type type = def[1];
|
|
|
|
|
2013-12-24 16:46:14 +00:00
|
|
|
struct track *track = mpctx->current_track[order][type];
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2015-07-28 22:09:44 +00:00
|
|
|
if (mpctx->playback_initialized) {
|
|
|
|
*(int *)arg = track ? track->user_tid : -2;
|
|
|
|
} else {
|
|
|
|
*(int *)arg = mpctx->opts->stream_id[order][type];
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
2018-04-28 14:42:12 +00:00
|
|
|
if (track) {
|
2012-08-19 16:01:30 +00:00
|
|
|
char *lang = track->lang;
|
2023-08-10 16:52:51 +00:00
|
|
|
if (!lang && type != STREAM_VIDEO) {
|
2013-12-16 19:40:02 +00:00
|
|
|
lang = "unknown";
|
2023-08-10 16:52:51 +00:00
|
|
|
} else if (!lang) {
|
|
|
|
lang = "";
|
|
|
|
}
|
2012-02-19 13:15:41 +00:00
|
|
|
|
2018-04-28 14:42:12 +00:00
|
|
|
if (track->title) {
|
2011-07-03 17:41:46 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "(%d) %s (\"%s\")",
|
2012-08-19 16:01:30 +00:00
|
|
|
track->user_tid, lang, track->title);
|
2018-04-28 14:42:12 +00:00
|
|
|
} else {
|
2012-08-19 16:01:30 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "(%d) %s",
|
|
|
|
track->user_tid, lang);
|
2018-04-28 14:42:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2018-04-28 14:47:25 +00:00
|
|
|
const char *msg = "no";
|
|
|
|
if (!mpctx->playback_initialized &&
|
|
|
|
mpctx->opts->stream_id[order][type] == -1)
|
|
|
|
msg = "auto";
|
|
|
|
*(char **) arg = talloc_strdup(NULL, msg);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-09-22 04:15:36 +00:00
|
|
|
case M_PROPERTY_SWITCH: {
|
2018-04-28 14:47:25 +00:00
|
|
|
if (mpctx->playback_initialized) {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
|
|
|
do {
|
|
|
|
track = track_next(mpctx, type, sarg->inc >= 0 ? +1 : -1, track);
|
|
|
|
mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION);
|
|
|
|
} while (mpctx->current_track[order][type] != track);
|
|
|
|
print_track_list(mpctx, "Track switched:");
|
|
|
|
} else {
|
|
|
|
// Simply cycle between "no" and "auto". It's possible that this does
|
|
|
|
// not always do what the user means, but keep the complexity low.
|
2020-04-15 15:10:01 +00:00
|
|
|
mark_track_selection(mpctx, order, type,
|
|
|
|
mpctx->opts->stream_id[order][type] == -1 ? -2 : -1);
|
2018-04-28 14:47:25 +00:00
|
|
|
}
|
2012-09-18 12:00:08 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-22 04:15:36 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2012-08-19 16:01:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2015-07-03 00:33:54 +00:00
|
|
|
static int track_channels(struct track *track)
|
|
|
|
{
|
2016-01-12 22:48:19 +00:00
|
|
|
return track->stream ? track->stream->codec->channels.num : 0;
|
2015-07-03 00:33:54 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 15:53:11 +00:00
|
|
|
static int get_track_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct track *track = mpctx->tracks[item];
|
|
|
|
|
2016-02-29 19:55:44 +00:00
|
|
|
struct mp_codec_params p =
|
|
|
|
track->stream ? *track->stream->codec : (struct mp_codec_params){0};
|
|
|
|
|
2020-03-21 21:05:50 +00:00
|
|
|
char decoder_desc[256] = {0};
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
if (track->dec)
|
f_decoder_wrapper: replace most public fields with setters/getters
I may (optionally) move decoding to a separate thread in a future
change. It's a bit attractive to move the entire decoder wrapper to
there, so if the demuxer has a new packet, it doesn't have to wake up
the main thread, and can directly wake up the decoder. (Although that's
bullshit, since there's a queue in between, and libavcodec's
multi-threaded decoding plays cross-threads ping pong with packets
anyway. On the other hand, the main thread would still have to shuffle
the packets around, so whatever, just seems like better design.)
As preparation, there shouldn't be any mutable state exposed by the
wrapper. But there's still a large number of corner-caseish crap, so
just use setters/getters for them. This recorder thing will inherently
not work, so it'll have to be disabled if threads are used.
This is a bit painful, but probably still the right thing. Like
speculatively pulling teeth.
2020-02-28 20:17:55 +00:00
|
|
|
mp_decoder_wrapper_get_desc(track->dec, decoder_desc, sizeof(decoder_desc));
|
2014-02-18 23:21:56 +00:00
|
|
|
|
2017-02-20 13:02:10 +00:00
|
|
|
bool has_rg = track->stream && track->stream->codec->replaygain_data;
|
2016-08-13 13:21:09 +00:00
|
|
|
struct replaygain_data rg = has_rg ? *track->stream->codec->replaygain_data
|
|
|
|
: (struct replaygain_data){0};
|
|
|
|
|
2019-08-01 10:51:13 +00:00
|
|
|
double par = 0.0;
|
|
|
|
if (p.par_h)
|
|
|
|
par = p.par_w / (double) p.par_h;
|
|
|
|
|
2020-04-16 10:03:18 +00:00
|
|
|
int order = -1;
|
|
|
|
if (track->selected) {
|
|
|
|
for (int i = 0; i < num_ptracks[track->type]; i++) {
|
|
|
|
if (mpctx->current_track[i][track->type] == track) {
|
|
|
|
order = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:53:11 +00:00
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"id", SUB_PROP_INT(track->user_tid)},
|
|
|
|
{"type", SUB_PROP_STR(stream_type_name(track->type)),
|
|
|
|
.unavailable = !stream_type_name(track->type)},
|
|
|
|
{"src-id", SUB_PROP_INT(track->demuxer_id),
|
|
|
|
.unavailable = track->demuxer_id == -1},
|
|
|
|
{"title", SUB_PROP_STR(track->title),
|
|
|
|
.unavailable = !track->title},
|
|
|
|
{"lang", SUB_PROP_STR(track->lang),
|
|
|
|
.unavailable = !track->lang},
|
2015-07-03 00:33:54 +00:00
|
|
|
{"audio-channels", SUB_PROP_INT(track_channels(track)),
|
|
|
|
.unavailable = track_channels(track) <= 0},
|
2023-02-20 05:53:09 +00:00
|
|
|
{"image", SUB_PROP_BOOL(track->image)},
|
|
|
|
{"albumart", SUB_PROP_BOOL(track->attached_picture)},
|
|
|
|
{"default", SUB_PROP_BOOL(track->default_track)},
|
|
|
|
{"forced", SUB_PROP_BOOL(track->forced_track)},
|
2021-06-25 07:35:51 +00:00
|
|
|
{"auto-forced-only", SUB_PROP_BOOL(track->forced_only_def)},
|
2023-02-20 05:53:09 +00:00
|
|
|
{"dependent", SUB_PROP_BOOL(track->dependent_track)},
|
|
|
|
{"visual-impaired", SUB_PROP_BOOL(track->visual_impaired_track)},
|
|
|
|
{"hearing-impaired", SUB_PROP_BOOL(track->hearing_impaired_track)},
|
|
|
|
{"external", SUB_PROP_BOOL(track->is_external)},
|
|
|
|
{"selected", SUB_PROP_BOOL(track->selected)},
|
2020-04-16 10:03:18 +00:00
|
|
|
{"main-selection", SUB_PROP_INT(order), .unavailable = order < 0},
|
2014-02-15 15:53:11 +00:00
|
|
|
{"external-filename", SUB_PROP_STR(track->external_filename),
|
|
|
|
.unavailable = !track->external_filename},
|
2014-10-21 11:16:48 +00:00
|
|
|
{"ff-index", SUB_PROP_INT(track->ff_index)},
|
2023-02-21 21:26:50 +00:00
|
|
|
{"hls-bitrate", SUB_PROP_INT(track->hls_bitrate),
|
|
|
|
.unavailable = !track->hls_bitrate},
|
|
|
|
{"program-id", SUB_PROP_INT(track->program_id),
|
|
|
|
.unavailable = track->program_id < 0},
|
2016-02-29 19:55:44 +00:00
|
|
|
{"decoder-desc", SUB_PROP_STR(decoder_desc),
|
f_decoder_wrapper: replace most public fields with setters/getters
I may (optionally) move decoding to a separate thread in a future
change. It's a bit attractive to move the entire decoder wrapper to
there, so if the demuxer has a new packet, it doesn't have to wake up
the main thread, and can directly wake up the decoder. (Although that's
bullshit, since there's a queue in between, and libavcodec's
multi-threaded decoding plays cross-threads ping pong with packets
anyway. On the other hand, the main thread would still have to shuffle
the packets around, so whatever, just seems like better design.)
As preparation, there shouldn't be any mutable state exposed by the
wrapper. But there's still a large number of corner-caseish crap, so
just use setters/getters for them. This recorder thing will inherently
not work, so it'll have to be disabled if threads are used.
This is a bit painful, but probably still the right thing. Like
speculatively pulling teeth.
2020-02-28 20:17:55 +00:00
|
|
|
.unavailable = !decoder_desc[0]},
|
2016-02-29 19:55:44 +00:00
|
|
|
{"codec", SUB_PROP_STR(p.codec),
|
|
|
|
.unavailable = !p.codec},
|
|
|
|
{"demux-w", SUB_PROP_INT(p.disp_w), .unavailable = !p.disp_w},
|
|
|
|
{"demux-h", SUB_PROP_INT(p.disp_h), .unavailable = !p.disp_h},
|
|
|
|
{"demux-channel-count", SUB_PROP_INT(p.channels.num),
|
|
|
|
.unavailable = !p.channels.num},
|
|
|
|
{"demux-channels", SUB_PROP_STR(mp_chmap_to_str(&p.channels)),
|
|
|
|
.unavailable = !p.channels.num},
|
|
|
|
{"demux-samplerate", SUB_PROP_INT(p.samplerate),
|
|
|
|
.unavailable = !p.samplerate},
|
|
|
|
{"demux-fps", SUB_PROP_DOUBLE(p.fps), .unavailable = p.fps <= 0},
|
2019-08-01 10:51:13 +00:00
|
|
|
{"demux-bitrate", SUB_PROP_INT(p.bitrate), .unavailable = p.bitrate <= 0},
|
|
|
|
{"demux-rotation", SUB_PROP_INT(p.rotate), .unavailable = p.rotate <= 0},
|
|
|
|
{"demux-par", SUB_PROP_DOUBLE(par), .unavailable = par <= 0},
|
2016-08-13 13:21:09 +00:00
|
|
|
{"replaygain-track-peak", SUB_PROP_FLOAT(rg.track_peak),
|
|
|
|
.unavailable = !has_rg},
|
|
|
|
{"replaygain-track-gain", SUB_PROP_FLOAT(rg.track_gain),
|
|
|
|
.unavailable = !has_rg},
|
|
|
|
{"replaygain-album-peak", SUB_PROP_FLOAT(rg.album_peak),
|
|
|
|
.unavailable = !has_rg},
|
|
|
|
{"replaygain-album-gain", SUB_PROP_FLOAT(rg.album_gain),
|
|
|
|
.unavailable = !has_rg},
|
2014-02-15 15:53:11 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2013-05-15 00:17:47 +00:00
|
|
|
static const char *track_type_name(enum stream_type t)
|
|
|
|
{
|
|
|
|
switch (t) {
|
|
|
|
case STREAM_VIDEO: return "Video";
|
|
|
|
case STREAM_AUDIO: return "Audio";
|
|
|
|
case STREAM_SUB: return "Sub";
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_list_tracks(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:53:11 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-05-15 00:17:47 +00:00
|
|
|
char *res = NULL;
|
|
|
|
|
|
|
|
for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *track = mpctx->tracks[n];
|
|
|
|
if (track->type != type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
res = talloc_asprintf_append(res, "%s: ",
|
|
|
|
track_type_name(track->type));
|
2016-05-03 20:41:53 +00:00
|
|
|
res = talloc_strdup_append(res,
|
|
|
|
track->selected ? list_current : list_normal);
|
2013-05-15 00:17:47 +00:00
|
|
|
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
|
|
|
|
if (track->title)
|
|
|
|
res = talloc_asprintf_append(res, "'%s' ", track->title);
|
|
|
|
if (track->lang)
|
|
|
|
res = talloc_asprintf_append(res, "(%s) ", track->lang);
|
|
|
|
if (track->is_external)
|
|
|
|
res = talloc_asprintf_append(res, "(external) ");
|
|
|
|
res = talloc_asprintf_append(res, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
res = talloc_asprintf_append(res, "\n");
|
|
|
|
}
|
|
|
|
|
2016-02-15 20:03:51 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
2013-05-15 00:17:47 +00:00
|
|
|
if (demuxer && demuxer->num_editions > 1)
|
|
|
|
res = talloc_asprintf_append(res, "\nEdition: %d of %d\n",
|
|
|
|
demuxer->edition + 1,
|
|
|
|
demuxer->num_editions);
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-02-15 15:53:11 +00:00
|
|
|
return m_property_read_list(action, arg, mpctx->num_tracks,
|
|
|
|
get_track_entry, mpctx);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 15:23:13 +00:00
|
|
|
static int property_current_tracks(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
|
|
|
|
if (action != M_PROPERTY_KEY_ACTION)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int type = -1;
|
|
|
|
int order = 0;
|
|
|
|
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
|
|
|
|
|
|
|
if (bstr_equals0(key, "video")) {
|
|
|
|
type = STREAM_VIDEO;
|
|
|
|
} else if (bstr_equals0(key, "audio")) {
|
|
|
|
type = STREAM_AUDIO;
|
|
|
|
} else if (bstr_equals0(key, "sub")) {
|
|
|
|
type = STREAM_SUB;
|
|
|
|
} else if (bstr_equals0(key, "sub2")) {
|
|
|
|
type = STREAM_SUB;
|
|
|
|
order = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type < 0)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
|
|
|
struct track *t = mpctx->current_track[order][type];
|
2021-09-15 19:33:47 +00:00
|
|
|
|
|
|
|
if (!t && mpctx->lavfi) {
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
if (mpctx->tracks[n]->type == type && mpctx->tracks[n]->selected) {
|
|
|
|
t = mpctx->tracks[n];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-12 15:23:13 +00:00
|
|
|
if (!t)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int index = -1;
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
if (mpctx->tracks[n] == t) {
|
|
|
|
index = n;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(index >= 0);
|
|
|
|
|
|
|
|
char *name = mp_tprintf(80, "track-list/%d/%s", index, rem);
|
|
|
|
return mp_property_do(name, ka->action, ka->arg, ctx);
|
|
|
|
}
|
|
|
|
|
2016-05-04 14:55:26 +00:00
|
|
|
static int mp_property_hwdec_current(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
struct mp_decoder_wrapper *dec = track ? track->dec : NULL;
|
2016-05-04 14:55:26 +00:00
|
|
|
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
if (!dec)
|
2016-05-04 14:55:26 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2017-12-01 20:05:54 +00:00
|
|
|
char *current = NULL;
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
mp_decoder_wrapper_control(dec, VDCTRL_GET_HWDEC, ¤t);
|
2023-08-10 01:39:36 +00:00
|
|
|
if (!current || !current[0])
|
2017-12-01 20:05:54 +00:00
|
|
|
current = "no";
|
|
|
|
return m_property_strdup_ro(action, arg, current);
|
2016-05-04 14:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_hwdec_interop(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-05-09 17:42:03 +00:00
|
|
|
if (!mpctx->video_out || !mpctx->video_out->hwdec_devs)
|
2016-05-04 14:55:26 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
vo_gpu: make it possible to load multiple hwdec interop drivers
Make the VO<->decoder interface capable of supporting multiple hwdec
APIs at once. The main gain is that this simplifies autoprobing a lot.
Before this change, it could happen that the VO loaded the "wrong" hwdec
API, and the decoder was stuck with the choice (breaking hw decoding).
With the change applied, the VO simply loads all available APIs, so
autoprobing trickery is left entirely to the decoder.
In the past, we were quite careful about not accidentally loading the
wrong interop drivers. This was in part to make sure autoprobing works,
but also because libva had this obnoxious bug of dumping garbage to
stderr when using the API. libva was fixed, so this is not a problem
anymore.
The --opengl-hwdec-interop option is changed in various ways (again...),
and renamed to --gpu-hwdec-interop. It does not have much use anymore,
other than debugging. It's notable that the order in the hwdec interop
array ra_hwdec_drivers[] still matters if multiple drivers support the
same image formats, so the option can explicitly force one, if that
should ever be necessary, or more likely, for debugging. One example are
the ra_hwdec_d3d11egl and ra_hwdec_d3d11eglrgb drivers, which both
support d3d11 input.
vo_gpu now always loads the interop lazily by default, but when it does,
it loads them all. vo_opengl_cb now always loads them when the GL
context handle is initialized. I don't expect that this causes any
problems.
It's now possible to do things like changing between vdpau and nvdec
decoding at runtime.
This is also preparation for cleaning up vd_lavc.c hwdec autoprobing.
It's another reason why hwdec_devices_request_all() does not take a
hwdec type anymore.
2017-12-01 04:05:00 +00:00
|
|
|
char *names = hwdec_devices_get_names(mpctx->video_out->hwdec_devs);
|
|
|
|
int res = m_property_strdup_ro(action, arg, names);
|
|
|
|
talloc_free(names);
|
|
|
|
return res;
|
2016-05-04 14:55:26 +00:00
|
|
|
}
|
|
|
|
|
2014-08-19 19:19:38 +00:00
|
|
|
static int get_frame_count(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
2016-01-17 17:07:50 +00:00
|
|
|
return -1;
|
|
|
|
if (!mpctx->vo_chain)
|
|
|
|
return -1;
|
2014-10-29 20:54:59 +00:00
|
|
|
double len = get_time_length(mpctx);
|
2018-02-01 08:20:25 +00:00
|
|
|
double fps = mpctx->vo_chain->filter->container_fps;
|
2014-10-29 20:54:59 +00:00
|
|
|
if (len < 0 || fps <= 0)
|
|
|
|
return 0;
|
2014-08-19 19:19:38 +00:00
|
|
|
|
2014-10-29 20:54:59 +00:00
|
|
|
return len * fps;
|
2014-08-19 19:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_frame_number(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
int frames = get_frame_count(mpctx);
|
|
|
|
if (frames < 0)
|
2014-08-19 19:19:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-12-26 17:36:45 +00:00
|
|
|
return m_property_int_ro(action, arg,
|
2016-01-17 17:07:50 +00:00
|
|
|
lrint(get_current_pos_ratio(mpctx, false) * frames));
|
2014-08-19 19:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
int frames = get_frame_count(mpctx);
|
|
|
|
if (frames < 0)
|
2014-08-19 19:19:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2016-01-17 17:07:50 +00:00
|
|
|
return m_property_int_ro(action, arg, frames);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Video codec tag (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_video_format(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
|
|
|
const char *c = track && track->stream ? track->stream->codec->codec : NULL;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, c);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Video codec name (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_video_codec(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-05-29 22:14:41 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
f_decoder_wrapper: replace most public fields with setters/getters
I may (optionally) move decoding to a separate thread in a future
change. It's a bit attractive to move the entire decoder wrapper to
there, so if the demuxer has a new packet, it doesn't have to wake up
the main thread, and can directly wake up the decoder. (Although that's
bullshit, since there's a queue in between, and libavcodec's
multi-threaded decoding plays cross-threads ping pong with packets
anyway. On the other hand, the main thread would still have to shuffle
the packets around, so whatever, just seems like better design.)
As preparation, there shouldn't be any mutable state exposed by the
wrapper. But there's still a large number of corner-caseish crap, so
just use setters/getters for them. This recorder thing will inherently
not work, so it'll have to be disabled if threads are used.
This is a bit painful, but probably still the right thing. Like
speculatively pulling teeth.
2020-02-28 20:17:55 +00:00
|
|
|
char desc[256] = "";
|
|
|
|
if (track && track->dec)
|
|
|
|
mp_decoder_wrapper_get_desc(track->dec, desc, sizeof(desc));
|
|
|
|
return m_property_strdup_ro(action, arg, desc[0] ? desc : NULL);
|
2007-05-29 22:14:41 +00:00
|
|
|
}
|
|
|
|
|
2023-08-11 15:14:27 +00:00
|
|
|
static const char *get_aspect_ratio_name(double ratio)
|
|
|
|
{
|
|
|
|
// Depending on cropping/mastering exact ratio may differ.
|
|
|
|
#define RATIO_THRESH 0.025
|
|
|
|
#define RATIO_CASE(ref, name) \
|
|
|
|
if (fabs(ratio - (ref)) < RATIO_THRESH) \
|
|
|
|
return name; \
|
|
|
|
|
|
|
|
// https://en.wikipedia.org/wiki/Aspect_ratio_(image)
|
|
|
|
RATIO_CASE(9.0 / 16.0, "Vertical")
|
|
|
|
RATIO_CASE(1.0, "Square");
|
|
|
|
RATIO_CASE(19.0 / 16.0, "Movietone Ratio");
|
|
|
|
RATIO_CASE(5.0 / 4.0, "5:4");
|
|
|
|
RATIO_CASE(4.0 / 3.0, "4:3");
|
|
|
|
RATIO_CASE(11.0 / 8.0, "Academy Ratio");
|
|
|
|
RATIO_CASE(1.43, "IMAX Ratio");
|
|
|
|
RATIO_CASE(3.0 / 2.0, "VistaVision Ratio");
|
|
|
|
RATIO_CASE(16.0 / 10.0, "16:10");
|
|
|
|
RATIO_CASE(5.0 / 3.0, "35mm Widescreen Ratio");
|
|
|
|
RATIO_CASE(16.0 / 9.0, "16:9");
|
|
|
|
RATIO_CASE(7.0 / 4.0, "Early 35mm Widescreen Ratio");
|
|
|
|
RATIO_CASE(1.85, "Academy Flat");
|
|
|
|
RATIO_CASE(256.0 / 135.0, "SMPTE/DCI Ratio");
|
|
|
|
RATIO_CASE(2.0, "Univisium");
|
|
|
|
RATIO_CASE(2.208, "70mm film");
|
|
|
|
RATIO_CASE(2.35, "Scope");
|
|
|
|
RATIO_CASE(2.39, "Panavision");
|
|
|
|
RATIO_CASE(2.55, "Original CinemaScope");
|
|
|
|
RATIO_CASE(2.59, "Full-frame Cinerama");
|
|
|
|
RATIO_CASE(24.0 / 9.0, "Full-frame Super 16mm");
|
|
|
|
RATIO_CASE(2.76, "Ultra Panavision 70");
|
|
|
|
RATIO_CASE(32.0 / 9.0, "32:9");
|
|
|
|
RATIO_CASE(3.6, "Ultra-WideScreen 3.6");
|
|
|
|
RATIO_CASE(4.0, "Polyvision");
|
|
|
|
RATIO_CASE(12.0, "Circle-Vision 360°");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
#undef RATIO_THRESH
|
|
|
|
#undef RATIO_CASE
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
static int property_imgparams(struct mp_image_params p, int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2014-02-15 15:42:48 +00:00
|
|
|
if (!p.imgfmt)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2015-12-19 19:04:31 +00:00
|
|
|
int d_w, d_h;
|
|
|
|
mp_image_params_get_dsize(&p, &d_w, &d_h);
|
2014-02-15 15:42:48 +00:00
|
|
|
|
2015-01-10 18:11:28 +00:00
|
|
|
struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p.imgfmt);
|
2015-01-10 11:29:10 +00:00
|
|
|
int bpp = 0;
|
2015-01-10 18:11:28 +00:00
|
|
|
for (int i = 0; i < desc.num_planes; i++)
|
|
|
|
bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]);
|
2015-01-10 11:29:10 +00:00
|
|
|
|
2020-08-15 10:04:35 +00:00
|
|
|
// Alpha type is not supported by FFmpeg, so MP_ALPHA_AUTO may mean alpha
|
|
|
|
// is of an unknown type, or simply not present. Normalize to AUTO=no alpha.
|
|
|
|
if (!!(desc.flags & MP_IMGFLAG_ALPHA) != (p.alpha != MP_ALPHA_AUTO)) {
|
|
|
|
p.alpha =
|
|
|
|
(desc.flags & MP_IMGFLAG_ALPHA) ? MP_ALPHA_STRAIGHT : MP_ALPHA_AUTO;
|
|
|
|
}
|
|
|
|
|
2023-08-11 15:14:27 +00:00
|
|
|
const char *aspect_name = get_aspect_ratio_name(d_w / (double)d_h);
|
2014-02-15 15:42:48 +00:00
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))},
|
2020-10-16 09:06:37 +00:00
|
|
|
{"hw-pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.hw_subfmt)),
|
|
|
|
.unavailable = !p.hw_subfmt},
|
2015-01-10 20:16:34 +00:00
|
|
|
{"average-bpp", SUB_PROP_INT(bpp),
|
2015-01-10 18:11:28 +00:00
|
|
|
.unavailable = !bpp},
|
2014-02-15 15:42:48 +00:00
|
|
|
{"w", SUB_PROP_INT(p.w)},
|
|
|
|
{"h", SUB_PROP_INT(p.h)},
|
2015-12-19 19:04:31 +00:00
|
|
|
{"dw", SUB_PROP_INT(d_w)},
|
|
|
|
{"dh", SUB_PROP_INT(d_h)},
|
|
|
|
{"aspect", SUB_PROP_FLOAT(d_w / (double)d_h)},
|
2023-08-11 15:14:27 +00:00
|
|
|
{"aspect-name", SUB_PROP_STR(aspect_name), .unavailable = !aspect_name},
|
2015-12-19 19:04:31 +00:00
|
|
|
{"par", SUB_PROP_FLOAT(p.p_w / (double)p.p_h)},
|
2015-03-30 21:52:28 +00:00
|
|
|
{"colormatrix",
|
2016-06-29 07:16:13 +00:00
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_names, p.color.space))},
|
2015-03-30 21:52:28 +00:00
|
|
|
{"colorlevels",
|
2016-06-29 07:16:13 +00:00
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_levels_names, p.color.levels))},
|
2015-03-30 21:52:28 +00:00
|
|
|
{"primaries",
|
2016-06-29 07:16:13 +00:00
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_prim_names, p.color.primaries))},
|
2015-03-31 02:50:49 +00:00
|
|
|
{"gamma",
|
2016-06-29 07:16:13 +00:00
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_trc_names, p.color.gamma))},
|
2016-07-09 02:18:45 +00:00
|
|
|
{"sig-peak", SUB_PROP_FLOAT(p.color.sig_peak)},
|
2017-06-14 18:06:56 +00:00
|
|
|
{"light",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_light_names, p.color.light))},
|
2015-03-30 21:52:28 +00:00
|
|
|
{"chroma-location",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_chroma_names, p.chroma_location))},
|
2015-06-23 13:20:21 +00:00
|
|
|
{"stereo-in",
|
2018-04-21 11:31:00 +00:00
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_stereo3d_names, p.stereo3d))},
|
2014-04-21 20:54:43 +00:00
|
|
|
{"rotate", SUB_PROP_INT(p.rotate)},
|
2020-08-15 10:04:35 +00:00
|
|
|
{"alpha",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_alpha_names, p.alpha)),
|
|
|
|
// avoid using "auto" for "no", so just make it unavailable
|
|
|
|
.unavailable = p.alpha == MP_ALPHA_AUTO},
|
2014-02-15 15:42:48 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2014-01-09 20:19:19 +00:00
|
|
|
static struct mp_image_params get_video_out_params(struct MPContext *mpctx)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
video: rewrite filtering glue code
Get rid of the old vf.c code. Replace it with a generic filtering
framework, which can potentially handle more than just --vf. At least
reimplementing --af with this code is planned.
This changes some --vf semantics (including runtime behavior and the
"vf" command). The most important ones are listed in interface-changes.
vf_convert.c is renamed to f_swscale.c. It is now an internal filter
that can not be inserted by the user manually.
f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed
once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is
conceptually easy, but a big mess due to the data flow changes).
The existing filters are all changed heavily. The data flow of the new
filter framework is different. Especially EOF handling changes - EOF is
now a "frame" rather than a state, and must be passed through exactly
once.
Another major thing is that all filters must support dynamic format
changes. The filter reconfig() function goes away. (This sounds complex,
but since all filters need to handle EOF draining anyway, they can use
the same code, and it removes the mess with reconfig() having to predict
the output format, which completely breaks with libavfilter anyway.)
In addition, there is no automatic format negotiation or conversion.
libavfilter's primitive and insufficient API simply doesn't allow us to
do this in a reasonable way. Instead, filters can use f_autoconvert as
sub-filter, and tell it which formats they support. This filter will in
turn add actual conversion filters, such as f_swscale, to perform
necessary format changes.
vf_vapoursynth.c uses the same basic principle of operation as before,
but with worryingly different details in data flow. Still appears to
work.
The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are
heavily changed. Fortunately, they all used refqueue.c, which is for
sharing the data flow logic (especially for managing future/past
surfaces and such). It turns out it can be used to factor out most of
the data flow. Some of these filters accepted software input. Instead of
having ad-hoc upload code in each filter, surface upload is now
delegated to f_autoconvert, which can use f_hwupload to perform this.
Exporting VO capabilities is still a big mess (mp_stream_info stuff).
The D3D11 code drops the redundant image formats, and all code uses the
hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a
big mess for now.
f_async_queue is unused.
2018-01-16 10:53:44 +00:00
|
|
|
if (!mpctx->vo_chain)
|
2014-01-09 20:19:19 +00:00
|
|
|
return (struct mp_image_params){0};
|
|
|
|
|
video: rewrite filtering glue code
Get rid of the old vf.c code. Replace it with a generic filtering
framework, which can potentially handle more than just --vf. At least
reimplementing --af with this code is planned.
This changes some --vf semantics (including runtime behavior and the
"vf" command). The most important ones are listed in interface-changes.
vf_convert.c is renamed to f_swscale.c. It is now an internal filter
that can not be inserted by the user manually.
f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed
once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is
conceptually easy, but a big mess due to the data flow changes).
The existing filters are all changed heavily. The data flow of the new
filter framework is different. Especially EOF handling changes - EOF is
now a "frame" rather than a state, and must be passed through exactly
once.
Another major thing is that all filters must support dynamic format
changes. The filter reconfig() function goes away. (This sounds complex,
but since all filters need to handle EOF draining anyway, they can use
the same code, and it removes the mess with reconfig() having to predict
the output format, which completely breaks with libavfilter anyway.)
In addition, there is no automatic format negotiation or conversion.
libavfilter's primitive and insufficient API simply doesn't allow us to
do this in a reasonable way. Instead, filters can use f_autoconvert as
sub-filter, and tell it which formats they support. This filter will in
turn add actual conversion filters, such as f_swscale, to perform
necessary format changes.
vf_vapoursynth.c uses the same basic principle of operation as before,
but with worryingly different details in data flow. Still appears to
work.
The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are
heavily changed. Fortunately, they all used refqueue.c, which is for
sharing the data flow logic (especially for managing future/past
surfaces and such). It turns out it can be used to factor out most of
the data flow. Some of these filters accepted software input. Instead of
having ad-hoc upload code in each filter, surface upload is now
delegated to f_autoconvert, which can use f_hwupload to perform this.
Exporting VO capabilities is still a big mess (mp_stream_info stuff).
The D3D11 code drops the redundant image formats, and all code uses the
hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a
big mess for now.
f_async_queue is unused.
2018-01-16 10:53:44 +00:00
|
|
|
return mpctx->vo_chain->filter->output_params;
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vo_imgparams(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_imgparams(get_video_out_params(ctx), action, arg);
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
2016-09-20 13:40:44 +00:00
|
|
|
static int mp_property_dec_imgparams(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct mp_image_params p = {0};
|
|
|
|
struct vo_chain *vo_c = mpctx->vo_chain;
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
if (vo_c && vo_c->track)
|
|
|
|
mp_decoder_wrapper_get_video_dec_params(vo_c->track->dec, &p);
|
2016-09-20 13:40:44 +00:00
|
|
|
if (!p.imgfmt)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return property_imgparams(p, action, arg);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vd_imgparams(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-13 23:18:48 +00:00
|
|
|
struct vo_chain *vo_c = mpctx->vo_chain;
|
2016-02-01 21:28:47 +00:00
|
|
|
if (!vo_c)
|
2014-01-09 20:19:19 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2016-02-01 21:28:47 +00:00
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
2016-01-17 17:07:50 +00:00
|
|
|
struct mp_codec_params *c =
|
|
|
|
track && track->stream ? track->stream->codec : NULL;
|
video: rewrite filtering glue code
Get rid of the old vf.c code. Replace it with a generic filtering
framework, which can potentially handle more than just --vf. At least
reimplementing --af with this code is planned.
This changes some --vf semantics (including runtime behavior and the
"vf" command). The most important ones are listed in interface-changes.
vf_convert.c is renamed to f_swscale.c. It is now an internal filter
that can not be inserted by the user manually.
f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed
once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is
conceptually easy, but a big mess due to the data flow changes).
The existing filters are all changed heavily. The data flow of the new
filter framework is different. Especially EOF handling changes - EOF is
now a "frame" rather than a state, and must be passed through exactly
once.
Another major thing is that all filters must support dynamic format
changes. The filter reconfig() function goes away. (This sounds complex,
but since all filters need to handle EOF draining anyway, they can use
the same code, and it removes the mess with reconfig() having to predict
the output format, which completely breaks with libavfilter anyway.)
In addition, there is no automatic format negotiation or conversion.
libavfilter's primitive and insufficient API simply doesn't allow us to
do this in a reasonable way. Instead, filters can use f_autoconvert as
sub-filter, and tell it which formats they support. This filter will in
turn add actual conversion filters, such as f_swscale, to perform
necessary format changes.
vf_vapoursynth.c uses the same basic principle of operation as before,
but with worryingly different details in data flow. Still appears to
work.
The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are
heavily changed. Fortunately, they all used refqueue.c, which is for
sharing the data flow logic (especially for managing future/past
surfaces and such). It turns out it can be used to factor out most of
the data flow. Some of these filters accepted software input. Instead of
having ad-hoc upload code in each filter, surface upload is now
delegated to f_autoconvert, which can use f_hwupload to perform this.
Exporting VO capabilities is still a big mess (mp_stream_info stuff).
The D3D11 code drops the redundant image formats, and all code uses the
hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a
big mess for now.
f_async_queue is unused.
2018-01-16 10:53:44 +00:00
|
|
|
if (vo_c->filter->input_params.imgfmt) {
|
|
|
|
return property_imgparams(vo_c->filter->input_params, action, arg);
|
2016-01-17 17:07:50 +00:00
|
|
|
} else if (c && c->disp_w && c->disp_h) {
|
2014-02-15 15:42:48 +00:00
|
|
|
// Simplistic fallback for stupid scripts querying "width"/"height"
|
|
|
|
// before the first frame is decoded.
|
|
|
|
struct m_sub_property props[] = {
|
2016-01-12 22:48:19 +00:00
|
|
|
{"w", SUB_PROP_INT(c->disp_w)},
|
|
|
|
{"h", SUB_PROP_INT(c->disp_h)},
|
2014-02-15 15:42:48 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-22 17:54:22 +00:00
|
|
|
static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct mp_image *f =
|
|
|
|
mpctx->video_out ? vo_get_current_frame(mpctx->video_out) : NULL;
|
|
|
|
if (!f)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
const char *pict_types[] = {0, "I", "P", "B"};
|
|
|
|
const char *pict_type = f->pict_type >= 1 && f->pict_type <= 3
|
|
|
|
? pict_types[f->pict_type] : NULL;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"picture-type", SUB_PROP_STR(pict_type), .unavailable = !pict_type},
|
2023-02-20 05:53:09 +00:00
|
|
|
{"interlaced", SUB_PROP_BOOL(!!(f->fields & MP_IMGFIELD_INTERLACED))},
|
|
|
|
{"tff", SUB_PROP_BOOL(!!(f->fields & MP_IMGFIELD_TOP_FIRST))},
|
|
|
|
{"repeat", SUB_PROP_BOOL(!!(f->fields & MP_IMGFIELD_REPEAT_FIRST))},
|
2015-11-22 17:54:22 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2016-04-24 18:11:36 +00:00
|
|
|
talloc_free(f);
|
2015-11-22 17:54:22 +00:00
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2021-08-07 11:59:47 +00:00
|
|
|
static int mp_property_current_window_scale(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-10-31 19:19:40 +00:00
|
|
|
{
|
2021-08-07 11:59:47 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-10-31 19:19:40 +00:00
|
|
|
struct vo *vo = mpctx->video_out;
|
2014-01-09 20:19:19 +00:00
|
|
|
if (!vo)
|
2021-08-07 11:59:47 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-10-31 19:19:40 +00:00
|
|
|
|
2014-01-09 20:19:19 +00:00
|
|
|
struct mp_image_params params = get_video_out_params(mpctx);
|
2015-12-19 19:04:31 +00:00
|
|
|
int vid_w, vid_h;
|
|
|
|
mp_image_params_get_dsize(¶ms, &vid_w, &vid_h);
|
2013-10-31 19:19:40 +00:00
|
|
|
if (vid_w < 1 || vid_h < 1)
|
2021-08-07 11:59:47 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2019-12-16 01:32:17 +00:00
|
|
|
|
2021-08-09 13:59:55 +00:00
|
|
|
if (params.rotate % 180 == 90 && (vo->driver->caps & VO_CAP_ROTATE90))
|
|
|
|
MPSWAP(int, vid_w, vid_h);
|
|
|
|
|
2021-08-09 15:33:55 +00:00
|
|
|
if (vo->monitor_par < 1) {
|
|
|
|
vid_h = MPCLAMP(vid_h / vo->monitor_par, 1, 16000);
|
|
|
|
} else {
|
|
|
|
vid_w = MPCLAMP(vid_w * vo->monitor_par, 1, 16000);
|
|
|
|
}
|
|
|
|
|
2020-11-08 00:36:26 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2021-08-09 13:51:50 +00:00
|
|
|
// Also called by update_window_scale as a NULL property.
|
2020-11-08 00:36:26 +00:00
|
|
|
double scale = *(double *)arg;
|
|
|
|
int s[2] = {vid_w * scale, vid_h * scale};
|
|
|
|
if (s[0] <= 0 || s[1] <= 0)
|
|
|
|
return M_PROPERTY_INVALID_FORMAT;
|
|
|
|
vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
2021-08-07 11:59:47 +00:00
|
|
|
int s[2];
|
|
|
|
if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
|
|
|
|
s[0] < 1 || s[1] < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
double xs = (double)s[0] / vid_w;
|
|
|
|
double ys = (double)s[1] / vid_h;
|
|
|
|
return m_property_double_ro(action, arg, (xs + ys) / 2);
|
2013-10-31 19:19:40 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 11:59:47 +00:00
|
|
|
static void update_window_scale(struct MPContext *mpctx)
|
2019-11-24 23:26:36 +00:00
|
|
|
{
|
2021-08-07 11:59:47 +00:00
|
|
|
double scale = mpctx->opts->vo->window_scale;
|
2021-08-09 13:51:50 +00:00
|
|
|
mp_property_current_window_scale(mpctx, (struct m_property *)NULL,
|
|
|
|
M_PROPERTY_SET, (void*)&scale);
|
2019-11-24 23:26:36 +00:00
|
|
|
}
|
|
|
|
|
2015-03-10 13:50:56 +00:00
|
|
|
static int mp_property_display_fps(void *ctx, struct m_property *prop,
|
2015-03-12 22:41:25 +00:00
|
|
|
int action, void *arg)
|
2015-03-10 13:50:56 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2018-03-13 11:34:26 +00:00
|
|
|
double fps = mpctx->video_out ? vo_get_display_fps(mpctx->video_out) : 0;
|
2019-11-24 23:47:53 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
MP_WARN(mpctx, "Setting the display-fps property is deprecated; set "
|
|
|
|
"the override-display-fps property instead.\n");
|
|
|
|
struct mpv_node val = {
|
|
|
|
.format = MPV_FORMAT_DOUBLE,
|
|
|
|
.u.double_ = *(double *)arg,
|
|
|
|
};
|
|
|
|
return m_config_set_option_node(mpctx->mconfig,
|
|
|
|
bstr0("override-display-fps"), &val, 0)
|
|
|
|
>= 0 ? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
if (fps <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2018-03-13 11:34:26 +00:00
|
|
|
return m_property_double_ro(action, arg, fps);
|
2019-11-24 23:47:53 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_DOUBLE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2015-03-10 13:50:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 21:07:56 +00:00
|
|
|
static int mp_property_estimated_display_fps(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
double interval = vo_get_estimated_vsync_interval(vo);
|
|
|
|
if (interval <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_double_ro(action, arg, 1.0 / interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_vsync_jitter(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
double stddev = vo_get_estimated_vsync_jitter(vo);
|
|
|
|
if (stddev < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_double_ro(action, arg, stddev);
|
|
|
|
}
|
|
|
|
|
2021-04-12 17:51:41 +00:00
|
|
|
static int mp_property_display_resolution(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
int res[2];
|
|
|
|
if (vo_control(vo, VOCTRL_GET_DISPLAY_RES, &res) <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (strcmp(prop->name, "display-width") == 0) {
|
|
|
|
return m_property_int_ro(action, arg, res[0]);
|
|
|
|
} else {
|
|
|
|
return m_property_int_ro(action, arg, res[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-20 11:47:00 +00:00
|
|
|
static int mp_property_hidpi_scale(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2020-01-08 01:16:45 +00:00
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2019-12-20 11:47:00 +00:00
|
|
|
struct vo *vo = mpctx->video_out;
|
2020-01-08 01:16:45 +00:00
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (!cmd->cached_window_scale) {
|
|
|
|
double scale = 0;
|
|
|
|
if (vo_control(vo, VOCTRL_GET_HIDPI_SCALE, &scale) < 1 || !scale)
|
|
|
|
scale = -1;
|
|
|
|
cmd->cached_window_scale = scale;
|
|
|
|
}
|
|
|
|
if (cmd->cached_window_scale < 0)
|
2019-12-20 11:47:00 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2020-01-08 01:16:45 +00:00
|
|
|
return m_property_double_ro(action, arg, cmd->cached_window_scale);
|
2019-12-20 11:47:00 +00:00
|
|
|
}
|
|
|
|
|
2020-09-07 16:22:25 +00:00
|
|
|
static int mp_property_focused(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
bool focused;
|
|
|
|
if (vo_control(vo, VOCTRL_GET_FOCUSED, &focused) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg, focused);
|
2020-09-07 16:22:25 +00:00
|
|
|
}
|
|
|
|
|
2014-11-06 02:16:32 +00:00
|
|
|
static int mp_property_display_names(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char** display_names;
|
|
|
|
if (vo_control(vo, VOCTRL_GET_DISPLAY_NAMES, &display_names) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
*(char ***)arg = display_names;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-10-24 13:34:53 +00:00
|
|
|
static int mp_property_vo_configured(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2023-02-20 05:53:09 +00:00
|
|
|
return m_property_bool_ro(action, arg,
|
2014-10-24 13:34:53 +00:00
|
|
|
mpctx->video_out && mpctx->video_out->config_ok);
|
|
|
|
}
|
|
|
|
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
static void get_frame_perf(struct mpv_node *node, struct mp_frame_perf *perf)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < perf->count; i++) {
|
|
|
|
struct mp_pass_perf *data = &perf->perf[i];
|
|
|
|
struct mpv_node *pass = node_array_add(node, MPV_FORMAT_NODE_MAP);
|
|
|
|
|
|
|
|
node_map_add_string(pass, "desc", perf->desc[i]);
|
|
|
|
node_map_add(pass, "last", MPV_FORMAT_INT64)->u.int64 = data->last;
|
|
|
|
node_map_add(pass, "avg", MPV_FORMAT_INT64)->u.int64 = data->avg;
|
|
|
|
node_map_add(pass, "peak", MPV_FORMAT_INT64)->u.int64 = data->peak;
|
|
|
|
node_map_add(pass, "count", MPV_FORMAT_INT64)->u.int64 = data->count;
|
|
|
|
struct mpv_node *samples = node_map_add(pass, "samples", MPV_FORMAT_NODE_ARRAY);
|
2017-09-10 22:27:27 +00:00
|
|
|
for (int n = 0; n < data->count; n++)
|
|
|
|
node_array_add(samples, MPV_FORMAT_INT64)->u.int64 = data->samples[n];
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *asprint_perf(char *res, struct mp_frame_perf *perf)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < perf->count; i++) {
|
|
|
|
struct mp_pass_perf *pass = &perf->perf[i];
|
|
|
|
res = talloc_asprintf_append(res,
|
|
|
|
"- %s: last %dus avg %dus peak %dus\n", perf->desc[i],
|
|
|
|
(int)pass->last/1000, (int)pass->avg/1000, (int)pass->peak/1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_vo_passes(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2016-06-08 09:39:31 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->video_out)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
// Return the type right away if requested, to avoid having to
|
|
|
|
// go through a completely unnecessary VOCTRL
|
|
|
|
if (action == M_PROPERTY_GET_TYPE) {
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
2017-09-11 16:20:18 +00:00
|
|
|
int ret = M_PROPERTY_UNAVAILABLE;
|
|
|
|
struct voctrl_performance_data *data = talloc_ptrtype(NULL, data);
|
|
|
|
if (vo_control(mpctx->video_out, VOCTRL_PERFORMANCE_DATA, data) <= 0)
|
|
|
|
goto out;
|
2016-06-08 09:39:31 +00:00
|
|
|
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
char *res = NULL;
|
|
|
|
res = talloc_asprintf_append(res, "fresh:\n");
|
2017-09-11 16:20:18 +00:00
|
|
|
res = asprint_perf(res, &data->fresh);
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
res = talloc_asprintf_append(res, "\nredraw:\n");
|
2017-09-11 16:20:18 +00:00
|
|
|
res = asprint_perf(res, &data->redraw);
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
*(char **)arg = res;
|
2017-09-11 16:20:18 +00:00
|
|
|
ret = M_PROPERTY_OK;
|
|
|
|
goto out;
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
}
|
2016-06-08 09:39:31 +00:00
|
|
|
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
struct mpv_node node;
|
|
|
|
node_init(&node, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
struct mpv_node *fresh = node_map_add(&node, "fresh", MPV_FORMAT_NODE_ARRAY);
|
|
|
|
struct mpv_node *redraw = node_map_add(&node, "redraw", MPV_FORMAT_NODE_ARRAY);
|
2017-09-11 16:20:18 +00:00
|
|
|
get_frame_perf(fresh, &data->fresh);
|
|
|
|
get_frame_perf(redraw, &data->redraw);
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
*(struct mpv_node *)arg = node;
|
2017-09-11 16:20:18 +00:00
|
|
|
ret = M_PROPERTY_OK;
|
|
|
|
goto out;
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-08 09:39:31 +00:00
|
|
|
|
2017-09-11 16:20:18 +00:00
|
|
|
ret = M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
out:
|
|
|
|
talloc_free(data);
|
|
|
|
return ret;
|
2016-06-08 09:39:31 +00:00
|
|
|
}
|
|
|
|
|
stats: some more performance graphs
Add an infrastructure for collecting performance-related data, use it in
some places. Add rendering of them to stats.lua.
There were two main goals: minimal impact on the normal code and normal
playback. So all these stats_* function calls either happen only during
initialization, or return immediately if no stats collection is going
on. That's why it does this lazily adding of stats entries etc. (a first
iteration made each stats entry an API thing, instead of just a single
stats_ctx, but I thought that was getting too intrusive in the "normal"
code, even if everything gets worse inside of stats.c).
You could get most of this information from various profilers (including
the extremely primitive --dump-stats thing in mpv), but this makes it
easier to see the most important information at once (at least in
theory), partially because we know best about the context of various
things.
Not very happy with this. It's all pretty primitive and dumb. At this
point I just wanted to get over with it, without necessarily having to
revisit it later, but with having my stupid statistics.
Somehow the code feels terrible. There are a lot of meh decisions in
there that could be better or worse (but mostly could be better), and it
just sucks but it's also trivial and uninteresting and does the job. I
guess I hate programming. It's so tedious and the result is always shit.
Anyway, enjoy.
2020-04-08 22:27:54 +00:00
|
|
|
static int mp_property_perf_info(void *ctx, struct m_property *p, int action,
|
|
|
|
void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
stats_global_query(mpctx->global, (struct mpv_node *)arg);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-02 16:35:31 +00:00
|
|
|
static int mp_property_vo(void *ctx, struct m_property *p, int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_strdup_ro(action, arg,
|
|
|
|
mpctx->video_out ? mpctx->video_out->driver->name : NULL);
|
|
|
|
}
|
|
|
|
|
2020-01-07 23:14:20 +00:00
|
|
|
static int mp_property_osd_dim(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-30 20:25:34 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-03-08 20:54:17 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd);
|
2013-09-30 20:25:34 +00:00
|
|
|
|
2020-01-07 23:14:20 +00:00
|
|
|
if (!mpctx->video_out || !mpctx->video_out->config_ok)
|
|
|
|
vo_res = (struct mp_osd_res){0};
|
2013-09-30 20:25:34 +00:00
|
|
|
|
2020-01-07 23:14:20 +00:00
|
|
|
double aspect = 1.0 * vo_res.w / MPMAX(vo_res.h, 1) /
|
|
|
|
(vo_res.display_par ? vo_res.display_par : 1);
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
2021-04-29 13:53:58 +00:00
|
|
|
{"w", SUB_PROP_INT(vo_res.w)},
|
|
|
|
{"h", SUB_PROP_INT(vo_res.h)},
|
2020-01-07 23:14:20 +00:00
|
|
|
{"par", SUB_PROP_DOUBLE(vo_res.display_par)},
|
|
|
|
{"aspect", SUB_PROP_DOUBLE(aspect)},
|
2021-04-29 13:53:58 +00:00
|
|
|
{"mt", SUB_PROP_INT(vo_res.mt)},
|
|
|
|
{"mb", SUB_PROP_INT(vo_res.mb)},
|
|
|
|
{"ml", SUB_PROP_INT(vo_res.ml)},
|
|
|
|
{"mr", SUB_PROP_INT(vo_res.mr)},
|
2020-01-07 23:14:20 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 22:12:59 +00:00
|
|
|
static int mp_property_osd_sym(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
char temp[20];
|
|
|
|
get_current_osd_sym(mpctx, temp, sizeof(temp));
|
|
|
|
return m_property_strdup_ro(action, arg, temp);
|
|
|
|
}
|
|
|
|
|
2014-09-17 22:49:55 +00:00
|
|
|
static int mp_property_osd_ass(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct m_sub_property props[] = {
|
2016-05-03 20:29:12 +00:00
|
|
|
{"0", SUB_PROP_STR(OSD_ASS_0)},
|
|
|
|
{"1", SUB_PROP_STR(OSD_ASS_1)},
|
2014-09-17 22:49:55 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2019-12-25 18:42:44 +00:00
|
|
|
static int mp_property_mouse_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
struct mpv_node node;
|
2019-12-25 18:52:19 +00:00
|
|
|
int x, y, hover;
|
|
|
|
mp_input_get_mouse_pos(mpctx->input, &x, &y, &hover);
|
2019-12-25 18:42:44 +00:00
|
|
|
|
|
|
|
node_init(&node, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
node_map_add_int64(&node, "x", x);
|
|
|
|
node_map_add_int64(&node, "y", y);
|
2019-12-25 18:52:19 +00:00
|
|
|
node_map_add_flag(&node, "hover", hover);
|
2019-12-25 18:42:44 +00:00
|
|
|
*(struct mpv_node *)arg = node;
|
|
|
|
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Video fps (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_fps(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2018-02-01 08:20:25 +00:00
|
|
|
float fps = mpctx->vo_chain ? mpctx->vo_chain->filter->container_fps : 0;
|
2014-11-28 23:34:53 +00:00
|
|
|
if (fps < 0.1 || !isfinite(fps))
|
|
|
|
return M_PROPERTY_UNAVAILABLE;;
|
|
|
|
return m_property_float_ro(action, arg, fps);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vf_fps(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-05-07 22:49:21 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2016-01-17 17:07:50 +00:00
|
|
|
if (!mpctx->vo_chain)
|
2014-05-07 22:49:21 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
player: refactor display-sync frame duration calculations
Get rid of get_past_frame_durations(), which was a bit too messy. Add
a past_frames array, which contains the same information in a more
reasonable way. This also means that we can get the exact current and
past frame durations without going through awful stuff. (The main
problem is that vo_pts_history contains future frames as well, which is
needed for frame backstepping etc., but gets in the way here.)
Also disable the automatic disabling of display-sync if the frame
duration changes, and extend the frame durations allowed for display
sync. To allow arbitrarily high durations, vo.c needs to be changed
to pause and potentially redraw OSD while showing a single frame, so
they're still limited.
In an attempt to deal with VFR, calculate the overall speed using the
average FPS. The frame scheduling itself does not use the average FPS,
but the duration of the current frame. This does not work too well,
but provides a good base for further improvements.
Where this commit actually helps a lot is dealing with rounded
timestamps, e.g. if the container framerate is wrong or unknown, or
if the muxer wrote incorrectly rounded timestamps. While the rounding
errors apparently can't be get rid of completely in the general case,
this is still much better than e.g. disabling display-sync completely
just because some frame durations go out of bounds.
2015-11-13 21:45:40 +00:00
|
|
|
double avg = calc_average_frame_duration(mpctx);
|
|
|
|
if (avg <= 0)
|
2015-08-10 16:38:57 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
player: refactor display-sync frame duration calculations
Get rid of get_past_frame_durations(), which was a bit too messy. Add
a past_frames array, which contains the same information in a more
reasonable way. This also means that we can get the exact current and
past frame durations without going through awful stuff. (The main
problem is that vo_pts_history contains future frames as well, which is
needed for frame backstepping etc., but gets in the way here.)
Also disable the automatic disabling of display-sync if the frame
duration changes, and extend the frame durations allowed for display
sync. To allow arbitrarily high durations, vo.c needs to be changed
to pause and potentially redraw OSD while showing a single frame, so
they're still limited.
In an attempt to deal with VFR, calculate the overall speed using the
average FPS. The frame scheduling itself does not use the average FPS,
but the duration of the current frame. This does not work too well,
but provides a good base for further improvements.
Where this commit actually helps a lot is dealing with rounded
timestamps, e.g. if the container framerate is wrong or unknown, or
if the muxer wrote incorrectly rounded timestamps. While the rounding
errors apparently can't be get rid of completely in the general case,
this is still much better than e.g. disabling display-sync completely
just because some frame durations go out of bounds.
2015-11-13 21:45:40 +00:00
|
|
|
return m_property_double_ro(action, arg, 1.0 / avg);
|
2014-05-07 22:49:21 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 16:45:37 +00:00
|
|
|
/// Video aspect (RW) (deprecated)
|
|
|
|
// FIXME: please delete this mess as soon as the deprecation period is over
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_aspect(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2019-10-04 16:45:37 +00:00
|
|
|
struct m_config_option *opt;
|
|
|
|
opt = m_config_get_co_raw(mpctx->mconfig, bstr0("video-aspect-override"));
|
|
|
|
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
for (int n = 0; n < cmd->num_warned_deprecated; n++) {
|
|
|
|
if (strcmp(cmd->warned_deprecated[n], prop->name) == 0)
|
|
|
|
goto skip_warn;
|
|
|
|
}
|
|
|
|
|
|
|
|
MP_WARN(mpctx, "Warning: property 'video-aspect' is deprecated, refer to "
|
|
|
|
"'video-params/aspect' and 'video-aspect-override'.\n");
|
|
|
|
MP_TARRAY_APPEND(cmd, cmd->warned_deprecated, cmd->num_warned_deprecated,
|
|
|
|
(char *)prop->name);
|
|
|
|
|
|
|
|
skip_warn: ;
|
2016-02-02 21:12:24 +00:00
|
|
|
|
2020-02-29 23:28:09 +00:00
|
|
|
float aspect = *(float *)opt->data;
|
2016-02-02 21:12:24 +00:00
|
|
|
if (mpctx->vo_chain && aspect <= 0) {
|
video: rewrite filtering glue code
Get rid of the old vf.c code. Replace it with a generic filtering
framework, which can potentially handle more than just --vf. At least
reimplementing --af with this code is planned.
This changes some --vf semantics (including runtime behavior and the
"vf" command). The most important ones are listed in interface-changes.
vf_convert.c is renamed to f_swscale.c. It is now an internal filter
that can not be inserted by the user manually.
f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed
once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is
conceptually easy, but a big mess due to the data flow changes).
The existing filters are all changed heavily. The data flow of the new
filter framework is different. Especially EOF handling changes - EOF is
now a "frame" rather than a state, and must be passed through exactly
once.
Another major thing is that all filters must support dynamic format
changes. The filter reconfig() function goes away. (This sounds complex,
but since all filters need to handle EOF draining anyway, they can use
the same code, and it removes the mess with reconfig() having to predict
the output format, which completely breaks with libavfilter anyway.)
In addition, there is no automatic format negotiation or conversion.
libavfilter's primitive and insufficient API simply doesn't allow us to
do this in a reasonable way. Instead, filters can use f_autoconvert as
sub-filter, and tell it which formats they support. This filter will in
turn add actual conversion filters, such as f_swscale, to perform
necessary format changes.
vf_vapoursynth.c uses the same basic principle of operation as before,
but with worryingly different details in data flow. Still appears to
work.
The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are
heavily changed. Fortunately, they all used refqueue.c, which is for
sharing the data flow logic (especially for managing future/past
surfaces and such). It turns out it can be used to factor out most of
the data flow. Some of these filters accepted software input. Instead of
having ad-hoc upload code in each filter, surface upload is now
delegated to f_autoconvert, which can use f_hwupload to perform this.
Exporting VO capabilities is still a big mess (mp_stream_info stuff).
The D3D11 code drops the redundant image formats, and all code uses the
hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a
big mess for now.
f_async_queue is unused.
2018-01-16 10:53:44 +00:00
|
|
|
struct mp_image_params *params = &mpctx->vo_chain->filter->input_params;
|
2016-02-02 21:12:24 +00:00
|
|
|
if (params && params->p_w > 0 && params->p_h > 0) {
|
|
|
|
int d_w, d_h;
|
|
|
|
mp_image_params_get_dsize(params, &d_w, &d_h);
|
|
|
|
aspect = (float)d_w / d_h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
if (track && track->stream && aspect <= 0) {
|
|
|
|
struct mp_codec_params *c = track->stream->codec;
|
2016-02-02 21:12:24 +00:00
|
|
|
if (c->disp_w && c->disp_h)
|
|
|
|
aspect = (float)c->disp_w / c->disp_h;
|
|
|
|
}
|
|
|
|
|
2012-09-22 03:13:29 +00:00
|
|
|
switch (action) {
|
2019-10-04 16:45:37 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = *(opt->opt);
|
|
|
|
return M_PROPERTY_OK;
|
2016-01-16 22:23:44 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
2020-02-29 23:28:09 +00:00
|
|
|
if (aspect < 0) {
|
2016-02-02 21:12:24 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.3f (original)", aspect);
|
2016-01-16 22:23:44 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-09-26 14:53:17 +00:00
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
*(float *)arg = aspect;
|
2012-09-22 03:13:29 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2019-11-10 22:53:57 +00:00
|
|
|
case M_PROPERTY_SET:
|
2019-11-25 19:25:20 +00:00
|
|
|
if (m_config_set_option_raw(mpctx->mconfig, opt, arg, 0) < 0)
|
2019-10-04 16:45:37 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2023-08-11 10:13:14 +00:00
|
|
|
#define doubles_equal(x, y) (fabs((x) - (y)) <= 0.001)
|
2019-12-21 13:25:47 +00:00
|
|
|
|
|
|
|
static int mp_property_video_aspect_override(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2023-08-11 10:13:14 +00:00
|
|
|
double aspect_ratio;
|
2019-12-21 13:25:47 +00:00
|
|
|
mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &aspect_ratio);
|
|
|
|
|
2023-08-11 10:13:14 +00:00
|
|
|
if (doubles_equal(aspect_ratio, 2.35 / 1.0))
|
2019-12-21 13:25:47 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "2.35:1");
|
2023-08-11 10:13:14 +00:00
|
|
|
else if (doubles_equal(aspect_ratio, 16.0 / 9.0))
|
2019-12-21 13:25:47 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "16:9");
|
2023-08-11 10:13:14 +00:00
|
|
|
else if (doubles_equal(aspect_ratio, 16.0 / 10.0))
|
2019-12-21 13:25:47 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "16:10");
|
2023-08-11 10:13:14 +00:00
|
|
|
else if (doubles_equal(aspect_ratio, 4.0 / 3.0))
|
2019-12-21 13:25:47 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "4:3");
|
2023-08-11 10:13:14 +00:00
|
|
|
else if (doubles_equal(aspect_ratio, -1.0))
|
2019-12-21 13:25:47 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "Original");
|
|
|
|
else
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.3f", aspect_ratio);
|
|
|
|
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Subtitle delay (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_sub_delay(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2012-09-18 13:31:46 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_PRINT:
|
2017-12-29 16:19:25 +00:00
|
|
|
*(char **)arg = format_delay(opts->subs_rend->sub_delay);
|
2012-09-18 13:31:46 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2016-09-19 18:16:44 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2016-09-13 01:17:10 +00:00
|
|
|
/// Subtitle speed (RW)
|
|
|
|
static int mp_property_sub_speed(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2017-04-10 19:22:26 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2017-12-29 16:19:25 +00:00
|
|
|
*(char **)arg =
|
|
|
|
talloc_asprintf(NULL, "%4.1f%%", 100 * opts->subs_rend->sub_speed);
|
2016-09-13 01:17:40 +00:00
|
|
|
return M_PROPERTY_OK;
|
2016-09-13 01:17:10 +00:00
|
|
|
}
|
2016-09-19 18:16:44 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2016-09-13 01:17:10 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_sub_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-09-25 01:24:38 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2012-09-25 01:24:38 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2023-08-10 20:51:44 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%4.2f%%/100", opts->subs_rend->sub_pos);
|
2012-09-25 01:24:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2016-09-19 18:16:44 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
|
|
|
|
2021-05-09 17:05:13 +00:00
|
|
|
static int get_sub_text(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg, int sub_index)
|
2016-08-27 19:14:41 +00:00
|
|
|
{
|
2020-05-14 20:14:49 +00:00
|
|
|
int type = *(int *)prop->priv;
|
2016-08-27 19:14:41 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2021-05-09 17:05:13 +00:00
|
|
|
struct track *track = mpctx->current_track[sub_index][STREAM_SUB];
|
2016-08-27 19:14:41 +00:00
|
|
|
struct dec_sub *sub = track ? track->d_sub : NULL;
|
|
|
|
double pts = mpctx->playback_pts;
|
|
|
|
if (!sub || pts == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2020-05-14 20:14:49 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char *text = sub_get_text(sub, pts, type);
|
|
|
|
if (!text)
|
|
|
|
text = talloc_strdup(NULL, "");
|
|
|
|
*(char **)arg = text;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2016-08-27 19:14:41 +00:00
|
|
|
}
|
|
|
|
|
2021-05-09 17:05:13 +00:00
|
|
|
static int mp_property_sub_text(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return get_sub_text(ctx, prop, action, arg, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_secondary_sub_text(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return get_sub_text(ctx, prop, action, arg, 1);
|
|
|
|
}
|
|
|
|
|
2019-09-21 18:11:18 +00:00
|
|
|
static struct sd_times get_times(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct sd_times res = { .start = MP_NOPTS_VALUE, .end = MP_NOPTS_VALUE };
|
|
|
|
MPContext *mpctx = ctx;
|
2021-07-12 18:29:59 +00:00
|
|
|
int track_ind = *(int *)prop->priv;
|
|
|
|
struct track *track = mpctx->current_track[track_ind][STREAM_SUB];
|
2019-09-21 18:11:18 +00:00
|
|
|
struct dec_sub *sub = track ? track->d_sub : NULL;
|
|
|
|
double pts = mpctx->playback_pts;
|
|
|
|
if (!sub || pts == MP_NOPTS_VALUE)
|
|
|
|
return res;
|
|
|
|
return sub_get_times(sub, pts);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_sub_start(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
double start = get_times(ctx, prop, action, arg).start;
|
|
|
|
if (start == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_double_ro(action, arg, start);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mp_property_sub_end(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
double end = get_times(ctx, prop, action, arg).end;
|
|
|
|
if (end == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_double_ro(action, arg, end);
|
|
|
|
}
|
|
|
|
|
2021-06-25 07:36:05 +00:00
|
|
|
static int mp_property_sub_forced_only_cur(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
int ret = mpctx->opts->subs_rend->forced_subs_only;
|
|
|
|
if (ret == -1) {
|
|
|
|
struct track *track = mpctx->current_track[0][STREAM_SUB];
|
|
|
|
ret = track && track->forced_only_def;
|
|
|
|
}
|
|
|
|
return m_property_bool_ro(action, arg, ret);
|
|
|
|
}
|
|
|
|
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
static int mp_property_playlist_current_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct playlist *pl = mpctx->playlist;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
*(int *)arg = playlist_entry_to_index(pl, pl->current);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
pl->current = playlist_entry_from_index(pl, *(int *)arg);
|
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_INT};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mp_property_playlist_playing_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct playlist *pl = mpctx->playlist;
|
|
|
|
return m_property_int_ro(action, arg,
|
|
|
|
playlist_entry_to_index(pl, mpctx->playing));
|
|
|
|
}
|
|
|
|
|
2016-05-26 16:43:49 +00:00
|
|
|
static int mp_property_playlist_pos_x(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg, int base)
|
2013-06-28 20:16:29 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-06-28 20:16:29 +00:00
|
|
|
struct playlist *pl = mpctx->playlist;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
int pos = playlist_entry_to_index(pl, pl->current);
|
2020-03-21 13:44:09 +00:00
|
|
|
*(int *)arg = pos < 0 ? -1 : pos + base;
|
2013-06-28 20:16:29 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET: {
|
2016-05-26 16:43:49 +00:00
|
|
|
int pos = *(int *)arg - base;
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
if (pos >= 0 && playlist_entry_to_index(pl, pl->current) == pos) {
|
|
|
|
MP_WARN(mpctx, "Behavior of %s when writing the same value will "
|
|
|
|
"change (currently restarts, it will stop doing this).\n",
|
|
|
|
prop->name);
|
|
|
|
}
|
2020-03-21 13:44:09 +00:00
|
|
|
mp_set_playlist_entry(mpctx, playlist_entry_from_index(pl, pos));
|
2013-06-28 20:16:29 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2020-03-21 13:44:09 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_INT};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_CONSTRICTED_TYPE: {
|
2013-06-28 20:16:29 +00:00
|
|
|
struct m_option opt = {
|
|
|
|
.type = CONF_TYPE_INT,
|
2016-05-26 16:43:49 +00:00
|
|
|
.min = base,
|
|
|
|
.max = playlist_entry_count(pl) - 1 + base,
|
2013-06-28 20:16:29 +00:00
|
|
|
};
|
|
|
|
*(struct m_option *)arg = opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2016-05-26 16:43:49 +00:00
|
|
|
static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return mp_property_playlist_pos_x(ctx, prop, action, arg, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_playlist_pos_1(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return mp_property_playlist_pos_x(ctx, prop, action, arg, 1);
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:54:55 +00:00
|
|
|
static int get_playlist_entry(int item, int action, void *arg, void *ctx)
|
2013-06-28 20:16:29 +00:00
|
|
|
{
|
2019-12-28 20:12:02 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
|
|
|
|
struct playlist_entry *e = playlist_entry_from_index(mpctx->playlist, item);
|
2014-02-15 15:54:55 +00:00
|
|
|
if (!e)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
|
2014-11-17 21:43:30 +00:00
|
|
|
bool current = mpctx->playlist->current == e;
|
|
|
|
bool playing = mpctx->playing == e;
|
2014-02-15 15:54:55 +00:00
|
|
|
struct m_sub_property props[] = {
|
2023-08-11 04:27:28 +00:00
|
|
|
{"filename", SUB_PROP_STR(e->filename)},
|
|
|
|
{"current", SUB_PROP_BOOL(1), .unavailable = !current},
|
|
|
|
{"playing", SUB_PROP_BOOL(1), .unavailable = !playing},
|
|
|
|
{"title", SUB_PROP_STR(e->title), .unavailable = !e->title},
|
|
|
|
{"id", SUB_PROP_INT64(e->id)},
|
|
|
|
{"playlist-path", SUB_PROP_STR(e->playlist_path), .unavailable = !e->playlist_path},
|
2014-02-15 15:54:55 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
2013-06-28 20:16:29 +00:00
|
|
|
}
|
|
|
|
|
2023-08-11 04:27:28 +00:00
|
|
|
static int mp_property_playlist_path(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->playlist->current)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
struct playlist_entry *e = mpctx->playlist->current;
|
|
|
|
return m_property_strdup_ro(action, arg, e->playlist_path);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playlist(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:54:55 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2017-01-26 17:24:53 +00:00
|
|
|
struct playlist *pl = mpctx->playlist;
|
2013-05-15 00:17:47 +00:00
|
|
|
char *res = talloc_strdup(NULL, "");
|
|
|
|
|
2019-12-28 20:12:02 +00:00
|
|
|
for (int n = 0; n < pl->num_entries; n++) {
|
|
|
|
struct playlist_entry *e = pl->entries[n];
|
2019-01-04 11:24:12 +00:00
|
|
|
char *p = e->title;
|
|
|
|
if (!p) {
|
|
|
|
p = e->filename;
|
|
|
|
if (!mp_is_url(bstr0(p))) {
|
|
|
|
char *s = mp_basename(e->filename);
|
|
|
|
if (s[0])
|
|
|
|
p = s;
|
|
|
|
}
|
2014-12-27 20:19:52 +00:00
|
|
|
}
|
2017-01-26 17:24:53 +00:00
|
|
|
const char *m = pl->current == e ? list_current : list_normal;
|
2016-05-03 20:41:53 +00:00
|
|
|
res = talloc_asprintf_append(res, "%s%s\n", m, p);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 17:24:53 +00:00
|
|
|
*(char **)arg =
|
|
|
|
cut_osd_list(mpctx, res, playlist_entry_to_index(pl, pl->current));
|
2013-05-15 00:17:47 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2016-08-19 13:13:54 +00:00
|
|
|
|
2014-02-15 15:54:55 +00:00
|
|
|
return m_property_read_list(action, arg, playlist_entry_count(mpctx->playlist),
|
2019-12-28 20:12:02 +00:00
|
|
|
get_playlist_entry, mpctx);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 11:41:38 +00:00
|
|
|
static char *print_obj_osd_list(struct m_obj_settings *list)
|
|
|
|
{
|
|
|
|
char *res = NULL;
|
|
|
|
for (int n = 0; list && list[n].name; n++) {
|
|
|
|
res = talloc_asprintf_append(res, "%s [", list[n].name);
|
|
|
|
for (int i = 0; list[n].attribs && list[n].attribs[i]; i += 2) {
|
|
|
|
res = talloc_asprintf_append(res, "%s%s=%s", i > 0 ? " " : "",
|
|
|
|
list[n].attribs[i],
|
|
|
|
list[n].attribs[i + 1]);
|
|
|
|
}
|
2017-03-25 16:07:40 +00:00
|
|
|
res = talloc_asprintf_append(res, "]");
|
|
|
|
if (!list[n].enabled)
|
|
|
|
res = talloc_strdup_append(res, " (disabled)");
|
|
|
|
res = talloc_strdup_append(res, "\n");
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
if (!res)
|
|
|
|
res = talloc_strdup(NULL, "(empty)");
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_filter(struct m_property *prop, int action, void *arg,
|
2013-08-03 11:41:38 +00:00
|
|
|
MPContext *mpctx, enum stream_type mt)
|
|
|
|
{
|
2019-11-25 00:16:03 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-08-03 11:41:38 +00:00
|
|
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
|
|
|
bstr0(prop->name));
|
|
|
|
*(char **)arg = print_obj_osd_list(*(struct m_obj_settings **)opt->data);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vf(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-08-03 11:41:38 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_filter(prop, action, arg, ctx, STREAM_VIDEO);
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_af(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-08-03 11:41:38 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_filter(prop, action, arg, ctx, STREAM_AUDIO);
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
static int mp_property_ab_loop(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
2014-11-18 19:28:54 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
2014-11-17 23:09:42 +00:00
|
|
|
if (action == M_PROPERTY_KEY_ACTION) {
|
|
|
|
double val;
|
|
|
|
if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &val) < 1)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
|
|
|
|
return property_time(action, arg, val);
|
|
|
|
}
|
2019-11-24 23:26:36 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2014-11-17 23:09:42 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 00:00:58 +00:00
|
|
|
static int mp_property_packet_bitrate(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-04-20 18:52:16 +00:00
|
|
|
int type = (uintptr_t)prop->priv & ~0x100;
|
|
|
|
bool old = (uintptr_t)prop->priv & 0x100;
|
2014-12-12 00:00:58 +00:00
|
|
|
|
2015-10-23 12:58:01 +00:00
|
|
|
struct demuxer *demuxer = NULL;
|
|
|
|
if (mpctx->current_track[0][type])
|
|
|
|
demuxer = mpctx->current_track[0][type]->demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
2014-12-12 00:00:58 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
double r[STREAM_TYPE_COUNT];
|
2018-09-07 20:26:48 +00:00
|
|
|
demux_get_bitrate_stats(demuxer, r);
|
2015-10-23 12:53:19 +00:00
|
|
|
if (r[type] < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-12-12 00:00:58 +00:00
|
|
|
|
2015-04-20 18:52:16 +00:00
|
|
|
// r[type] is in bytes/second -> bits
|
|
|
|
double rate = r[type] * 8;
|
|
|
|
|
|
|
|
// Same story, but used kilobits for some reason.
|
|
|
|
if (old)
|
2019-01-19 21:51:38 +00:00
|
|
|
return m_property_int64_ro(action, arg, llrint(rate / 1000.0));
|
2015-04-20 18:52:16 +00:00
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
rate /= 1000;
|
|
|
|
if (rate < 1000) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d kbps", (int)rate);
|
|
|
|
} else {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.3f mbps", rate / 1000.0);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2019-01-19 21:51:38 +00:00
|
|
|
return m_property_int64_ro(action, arg, llrint(rate));
|
2014-12-12 00:00:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 21:00:01 +00:00
|
|
|
static int mp_property_cwd(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char *cwd = mp_getcwd(NULL);
|
|
|
|
if (!cwd)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
*(char **)arg = cwd;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:26:55 +00:00
|
|
|
static int mp_property_protocols(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char ***)arg = stream_get_proto_list();
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2020-05-14 20:22:33 +00:00
|
|
|
static int mp_property_keylist(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char ***)arg = mp_get_key_list();
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2016-02-29 19:57:31 +00:00
|
|
|
static int get_decoder_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct mp_decoder_list *codecs = ctx;
|
|
|
|
struct mp_decoder_entry *c = &codecs->entries[item];
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"codec", SUB_PROP_STR(c->codec)},
|
2016-03-01 20:46:49 +00:00
|
|
|
{"driver" , SUB_PROP_STR(c->decoder)},
|
2016-02-29 19:57:31 +00:00
|
|
|
{"description", SUB_PROP_STR(c->desc)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_decoders(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct mp_decoder_list *codecs = talloc_zero(NULL, struct mp_decoder_list);
|
|
|
|
struct mp_decoder_list *v = talloc_steal(codecs, video_decoder_list());
|
|
|
|
struct mp_decoder_list *a = talloc_steal(codecs, audio_decoder_list());
|
|
|
|
mp_append_decoders(codecs, v);
|
|
|
|
mp_append_decoders(codecs, a);
|
|
|
|
int r = m_property_read_list(action, arg, codecs->num_entries,
|
|
|
|
get_decoder_entry, codecs);
|
|
|
|
talloc_free(codecs);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2016-03-01 20:46:49 +00:00
|
|
|
static int mp_property_encoders(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct mp_decoder_list *codecs = talloc_zero(NULL, struct mp_decoder_list);
|
|
|
|
mp_add_lavc_encoders(codecs);
|
|
|
|
int r = m_property_read_list(action, arg, codecs->num_entries,
|
|
|
|
get_decoder_entry, codecs);
|
|
|
|
talloc_free(codecs);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-01-02 20:46:58 +00:00
|
|
|
static int mp_property_lavf_demuxers(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char ***)arg = mp_get_lavf_demuxers();
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-11-02 16:44:24 +00:00
|
|
|
static int mp_property_version(void *ctx, struct m_property *prop,
|
2014-11-17 23:09:42 +00:00
|
|
|
int action, void *arg)
|
2014-11-02 16:44:24 +00:00
|
|
|
{
|
|
|
|
return m_property_strdup_ro(action, arg, mpv_version);
|
|
|
|
}
|
|
|
|
|
2014-11-13 15:18:40 +00:00
|
|
|
static int mp_property_configuration(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return m_property_strdup_ro(action, arg, CONFIGURATION);
|
|
|
|
}
|
|
|
|
|
2016-02-29 19:59:20 +00:00
|
|
|
static int mp_property_ffmpeg(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return m_property_strdup_ro(action, arg, av_version_info());
|
|
|
|
}
|
|
|
|
|
2020-03-08 18:08:41 +00:00
|
|
|
static int mp_property_libass_version(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return m_property_int64_ro(action, arg, ass_library_version());
|
|
|
|
}
|
|
|
|
|
2022-01-23 05:06:26 +00:00
|
|
|
static int mp_property_platform(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return m_property_strdup_ro(action, arg, PLATFORM);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_alias(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-04-14 22:22:51 +00:00
|
|
|
{
|
|
|
|
const char *real_property = prop->priv;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_do(real_property, action, arg, ctx);
|
2013-04-14 22:22:51 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 18:01:12 +00:00
|
|
|
static int mp_property_deprecated_alias(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
const char *real_property = prop->priv;
|
2016-11-23 16:30:46 +00:00
|
|
|
for (int n = 0; n < cmd->num_warned_deprecated; n++) {
|
|
|
|
if (strcmp(cmd->warned_deprecated[n], prop->name) == 0)
|
|
|
|
goto done;
|
2015-05-22 18:01:12 +00:00
|
|
|
}
|
2016-11-23 16:30:46 +00:00
|
|
|
MP_WARN(mpctx, "Warning: property '%s' was replaced with '%s' and "
|
|
|
|
"might be removed in the future.\n", prop->name, real_property);
|
|
|
|
MP_TARRAY_APPEND(cmd, cmd->warned_deprecated, cmd->num_warned_deprecated,
|
|
|
|
(char *)prop->name);
|
|
|
|
|
|
|
|
done:
|
2015-05-22 18:01:12 +00:00
|
|
|
return mp_property_do(real_property, action, arg, ctx);
|
|
|
|
}
|
|
|
|
|
2014-10-15 20:39:33 +00:00
|
|
|
static int access_options(struct m_property_action_arg *ka, bool local,
|
|
|
|
MPContext *mpctx)
|
2013-07-25 21:36:01 +00:00
|
|
|
{
|
|
|
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
|
|
|
bstr0(ka->key));
|
|
|
|
if (!opt)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
2013-07-27 19:24:44 +00:00
|
|
|
if (!opt->data)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-07-25 21:36:01 +00:00
|
|
|
|
|
|
|
switch (ka->action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
m_option_copy(opt->opt, ka->arg, opt->data);
|
|
|
|
return M_PROPERTY_OK;
|
2014-05-18 16:57:02 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2014-10-15 20:39:33 +00:00
|
|
|
if (local && !mpctx->playing)
|
|
|
|
return M_PROPERTY_ERROR;
|
2019-11-10 22:53:57 +00:00
|
|
|
int flags = local ? M_SETOPT_BACKUP : 0;
|
2014-10-15 20:39:33 +00:00
|
|
|
int r = m_config_set_option_raw(mpctx->mconfig, opt, ka->arg, flags);
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2014-05-18 16:57:02 +00:00
|
|
|
return r < 0 ? M_PROPERTY_ERROR : M_PROPERTY_OK;
|
|
|
|
}
|
2013-07-25 21:36:01 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)ka->arg = *opt->opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-02-24 20:18:53 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
2013-07-25 21:36:01 +00:00
|
|
|
|
2014-10-15 20:39:33 +00:00
|
|
|
static int access_option_list(int action, void *arg, bool local, MPContext *mpctx)
|
2014-02-24 20:18:53 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char ***)arg = m_config_list_options(NULL, mpctx->mconfig);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_KEY_ACTION:
|
2014-10-15 20:39:33 +00:00
|
|
|
return access_options(arg, local, mpctx);
|
2014-02-24 20:18:53 +00:00
|
|
|
}
|
2013-07-25 21:36:01 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-10-15 20:39:33 +00:00
|
|
|
|
|
|
|
static int mp_property_options(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return access_option_list(action, arg, false, mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_local_options(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return access_option_list(action, arg, true, mpctx);
|
|
|
|
}
|
|
|
|
|
2014-11-13 16:27:31 +00:00
|
|
|
static int mp_property_option_info(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-11-07 15:33:41 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
|
|
|
struct m_config_option *co = m_config_get_co(mpctx->mconfig, key);
|
|
|
|
if (!co)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
2018-05-21 11:45:06 +00:00
|
|
|
const struct m_option *opt = co->opt;
|
2014-11-07 15:33:41 +00:00
|
|
|
|
2014-11-13 17:00:07 +00:00
|
|
|
union m_option_value def = {0};
|
2018-05-21 11:45:06 +00:00
|
|
|
const void *def_ptr = m_config_get_co_default(mpctx->mconfig, co);
|
|
|
|
if (def_ptr && opt->type->size > 0)
|
|
|
|
memcpy(&def, def_ptr, opt->type->size);
|
2014-11-13 17:00:07 +00:00
|
|
|
|
2020-03-13 15:49:39 +00:00
|
|
|
bool has_minmax = opt->min < opt->max &&
|
|
|
|
(opt->type->flags & M_OPT_TYPE_USES_RANGE);
|
2014-11-13 17:00:07 +00:00
|
|
|
char **choices = NULL;
|
|
|
|
|
|
|
|
if (opt->type == &m_option_type_choice) {
|
2021-10-03 17:31:45 +00:00
|
|
|
const struct m_opt_choice_alternatives *alt = opt->priv;
|
2014-11-13 17:00:07 +00:00
|
|
|
int num = 0;
|
|
|
|
for ( ; alt->name; alt++)
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, alt->name);
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, NULL);
|
2014-11-14 13:52:51 +00:00
|
|
|
}
|
|
|
|
if (opt->type == &m_option_type_obj_settings_list) {
|
2021-10-03 17:31:42 +00:00
|
|
|
const struct m_obj_list *objs = opt->priv;
|
2014-11-14 13:52:51 +00:00
|
|
|
int num = 0;
|
|
|
|
for (int n = 0; ; n++) {
|
|
|
|
struct m_obj_desc desc = {0};
|
|
|
|
if (!objs->get_desc(&desc, n))
|
|
|
|
break;
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, (char *)desc.name);
|
|
|
|
}
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, NULL);
|
2014-11-13 17:00:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-07 15:33:41 +00:00
|
|
|
struct m_sub_property props[] = {
|
2014-11-13 17:00:07 +00:00
|
|
|
{"name", SUB_PROP_STR(co->name)},
|
|
|
|
{"type", SUB_PROP_STR(opt->type->name)},
|
2023-02-20 05:53:09 +00:00
|
|
|
{"set-from-commandline", SUB_PROP_BOOL(co->is_set_from_cmdline)},
|
|
|
|
{"set-locally", SUB_PROP_BOOL(co->is_set_locally)},
|
2014-11-13 17:00:07 +00:00
|
|
|
{"default-value", *opt, def},
|
|
|
|
{"min", SUB_PROP_DOUBLE(opt->min),
|
2020-03-13 15:49:39 +00:00
|
|
|
.unavailable = !(has_minmax && opt->min != DBL_MIN)},
|
2014-11-13 17:00:07 +00:00
|
|
|
{"max", SUB_PROP_DOUBLE(opt->max),
|
2020-03-13 15:49:39 +00:00
|
|
|
.unavailable = !(has_minmax && opt->max != DBL_MAX)},
|
2014-11-13 17:00:07 +00:00
|
|
|
{"choices", .type = {.type = CONF_TYPE_STRING_LIST},
|
|
|
|
.value = {.string_list = choices}, .unavailable = !choices},
|
2014-11-07 15:33:41 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2014-11-08 09:19:17 +00:00
|
|
|
struct m_property_action_arg next_ka = *ka;
|
|
|
|
next_ka.key = rem;
|
2014-11-13 17:00:07 +00:00
|
|
|
int r = m_property_read_sub(props, M_PROPERTY_KEY_ACTION, &next_ka);
|
|
|
|
talloc_free(choices);
|
|
|
|
return r;
|
2014-11-07 15:33:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-08-01 23:35:32 +00:00
|
|
|
static int mp_property_list(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
2016-09-01 18:00:43 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
|
2014-08-01 23:35:32 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char **list = NULL;
|
|
|
|
int num = 0;
|
2016-09-01 18:00:43 +00:00
|
|
|
for (int n = 0; cmd->properties[n].name; n++) {
|
2014-08-01 23:35:32 +00:00
|
|
|
MP_TARRAY_APPEND(NULL, list, num,
|
2016-09-01 18:00:43 +00:00
|
|
|
talloc_strdup(NULL, cmd->properties[n].name));
|
2014-08-01 23:35:32 +00:00
|
|
|
}
|
|
|
|
MP_TARRAY_APPEND(NULL, list, num, NULL);
|
|
|
|
*(char ***)arg = list;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2016-08-28 17:42:03 +00:00
|
|
|
static int mp_profile_list(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
*(struct mpv_node *)arg = m_config_get_profiles(mpctx->mconfig);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2019-11-22 21:52:31 +00:00
|
|
|
static int mp_property_commands(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
struct mpv_node *root = arg;
|
|
|
|
node_init(root, MPV_FORMAT_NODE_ARRAY, NULL);
|
|
|
|
|
|
|
|
for (int n = 0; mp_cmds[n].name; n++) {
|
|
|
|
const struct mp_cmd_def *cmd = &mp_cmds[n];
|
|
|
|
struct mpv_node *entry = node_array_add(root, MPV_FORMAT_NODE_MAP);
|
|
|
|
|
|
|
|
node_map_add_string(entry, "name", cmd->name);
|
2019-12-24 15:03:16 +00:00
|
|
|
|
|
|
|
struct mpv_node *args =
|
|
|
|
node_map_add(entry, "args", MPV_FORMAT_NODE_ARRAY);
|
|
|
|
for (int i = 0; i < MP_CMD_DEF_MAX_ARGS; i++) {
|
|
|
|
const struct m_option *a = &cmd->args[i];
|
|
|
|
if (!a->type)
|
|
|
|
break;
|
|
|
|
struct mpv_node *ae = node_array_add(args, MPV_FORMAT_NODE_MAP);
|
|
|
|
node_map_add_string(ae, "name", a->name);
|
|
|
|
node_map_add_string(ae, "type", a->type->name);
|
|
|
|
node_map_add_flag(ae, "optional", a->flags & MP_CMD_OPT_ARG);
|
|
|
|
}
|
|
|
|
|
|
|
|
node_map_add_flag(entry, "vararg", cmd->vararg);
|
2019-11-22 21:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2019-11-22 23:39:07 +00:00
|
|
|
static int mp_property_bindings(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
*(struct mpv_node *)arg = mp_input_get_bindings(mpctx->input);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2019-12-18 07:58:49 +00:00
|
|
|
|
|
|
|
static int mp_property_script_props(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = script_props_type;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
m_option_copy(&script_props_type, arg, &cmd->script_props);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
m_option_copy(&script_props_type, &cmd->script_props, arg);
|
|
|
|
mp_notify_property(mpctx, prop->name);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2022-12-16 01:20:43 +00:00
|
|
|
static int do_list_udata(int item, int action, void *arg, void *ctx);
|
|
|
|
|
|
|
|
struct udata_ctx {
|
|
|
|
MPContext *mpctx;
|
|
|
|
const char *path;
|
|
|
|
mpv_node *node;
|
2023-03-10 23:07:00 +00:00
|
|
|
void *ta_parent;
|
2022-12-16 01:20:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int do_op_udata(struct udata_ctx* ctx, int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx->mpctx;
|
|
|
|
mpv_node *node = ctx->node;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = udata_type;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
case M_PROPERTY_GET_NODE: // same as GET, because type==mpv_node
|
|
|
|
assert(node);
|
|
|
|
m_option_copy(&udata_type, arg, node);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
char *str = m_option_pretty_print(&udata_type, node);
|
|
|
|
*(char **)arg = str;
|
|
|
|
return str != NULL;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
case M_PROPERTY_SET_NODE:
|
|
|
|
assert(node);
|
|
|
|
m_option_copy(&udata_type, node, arg);
|
2023-03-10 23:07:00 +00:00
|
|
|
talloc_steal(ctx->ta_parent, node_get_alloc(node));
|
2022-12-16 01:20:43 +00:00
|
|
|
mp_notify_property(mpctx, ctx->path);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
assert(node);
|
|
|
|
|
|
|
|
// If we're operating on an array, sub-object access is handled by m_property_read_list
|
|
|
|
if (node->format == MPV_FORMAT_NODE_ARRAY)
|
|
|
|
return m_property_read_list(action, arg, node->u.list->num, &do_list_udata, ctx);
|
|
|
|
|
|
|
|
// Sub-objects only make sense for arrays and maps
|
|
|
|
if (node->format != MPV_FORMAT_NODE_MAP)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
struct m_property_action_arg *act = arg;
|
|
|
|
|
|
|
|
// See if the next layer down will also be a sub-object access
|
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
bool has_split = m_property_split_path(act->key, &key, &rem);
|
|
|
|
|
|
|
|
if (!has_split && act->action == M_PROPERTY_DELETE) {
|
|
|
|
// Find the object we're looking for
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < node->u.list->num; i++) {
|
|
|
|
if (bstr_equals0(key, node->u.list->keys[i]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return if it didn't exist
|
|
|
|
if (i == node->u.list->num)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
|
|
|
// Delete the item
|
|
|
|
m_option_free(&udata_type, &node->u.list->values[i]);
|
|
|
|
talloc_free(node->u.list->keys[i]);
|
|
|
|
|
|
|
|
// Shift the remaining items back
|
|
|
|
for (i++; i < node->u.list->num; i++) {
|
|
|
|
node->u.list->values[i - 1] = node->u.list->values[i];
|
|
|
|
node->u.list->keys[i - 1] = node->u.list->keys[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// And decrement the count
|
|
|
|
node->u.list->num--;
|
|
|
|
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Look up the next level down
|
|
|
|
mpv_node *cnode = node_map_bget(node, key);
|
|
|
|
|
|
|
|
if (!cnode) {
|
|
|
|
switch (act->action) {
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
case M_PROPERTY_SET_NODE: {
|
|
|
|
// If we're doing a set, and the key doesn't exist, create it.
|
|
|
|
// If we're recursing another layer down, make it an empty map;
|
|
|
|
// otherwise, make it NONE, since we'll be overwriting it at the next level.
|
|
|
|
cnode = node_map_badd(node, key, has_split ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NONE);
|
|
|
|
if (!cnode)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
break;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
// Nonexistent keys have type NODE, so they can be overwritten
|
|
|
|
*(struct m_option *)act->arg = udata_type;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
default:
|
|
|
|
// We can't perform any other options on nonexistent keys
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct udata_ctx nctx = *ctx;
|
|
|
|
nctx.node = cnode;
|
2023-03-10 23:07:00 +00:00
|
|
|
nctx.ta_parent = node_get_alloc(node);
|
2022-12-16 01:20:43 +00:00
|
|
|
|
|
|
|
// If we're going down another level, set up a new key-action.
|
|
|
|
if (has_split) {
|
|
|
|
struct m_property_action_arg sub_act = {
|
|
|
|
.key = rem,
|
|
|
|
.action = act->action,
|
|
|
|
.arg = act->arg,
|
|
|
|
};
|
|
|
|
|
|
|
|
return do_op_udata(&nctx, M_PROPERTY_KEY_ACTION, &sub_act);
|
|
|
|
} else {
|
|
|
|
return do_op_udata(&nctx, act->action, act->arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_list_udata(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct udata_ctx nctx = *(struct udata_ctx*)ctx;
|
|
|
|
nctx.node = &nctx.node->u.list->values[item];
|
2023-03-10 23:07:00 +00:00
|
|
|
nctx.ta_parent = &nctx.node->u.list;
|
2022-12-16 01:20:43 +00:00
|
|
|
|
|
|
|
return do_op_udata(&nctx, action, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_udata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
// The root of udata is a shared map; don't allow overwriting
|
|
|
|
// or deleting the whole thing
|
|
|
|
if (action == M_PROPERTY_SET || action == M_PROPERTY_SET_NODE ||
|
|
|
|
action == M_PROPERTY_DELETE)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
char *path = NULL;
|
|
|
|
if (action == M_PROPERTY_KEY_ACTION) {
|
|
|
|
struct m_property_action_arg *act = arg;
|
|
|
|
if (act->action == M_PROPERTY_SET || act->action == M_PROPERTY_SET_NODE)
|
|
|
|
path = talloc_asprintf(NULL, "%s/%s", prop->name, act->key);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct udata_ctx nctx = {
|
|
|
|
.mpctx = mpctx,
|
|
|
|
.path = path,
|
|
|
|
.node = &mpctx->command_ctx->udata,
|
2023-03-10 23:07:00 +00:00
|
|
|
.ta_parent = &mpctx->command_ctx,
|
2022-12-16 01:20:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int ret = do_op_udata(&nctx, action, arg);
|
|
|
|
|
|
|
|
talloc_free(path);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-14 22:22:51 +00:00
|
|
|
// Redirect a property name to another
|
|
|
|
#define M_PROPERTY_ALIAS(name, real_property) \
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{(name), mp_property_alias, .priv = (real_property)}
|
2014-02-15 15:42:48 +00:00
|
|
|
|
2015-05-22 18:01:12 +00:00
|
|
|
#define M_PROPERTY_DEPRECATED_ALIAS(name, real_property) \
|
|
|
|
{(name), mp_property_deprecated_alias, .priv = (real_property)}
|
|
|
|
|
2016-09-01 18:00:43 +00:00
|
|
|
// Base list of properties. This does not include option-mapped properties.
|
|
|
|
static const struct m_property mp_properties_base[] = {
|
2007-02-21 00:49:24 +00:00
|
|
|
// General
|
2021-05-01 12:26:50 +00:00
|
|
|
{"pid", mp_property_pid},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"speed", mp_property_playback_speed},
|
2015-08-10 16:40:16 +00:00
|
|
|
{"audio-speed-correction", mp_property_av_speed_correction, .priv = "a"},
|
|
|
|
{"video-speed-correction", mp_property_av_speed_correction, .priv = "v"},
|
2015-08-10 16:43:25 +00:00
|
|
|
{"display-sync-active", mp_property_display_sync_active},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"filename", mp_property_filename},
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
{"stream-open-filename", mp_property_stream_open_filename},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"file-size", mp_property_file_size},
|
|
|
|
{"path", mp_property_path},
|
|
|
|
{"media-title", mp_property_media_title},
|
|
|
|
{"stream-path", mp_property_stream_path},
|
2016-09-01 18:01:02 +00:00
|
|
|
{"current-demuxer", mp_property_demuxer},
|
2015-01-23 14:59:06 +00:00
|
|
|
{"file-format", mp_property_file_format},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"stream-pos", mp_property_stream_pos},
|
|
|
|
{"stream-end", mp_property_stream_end},
|
2015-05-22 18:02:47 +00:00
|
|
|
{"duration", mp_property_duration},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"avsync", mp_property_avsync},
|
|
|
|
{"total-avsync-change", mp_property_total_avsync_change},
|
2015-10-30 13:05:41 +00:00
|
|
|
{"mistimed-frame-count", mp_property_mistimed_frame_count},
|
2015-11-13 21:48:32 +00:00
|
|
|
{"vsync-ratio", mp_property_vsync_ratio},
|
2021-04-12 17:51:41 +00:00
|
|
|
{"display-width", mp_property_display_resolution},
|
|
|
|
{"display-height", mp_property_display_resolution},
|
2017-01-20 16:01:29 +00:00
|
|
|
{"decoder-frame-drop-count", mp_property_frame_drop_dec},
|
|
|
|
{"frame-drop-count", mp_property_frame_drop_vo},
|
2015-11-13 21:41:41 +00:00
|
|
|
{"vo-delayed-frame-count", mp_property_vo_delayed_frame_count},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"percent-pos", mp_property_percent_pos},
|
|
|
|
{"time-start", mp_property_time_start},
|
|
|
|
{"time-pos", mp_property_time_pos},
|
|
|
|
{"time-remaining", mp_property_remaining},
|
2016-09-19 17:11:14 +00:00
|
|
|
{"audio-pts", mp_property_audio_pts},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"playtime-remaining", mp_property_playtime_remaining},
|
2014-06-29 17:27:46 +00:00
|
|
|
{"playback-time", mp_property_playback_time},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"chapter", mp_property_chapter},
|
|
|
|
{"edition", mp_property_edition},
|
2019-12-16 00:47:06 +00:00
|
|
|
{"current-edition", mp_property_current_edition},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"chapters", mp_property_chapters},
|
|
|
|
{"editions", mp_property_editions},
|
|
|
|
{"metadata", mp_property_metadata},
|
2014-12-29 22:03:39 +00:00
|
|
|
{"filtered-metadata", mp_property_filtered_metadata},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"chapter-metadata", mp_property_chapter_metadata},
|
2015-09-11 21:04:02 +00:00
|
|
|
{"vf-metadata", mp_property_filter_metadata, .priv = "vf"},
|
|
|
|
{"af-metadata", mp_property_filter_metadata, .priv = "af"},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"core-idle", mp_property_core_idle},
|
|
|
|
{"eof-reached", mp_property_eof_reached},
|
2014-08-07 22:13:27 +00:00
|
|
|
{"seeking", mp_property_seeking},
|
2014-10-21 11:32:30 +00:00
|
|
|
{"playback-abort", mp_property_playback_abort},
|
2018-09-01 11:04:45 +00:00
|
|
|
{"cache-speed", mp_property_cache_speed},
|
2014-08-28 15:48:31 +00:00
|
|
|
{"demuxer-cache-duration", mp_property_demuxer_cache_duration},
|
2015-04-20 21:47:13 +00:00
|
|
|
{"demuxer-cache-time", mp_property_demuxer_cache_time},
|
2014-08-28 15:48:31 +00:00
|
|
|
{"demuxer-cache-idle", mp_property_demuxer_cache_idle},
|
2017-03-10 00:44:55 +00:00
|
|
|
{"demuxer-start-time", mp_property_demuxer_start_time},
|
2017-10-21 19:13:53 +00:00
|
|
|
{"demuxer-cache-state", mp_property_demuxer_cache_state},
|
2014-10-07 20:07:07 +00:00
|
|
|
{"cache-buffering-state", mp_property_cache_buffering},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"paused-for-cache", mp_property_paused_for_cache},
|
2017-03-24 14:31:01 +00:00
|
|
|
{"demuxer-via-network", mp_property_demuxer_is_network},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"clock", mp_property_clock},
|
|
|
|
{"seekable", mp_property_seekable},
|
2015-01-26 12:46:33 +00:00
|
|
|
{"partially-seekable", mp_property_partially_seekable},
|
2016-09-01 18:01:02 +00:00
|
|
|
{"idle-active", mp_property_idle},
|
2022-11-22 15:42:30 +00:00
|
|
|
{"window-id", mp_property_window_id},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
|
|
|
|
{"chapter-list", mp_property_list_chapters},
|
|
|
|
{"track-list", property_list_tracks},
|
2020-08-12 15:23:13 +00:00
|
|
|
{"current-tracks", property_current_tracks},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"edition-list", property_list_editions},
|
|
|
|
|
|
|
|
{"playlist", mp_property_playlist},
|
2023-08-11 04:27:28 +00:00
|
|
|
{"playlist-path", mp_property_playlist_path},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"playlist-pos", mp_property_playlist_pos},
|
2016-05-26 16:43:49 +00:00
|
|
|
{"playlist-pos-1", mp_property_playlist_pos_1},
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
{"playlist-current-pos", mp_property_playlist_current_pos},
|
|
|
|
{"playlist-playing-pos", mp_property_playlist_playing_pos},
|
2014-02-15 15:54:55 +00:00
|
|
|
M_PROPERTY_ALIAS("playlist-count", "playlist/count"),
|
2013-05-15 00:17:47 +00:00
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
// Audio
|
2016-01-26 14:12:42 +00:00
|
|
|
{"mixer-active", mp_property_mixer_active},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"volume", mp_property_volume},
|
2016-07-09 16:31:18 +00:00
|
|
|
{"ao-volume", mp_property_ao_volume},
|
|
|
|
{"ao-mute", mp_property_ao_mute},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"audio-delay", mp_property_audio_delay},
|
2015-05-22 18:05:04 +00:00
|
|
|
{"audio-codec-name", mp_property_audio_codec_name},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"audio-codec", mp_property_audio_codec},
|
2015-05-22 18:23:47 +00:00
|
|
|
{"audio-params", mp_property_audio_params},
|
|
|
|
{"audio-out-params", mp_property_audio_out_params},
|
2019-11-25 18:49:09 +00:00
|
|
|
{"aid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_AUDIO}},
|
2014-10-27 11:16:32 +00:00
|
|
|
{"audio-device", mp_property_audio_device},
|
2014-10-10 17:46:21 +00:00
|
|
|
{"audio-device-list", mp_property_audio_devices},
|
2015-02-02 16:35:31 +00:00
|
|
|
{"current-ao", mp_property_ao},
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
// Video
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"video-out-params", mp_property_vo_imgparams},
|
2016-09-20 13:40:44 +00:00
|
|
|
{"video-dec-params", mp_property_dec_imgparams},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"video-params", mp_property_vd_imgparams},
|
|
|
|
{"video-format", mp_property_video_format},
|
2015-11-22 17:54:22 +00:00
|
|
|
{"video-frame-info", mp_property_video_frame_info},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"video-codec", mp_property_video_codec},
|
2014-02-15 15:42:48 +00:00
|
|
|
M_PROPERTY_ALIAS("dwidth", "video-out-params/dw"),
|
|
|
|
M_PROPERTY_ALIAS("dheight", "video-out-params/dh"),
|
|
|
|
M_PROPERTY_ALIAS("width", "video-params/w"),
|
|
|
|
M_PROPERTY_ALIAS("height", "video-params/h"),
|
2019-12-16 01:32:17 +00:00
|
|
|
{"current-window-scale", mp_property_current_window_scale},
|
2014-10-24 13:34:53 +00:00
|
|
|
{"vo-configured", mp_property_vo_configured},
|
vo_opengl: refactor vo performance subsystem
This replaces `vo-performance` by `vo-passes`, bringing with it a number
of changes and improvements:
1. mpv users can now introspect the vo_opengl passes, which is something
that has been requested multiple times.
2. performance data is now measured per-pass, which helps both
development and debugging.
3. since adding more passes is cheap, we can now report information for
more passes (e.g. the blit pass, and the osd pass). Note: we also
switch to nanosecond scale, to be able to measure these passes
better.
4. `--user-shaders` authors can now describe their own passes, helping
users both identify which user shaders are active at any given time
as well as helping shader authors identify performance issues.
5. the timing data per pass is now exported as a full list of samples,
so projects like Argon-/mpv-stats can immediately read out all of the
samples and render a graph without having to manually poll this
option constantly.
Due to gl_timer's design being complicated (directly reading performance
data would block, so we delay the actual read-back until the next _start
command), it's vital not to conflate different passes that might be
doing different things from one frame to another. To accomplish this,
the actual timers are stored as part of the gl_shader_cache's sc_entry,
which makes them unique for that exact shader.
Starting and stopping the time measurement is easy to unify with the
gl_sc architecture, because the existing API already relies on a
"generate, render, reset" flow, so we can just put timer_start and
timer_stop in sc_generate and sc_reset, respectively.
The ugliest thing about this code is that due to the need to keep pass
information relatively stable in between frames, we need to distinguish
between "new" and "redrawn" frames, which bloats the code somewhat and
also feels hacky and vo_opengl-specific. (But then again, this entire
thing is vo_opengl-specific)
2017-06-29 15:00:06 +00:00
|
|
|
{"vo-passes", mp_property_vo_passes},
|
stats: some more performance graphs
Add an infrastructure for collecting performance-related data, use it in
some places. Add rendering of them to stats.lua.
There were two main goals: minimal impact on the normal code and normal
playback. So all these stats_* function calls either happen only during
initialization, or return immediately if no stats collection is going
on. That's why it does this lazily adding of stats entries etc. (a first
iteration made each stats entry an API thing, instead of just a single
stats_ctx, but I thought that was getting too intrusive in the "normal"
code, even if everything gets worse inside of stats.c).
You could get most of this information from various profilers (including
the extremely primitive --dump-stats thing in mpv), but this makes it
easier to see the most important information at once (at least in
theory), partially because we know best about the context of various
things.
Not very happy with this. It's all pretty primitive and dumb. At this
point I just wanted to get over with it, without necessarily having to
revisit it later, but with having my stupid statistics.
Somehow the code feels terrible. There are a lot of meh decisions in
there that could be better or worse (but mostly could be better), and it
just sucks but it's also trivial and uninteresting and does the job. I
guess I hate programming. It's so tedious and the result is always shit.
Anyway, enjoy.
2020-04-08 22:27:54 +00:00
|
|
|
{"perf-info", mp_property_perf_info},
|
2015-02-02 16:35:31 +00:00
|
|
|
{"current-vo", mp_property_vo},
|
2016-09-01 18:01:02 +00:00
|
|
|
{"container-fps", mp_property_fps},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"estimated-vf-fps", mp_property_vf_fps},
|
|
|
|
{"video-aspect", mp_property_aspect},
|
2019-12-21 13:25:47 +00:00
|
|
|
{"video-aspect-override", mp_property_video_aspect_override},
|
2019-11-25 18:49:09 +00:00
|
|
|
{"vid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_VIDEO}},
|
2016-05-04 14:55:26 +00:00
|
|
|
{"hwdec-current", mp_property_hwdec_current},
|
|
|
|
{"hwdec-interop", mp_property_hwdec_interop},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
|
2014-08-19 19:19:38 +00:00
|
|
|
{"estimated-frame-count", mp_property_frame_count},
|
|
|
|
{"estimated-frame-number", mp_property_frame_number},
|
|
|
|
|
2020-01-07 23:14:20 +00:00
|
|
|
{"osd-dimensions", mp_property_osd_dim},
|
|
|
|
M_PROPERTY_ALIAS("osd-width", "osd-dimensions/w"),
|
|
|
|
M_PROPERTY_ALIAS("osd-height", "osd-dimensions/h"),
|
|
|
|
M_PROPERTY_ALIAS("osd-par", "osd-dimensions/par"),
|
2013-09-30 20:25:34 +00:00
|
|
|
|
2014-09-17 22:12:59 +00:00
|
|
|
{"osd-sym-cc", mp_property_osd_sym},
|
2014-09-17 22:49:55 +00:00
|
|
|
{"osd-ass-cc", mp_property_osd_ass},
|
2014-09-17 22:12:59 +00:00
|
|
|
|
2019-12-25 18:42:44 +00:00
|
|
|
{"mouse-pos", mp_property_mouse_pos},
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
// Subs
|
2019-11-25 18:49:09 +00:00
|
|
|
{"sid", property_switch_track, .priv = (void *)(const int[]){0, STREAM_SUB}},
|
|
|
|
{"secondary-sid", property_switch_track,
|
|
|
|
.priv = (void *)(const int[]){1, STREAM_SUB}},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"sub-delay", mp_property_sub_delay},
|
2016-09-13 01:17:10 +00:00
|
|
|
{"sub-speed", mp_property_sub_speed},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"sub-pos", mp_property_sub_pos},
|
2020-05-14 20:14:49 +00:00
|
|
|
{"sub-text", mp_property_sub_text,
|
|
|
|
.priv = (void *)&(const int){SD_TEXT_TYPE_PLAIN}},
|
2021-05-09 17:05:13 +00:00
|
|
|
{"secondary-sub-text", mp_property_secondary_sub_text,
|
|
|
|
.priv = (void *)&(const int){SD_TEXT_TYPE_PLAIN}},
|
2020-05-14 20:14:49 +00:00
|
|
|
{"sub-text-ass", mp_property_sub_text,
|
|
|
|
.priv = (void *)&(const int){SD_TEXT_TYPE_ASS}},
|
2021-07-12 18:29:59 +00:00
|
|
|
{"sub-start", mp_property_sub_start,
|
|
|
|
.priv = (void *)&(const int){0}},
|
2021-07-12 18:42:03 +00:00
|
|
|
{"secondary-sub-start", mp_property_sub_start,
|
2021-07-12 18:29:59 +00:00
|
|
|
.priv = (void *)&(const int){1}},
|
|
|
|
{"sub-end", mp_property_sub_end,
|
|
|
|
.priv = (void *)&(const int){0}},
|
2021-07-12 18:42:03 +00:00
|
|
|
{"secondary-sub-end", mp_property_sub_end,
|
2021-07-12 18:29:59 +00:00
|
|
|
.priv = (void *)&(const int){1}},
|
2021-06-25 07:36:05 +00:00
|
|
|
{"sub-forced-only-cur", mp_property_sub_forced_only_cur},
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"vf", mp_property_vf},
|
|
|
|
{"af", mp_property_af},
|
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
{"ab-loop-a", mp_property_ab_loop},
|
|
|
|
{"ab-loop-b", mp_property_ab_loop},
|
|
|
|
|
2015-04-20 18:52:16 +00:00
|
|
|
#define PROPERTY_BITRATE(name, old, type) \
|
|
|
|
{name, mp_property_packet_bitrate, (void *)(uintptr_t)((type)|(old?0x100:0))}
|
|
|
|
PROPERTY_BITRATE("packet-video-bitrate", true, STREAM_VIDEO),
|
|
|
|
PROPERTY_BITRATE("packet-audio-bitrate", true, STREAM_AUDIO),
|
|
|
|
PROPERTY_BITRATE("packet-sub-bitrate", true, STREAM_SUB),
|
|
|
|
|
|
|
|
PROPERTY_BITRATE("video-bitrate", false, STREAM_VIDEO),
|
|
|
|
PROPERTY_BITRATE("audio-bitrate", false, STREAM_AUDIO),
|
|
|
|
PROPERTY_BITRATE("sub-bitrate", false, STREAM_SUB),
|
2014-12-12 00:00:58 +00:00
|
|
|
|
2020-09-07 16:22:25 +00:00
|
|
|
{"focused", mp_property_focused},
|
2014-11-06 02:16:32 +00:00
|
|
|
{"display-names", mp_property_display_names},
|
2015-03-10 13:50:56 +00:00
|
|
|
{"display-fps", mp_property_display_fps},
|
2015-11-25 21:07:56 +00:00
|
|
|
{"estimated-display-fps", mp_property_estimated_display_fps},
|
|
|
|
{"vsync-jitter", mp_property_vsync_jitter},
|
2019-12-20 11:47:00 +00:00
|
|
|
{"display-hidpi-scale", mp_property_hidpi_scale},
|
2014-11-02 19:48:45 +00:00
|
|
|
|
2015-03-24 21:00:01 +00:00
|
|
|
{"working-directory", mp_property_cwd},
|
|
|
|
|
2015-05-23 13:26:55 +00:00
|
|
|
{"protocol-list", mp_property_protocols},
|
2016-02-29 19:57:31 +00:00
|
|
|
{"decoder-list", mp_property_decoders},
|
2016-03-01 20:46:49 +00:00
|
|
|
{"encoder-list", mp_property_encoders},
|
2018-01-02 20:46:58 +00:00
|
|
|
{"demuxer-lavf-list", mp_property_lavf_demuxers},
|
2020-05-14 20:22:33 +00:00
|
|
|
{"input-key-list", mp_property_keylist},
|
2015-05-23 13:26:55 +00:00
|
|
|
|
2014-11-02 16:44:24 +00:00
|
|
|
{"mpv-version", mp_property_version},
|
2014-11-13 15:18:40 +00:00
|
|
|
{"mpv-configuration", mp_property_configuration},
|
2016-02-29 19:59:20 +00:00
|
|
|
{"ffmpeg-version", mp_property_ffmpeg},
|
2020-03-08 18:08:41 +00:00
|
|
|
{"libass-version", mp_property_libass_version},
|
2022-01-23 05:06:26 +00:00
|
|
|
{"platform", mp_property_platform},
|
2014-11-02 16:44:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"options", mp_property_options},
|
2014-10-15 20:39:33 +00:00
|
|
|
{"file-local-options", mp_property_local_options},
|
2014-11-13 16:27:31 +00:00
|
|
|
{"option-info", mp_property_option_info},
|
2014-08-01 23:35:32 +00:00
|
|
|
{"property-list", mp_property_list},
|
2016-08-28 17:42:03 +00:00
|
|
|
{"profile-list", mp_profile_list},
|
2019-11-22 21:52:31 +00:00
|
|
|
{"command-list", mp_property_commands},
|
2019-11-22 23:39:07 +00:00
|
|
|
{"input-bindings", mp_property_bindings},
|
2013-07-25 21:36:01 +00:00
|
|
|
|
2019-12-18 07:58:49 +00:00
|
|
|
{"shared-script-properties", mp_property_script_props},
|
2022-12-16 01:20:43 +00:00
|
|
|
{"user-data", mp_property_udata},
|
2019-12-18 07:58:49 +00:00
|
|
|
|
2015-03-30 21:52:28 +00:00
|
|
|
M_PROPERTY_ALIAS("video", "vid"),
|
|
|
|
M_PROPERTY_ALIAS("audio", "aid"),
|
|
|
|
M_PROPERTY_ALIAS("sub", "sid"),
|
2016-09-01 18:00:43 +00:00
|
|
|
|
|
|
|
// compatibility
|
2015-03-30 21:52:28 +00:00
|
|
|
M_PROPERTY_ALIAS("colormatrix", "video-params/colormatrix"),
|
|
|
|
M_PROPERTY_ALIAS("colormatrix-input-range", "video-params/colorlevels"),
|
|
|
|
M_PROPERTY_ALIAS("colormatrix-primaries", "video-params/primaries"),
|
2015-03-31 02:50:49 +00:00
|
|
|
M_PROPERTY_ALIAS("colormatrix-gamma", "video-params/gamma"),
|
2017-01-20 16:01:29 +00:00
|
|
|
|
|
|
|
M_PROPERTY_DEPRECATED_ALIAS("drop-frame-count", "decoder-frame-drop-count"),
|
|
|
|
M_PROPERTY_DEPRECATED_ALIAS("vo-drop-frame-count", "frame-drop-count"),
|
2007-02-21 00:49:24 +00:00
|
|
|
};
|
|
|
|
|
2014-04-05 21:54:21 +00:00
|
|
|
// Each entry describes which properties an event (possibly) changes.
|
2014-06-10 21:56:05 +00:00
|
|
|
#define E(x, ...) [x] = (const char*const[]){__VA_ARGS__, NULL}
|
|
|
|
static const char *const *const mp_event_property_change[] = {
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_START_FILE, "*"),
|
|
|
|
E(MPV_EVENT_END_FILE, "*"),
|
|
|
|
E(MPV_EVENT_FILE_LOADED, "*"),
|
2015-02-01 17:25:12 +00:00
|
|
|
E(MP_EVENT_CHANGE_ALL, "*"),
|
2021-12-02 16:19:39 +00:00
|
|
|
E(MP_EVENT_TRACKS_CHANGED, "track-list", "current-tracks"),
|
|
|
|
E(MP_EVENT_TRACK_SWITCHED, "track-list", "current-tracks"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_IDLE, "*"),
|
2016-09-19 17:11:14 +00:00
|
|
|
E(MPV_EVENT_TICK, "time-pos", "audio-pts", "stream-pos", "avsync",
|
2014-10-18 22:49:37 +00:00
|
|
|
"percent-pos", "time-remaining", "playtime-remaining", "playback-time",
|
2015-02-27 11:23:29 +00:00
|
|
|
"estimated-vf-fps", "drop-frame-count", "vo-drop-frame-count",
|
2015-08-10 16:43:25 +00:00
|
|
|
"total-avsync-change", "audio-speed-correction", "video-speed-correction",
|
2015-11-25 21:07:56 +00:00
|
|
|
"vo-delayed-frame-count", "mistimed-frame-count", "vsync-ratio",
|
2021-05-09 17:05:13 +00:00
|
|
|
"estimated-display-fps", "vsync-jitter", "sub-text", "secondary-sub-text",
|
|
|
|
"audio-bitrate", "video-bitrate", "sub-bitrate", "decoder-frame-drop-count",
|
2020-10-28 00:45:30 +00:00
|
|
|
"frame-drop-count", "video-frame-info", "vf-metadata", "af-metadata",
|
2021-07-12 18:29:59 +00:00
|
|
|
"sub-start", "sub-end", "secondary-sub-start", "secondary-sub-end"),
|
2017-12-24 00:56:09 +00:00
|
|
|
E(MP_EVENT_DURATION_UPDATE, "duration"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
|
|
|
|
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
|
2023-08-11 15:14:27 +00:00
|
|
|
"width", "height", "fps", "aspect", "aspect-name", "vo-configured", "current-vo",
|
2020-01-07 23:14:20 +00:00
|
|
|
"video-aspect", "video-dec-params", "osd-dimensions",
|
2017-03-31 15:28:15 +00:00
|
|
|
"hwdec", "hwdec-current", "hwdec-interop"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate",
|
2017-11-29 19:13:28 +00:00
|
|
|
"samplerate", "channels", "audio", "volume", "mute",
|
2016-07-09 16:31:18 +00:00
|
|
|
"current-ao", "audio-codec-name", "audio-params",
|
2016-01-26 14:12:42 +00:00
|
|
|
"audio-out-params", "volume-max", "mixer-active"),
|
2015-12-24 16:36:02 +00:00
|
|
|
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
|
|
|
|
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
|
2021-12-02 16:19:39 +00:00
|
|
|
E(MP_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"),
|
|
|
|
E(MP_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"),
|
2019-09-20 17:21:49 +00:00
|
|
|
E(MP_EVENT_CACHE_UPDATE,
|
2015-04-20 21:47:13 +00:00
|
|
|
"demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache",
|
2016-09-02 07:42:19 +00:00
|
|
|
"demuxer-cache-time", "cache-buffering-state", "cache-speed",
|
2019-09-20 17:21:49 +00:00
|
|
|
"demuxer-cache-state"),
|
2019-12-16 01:32:17 +00:00
|
|
|
E(MP_EVENT_WIN_RESIZE, "current-window-scale", "osd-width", "osd-height",
|
2020-01-07 23:14:20 +00:00
|
|
|
"osd-par", "osd-dimensions"),
|
2021-05-23 21:40:55 +00:00
|
|
|
E(MP_EVENT_WIN_STATE, "display-names", "display-fps", "display-width",
|
2021-04-12 17:51:41 +00:00
|
|
|
"display-height"),
|
2020-01-08 19:23:12 +00:00
|
|
|
E(MP_EVENT_WIN_STATE2, "display-hidpi-scale"),
|
2020-09-07 16:22:25 +00:00
|
|
|
E(MP_EVENT_FOCUS, "focused"),
|
2016-06-20 19:35:59 +00:00
|
|
|
E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
"playlist-count", "playlist/count", "playlist-current-pos",
|
|
|
|
"playlist-playing-pos"),
|
2019-12-25 18:42:44 +00:00
|
|
|
E(MP_EVENT_INPUT_PROCESSED, "mouse-pos"),
|
2017-04-14 16:56:03 +00:00
|
|
|
E(MP_EVENT_CORE_IDLE, "core-idle", "eof-reached"),
|
2014-04-05 21:54:21 +00:00
|
|
|
};
|
|
|
|
#undef E
|
|
|
|
|
2015-06-09 16:05:12 +00:00
|
|
|
// If there is no prefix, return length+1 (avoids matching full name as prefix).
|
2014-08-01 23:39:28 +00:00
|
|
|
static int prefix_len(const char *p)
|
|
|
|
{
|
|
|
|
const char *end = strchr(p, '/');
|
2015-06-09 16:05:12 +00:00
|
|
|
return end ? end - p : strlen(p) + 1;
|
2014-08-01 23:39:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool match_property(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
if (strcmp(a, "*") == 0)
|
|
|
|
return true;
|
2016-09-23 18:49:08 +00:00
|
|
|
// Give options and properties the same ID each, so change notifications
|
|
|
|
// work both way.
|
|
|
|
if (strncmp(a, "options/", 8) == 0)
|
|
|
|
a += 8;
|
|
|
|
if (strncmp(b, "options/", 8) == 0)
|
|
|
|
b += 8;
|
2014-08-01 23:39:28 +00:00
|
|
|
int len_a = prefix_len(a);
|
|
|
|
int len_b = prefix_len(b);
|
|
|
|
return strncmp(a, b, MPMIN(len_a, len_b)) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a bitset of events which change the property.
|
|
|
|
uint64_t mp_get_property_event_mask(const char *name)
|
|
|
|
{
|
|
|
|
uint64_t mask = 0;
|
|
|
|
for (int n = 0; n < MP_ARRAY_SIZE(mp_event_property_change); n++) {
|
|
|
|
const char *const *const list = mp_event_property_change[n];
|
|
|
|
for (int i = 0; list && list[i]; i++) {
|
|
|
|
if (match_property(list[i], name))
|
|
|
|
mask |= 1ULL << n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return an ID for the property. It might not be unique, but is good enough
|
|
|
|
// for property change handling. Return -1 if property unknown.
|
2016-09-01 18:00:43 +00:00
|
|
|
int mp_get_property_id(struct MPContext *mpctx, const char *name)
|
2014-08-01 23:39:28 +00:00
|
|
|
{
|
2016-09-01 18:00:43 +00:00
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
for (int n = 0; ctx->properties[n].name; n++) {
|
|
|
|
if (match_property(ctx->properties[n].name, name))
|
2014-08-01 23:39:28 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-04-08 19:24:14 +00:00
|
|
|
static bool is_property_set(int action, void *val)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
case M_PROPERTY_SWITCH:
|
|
|
|
case M_PROPERTY_SET_STRING:
|
|
|
|
case M_PROPERTY_SET_NODE:
|
2018-11-28 16:40:02 +00:00
|
|
|
case M_PROPERTY_MULTIPLY:
|
2014-04-08 19:24:14 +00:00
|
|
|
return true;
|
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
struct m_property_action_arg *key = val;
|
|
|
|
return is_property_set(key->action, key->arg);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-29 23:56:23 +00:00
|
|
|
int mp_property_do(const char *name, int action, void *val,
|
|
|
|
struct MPContext *ctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2016-09-01 18:00:43 +00:00
|
|
|
struct command_ctx *cmd = ctx->command_ctx;
|
|
|
|
int r = m_property_do(ctx->log, cmd->properties, name, action, val, ctx);
|
2019-11-29 23:56:23 +00:00
|
|
|
|
2016-04-15 11:20:05 +00:00
|
|
|
if (mp_msg_test(ctx->log, MSGL_V) && is_property_set(action, val)) {
|
|
|
|
struct m_option ot = {0};
|
|
|
|
void *data = val;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET_NODE:
|
|
|
|
ot.type = &m_option_type_node;
|
|
|
|
break;
|
|
|
|
case M_PROPERTY_SET_STRING:
|
|
|
|
ot.type = &m_option_type_string;
|
|
|
|
data = &val;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
char *t = ot.type ? m_option_print(&ot, data) : NULL;
|
|
|
|
MP_VERBOSE(ctx, "Set property: %s%s%s -> %d\n",
|
|
|
|
name, t ? "=" : "", t ? t : "", r);
|
|
|
|
talloc_free(t);
|
|
|
|
}
|
2014-04-08 19:24:14 +00:00
|
|
|
return r;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 21:33:38 +00:00
|
|
|
char *mp_property_expand_string(struct MPContext *mpctx, const char *str)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2016-09-01 18:00:43 +00:00
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
return m_properties_expand_string(ctx->properties, str, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 13:46:23 +00:00
|
|
|
// Before expanding properties, parse C-style escapes like "\n"
|
|
|
|
char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str)
|
|
|
|
{
|
|
|
|
void *tmp = talloc_new(NULL);
|
|
|
|
bstr strb = bstr0(str);
|
|
|
|
bstr dst = {0};
|
|
|
|
while (strb.len) {
|
|
|
|
if (!mp_append_escaped_string(tmp, &dst, &strb)) {
|
|
|
|
talloc_free(tmp);
|
|
|
|
return talloc_strdup(NULL, "(broken escape sequences)");
|
|
|
|
}
|
|
|
|
// pass " through literally
|
|
|
|
if (!bstr_eatstart0(&strb, "\""))
|
|
|
|
break;
|
|
|
|
bstr_xappend(tmp, &dst, bstr0("\""));
|
|
|
|
}
|
|
|
|
char *r = mp_property_expand_string(mpctx, dst.start);
|
|
|
|
talloc_free(tmp);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2016-09-01 18:00:43 +00:00
|
|
|
void property_print_help(struct MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2016-09-01 18:00:43 +00:00
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
m_properties_print_help_list(mpctx->log, ctx->properties);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2009-09-19 01:17:30 +00:00
|
|
|
/* List of default ways to show a property on OSD.
|
|
|
|
*
|
2012-09-25 01:24:38 +00:00
|
|
|
* If osd_progbar is set, a bar showing the current position between min/max
|
|
|
|
* values of the property is shown. In this case osd_msg is only used for
|
|
|
|
* terminal output if there is no video; it'll be a label shown together with
|
|
|
|
* percentage.
|
2009-09-19 01:17:30 +00:00
|
|
|
*/
|
2014-06-10 21:56:05 +00:00
|
|
|
static const struct property_osd_display {
|
2012-09-25 01:24:38 +00:00
|
|
|
// property name
|
2009-09-19 01:17:30 +00:00
|
|
|
const char *name;
|
2012-09-25 01:24:38 +00:00
|
|
|
// name used on OSD
|
|
|
|
const char *osd_name;
|
|
|
|
// progressbar type
|
|
|
|
int osd_progbar;
|
|
|
|
// Needs special ways to display the new value (seeks are delayed)
|
|
|
|
int seek_msg, seek_bar;
|
2017-08-23 12:23:37 +00:00
|
|
|
// Show a marker thing on OSD bar. Ignored if osd_progbar==0.
|
|
|
|
float marker;
|
2013-09-20 21:33:38 +00:00
|
|
|
// Free-form message (if NULL, osd_name or the property name is used)
|
|
|
|
const char *msg;
|
2009-09-19 01:17:30 +00:00
|
|
|
} property_osd_display[] = {
|
|
|
|
// general
|
2018-01-06 03:47:10 +00:00
|
|
|
{"loop-playlist", "Loop"},
|
|
|
|
{"loop-file", "Loop current file"},
|
|
|
|
{"chapter",
|
|
|
|
.seek_msg = OSD_SEEK_INFO_CHAPTER_TEXT,
|
|
|
|
.seek_bar = OSD_SEEK_INFO_BAR},
|
|
|
|
{"hr-seek", "hr-seek"},
|
|
|
|
{"speed", "Speed"},
|
|
|
|
{"clock", "Clock"},
|
2020-04-12 22:18:04 +00:00
|
|
|
{"edition", "Edition"},
|
2009-09-19 01:17:30 +00:00
|
|
|
// audio
|
2018-01-06 03:47:10 +00:00
|
|
|
{"volume", "Volume",
|
|
|
|
.msg = "Volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",
|
|
|
|
.osd_progbar = OSD_VOLUME, .marker = 100},
|
|
|
|
{"ao-volume", "AO Volume",
|
|
|
|
.msg = "AO Volume: ${?ao-volume:${ao-volume}% ${?ao-mute==yes:(Muted)}}${!ao-volume:${ao-volume}}",
|
|
|
|
.osd_progbar = OSD_VOLUME, .marker = 100},
|
|
|
|
{"mute", "Mute"},
|
|
|
|
{"ao-mute", "AO Mute"},
|
|
|
|
{"audio-delay", "A-V delay"},
|
|
|
|
{"audio", "Audio"},
|
2009-09-19 01:17:30 +00:00
|
|
|
// video
|
2018-01-06 03:47:10 +00:00
|
|
|
{"panscan", "Panscan", .osd_progbar = OSD_PANSCAN},
|
|
|
|
{"taskbar-progress", "Progress in taskbar"},
|
|
|
|
{"snap-window", "Snap to screen edges"},
|
|
|
|
{"ontop", "Stay on top"},
|
2021-02-20 20:07:58 +00:00
|
|
|
{"on-all-workspaces", "Visibility on all workspaces"},
|
2018-01-06 03:47:10 +00:00
|
|
|
{"border", "Border"},
|
|
|
|
{"framedrop", "Framedrop"},
|
|
|
|
{"deinterlace", "Deinterlace"},
|
|
|
|
{"gamma", "Gamma", .osd_progbar = OSD_BRIGHTNESS },
|
|
|
|
{"brightness", "Brightness", .osd_progbar = OSD_BRIGHTNESS},
|
|
|
|
{"contrast", "Contrast", .osd_progbar = OSD_CONTRAST},
|
|
|
|
{"saturation", "Saturation", .osd_progbar = OSD_SATURATION},
|
|
|
|
{"hue", "Hue", .osd_progbar = OSD_HUE},
|
|
|
|
{"angle", "Angle"},
|
2009-09-19 01:17:30 +00:00
|
|
|
// subs
|
2018-01-06 03:47:10 +00:00
|
|
|
{"sub", "Subtitles"},
|
|
|
|
{"secondary-sid", "Secondary subtitles"},
|
|
|
|
{"sub-pos", "Sub position"},
|
|
|
|
{"sub-delay", "Sub delay"},
|
|
|
|
{"sub-speed", "Sub speed"},
|
|
|
|
{"sub-visibility",
|
2022-01-19 19:56:28 +00:00
|
|
|
.msg = "Subtitles ${!sub-visibility==yes:hidden}"
|
|
|
|
"${?sub-visibility==yes:visible${?sub==no: (but no subtitles selected)}}"},
|
|
|
|
{"secondary-sub-visibility",
|
|
|
|
.msg = "Secondary Subtitles ${!secondary-sub-visibility==yes:hidden}"
|
|
|
|
"${?secondary-sub-visibility==yes:visible${?secondary-sid==no: (but no secondary subtitles selected)}}"},
|
2018-01-06 03:47:10 +00:00
|
|
|
{"sub-forced-only", "Forced sub only"},
|
|
|
|
{"sub-scale", "Sub Scale"},
|
|
|
|
{"sub-ass-vsfilter-aspect-compat", "Subtitle VSFilter aspect compat"},
|
|
|
|
{"sub-ass-override", "ASS subtitle style override"},
|
|
|
|
{"vf", "Video filters", .msg = "Video filters:\n${vf}"},
|
|
|
|
{"af", "Audio filters", .msg = "Audio filters:\n${af}"},
|
|
|
|
{"ab-loop-a", "A-B loop start"},
|
2020-02-08 13:57:45 +00:00
|
|
|
{"ab-loop-b", .msg = "A-B loop: ${ab-loop-a} - ${ab-loop-b}"
|
|
|
|
"${?=ab-loop-count==0: (disabled)}"},
|
2018-01-06 03:47:10 +00:00
|
|
|
{"audio-device", "Audio device"},
|
2018-02-12 17:26:18 +00:00
|
|
|
{"hwdec", .msg = "Hardware decoding: ${hwdec-current}"},
|
2019-10-24 22:50:38 +00:00
|
|
|
{"video-aspect-override", "Aspect ratio override"},
|
2014-09-21 21:54:29 +00:00
|
|
|
// By default, don't display the following properties on OSD
|
2018-01-21 23:40:52 +00:00
|
|
|
{"pause", NULL},
|
2018-01-06 03:47:10 +00:00
|
|
|
{"fullscreen", NULL},
|
2019-11-26 00:46:47 +00:00
|
|
|
{"window-minimized", NULL},
|
|
|
|
{"window-maximized", NULL},
|
2012-09-25 01:24:38 +00:00
|
|
|
{0}
|
2009-09-19 01:17:30 +00:00
|
|
|
};
|
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
static void show_property_osd(MPContext *mpctx, const char *name, int osd_mode)
|
2009-09-19 01:17:30 +00:00
|
|
|
{
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2018-01-06 03:47:10 +00:00
|
|
|
struct property_osd_display disp = {.name = name, .osd_name = name};
|
2009-09-19 01:17:30 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (!osd_mode)
|
|
|
|
return;
|
2012-09-25 01:24:38 +00:00
|
|
|
|
2009-09-19 01:17:30 +00:00
|
|
|
// look for the command
|
2014-09-21 21:40:45 +00:00
|
|
|
for (const struct property_osd_display *p = property_osd_display; p->name; p++)
|
|
|
|
{
|
2014-02-21 12:18:50 +00:00
|
|
|
if (!strcmp(p->name, name)) {
|
2014-09-21 21:40:45 +00:00
|
|
|
disp = *p;
|
2009-09-19 01:17:30 +00:00
|
|
|
break;
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (osd_mode == MP_ON_OSD_AUTO) {
|
|
|
|
osd_mode =
|
|
|
|
((disp.msg || disp.osd_name || disp.seek_msg) ? MP_ON_OSD_MSG : 0) |
|
|
|
|
((disp.osd_progbar || disp.seek_bar) ? MP_ON_OSD_BAR : 0);
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
2009-09-19 01:17:30 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (!disp.osd_progbar)
|
|
|
|
disp.osd_progbar = ' ';
|
|
|
|
|
|
|
|
if (!disp.osd_name)
|
|
|
|
disp.osd_name = name;
|
|
|
|
|
|
|
|
if (disp.seek_msg || disp.seek_bar) {
|
2012-09-25 01:24:38 +00:00
|
|
|
mpctx->add_osd_seek_info |=
|
2014-09-21 21:40:45 +00:00
|
|
|
(osd_mode & MP_ON_OSD_MSG ? disp.seek_msg : 0) |
|
|
|
|
(osd_mode & MP_ON_OSD_BAR ? disp.seek_bar : 0);
|
2012-09-25 01:24:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-08 21:53:11 +00:00
|
|
|
struct m_option prop = {0};
|
player: more option/property consistency fixes
Some properties had a different type from their equivalent options (such
as mute, volume, deinterlace, edition). This wasn't really sane, as raw
option values should be always within their bounds. On the other hand,
these properties use a different type to reflect runtime limits (such as
range of available editions), or simply to improve the "UI" (you don't
want to cycle throuhg the completely useless "auto" value when cycling
the "mute" property).
Handle this by making them always return the option type, but also
allowing them to provide a "constricted" type, which is used for UI
purposes. All M_PROPERTY_GET_CONSTRICTED_TYPE changes are related to
this.
One consequence is that you can set the volume property to arbitrary
high values just like with the --volume option, but using the "add"
command it still restricts it to the --volume-max range.
Also deprecate --chapter, as it is grossly incompatible to the chapter
property. We pondered renaming it to --chapters, or introducing a more
powerful --range option, but concluded that --start --end is actually
enough.
These changes appear to take care of the last gross property/option
incompatibilities, although there might still be a few lurking.
2016-09-18 14:06:12 +00:00
|
|
|
mp_property_do(name, M_PROPERTY_GET_CONSTRICTED_TYPE, &prop, mpctx);
|
2020-03-13 15:49:39 +00:00
|
|
|
if ((osd_mode & MP_ON_OSD_BAR)) {
|
|
|
|
if (prop.type == CONF_TYPE_INT && prop.min < prop.max) {
|
2014-06-08 21:52:58 +00:00
|
|
|
int n = prop.min;
|
2017-08-23 12:23:37 +00:00
|
|
|
if (disp.osd_progbar)
|
|
|
|
n = disp.marker;
|
2012-09-21 12:05:52 +00:00
|
|
|
int i;
|
2014-09-21 21:40:45 +00:00
|
|
|
if (mp_property_do(name, M_PROPERTY_GET, &i, mpctx) > 0)
|
|
|
|
set_osd_bar(mpctx, disp.osd_progbar, prop.min, prop.max, n, i);
|
2020-03-13 15:49:39 +00:00
|
|
|
} else if (prop.type == CONF_TYPE_FLOAT && prop.min < prop.max) {
|
2014-06-08 21:52:58 +00:00
|
|
|
float n = prop.min;
|
2017-08-23 12:23:37 +00:00
|
|
|
if (disp.osd_progbar)
|
|
|
|
n = disp.marker;
|
2009-09-19 01:17:30 +00:00
|
|
|
float f;
|
2014-09-21 21:40:45 +00:00
|
|
|
if (mp_property_do(name, M_PROPERTY_GET, &f, mpctx) > 0)
|
|
|
|
set_osd_bar(mpctx, disp.osd_progbar, prop.min, prop.max, n, f);
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
2013-09-20 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (osd_mode & MP_ON_OSD_MSG) {
|
|
|
|
void *tmp = talloc_new(NULL);
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
const char *msg = disp.msg;
|
|
|
|
if (!msg)
|
|
|
|
msg = talloc_asprintf(tmp, "%s: ${%s}", disp.osd_name, name);
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
char *osd_msg = talloc_steal(tmp, mp_property_expand_string(mpctx, msg));
|
|
|
|
|
|
|
|
if (osd_msg && osd_msg[0])
|
|
|
|
set_osd_msg(mpctx, 1, opts->osd_duration, "%s", osd_msg);
|
|
|
|
|
|
|
|
talloc_free(tmp);
|
|
|
|
}
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-07-22 12:43:58 +00:00
|
|
|
static bool reinit_filters(MPContext *mpctx, enum stream_type mediatype)
|
|
|
|
{
|
|
|
|
switch (mediatype) {
|
|
|
|
case STREAM_VIDEO:
|
|
|
|
return reinit_video_filters(mpctx) >= 0;
|
|
|
|
case STREAM_AUDIO:
|
|
|
|
return reinit_audio_filters(mpctx) >= 0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-10 21:56:05 +00:00
|
|
|
static const char *const filter_opt[STREAM_TYPE_COUNT] = {
|
2013-08-03 11:38:40 +00:00
|
|
|
[STREAM_VIDEO] = "vf",
|
|
|
|
[STREAM_AUDIO] = "af",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int set_filters(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
struct m_obj_settings *new_chain)
|
2013-05-18 09:44:17 +00:00
|
|
|
{
|
2013-08-03 11:38:40 +00:00
|
|
|
bstr option = bstr0(filter_opt[mediatype]);
|
|
|
|
struct m_config_option *co = m_config_get_co(mpctx->mconfig, option);
|
|
|
|
if (!co)
|
|
|
|
return -1;
|
2013-07-22 12:43:58 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
struct m_obj_settings **list = co->data;
|
|
|
|
struct m_obj_settings *old_settings = *list;
|
|
|
|
*list = NULL;
|
|
|
|
m_option_copy(co->opt, list, &new_chain);
|
|
|
|
|
|
|
|
bool success = reinit_filters(mpctx, mediatype);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
m_option_free(co->opt, &old_settings);
|
2019-12-06 18:27:45 +00:00
|
|
|
m_config_notify_change_opt_ptr(mpctx->mconfig, list);
|
2013-08-03 11:38:40 +00:00
|
|
|
} else {
|
|
|
|
m_option_free(co->opt, list);
|
|
|
|
*list = old_settings;
|
2013-07-22 12:43:58 +00:00
|
|
|
}
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
return success ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
|
|
|
|
enum stream_type mediatype,
|
2013-08-03 11:38:40 +00:00
|
|
|
const char *cmd, const char *arg)
|
|
|
|
{
|
|
|
|
bstr option = bstr0(filter_opt[mediatype]);
|
|
|
|
struct m_config_option *co = m_config_get_co(mpctx->mconfig, option);
|
|
|
|
if (!co)
|
|
|
|
return -1;
|
|
|
|
|
2013-05-18 09:44:17 +00:00
|
|
|
// The option parser is used to modify the filter list itself.
|
|
|
|
char optname[20];
|
2013-08-03 11:38:40 +00:00
|
|
|
snprintf(optname, sizeof(optname), "%.*s-%s", BSTR_P(option), cmd);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
struct m_obj_settings *new_chain = NULL;
|
|
|
|
m_option_copy(co->opt, &new_chain, co->data);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
int r = m_option_parse(log, co->opt, bstr0(optname), bstr0(arg), &new_chain);
|
2013-08-03 11:38:40 +00:00
|
|
|
if (r >= 0)
|
|
|
|
r = set_filters(mpctx, mediatype, new_chain);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
m_option_free(co->opt, &new_chain);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
return r >= 0 ? 0 : -1;
|
2013-05-18 09:44:17 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 11:54:02 +00:00
|
|
|
static int edit_filters_osd(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
const char *cmd, const char *arg, bool on_osd)
|
|
|
|
{
|
2015-07-21 19:54:15 +00:00
|
|
|
int r = edit_filters(mpctx, mpctx->log, mediatype, cmd, arg);
|
2013-08-03 11:54:02 +00:00
|
|
|
if (on_osd) {
|
|
|
|
if (r >= 0) {
|
|
|
|
const char *prop = filter_opt[mediatype];
|
|
|
|
show_property_osd(mpctx, prop, MP_ON_OSD_MSG);
|
|
|
|
} else {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
|
2013-08-03 11:54:02 +00:00
|
|
|
"Changing filters failed!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-07-25 12:22:40 +00:00
|
|
|
static void recreate_overlays(struct MPContext *mpctx)
|
2013-09-30 20:27:37 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2016-07-01 17:39:04 +00:00
|
|
|
int overlay_next = !cmd->overlay_osd_current;
|
|
|
|
struct sub_bitmaps *new = &cmd->overlay_osd[overlay_next];
|
2022-01-11 20:03:27 +00:00
|
|
|
new->format = SUBBITMAP_BGRA;
|
2015-03-18 11:33:14 +00:00
|
|
|
new->change_id = 1;
|
2016-07-01 17:39:04 +00:00
|
|
|
|
|
|
|
bool valid = false;
|
|
|
|
|
2014-07-25 12:22:40 +00:00
|
|
|
new->num_parts = 0;
|
|
|
|
for (int n = 0; n < cmd->num_overlays; n++) {
|
2014-10-02 23:22:07 +00:00
|
|
|
struct overlay *o = &cmd->overlays[n];
|
2016-07-01 17:39:04 +00:00
|
|
|
if (o->source) {
|
|
|
|
struct mp_image *s = o->source;
|
|
|
|
struct sub_bitmap b = {
|
|
|
|
.bitmap = s->planes[0],
|
|
|
|
.stride = s->stride[0],
|
|
|
|
.w = s->w, .dw = s->w,
|
|
|
|
.h = s->h, .dh = s->h,
|
|
|
|
.x = o->x,
|
|
|
|
.y = o->y,
|
|
|
|
};
|
|
|
|
MP_TARRAY_APPEND(cmd, new->parts, new->num_parts, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cmd->overlay_packer)
|
|
|
|
cmd->overlay_packer = talloc_zero(cmd, struct bitmap_packer);
|
|
|
|
|
|
|
|
cmd->overlay_packer->padding = 1; // assume bilinear scaling
|
|
|
|
packer_set_size(cmd->overlay_packer, new->num_parts);
|
|
|
|
|
|
|
|
for (int n = 0; n < new->num_parts; n++)
|
|
|
|
cmd->overlay_packer->in[n] = (struct pos){new->parts[n].w, new->parts[n].h};
|
|
|
|
|
|
|
|
if (packer_pack(cmd->overlay_packer) < 0 || new->num_parts == 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
struct pos bb[2];
|
|
|
|
packer_get_bb(cmd->overlay_packer, bb);
|
|
|
|
|
|
|
|
new->packed_w = bb[1].x;
|
|
|
|
new->packed_h = bb[1].y;
|
|
|
|
|
|
|
|
if (!new->packed || new->packed->w < new->packed_w ||
|
|
|
|
new->packed->h < new->packed_h)
|
|
|
|
{
|
|
|
|
talloc_free(new->packed);
|
|
|
|
new->packed = mp_image_alloc(IMGFMT_BGRA, cmd->overlay_packer->w,
|
|
|
|
cmd->overlay_packer->h);
|
|
|
|
if (!new->packed)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
video: make OSD/subtitle bitmaps refcounted (sort of)
Making OSD/subtitle bitmaps refcounted was planend a longer time ago,
e.g. the sub_bitmaps.packed field (which refcounts the subtitle bitmap
data) was added in 2016. But nothing benefited much from it, because
struct sub_bitmaps was usually stack allocated, and there was this weird
callback stuff through osd_draw().
Make it possible to get actually refcounted subtitle bitmaps on the OSD
API level. For this, we just copy all subtitle data other than the
bitmaps with sub_bitmaps_copy(). At first, I had planned some fancy
refcount shit, but when that was a big mess and hard to debug and just
boiled to emulating malloc(), I made it a full allocation+copy. This
affects mostly the parts array. With crazy ASS subtitles, this parts
array can get pretty big (thousands of elements or more), in which case
the extra alloc/copy could become performance relevant. But then again
this is just pure bullshit, and I see no need to care. In practice, this
extra work most likely gets drowned out by libass murdering a single
core (while mpv is waiting for it) anyway. So fuck it.
I just wanted this so draw_bmp.c requires only a single call to render
everything. VOs also can benefit from this, because the weird callback
shit isn't necessary anymore (simpler code), but I haven't done anything
about it yet. In general I'd hope this will work towards simplifying the
OSD layer, which is prerequisite for making actual further improvements.
I haven't tested some cases such as the "overlay-add" command. Maybe it
crashes now? Who knows, who cares.
In addition, it might be worthwhile to reduce the code duplication
between all the things that output subtitle bitmaps (with repacking,
image allocation, etc.), but that's orthogonal.
2020-04-26 21:34:32 +00:00
|
|
|
if (!mp_image_make_writeable(new->packed))
|
|
|
|
goto done;
|
|
|
|
|
2016-07-01 17:39:04 +00:00
|
|
|
// clear padding
|
|
|
|
mp_image_clear(new->packed, 0, 0, new->packed->w, new->packed->h);
|
|
|
|
|
|
|
|
for (int n = 0; n < new->num_parts; n++) {
|
|
|
|
struct sub_bitmap *b = &new->parts[n];
|
|
|
|
struct pos pos = cmd->overlay_packer->result[n];
|
|
|
|
|
|
|
|
int stride = new->packed->stride[0];
|
|
|
|
void *pdata = (uint8_t *)new->packed->planes[0] + pos.y * stride + pos.x * 4;
|
|
|
|
memcpy_pic(pdata, b->bitmap, b->w * 4, b->h, stride, b->stride);
|
|
|
|
|
|
|
|
b->bitmap = pdata;
|
|
|
|
b->stride = stride;
|
|
|
|
|
|
|
|
b->src_x = pos.x;
|
|
|
|
b->src_y = pos.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
valid = true;
|
|
|
|
done:
|
|
|
|
if (!valid) {
|
|
|
|
new->format = SUBBITMAP_EMPTY;
|
|
|
|
new->num_parts = 0;
|
2014-07-25 12:22:40 +00:00
|
|
|
}
|
2016-07-01 17:39:04 +00:00
|
|
|
|
|
|
|
osd_set_external2(mpctx->osd, new);
|
2018-01-23 22:52:58 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
2016-07-01 17:39:04 +00:00
|
|
|
cmd->overlay_osd_current = overlay_next;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
// Set overlay with the given ID to the contents as described by "new".
|
|
|
|
static void replace_overlay(struct MPContext *mpctx, int id, struct overlay *new)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
assert(id >= 0);
|
|
|
|
if (id >= cmd->num_overlays) {
|
|
|
|
MP_TARRAY_GROW(cmd, cmd->overlays, id);
|
|
|
|
while (cmd->num_overlays <= id)
|
|
|
|
cmd->overlays[cmd->num_overlays++] = (struct overlay){0};
|
|
|
|
}
|
|
|
|
|
|
|
|
struct overlay *ptr = &cmd->overlays[id];
|
|
|
|
|
2016-07-01 17:39:04 +00:00
|
|
|
talloc_free(ptr->source);
|
2014-10-02 23:22:07 +00:00
|
|
|
*ptr = *new;
|
|
|
|
|
2016-07-01 17:39:04 +00:00
|
|
|
recreate_overlays(mpctx);
|
2014-10-02 23:22:07 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_overlay_add(void *pcmd)
|
2013-09-30 20:27:37 +00:00
|
|
|
{
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct mp_cmd_ctx *cmd = pcmd;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int id = cmd->args[0].v.i, x = cmd->args[1].v.i, y = cmd->args[2].v.i;
|
|
|
|
char *file = cmd->args[3].v.s;
|
|
|
|
int offset = cmd->args[4].v.i;
|
|
|
|
char *fmt = cmd->args[5].v.s;
|
|
|
|
int w = cmd->args[6].v.i, h = cmd->args[7].v.i, stride = cmd->args[8].v.i;
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
if (strcmp(fmt, "bgra") != 0) {
|
2016-07-14 18:04:59 +00:00
|
|
|
MP_ERR(mpctx, "overlay-add: unsupported OSD format '%s'\n", fmt);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2014-07-25 12:22:40 +00:00
|
|
|
if (id < 0 || id >= 64) { // arbitrary upper limit
|
2016-07-14 18:04:59 +00:00
|
|
|
MP_ERR(mpctx, "overlay-add: invalid id %d\n", id);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2016-07-01 17:39:04 +00:00
|
|
|
if (w <= 0 || h <= 0 || stride < w * 4 || (stride % 4)) {
|
2016-07-14 18:04:59 +00:00
|
|
|
MP_ERR(mpctx, "overlay-add: inconsistent parameters\n");
|
2014-10-02 23:22:07 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
struct overlay overlay = {
|
2016-07-01 17:39:04 +00:00
|
|
|
.source = mp_image_alloc(IMGFMT_BGRA, w, h),
|
|
|
|
.x = x,
|
|
|
|
.y = y,
|
2014-10-02 23:22:07 +00:00
|
|
|
};
|
2016-07-01 17:39:04 +00:00
|
|
|
if (!overlay.source)
|
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
int fd = -1;
|
|
|
|
bool close_fd = true;
|
2014-12-26 16:43:59 +00:00
|
|
|
void *p = NULL;
|
2013-09-30 20:27:37 +00:00
|
|
|
if (file[0] == '@') {
|
|
|
|
char *end;
|
|
|
|
fd = strtol(&file[1], &end, 10);
|
|
|
|
if (!file[1] || end[0])
|
|
|
|
fd = -1;
|
|
|
|
close_fd = false;
|
2014-10-02 23:24:48 +00:00
|
|
|
} else if (file[0] == '&') {
|
|
|
|
char *end;
|
|
|
|
unsigned long long addr = strtoull(&file[1], &end, 0);
|
|
|
|
if (!file[1] || end[0])
|
|
|
|
addr = 0;
|
|
|
|
p = (void *)(uintptr_t)addr;
|
2013-09-30 20:27:37 +00:00
|
|
|
} else {
|
2013-11-30 21:40:51 +00:00
|
|
|
fd = open(file, O_RDONLY | O_BINARY | O_CLOEXEC);
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2016-07-01 17:39:04 +00:00
|
|
|
int map_size = 0;
|
2014-10-02 23:22:07 +00:00
|
|
|
if (fd >= 0) {
|
2016-07-01 17:39:04 +00:00
|
|
|
map_size = offset + h * stride;
|
|
|
|
void *m = mmap(NULL, map_size, PROT_READ, MAP_SHARED, fd, 0);
|
2014-10-02 23:22:07 +00:00
|
|
|
if (close_fd)
|
|
|
|
close(fd);
|
2016-07-01 17:39:04 +00:00
|
|
|
if (m && m != MAP_FAILED)
|
2014-12-26 16:43:59 +00:00
|
|
|
p = m;
|
2014-10-02 23:22:07 +00:00
|
|
|
}
|
2014-12-26 16:43:59 +00:00
|
|
|
if (!p) {
|
2016-07-14 18:04:59 +00:00
|
|
|
MP_ERR(mpctx, "overlay-add: could not open or map '%s'\n", file);
|
2016-07-01 17:39:04 +00:00
|
|
|
talloc_free(overlay.source);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2016-07-01 17:39:04 +00:00
|
|
|
memcpy_pic(overlay.source->planes[0], (char *)p + offset, w * 4, h,
|
|
|
|
overlay.source->stride[0], stride);
|
|
|
|
if (map_size)
|
|
|
|
munmap(p, map_size);
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
replace_overlay(mpctx, id, &overlay);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
return;
|
2014-01-18 00:19:20 +00:00
|
|
|
error:
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_overlay_remove(void *p)
|
2013-09-30 20:27:37 +00:00
|
|
|
{
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
struct command_ctx *cmdctx = mpctx->command_ctx;
|
|
|
|
int id = cmd->args[0].v.i;
|
|
|
|
if (id >= 0 && id < cmdctx->num_overlays)
|
2014-10-02 23:22:07 +00:00
|
|
|
replace_overlay(mpctx, id, &(struct overlay){0});
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void overlay_uninit(struct MPContext *mpctx)
|
|
|
|
{
|
2014-07-25 12:22:40 +00:00
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2014-01-18 16:59:34 +00:00
|
|
|
if (!mpctx->osd)
|
|
|
|
return;
|
2014-07-25 12:22:40 +00:00
|
|
|
for (int id = 0; id < cmd->num_overlays; id++)
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
replace_overlay(mpctx, id, &(struct overlay){0});
|
2014-01-18 00:19:20 +00:00
|
|
|
osd_set_external2(mpctx->osd, NULL);
|
2016-07-01 17:39:04 +00:00
|
|
|
for (int n = 0; n < 2; n++)
|
|
|
|
mp_image_unrefp(&cmd->overlay_osd[n].packed);
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
static void cmd_osd_overlay(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2020-03-06 17:20:11 +00:00
|
|
|
double rc[4] = {0};
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
|
|
|
|
struct osd_external_ass ov = {
|
|
|
|
.owner = cmd->cmd->sender,
|
|
|
|
.id = cmd->args[0].v.i64,
|
|
|
|
.format = cmd->args[1].v.i,
|
|
|
|
.data = cmd->args[2].v.s,
|
|
|
|
.res_x = cmd->args[3].v.i,
|
|
|
|
.res_y = cmd->args[4].v.i,
|
|
|
|
.z = cmd->args[5].v.i,
|
2023-02-20 05:44:22 +00:00
|
|
|
.hidden = cmd->args[6].v.b,
|
|
|
|
.out_rc = cmd->args[7].v.b ? rc : NULL,
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
osd_set_external(mpctx->osd, &ov);
|
2020-03-06 17:20:11 +00:00
|
|
|
|
|
|
|
struct mpv_node *res = &cmd->result;
|
|
|
|
node_init(res, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
|
|
|
|
// (An empty rc uses INFINITY, avoid in JSON, just leave it unset.)
|
|
|
|
if (rc[0] < rc[2] && rc[1] < rc[3]) {
|
|
|
|
node_map_add_double(res, "x0", rc[0]);
|
|
|
|
node_map_add_double(res, "y0", rc[1]);
|
|
|
|
node_map_add_double(res, "x1", rc[2]);
|
|
|
|
node_map_add_double(res, "y1", rc[3]);
|
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
2014-10-23 11:11:41 +00:00
|
|
|
static struct track *find_track_with_url(struct MPContext *mpctx, int type,
|
|
|
|
const char *url)
|
|
|
|
{
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *track = mpctx->tracks[n];
|
|
|
|
if (track && track->type == type && track->is_external &&
|
|
|
|
strcmp(track->external_filename, url) == 0)
|
|
|
|
return track;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-27 23:33:52 +00:00
|
|
|
// Whether this property should react to key events generated by auto-repeat.
|
|
|
|
static bool check_property_autorepeat(char *property, struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct m_option prop = {0};
|
|
|
|
if (mp_property_do(property, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// This is a heuristic at best.
|
options: introduce bool option type, use it for --fullscreen
The option code is very old and was added to MPlayer in the early 2000s,
when C99 was still new. MPlayer did not use the "bool" type anywhere,l
and the logical option equivalent to bool, the "flag" option type, used
int, with the convention that only the values 0 and 1 are allowed.
mpv may have hammered many, many additional tentacles to the option
code, but some of the basics never changed, and m_option_type_flag still
uses int. This seems a bit weird, since mpv uses bool for booleans. So
finally introduce an m_option_type_bool. To avoid duplicating too much
code, change the flag code to bool, and "reimplement" m_option_type_flag
on top of m_option_type_bool.
As a "demonstration", change the --fullscreen option to this new type.
Ideally, all options would be changed too bool, and m_option_type_flag
would be removed. But that is a lot of monotonous thankless work, so I'm
not doing it, and making it a painful years long transition.
At the same time, I'm introducing a new concept for option declarations.
Instead of OPT_BOOL(), which define the full m_option struct contents,
there's OPTF_BOOL(), which only takes the option field name itself. The
name is provided via a normal struct field initializer. Other fields
(such as flags) can be provided via designated initializers.
The advantage of this is that we don't need tons of nested vararg
macros. We also don't need to deal with 0-sized varargs being a pain
(and in fact they are not a thing in standard C99 and probably C11).
There is no need to provide a mandatory flags argument either, which is
the reason why so many OPT_ macros are used with a "0" argument. (The
flag argument seems to confuse other developers; they either don't
immediately recognize what it is, and sometimes it's supposed to be the
option's default value.)
Not having to mess with the flag argument in such option macros is also
a reason for the removal of M_OPT_RANGE etc., for the better or worse.
The only place that special-cased the _flag option type was in
command.c; change it to use something effectively very similar that
automatically includes the new _bool option type. Everything else should
be transparent to the change. The fullscreen option change should be
transparent too, as C99 bool is basically an integer type that is
clamped to 0/1 (except in Swift, Swift sucks).
2020-03-14 01:07:35 +00:00
|
|
|
if (prop.type->flags & M_OPT_TYPE_CHOICE)
|
2013-10-27 23:33:52 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-25 08:03:06 +00:00
|
|
|
// Whether changes to this property (add/cycle cmds) benefit from cmd->scale
|
|
|
|
static bool check_property_scalable(char *property, struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct m_option prop = {0};
|
|
|
|
if (mp_property_do(property, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// These properties are backed by a floating-point number
|
|
|
|
return prop.type == &m_option_type_float ||
|
|
|
|
prop.type == &m_option_type_double ||
|
|
|
|
prop.type == &m_option_type_time ||
|
|
|
|
prop.type == &m_option_type_aspect;
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void show_property_status(struct mp_cmd_ctx *cmd, const char *name, int r)
|
2018-03-23 14:31:54 +00:00
|
|
|
{
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2018-03-23 14:31:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
int osd_duration = opts->osd_duration;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
2018-03-23 14:31:54 +00:00
|
|
|
|
|
|
|
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
show_property_osd(mpctx, name, cmd->on_osd);
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
if (r == M_PROPERTY_UNAVAILABLE)
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
2018-03-23 14:31:54 +00:00
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Unknown property: '%s'", name);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
2018-03-23 14:31:54 +00:00
|
|
|
} else if (r <= 0) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Failed to set property '%s'",
|
|
|
|
name);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
2018-03-23 14:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void change_property_cmd(struct mp_cmd_ctx *cmd,
|
|
|
|
const char *name, int action, void *arg)
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
{
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
int r = mp_property_do(name, action, arg, cmd->mpctx);
|
|
|
|
show_property_status(cmd, name, r);
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_cycle_values(void *p)
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
{
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
int first = 0, dir = 1;
|
|
|
|
|
|
|
|
if (strcmp(cmd->args[first].v.s, "!reverse") == 0) {
|
|
|
|
first += 1;
|
|
|
|
dir = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name = cmd->args[first].v.s;
|
|
|
|
first += 1;
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (first >= cmd->num_args) {
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
MP_ERR(mpctx, "cycle-values command does not have any value arguments.\n");
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
|
|
|
return;
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct m_option prop = {0};
|
|
|
|
int r = mp_property_do(name, M_PROPERTY_GET_TYPE, &prop, mpctx);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (r <= 0) {
|
|
|
|
show_property_status(cmd, name, r);
|
|
|
|
return;
|
|
|
|
}
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
|
|
|
|
union m_option_value curval = {0};
|
|
|
|
r = mp_property_do(name, M_PROPERTY_GET, &curval, mpctx);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (r <= 0) {
|
|
|
|
show_property_status(cmd, name, r);
|
|
|
|
return;
|
|
|
|
}
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
|
|
|
|
int current = -1;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
for (int n = first; n < cmd->num_args; n++) {
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
union m_option_value val = {0};
|
|
|
|
if (m_option_parse(mpctx->log, &prop, bstr0(name),
|
2018-05-01 10:31:32 +00:00
|
|
|
bstr0(cmd->args[n].v.s), &val) < 0)
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
continue;
|
|
|
|
|
2019-11-28 17:01:48 +00:00
|
|
|
if (m_option_equal(&prop, &curval, &val))
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
current = n;
|
|
|
|
|
|
|
|
m_option_free(&prop, &val);
|
|
|
|
|
|
|
|
if (current >= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_option_free(&prop, &curval);
|
|
|
|
|
|
|
|
if (current >= 0) {
|
|
|
|
current += dir;
|
|
|
|
if (current < first)
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
current = cmd->num_args - 1;
|
|
|
|
if (current >= cmd->num_args)
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
current = first;
|
|
|
|
} else {
|
|
|
|
MP_VERBOSE(mpctx, "Current value not found. Picking default.\n");
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
current = dir > 0 ? first : cmd->num_args - 1;
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
change_property_cmd(cmd, name, M_PROPERTY_SET_STRING, cmd->args[current].v.s);
|
command: change cycle-value command behavior
Instead of using an internal counter to keep track of the value that was
set last, attempt to find the current value of the property/option in
the value list, and then set the next value in the list.
There are some potential problems. If a property refuses to accept a
specific value, the cycle-values command will fail, and start from the
same position again. It can't know that it's supposed to skip the next
value. The same can happen to properties which behave "strangely", such
as the "aspect" property, which will return the current aspect if you
write "-1" to it. As a consequence, cycle-values can appear to get
"stuck".
I still think the new behavior is what users expect more, and which is
generally more useful. We won't restore the ability to get the old
behavior, unless we decide to revert this commit entirely.
Fixes #5772, and hopefully other complaints.
2018-04-28 16:14:43 +00:00
|
|
|
}
|
|
|
|
|
2018-05-06 16:27:18 +00:00
|
|
|
struct cmd_list_ctx {
|
|
|
|
struct MPContext *mpctx;
|
|
|
|
|
|
|
|
// actual list command
|
|
|
|
struct mp_cmd_ctx *parent;
|
|
|
|
|
|
|
|
bool current_valid;
|
|
|
|
pthread_t current;
|
|
|
|
bool completed_recursive;
|
|
|
|
|
|
|
|
// list of sub commands yet to run
|
|
|
|
struct mp_cmd **sub;
|
|
|
|
int num_sub;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void continue_cmd_list(struct cmd_list_ctx *list);
|
|
|
|
|
|
|
|
static void on_cmd_list_sub_completion(struct mp_cmd_ctx *cmd)
|
|
|
|
{
|
|
|
|
struct cmd_list_ctx *list = cmd->on_completion_priv;
|
|
|
|
|
|
|
|
if (list->current_valid && pthread_equal(list->current, pthread_self())) {
|
|
|
|
list->completed_recursive = true;
|
|
|
|
} else {
|
|
|
|
continue_cmd_list(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void continue_cmd_list(struct cmd_list_ctx *list)
|
|
|
|
{
|
|
|
|
while (list->parent->args[0].v.p) {
|
|
|
|
struct mp_cmd *sub = list->parent->args[0].v.p;
|
|
|
|
list->parent->args[0].v.p = sub->queue_next;
|
|
|
|
|
2020-02-23 18:48:25 +00:00
|
|
|
ta_set_parent(sub, NULL);
|
2018-05-06 16:27:18 +00:00
|
|
|
|
|
|
|
if (sub->flags & MP_ASYNC_CMD) {
|
|
|
|
// We run it "detached" (fire & forget)
|
2018-05-12 16:46:37 +00:00
|
|
|
run_command(list->mpctx, sub, NULL, NULL, NULL);
|
2018-05-06 16:27:18 +00:00
|
|
|
} else {
|
|
|
|
// Run the next command once this one completes.
|
|
|
|
|
|
|
|
list->completed_recursive = false;
|
|
|
|
list->current_valid = true;
|
|
|
|
list->current = pthread_self();
|
|
|
|
|
2018-05-12 16:46:37 +00:00
|
|
|
run_command(list->mpctx, sub, NULL, on_cmd_list_sub_completion, list);
|
2018-05-06 16:27:18 +00:00
|
|
|
|
|
|
|
list->current_valid = false;
|
|
|
|
|
|
|
|
// run_command() either recursively calls the completion function,
|
|
|
|
// or lets the command continue run in the background. If it was
|
|
|
|
// completed recursively, we can just continue our loop. Otherwise
|
|
|
|
// the completion handler will invoke this loop again elsewhere.
|
|
|
|
// We could unconditionally call continue_cmd_list() in the handler
|
|
|
|
// instead, but then stack depth would grow with list length.
|
|
|
|
if (!list->completed_recursive)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mp_cmd_ctx_complete(list->parent);
|
|
|
|
talloc_free(list);
|
|
|
|
}
|
|
|
|
|
2018-05-05 18:20:21 +00:00
|
|
|
static void cmd_list(void *p)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2018-05-05 18:20:21 +00:00
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
|
2018-05-06 16:27:18 +00:00
|
|
|
cmd->completed = false;
|
|
|
|
|
|
|
|
struct cmd_list_ctx *list = talloc_zero(NULL, struct cmd_list_ctx);
|
|
|
|
list->mpctx = cmd->mpctx;
|
|
|
|
list->parent = p;
|
|
|
|
|
|
|
|
continue_cmd_list(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct mp_cmd_def mp_cmd_list = { "list", cmd_list, .exec_async = true };
|
|
|
|
|
|
|
|
// Signal that the command is complete now. This also deallocates cmd.
|
|
|
|
// You must call this function in a state where the core is locked for the
|
|
|
|
// current thread (e.g. from the main thread, or from within mp_dispatch_lock()).
|
|
|
|
// Completion means the command is finished, even if it errored or never ran.
|
|
|
|
// Keep in mind that calling this can execute further user command that can
|
|
|
|
// change arbitrary state (due to cmd_list).
|
|
|
|
void mp_cmd_ctx_complete(struct mp_cmd_ctx *cmd)
|
|
|
|
{
|
|
|
|
cmd->completed = true;
|
|
|
|
if (!cmd->success)
|
|
|
|
mpv_free_node_contents(&cmd->result);
|
|
|
|
if (cmd->on_completion)
|
|
|
|
cmd->on_completion(cmd);
|
2018-05-12 16:46:37 +00:00
|
|
|
if (cmd->abort)
|
|
|
|
mp_abort_remove(cmd->mpctx, cmd->abort);
|
2018-05-06 16:27:18 +00:00
|
|
|
mpv_free_node_contents(&cmd->result);
|
|
|
|
talloc_free(cmd);
|
2018-05-05 18:20:21 +00:00
|
|
|
}
|
|
|
|
|
2018-05-06 16:27:18 +00:00
|
|
|
static void run_command_on_worker_thread(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *ctx = p;
|
|
|
|
struct MPContext *mpctx = ctx->mpctx;
|
|
|
|
|
|
|
|
mp_core_lock(mpctx);
|
|
|
|
|
|
|
|
bool exec_async = ctx->cmd->def->exec_async;
|
|
|
|
ctx->cmd->def->handler(ctx);
|
|
|
|
if (!exec_async)
|
|
|
|
mp_cmd_ctx_complete(ctx);
|
2018-05-05 18:20:21 +00:00
|
|
|
|
2018-05-06 16:27:18 +00:00
|
|
|
mpctx->outstanding_async -= 1;
|
|
|
|
if (!mpctx->outstanding_async && mp_is_shutting_down(mpctx))
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
|
|
|
|
mp_core_unlock(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run the given command. Upon command completion, on_completion is called. This
|
|
|
|
// can happen within the function, or for async commands, some time after the
|
|
|
|
// function returns (the caller is supposed to be able to handle both cases). In
|
|
|
|
// both cases, the callback will be called while the core is locked (i.e. you
|
|
|
|
// can access the core freely).
|
2018-05-12 16:46:37 +00:00
|
|
|
// If abort is non-NULL, then the caller creates the abort object. It must have
|
|
|
|
// been allocated with talloc. run_command() will register/unregister/destroy
|
|
|
|
// it. Must not be set if cmd->def->can_abort==false.
|
2018-05-06 16:27:18 +00:00
|
|
|
// on_completion_priv is copied to mp_cmd_ctx.on_completion_priv and can be
|
|
|
|
// accessed from the completion callback.
|
|
|
|
// The completion callback is invoked exactly once. If it's NULL, it's ignored.
|
|
|
|
// Ownership of cmd goes to the caller.
|
|
|
|
void run_command(struct MPContext *mpctx, struct mp_cmd *cmd,
|
2018-05-12 16:46:37 +00:00
|
|
|
struct mp_abort_entry *abort,
|
2018-05-06 16:27:18 +00:00
|
|
|
void (*on_completion)(struct mp_cmd_ctx *cmd),
|
|
|
|
void *on_completion_priv)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2018-05-06 16:27:18 +00:00
|
|
|
struct mp_cmd_ctx *ctx = talloc(NULL, struct mp_cmd_ctx);
|
|
|
|
*ctx = (struct mp_cmd_ctx){
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
.mpctx = mpctx,
|
2018-05-12 16:46:37 +00:00
|
|
|
.cmd = talloc_steal(ctx, cmd),
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
.args = cmd->args,
|
|
|
|
.num_args = cmd->nargs,
|
|
|
|
.priv = cmd->def->priv,
|
2018-05-12 16:46:37 +00:00
|
|
|
.abort = talloc_steal(ctx, abort),
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
.success = true,
|
2018-05-06 16:27:18 +00:00
|
|
|
.completed = true,
|
|
|
|
.on_completion = on_completion,
|
|
|
|
.on_completion_priv = on_completion_priv,
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
};
|
2018-01-21 23:36:08 +00:00
|
|
|
|
2018-05-12 16:46:37 +00:00
|
|
|
if (!ctx->abort && cmd->def->can_abort)
|
|
|
|
ctx->abort = talloc_zero(ctx, struct mp_abort_entry);
|
|
|
|
|
|
|
|
assert(cmd->def->can_abort == !!ctx->abort);
|
|
|
|
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
if (ctx->abort) {
|
|
|
|
ctx->abort->coupled_to_playback |= cmd->def->abort_on_playback_end;
|
2018-05-12 16:46:37 +00:00
|
|
|
mp_abort_add(mpctx, ctx->abort);
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
}
|
2018-05-12 16:46:37 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
ctx->on_osd = cmd->flags & MP_ON_OSD_FLAGS;
|
|
|
|
bool auto_osd = ctx->on_osd == MP_ON_OSD_AUTO;
|
|
|
|
ctx->msg_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_MSG);
|
|
|
|
ctx->bar_osd = auto_osd || (ctx->on_osd & MP_ON_OSD_BAR);
|
|
|
|
ctx->seek_msg_osd = auto_osd ? opts->osd_on_seek & 2 : ctx->msg_osd;
|
|
|
|
ctx->seek_bar_osd = auto_osd ? opts->osd_on_seek & 1 : ctx->bar_osd;
|
2013-05-18 10:56:22 +00:00
|
|
|
|
2019-12-19 11:50:10 +00:00
|
|
|
bool noise = cmd->def->is_noisy || cmd->mouse_move;
|
|
|
|
mp_cmd_dump(mpctx->log, noise ? MSGL_TRACE : MSGL_DEBUG, "Run command:", cmd);
|
2014-10-23 12:40:38 +00:00
|
|
|
|
2013-12-15 22:35:36 +00:00
|
|
|
if (cmd->flags & MP_EXPAND_PROPERTIES) {
|
2013-05-18 10:56:22 +00:00
|
|
|
for (int n = 0; n < cmd->nargs; n++) {
|
2013-11-28 18:04:16 +00:00
|
|
|
if (cmd->args[n].type->type == CONF_TYPE_STRING) {
|
2014-02-23 16:43:38 +00:00
|
|
|
char *s = mp_property_expand_string(mpctx, cmd->args[n].v.s);
|
2018-05-06 16:27:18 +00:00
|
|
|
if (!s) {
|
|
|
|
ctx->success = false;
|
|
|
|
mp_cmd_ctx_complete(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2014-02-23 16:43:38 +00:00
|
|
|
talloc_free(cmd->args[n].v.s);
|
|
|
|
cmd->args[n].v.s = s;
|
2013-05-18 10:56:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-06 16:27:18 +00:00
|
|
|
if (cmd->def->spawn_thread) {
|
|
|
|
mpctx->outstanding_async += 1; // prevent that core disappears
|
|
|
|
if (!mp_thread_pool_queue(mpctx->thread_pool,
|
|
|
|
run_command_on_worker_thread, ctx))
|
|
|
|
{
|
|
|
|
mpctx->outstanding_async -= 1;
|
|
|
|
ctx->success = false;
|
|
|
|
mp_cmd_ctx_complete(ctx);
|
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
} else {
|
2018-05-06 16:27:18 +00:00
|
|
|
bool exec_async = cmd->def->exec_async;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->def->handler(ctx);
|
2018-05-06 16:27:18 +00:00
|
|
|
if (!exec_async)
|
|
|
|
mp_cmd_ctx_complete(ctx);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-07 16:00:19 +00:00
|
|
|
// When a command shows a message. status is the level (e.g. MSGL_INFO), and
|
|
|
|
// msg+vararg is as in printf (don't include a trailing "\n").
|
|
|
|
void mp_cmd_msg(struct mp_cmd_ctx *cmd, int status, const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
va_start(ap, msg);
|
|
|
|
s = talloc_vasprintf(NULL, msg, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
MP_MSG(cmd->mpctx, status, "%s\n", s);
|
|
|
|
if (cmd->msg_osd && status <= MSGL_INFO)
|
|
|
|
set_osd_msg(cmd->mpctx, 1, cmd->mpctx->opts->osd_duration, "%s", s);
|
|
|
|
|
|
|
|
talloc_free(s);
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_seek(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
double v = cmd->args[0].v.d * cmd->cmd->scale;
|
|
|
|
int abs = cmd->args[1].v.i & 3;
|
|
|
|
enum seek_precision precision = MPSEEK_DEFAULT;
|
|
|
|
switch (((cmd->args[2].v.i | cmd->args[1].v.i) >> 3) & 3) {
|
|
|
|
case 1: precision = MPSEEK_KEYFRAME; break;
|
|
|
|
case 2: precision = MPSEEK_EXACT; break;
|
|
|
|
}
|
|
|
|
if (!mpctx->playback_initialized) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mark_seek(mpctx);
|
|
|
|
switch (abs) {
|
|
|
|
case 0: { // Relative seek
|
|
|
|
queue_seek(mpctx, MPSEEK_RELATIVE, v, precision, MPSEEK_FLAG_DELAY);
|
|
|
|
set_osd_function(mpctx, (v > 0) ? OSD_FFW : OSD_REW);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: { // Absolute seek by percentage
|
|
|
|
double ratio = v / 100.0;
|
|
|
|
double cur_pos = get_current_pos_ratio(mpctx, false);
|
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, ratio, precision, MPSEEK_FLAG_DELAY);
|
|
|
|
set_osd_function(mpctx, cur_pos < ratio ? OSD_FFW : OSD_REW);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: { // Absolute seek to a timestamp in seconds
|
|
|
|
if (v < 0) {
|
|
|
|
// Seek from end
|
|
|
|
double len = get_time_length(mpctx);
|
|
|
|
if (len < 0) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2016-10-01 18:51:17 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
v = MPMAX(0, len + v);
|
2015-05-20 11:26:36 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, MPSEEK_FLAG_DELAY);
|
|
|
|
set_osd_function(mpctx,
|
|
|
|
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: { // Relative seek by percentage
|
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR,
|
|
|
|
get_current_pos_ratio(mpctx, false) + v / 100.0,
|
|
|
|
precision, MPSEEK_FLAG_DELAY);
|
|
|
|
set_osd_function(mpctx, v > 0 ? OSD_FFW : OSD_REW);
|
|
|
|
break;
|
|
|
|
}}
|
|
|
|
if (cmd->seek_bar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
|
|
|
if (cmd->seek_msg_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_revert_seek(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
struct command_ctx *cmdctx = mpctx->command_ctx;
|
|
|
|
|
|
|
|
if (!mpctx->playback_initialized) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double oldpts = cmdctx->last_seek_pts;
|
|
|
|
if (cmdctx->marked_pts != MP_NOPTS_VALUE)
|
|
|
|
oldpts = cmdctx->marked_pts;
|
2020-07-17 12:21:42 +00:00
|
|
|
if (cmd->args[0].v.i & 3) {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmdctx->marked_pts = get_current_time(mpctx);
|
2020-07-17 12:21:42 +00:00
|
|
|
cmdctx->marked_permanent = cmd->args[0].v.i & 1;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
} else if (oldpts != MP_NOPTS_VALUE) {
|
2020-07-17 12:21:42 +00:00
|
|
|
if (!cmdctx->marked_permanent) {
|
|
|
|
cmdctx->marked_pts = MP_NOPTS_VALUE;
|
|
|
|
cmdctx->last_seek_pts = get_current_time(mpctx);
|
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, MPSEEK_EXACT,
|
|
|
|
MPSEEK_FLAG_DELAY);
|
|
|
|
set_osd_function(mpctx, OSD_REW);
|
|
|
|
if (cmd->seek_bar_osd)
|
2012-09-25 01:24:38 +00:00
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (cmd->seek_msg_osd)
|
2012-09-25 01:24:38 +00:00
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
} else {
|
|
|
|
cmd->success = false;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_set(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
|
|
|
|
change_property_cmd(cmd, cmd->args[0].v.s,
|
|
|
|
M_PROPERTY_SET_STRING, cmd->args[1].v.s);
|
|
|
|
}
|
|
|
|
|
2022-12-16 21:01:54 +00:00
|
|
|
static void cmd_del(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
const char *name = cmd->args[0].v.s;
|
|
|
|
int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
|
|
|
int osd_duration = mpctx->opts->osd_duration;
|
|
|
|
|
|
|
|
int r = mp_property_do(name, M_PROPERTY_DELETE, NULL, mpctx);
|
|
|
|
|
|
|
|
if (r == M_PROPERTY_OK) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Deleted property: '%s'", name);
|
|
|
|
cmd->success = true;
|
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Unknown property: '%s'", name);
|
|
|
|
cmd->success = false;
|
|
|
|
} else if (r <= 0) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Failed to set property '%s'",
|
|
|
|
name);
|
|
|
|
cmd->success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_change_list(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
char *name = cmd->args[0].v.s;
|
|
|
|
char *op = cmd->args[1].v.s;
|
|
|
|
char *value = cmd->args[2].v.s;
|
|
|
|
int osd_duration = mpctx->opts->osd_duration;
|
|
|
|
int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
|
|
|
|
2019-12-18 06:50:08 +00:00
|
|
|
struct m_option prop = {0};
|
|
|
|
if (mp_property_do(name, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0) {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Unknown option: '%s'", name);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2013-12-01 01:07:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 06:50:08 +00:00
|
|
|
const struct m_option_type *type = prop.type;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
bool found = false;
|
|
|
|
for (int i = 0; type->actions && type->actions[i].name; i++) {
|
|
|
|
const struct m_option_action *action = &type->actions[i];
|
|
|
|
if (strcmp(action->name, op) == 0)
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Unknown action: '%s'", op);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2019-12-18 06:50:08 +00:00
|
|
|
union m_option_value val = {0};
|
|
|
|
if (mp_property_do(name, M_PROPERTY_GET, &val, mpctx) <= 0) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Could not read: '%s'", name);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
char *optname = mp_tprintf(80, "%s-%s", name, op); // the dirty truth
|
2019-12-18 06:50:08 +00:00
|
|
|
int r = m_option_parse(mpctx->log, &prop, bstr0(optname), bstr0(value), &val);
|
|
|
|
if (r >= 0 && mp_property_do(name, M_PROPERTY_SET, &val, mpctx) <= 0)
|
|
|
|
r = -1;
|
|
|
|
m_option_free(&prop, &val);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (r < 0) {
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
|
|
|
"Failed setting option: '%s'", name);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2018-01-24 02:20:15 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
show_property_osd(mpctx, name, cmd->on_osd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_add_cycle(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
bool is_cycle = !!cmd->priv;
|
|
|
|
|
|
|
|
char *property = cmd->args[0].v.s;
|
2021-08-18 17:38:35 +00:00
|
|
|
if (cmd->cmd->repeated && !check_property_autorepeat(property, mpctx) &&
|
|
|
|
!(cmd->cmd->flags & MP_ALLOW_REPEAT) /* "repeatable" prefix */ )
|
|
|
|
{
|
2019-11-22 17:21:33 +00:00
|
|
|
MP_VERBOSE(mpctx, "Dropping command '%s' from auto-repeated key.\n",
|
|
|
|
cmd->cmd->original);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
return;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
double scale = 1;
|
|
|
|
int scale_units = cmd->cmd->scale_units;
|
|
|
|
if (check_property_scalable(property, mpctx)) {
|
|
|
|
scale = cmd->cmd->scale;
|
|
|
|
scale_units = 1;
|
2013-10-31 22:23:38 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
for (int i = 0; i < scale_units; i++) {
|
|
|
|
struct m_property_switch_arg s = {
|
|
|
|
.inc = cmd->args[1].v.d * scale,
|
|
|
|
.wrap = is_cycle,
|
|
|
|
};
|
|
|
|
change_property_cmd(cmd, property, M_PROPERTY_SWITCH, &s);
|
|
|
|
if (!cmd->success)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_multiply(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
|
|
|
|
change_property_cmd(cmd, cmd->args[0].v.s,
|
|
|
|
M_PROPERTY_MULTIPLY, &cmd->args[1].v.d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_frame_step(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2013-11-29 23:18:24 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (!mpctx->playback_initialized) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->cmd->is_up_down) {
|
|
|
|
if (cmd->cmd->is_up) {
|
|
|
|
if (mpctx->step_frames < 1)
|
|
|
|
set_pause_state(mpctx, true);
|
|
|
|
} else {
|
|
|
|
if (cmd->cmd->repeated) {
|
|
|
|
set_pause_state(mpctx, false);
|
2014-11-23 14:30:36 +00:00
|
|
|
} else {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
add_step_frame(mpctx, 1);
|
2014-11-23 14:30:36 +00:00
|
|
|
}
|
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
} else {
|
|
|
|
add_step_frame(mpctx, 1);
|
|
|
|
}
|
|
|
|
}
|
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.
This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.
This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.
There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)
Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 17:31:48 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_frame_back_step(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (!mpctx->playback_initialized) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
add_step_frame(mpctx, -1);
|
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_quit(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
bool write_watch_later = *(bool *)cmd->priv;
|
|
|
|
if (write_watch_later || mpctx->opts->position_save_on_quit)
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
|
|
|
mpctx->stop_play = PT_QUIT;
|
|
|
|
mpctx->quit_custom_rc = cmd->args[0].v.i;
|
|
|
|
mpctx->has_quit_custom_rc = true;
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_playlist_next_prev(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int dir = *(int *)cmd->priv;
|
|
|
|
int force = cmd->args[0].v.i;
|
|
|
|
|
|
|
|
struct playlist_entry *e = mp_next_file(mpctx, dir, force, true);
|
|
|
|
if (!e && !force) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_set_playlist_entry(mpctx, e);
|
|
|
|
if (cmd->on_osd & MP_ON_OSD_MSG)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_CURRENT_FILE;
|
|
|
|
}
|
|
|
|
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
static void cmd_playlist_play_index(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
struct playlist *pl = mpctx->playlist;
|
|
|
|
int pos = cmd->args[0].v.i;
|
|
|
|
|
|
|
|
if (pos == -2)
|
|
|
|
pos = playlist_entry_to_index(pl, pl->current);
|
|
|
|
|
|
|
|
mp_set_playlist_entry(mpctx, playlist_entry_from_index(pl, pos));
|
|
|
|
if (cmd->on_osd & MP_ON_OSD_MSG)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_CURRENT_FILE;
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_sub_step_seek(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
bool step = *(bool *)cmd->priv;
|
2021-07-12 18:42:03 +00:00
|
|
|
int track_ind = cmd->args[1].v.i;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
|
|
|
|
if (!mpctx->playback_initialized) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-12 18:42:03 +00:00
|
|
|
struct track *track = mpctx->current_track[track_ind][STREAM_SUB];
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct dec_sub *sub = track ? track->d_sub : NULL;
|
|
|
|
double refpts = get_current_time(mpctx);
|
|
|
|
if (sub && refpts != MP_NOPTS_VALUE) {
|
|
|
|
double a[2];
|
|
|
|
a[0] = refpts;
|
|
|
|
a[1] = cmd->args[0].v.i;
|
|
|
|
if (sub_control(sub, SD_CTRL_SUB_STEP, a) > 0) {
|
|
|
|
if (step) {
|
|
|
|
mpctx->opts->subs_rend->sub_delay -= a[0] - refpts;
|
2020-01-04 20:12:29 +00:00
|
|
|
m_config_notify_change_opt_ptr_notify(mpctx->mconfig,
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
&mpctx->opts->subs_rend->sub_delay);
|
|
|
|
show_property_osd(mpctx, "sub-delay", cmd->on_osd);
|
|
|
|
} else {
|
|
|
|
// We can easily get stuck by failing to seek to the video
|
|
|
|
// frame which actually shows the sub first (because video
|
|
|
|
// frame PTS and sub PTS rarely match exactly). Add some
|
|
|
|
// rounding for the mess of it.
|
|
|
|
a[0] += 0.01 * (a[1] >= 0 ? 1 : -1);
|
|
|
|
mark_seek(mpctx);
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, a[0], MPSEEK_EXACT,
|
|
|
|
MPSEEK_FLAG_DELAY);
|
|
|
|
set_osd_function(mpctx, (a[0] > refpts) ? OSD_FFW : OSD_REW);
|
|
|
|
if (cmd->seek_bar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
|
|
|
if (cmd->seek_msg_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
2012-09-01 17:49:04 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2013-12-24 16:46:14 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_print_text(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2012-10-11 00:24:13 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
MP_INFO(mpctx, "%s\n", cmd->args[0].v.s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_show_text(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int osd_duration = mpctx->opts->osd_duration;
|
|
|
|
|
|
|
|
// if no argument supplied use default osd_duration, else <arg> ms.
|
|
|
|
set_osd_msg(mpctx, cmd->args[2].v.i,
|
|
|
|
(cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
|
|
|
|
"%s", cmd->args[0].v.s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_expand_text(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
2018-05-06 16:27:18 +00:00
|
|
|
cmd->result = (mpv_node){
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
.format = MPV_FORMAT_STRING,
|
|
|
|
.u.string = mp_property_expand_string(mpctx, cmd->args[0].v.s)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-04-04 15:12:18 +00:00
|
|
|
static void cmd_expand_path(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
cmd->result = (mpv_node){
|
|
|
|
.format = MPV_FORMAT_STRING,
|
|
|
|
.u.string = mp_get_user_path(NULL, mpctx->global, cmd->args[0].v.s)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_loadfile(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
char *filename = cmd->args[0].v.s;
|
|
|
|
int append = cmd->args[1].v.i;
|
|
|
|
|
|
|
|
if (!append)
|
|
|
|
playlist_clear(mpctx->playlist);
|
|
|
|
|
|
|
|
struct playlist_entry *entry = playlist_entry_new(filename);
|
|
|
|
if (cmd->args[2].v.str_list) {
|
|
|
|
char **pairs = cmd->args[2].v.str_list;
|
|
|
|
for (int i = 0; pairs[i] && pairs[i + 1]; i += 2)
|
|
|
|
playlist_entry_add_param(entry, bstr0(pairs[i]), bstr0(pairs[i + 1]));
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
playlist_add(mpctx->playlist, entry);
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2020-03-21 16:45:30 +00:00
|
|
|
struct mpv_node *res = &cmd->result;
|
|
|
|
node_init(res, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
node_map_add_int64(res, "playlist_entry_id", entry->id);
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (!append || (append == 2 && !mpctx->playlist->current)) {
|
|
|
|
if (mpctx->opts->position_save_on_quit) // requested in issue #1148
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
|
|
|
mp_set_playlist_entry(mpctx, entry);
|
2017-03-26 17:29:10 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
2017-03-26 17:29:10 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_loadlist(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
char *filename = cmd->args[0].v.s;
|
2021-06-26 15:36:06 +00:00
|
|
|
int append = cmd->args[1].v.i;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2018-05-18 20:19:10 +00:00
|
|
|
struct playlist *pl = playlist_parse_file(filename, cmd->abort->cancel,
|
|
|
|
mpctx->global);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (pl) {
|
|
|
|
prepare_playlist(mpctx, pl);
|
|
|
|
struct playlist_entry *new = pl->current;
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
if (!append)
|
|
|
|
playlist_clear(mpctx->playlist);
|
2020-03-21 16:45:30 +00:00
|
|
|
struct playlist_entry *first = playlist_entry_from_index(pl, 0);
|
|
|
|
int num_entries = pl->num_entries;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
playlist_append_entries(mpctx->playlist, pl);
|
|
|
|
talloc_free(pl);
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
|
2019-12-28 20:12:02 +00:00
|
|
|
if (!new)
|
|
|
|
new = playlist_get_first(mpctx->playlist);
|
|
|
|
|
2021-06-26 15:36:06 +00:00
|
|
|
if ((!append || (append == 2 && !mpctx->playlist->current)) && new)
|
2019-12-28 20:12:02 +00:00
|
|
|
mp_set_playlist_entry(mpctx, new);
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
|
2020-03-21 16:45:30 +00:00
|
|
|
struct mpv_node *res = &cmd->result;
|
|
|
|
node_init(res, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
if (num_entries) {
|
|
|
|
node_map_add_int64(res, "playlist_entry_id", first->id);
|
|
|
|
node_map_add_int64(res, "num_entries", num_entries);
|
|
|
|
}
|
|
|
|
|
2016-06-20 19:35:59 +00:00
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
2016-09-16 12:24:15 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
} else {
|
|
|
|
MP_ERR(mpctx, "Unable to load playlist %s.\n", filename);
|
|
|
|
cmd->success = false;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_playlist_clear(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2014-12-29 21:08:22 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
// Supposed to clear the playlist, except the currently played item.
|
|
|
|
if (mpctx->playlist->current_was_replaced)
|
|
|
|
mpctx->playlist->current = NULL;
|
2019-12-28 20:12:02 +00:00
|
|
|
playlist_clear_except_current(mpctx->playlist);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_playlist_remove(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2012-02-10 18:03:24 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct playlist_entry *e = playlist_entry_from_index(mpctx->playlist,
|
|
|
|
cmd->args[0].v.i);
|
|
|
|
if (cmd->args[0].v.i < 0)
|
|
|
|
e = mpctx->playlist->current;
|
|
|
|
if (!e) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2013-07-02 11:17:50 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
// Can't play a removed entry
|
|
|
|
if (mpctx->playlist->current == e && !mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
|
|
|
playlist_remove(mpctx->playlist, e);
|
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_playlist_move(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
struct playlist_entry *e1 = playlist_entry_from_index(mpctx->playlist,
|
|
|
|
cmd->args[0].v.i);
|
|
|
|
struct playlist_entry *e2 = playlist_entry_from_index(mpctx->playlist,
|
|
|
|
cmd->args[1].v.i);
|
|
|
|
if (!e1) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2013-07-02 11:17:50 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
playlist_move(mpctx->playlist, e1, e2);
|
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_playlist_shuffle(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
playlist_shuffle(mpctx->playlist);
|
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
}
|
|
|
|
|
2019-12-28 20:32:03 +00:00
|
|
|
static void cmd_playlist_unshuffle(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
playlist_unshuffle(mpctx->playlist);
|
|
|
|
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_stop(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
int flags = cmd->args[0].v.i;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
if (!(flags & 1))
|
|
|
|
playlist_clear(mpctx->playlist);
|
2020-05-19 21:03:49 +00:00
|
|
|
|
|
|
|
if (mpctx->opts->player_idle_mode < 2 &&
|
|
|
|
mpctx->opts->position_save_on_quit)
|
|
|
|
{
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (mpctx->stop_play != PT_QUIT)
|
|
|
|
mpctx->stop_play = PT_STOP;
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_show_progress(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
mpctx->add_osd_seek_info |=
|
|
|
|
(cmd->msg_osd ? OSD_SEEK_INFO_TEXT : 0) |
|
|
|
|
(cmd->bar_osd ? OSD_SEEK_INFO_BAR : 0);
|
|
|
|
mpctx->osd_force_update = true;
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_track_add(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int type = *(int *)cmd->priv;
|
2021-02-26 11:05:24 +00:00
|
|
|
bool is_albumart = type == STREAM_VIDEO &&
|
2023-02-20 05:44:22 +00:00
|
|
|
cmd->args[4].v.b;
|
2010-04-09 19:20:52 +00:00
|
|
|
|
2018-05-19 16:25:54 +00:00
|
|
|
if (mpctx->stop_play) {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
|
|
|
return;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (cmd->args[1].v.i == 2) {
|
|
|
|
struct track *t = find_track_with_url(mpctx, type, cmd->args[0].v.s);
|
|
|
|
if (t) {
|
|
|
|
if (mpctx->playback_initialized) {
|
|
|
|
mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
|
|
|
|
print_track_list(mpctx, "Track switched:");
|
|
|
|
} else {
|
2020-04-15 15:10:01 +00:00
|
|
|
mark_track_selection(mpctx, 0, t->type, t->user_tid);
|
2014-10-23 11:11:41 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
return;
|
2014-10-23 11:11:41 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type,
|
2021-02-26 11:05:24 +00:00
|
|
|
cmd->abort->cancel, is_albumart);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (first < 0) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int n = first; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *t = mpctx->tracks[n];
|
|
|
|
if (cmd->args[1].v.i == 1) {
|
|
|
|
t->no_default = true;
|
|
|
|
} else if (n == first) {
|
|
|
|
if (mpctx->playback_initialized) {
|
|
|
|
mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
|
|
|
|
} else {
|
2020-04-15 15:10:01 +00:00
|
|
|
mark_track_selection(mpctx, 0, t->type, t->user_tid);
|
2016-09-10 11:51:17 +00:00
|
|
|
}
|
2014-10-20 21:55:29 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
char *title = cmd->args[2].v.s;
|
|
|
|
if (title && title[0])
|
|
|
|
t->title = talloc_strdup(t, title);
|
|
|
|
char *lang = cmd->args[3].v.s;
|
|
|
|
if (lang && lang[0])
|
|
|
|
t->lang = talloc_strdup(t, lang);
|
2014-02-13 12:30:07 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (mpctx->playback_initialized)
|
|
|
|
print_track_list(mpctx, "Track added:");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_track_remove(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int type = *(int *)cmd->priv;
|
|
|
|
|
|
|
|
struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
|
|
|
|
if (!t) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2012-11-15 19:26:52 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_remove_track(mpctx, t);
|
|
|
|
if (mpctx->playback_initialized)
|
|
|
|
print_track_list(mpctx, "Track removed:");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_track_reload(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int type = *(int *)cmd->priv;
|
|
|
|
|
|
|
|
if (!mpctx->playback_initialized) {
|
|
|
|
MP_ERR(mpctx, "Cannot reload while not initialized.\n");
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2012-11-15 19:26:52 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
|
|
|
|
int nt_num = -1;
|
|
|
|
|
|
|
|
if (t && t->is_external && t->external_filename) {
|
|
|
|
char *filename = talloc_strdup(NULL, t->external_filename);
|
2021-02-26 11:05:24 +00:00
|
|
|
bool is_albumart = t->attached_picture;
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_remove_track(mpctx, t);
|
2021-03-07 21:53:19 +00:00
|
|
|
nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel,
|
2021-02-26 11:05:24 +00:00
|
|
|
is_albumart);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
talloc_free(filename);
|
2015-02-16 21:06:41 +00:00
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (nt_num < 0) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2015-03-04 16:21:02 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct track *nt = mpctx->tracks[nt_num];
|
|
|
|
mp_switch_track(mpctx, nt->type, nt, 0);
|
|
|
|
print_track_list(mpctx, "Reloaded:");
|
|
|
|
}
|
2013-07-08 18:34:26 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_rescan_external_files(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
2018-05-19 16:25:54 +00:00
|
|
|
if (mpctx->stop_play) {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2015-04-20 21:11:03 +00:00
|
|
|
}
|
|
|
|
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
autoload_external_files(mpctx, cmd->abort->cancel);
|
2018-05-17 18:10:39 +00:00
|
|
|
if (!cmd->args[0].v.i && mpctx->playback_initialized) {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
// somewhat fuzzy and not ideal
|
|
|
|
struct track *a = select_default_track(mpctx, 0, STREAM_AUDIO);
|
|
|
|
if (a && a->is_external)
|
|
|
|
mp_switch_track(mpctx, STREAM_AUDIO, a, 0);
|
|
|
|
struct track *s = select_default_track(mpctx, 0, STREAM_SUB);
|
|
|
|
if (s && s->is_external)
|
|
|
|
mp_switch_track(mpctx, STREAM_SUB, s, 0);
|
|
|
|
|
2020-02-27 21:30:14 +00:00
|
|
|
print_track_list(mpctx, "Track list:");
|
2013-11-29 22:36:44 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_run(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
char **args = talloc_zero_array(NULL, char *, cmd->num_args + 1);
|
|
|
|
for (int n = 0; n < cmd->num_args; n++)
|
|
|
|
args[n] = cmd->args[n].v.s;
|
2020-07-16 23:34:46 +00:00
|
|
|
mp_msg_flush_status_line(mpctx->log);
|
|
|
|
struct mp_subprocess_opts opts = {
|
|
|
|
.exe = args[0],
|
|
|
|
.args = args,
|
|
|
|
.fds = { {0, .src_fd = 0}, {1, .src_fd = 1}, {2, .src_fd = 2} },
|
|
|
|
.num_fds = 3,
|
|
|
|
.detach = true,
|
|
|
|
};
|
|
|
|
struct mp_subprocess_result res;
|
|
|
|
mp_subprocess2(&opts, &res);
|
|
|
|
if (res.error < 0) {
|
|
|
|
mp_err(mpctx->log, "Starting subprocess failed: %s\n",
|
|
|
|
mp_subprocess_err_str(res.error));
|
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
talloc_free(args);
|
|
|
|
}
|
2014-11-20 21:41:50 +00:00
|
|
|
|
2020-07-16 23:34:46 +00:00
|
|
|
struct subprocess_fd_ctx {
|
2018-05-12 13:14:07 +00:00
|
|
|
struct mp_log *log;
|
|
|
|
void* talloc_ctx;
|
|
|
|
int64_t max_size;
|
2020-07-16 23:34:46 +00:00
|
|
|
int msgl;
|
|
|
|
bool capture;
|
|
|
|
bstr output;
|
2018-05-12 13:14:07 +00:00
|
|
|
};
|
|
|
|
|
2020-07-16 23:34:46 +00:00
|
|
|
static void subprocess_read(void *p, char *data, size_t size)
|
2018-05-12 13:14:07 +00:00
|
|
|
{
|
2020-07-16 23:34:46 +00:00
|
|
|
struct subprocess_fd_ctx *ctx = p;
|
|
|
|
if (ctx->capture) {
|
|
|
|
if (ctx->output.len < ctx->max_size)
|
|
|
|
bstr_xappend(ctx->talloc_ctx, &ctx->output, (bstr){data, size});
|
2018-05-12 13:14:07 +00:00
|
|
|
} else {
|
2020-07-16 23:34:46 +00:00
|
|
|
mp_msg(ctx->log, ctx->msgl, "%.*s", (int)size, data);
|
2018-05-12 13:14:07 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2013-06-22 23:28:28 +00:00
|
|
|
|
2020-08-16 00:54:44 +00:00
|
|
|
static void subprocess_write(void *p)
|
|
|
|
{
|
|
|
|
// Unused; we write a full buffer.
|
|
|
|
}
|
|
|
|
|
2018-05-12 13:14:07 +00:00
|
|
|
static void cmd_subprocess(void *p)
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2018-05-12 13:14:07 +00:00
|
|
|
char **args = cmd->args[0].v.str_list;
|
2023-02-20 05:44:22 +00:00
|
|
|
bool playback_only = cmd->args[1].v.b;
|
|
|
|
bool detach = cmd->args[5].v.b;
|
2020-07-16 23:34:46 +00:00
|
|
|
char **env = cmd->args[6].v.str_list;
|
2020-08-16 00:54:44 +00:00
|
|
|
bstr stdin_data = bstr0(cmd->args[7].v.s);
|
2023-02-20 05:44:22 +00:00
|
|
|
bool passthrough_stdin = cmd->args[8].v.b;
|
2020-07-16 23:34:46 +00:00
|
|
|
|
|
|
|
if (env && !env[0])
|
|
|
|
env = NULL; // do not actually set an empty environment
|
2015-08-05 21:55:16 +00:00
|
|
|
|
2018-05-12 13:14:07 +00:00
|
|
|
if (!args || !args[0]) {
|
|
|
|
MP_ERR(mpctx, "program name missing\n");
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2014-11-18 20:33:15 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 00:54:44 +00:00
|
|
|
if (stdin_data.len && passthrough_stdin) {
|
|
|
|
MP_ERR(mpctx, "both stdin_data and passthrough_stdin set\n");
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-12 13:14:07 +00:00
|
|
|
void *tmp = talloc_new(NULL);
|
2020-07-16 23:34:46 +00:00
|
|
|
|
|
|
|
struct mp_log *fdlog = mp_log_new(tmp, mpctx->log, cmd->cmd->sender);
|
|
|
|
struct subprocess_fd_ctx fdctx[3];
|
|
|
|
for (int fd = 0; fd < 3; fd++) {
|
|
|
|
fdctx[fd] = (struct subprocess_fd_ctx) {
|
|
|
|
.log = fdlog,
|
|
|
|
.talloc_ctx = tmp,
|
|
|
|
.max_size = cmd->args[2].v.i,
|
|
|
|
.msgl = fd == 2 ? MSGL_ERR : MSGL_INFO,
|
|
|
|
};
|
|
|
|
}
|
2023-02-20 05:44:22 +00:00
|
|
|
fdctx[1].capture = cmd->args[3].v.b;
|
|
|
|
fdctx[2].capture = cmd->args[4].v.b;
|
2014-11-20 21:41:50 +00:00
|
|
|
|
2018-05-12 16:47:43 +00:00
|
|
|
pthread_mutex_lock(&mpctx->abort_lock);
|
|
|
|
cmd->abort->coupled_to_playback = playback_only;
|
|
|
|
mp_abort_recheck_locked(mpctx, cmd->abort);
|
|
|
|
pthread_mutex_unlock(&mpctx->abort_lock);
|
2018-05-12 13:14:07 +00:00
|
|
|
|
|
|
|
mp_core_unlock(mpctx);
|
|
|
|
|
2020-07-16 23:34:46 +00:00
|
|
|
struct mp_subprocess_opts opts = {
|
|
|
|
.exe = args[0],
|
|
|
|
.args = args,
|
|
|
|
.env = env,
|
|
|
|
.cancel = cmd->abort->cancel,
|
|
|
|
.detach = detach,
|
|
|
|
.fds = {
|
|
|
|
{
|
|
|
|
.fd = 0, // stdin
|
2020-08-16 00:54:44 +00:00
|
|
|
.src_fd = passthrough_stdin ? 0 : -1,
|
2020-07-16 23:34:46 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
.num_fds = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
// stdout, stderr
|
|
|
|
for (int fd = 1; fd < 3; fd++) {
|
|
|
|
bool capture = fdctx[fd].capture || !detach;
|
|
|
|
opts.fds[opts.num_fds++] = (struct mp_subprocess_fd){
|
|
|
|
.fd = fd,
|
|
|
|
.src_fd = capture ? -1 : fd,
|
|
|
|
.on_read = capture ? subprocess_read : NULL,
|
|
|
|
.on_read_ctx = &fdctx[fd],
|
|
|
|
};
|
|
|
|
}
|
2020-08-16 00:54:44 +00:00
|
|
|
// stdin
|
|
|
|
if (stdin_data.len) {
|
|
|
|
opts.fds[0] = (struct mp_subprocess_fd){
|
|
|
|
.fd = 0,
|
|
|
|
.src_fd = -1,
|
|
|
|
.on_write = subprocess_write,
|
|
|
|
.on_write_ctx = &fdctx[0],
|
|
|
|
.write_buf = &stdin_data,
|
|
|
|
};
|
|
|
|
}
|
2020-07-16 23:34:46 +00:00
|
|
|
|
|
|
|
struct mp_subprocess_result sres;
|
|
|
|
mp_subprocess2(&opts, &sres);
|
|
|
|
int status = sres.exit_status;
|
2018-05-12 13:14:07 +00:00
|
|
|
char *error = NULL;
|
2020-07-16 23:34:46 +00:00
|
|
|
if (sres.error < 0) {
|
|
|
|
error = (char *)mp_subprocess_err_str(sres.error);
|
|
|
|
status = sres.error;
|
|
|
|
}
|
2018-05-12 13:14:07 +00:00
|
|
|
|
|
|
|
mp_core_lock(mpctx);
|
|
|
|
|
|
|
|
struct mpv_node *res = &cmd->result;
|
|
|
|
node_init(res, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
node_map_add_int64(res, "status", status);
|
|
|
|
node_map_add_flag(res, "killed_by_us", status == MP_SUBPROCESS_EKILLED_BY_US);
|
|
|
|
node_map_add_string(res, "error_string", error ? error : "");
|
|
|
|
const char *sname[] = {NULL, "stdout", "stderr"};
|
2020-07-16 23:34:46 +00:00
|
|
|
for (int fd = 1; fd < 3; fd++) {
|
|
|
|
if (!fdctx[fd].capture)
|
2018-05-12 13:14:07 +00:00
|
|
|
continue;
|
|
|
|
struct mpv_byte_array *ba =
|
2020-07-16 23:34:46 +00:00
|
|
|
node_map_add(res, sname[fd], MPV_FORMAT_BYTE_ARRAY)->u.ba;
|
2018-05-12 13:14:07 +00:00
|
|
|
*ba = (struct mpv_byte_array){
|
2020-07-16 23:34:46 +00:00
|
|
|
.data = talloc_steal(ba, fdctx[fd].output.start),
|
|
|
|
.size = fdctx[fd].output.len,
|
2018-05-12 13:14:07 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
talloc_free(tmp);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2014-11-20 21:41:50 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_enable_input_section(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
mp_input_enable_section(mpctx->input, cmd->args[0].v.s, cmd->args[1].v.i);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_disable_input_section(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
mp_input_disable_section(mpctx->input, cmd->args[0].v.s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_define_input_section(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
mp_input_define_section(mpctx->input, cmd->args[0].v.s, "<api>",
|
2018-05-17 18:10:39 +00:00
|
|
|
cmd->args[1].v.s, !cmd->args[2].v.i,
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->cmd->sender);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_ab_loop(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int osd_duration = mpctx->opts->osd_duration;
|
|
|
|
int osdl = cmd->msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
|
|
|
|
|
|
|
double now = get_current_time(mpctx);
|
|
|
|
if (mpctx->opts->ab_loop[0] == MP_NOPTS_VALUE) {
|
|
|
|
mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
show_property_osd(mpctx, "ab-loop-a", cmd->on_osd);
|
|
|
|
} else if (mpctx->opts->ab_loop[1] == MP_NOPTS_VALUE) {
|
|
|
|
mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
show_property_osd(mpctx, "ab-loop-b", cmd->on_osd);
|
|
|
|
} else {
|
|
|
|
now = MP_NOPTS_VALUE;
|
|
|
|
mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Clear A-B loop");
|
2014-11-20 21:41:50 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2014-11-20 21:41:50 +00:00
|
|
|
|
2019-07-10 19:38:37 +00:00
|
|
|
static void cmd_align_cache_ab(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
double a = demux_probe_cache_dump_target(mpctx->demuxer,
|
|
|
|
mpctx->opts->ab_loop[0], false);
|
|
|
|
double b = demux_probe_cache_dump_target(mpctx->demuxer,
|
|
|
|
mpctx->opts->ab_loop[1], true);
|
|
|
|
|
|
|
|
mp_property_do("ab-loop-a", M_PROPERTY_SET, &a, mpctx);
|
|
|
|
mp_property_do("ab-loop-b", M_PROPERTY_SET, &b, mpctx);
|
|
|
|
|
|
|
|
// Happens to cover both properties.
|
|
|
|
show_property_osd(mpctx, "ab-loop-b", cmd->on_osd);
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_drop_buffers(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2014-10-27 10:52:42 +00:00
|
|
|
|
2020-09-17 13:34:40 +00:00
|
|
|
reset_playback_state(mpctx);
|
2013-07-22 12:43:58 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (mpctx->demuxer)
|
|
|
|
demux_flush(mpctx->demuxer);
|
|
|
|
}
|
2010-10-17 15:54:55 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_ao_reload(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
reload_audio_output(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_filter(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int type = *(int *)cmd->priv;
|
|
|
|
cmd->success = edit_filters_osd(mpctx, type, cmd->args[0].v.s,
|
|
|
|
cmd->args[1].v.s, cmd->msg_osd) >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_filter_command(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int type = *(int *)cmd->priv;
|
|
|
|
|
|
|
|
struct mp_output_chain *chain = NULL;
|
|
|
|
if (type == STREAM_VIDEO)
|
|
|
|
chain = mpctx->vo_chain ? mpctx->vo_chain->filter : NULL;
|
|
|
|
if (type == STREAM_AUDIO)
|
|
|
|
chain = mpctx->ao_chain ? mpctx->ao_chain->filter : NULL;
|
|
|
|
if (!chain) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2014-02-10 20:03:59 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
struct mp_filter_command filter_cmd = {
|
|
|
|
.type = MP_FILTER_COMMAND_TEXT,
|
|
|
|
.cmd = cmd->args[1].v.s,
|
|
|
|
.arg = cmd->args[2].v.s,
|
|
|
|
};
|
|
|
|
cmd->success = mp_output_chain_command(chain, cmd->args[0].v.s, &filter_cmd);
|
|
|
|
}
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_script_binding(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct mp_cmd *incmd = cmd->cmd;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
mpv_event_client_message event = {0};
|
|
|
|
char *name = cmd->args[0].v.s;
|
|
|
|
if (!name || !name[0]) {
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2014-02-17 01:33:47 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
|
|
|
|
char *sep = strchr(name, '/');
|
|
|
|
char *target = NULL;
|
|
|
|
char space[MAX_CLIENT_NAME];
|
|
|
|
if (sep) {
|
|
|
|
snprintf(space, sizeof(space), "%.*s", (int)(sep - name), name);
|
|
|
|
target = space;
|
|
|
|
name = sep + 1;
|
|
|
|
}
|
|
|
|
char state[3] = {'p', incmd->is_mouse_button ? 'm' : '-'};
|
|
|
|
if (incmd->is_up_down)
|
|
|
|
state[0] = incmd->repeated ? 'r' : (incmd->is_up ? 'u' : 'd');
|
2019-11-21 22:01:56 +00:00
|
|
|
event.num_args = 5;
|
|
|
|
event.args = (const char*[5]){"key-binding", name, state,
|
|
|
|
incmd->key_name ? incmd->key_name : "",
|
|
|
|
incmd->key_text ? incmd->key_text : ""};
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (mp_client_send_event_dup(mpctx, target,
|
|
|
|
MPV_EVENT_CLIENT_MESSAGE, &event) < 0)
|
|
|
|
{
|
|
|
|
MP_VERBOSE(mpctx, "Can't find script '%s' when handling input.\n",
|
|
|
|
target ? target : "-");
|
|
|
|
cmd->success = false;
|
2014-03-17 17:26:56 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2014-02-17 01:33:47 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_script_message_to(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2013-09-30 20:27:37 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mpv_event_client_message *event = talloc_ptrtype(NULL, event);
|
|
|
|
*event = (mpv_event_client_message){0};
|
|
|
|
for (int n = 1; n < cmd->num_args; n++) {
|
|
|
|
MP_TARRAY_APPEND(event, event->args, event->num_args,
|
|
|
|
talloc_strdup(event, cmd->args[n].v.s));
|
|
|
|
}
|
|
|
|
if (mp_client_send_event(mpctx, cmd->args[0].v.s, 0,
|
|
|
|
MPV_EVENT_CLIENT_MESSAGE, event) < 0)
|
|
|
|
{
|
|
|
|
MP_VERBOSE(mpctx, "Can't find script '%s' to send message to.\n",
|
|
|
|
cmd->args[0].v.s);
|
|
|
|
cmd->success = false;
|
|
|
|
}
|
|
|
|
}
|
2013-09-30 20:27:37 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_script_message(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
const char **args = talloc_array(NULL, const char *, cmd->num_args);
|
|
|
|
mpv_event_client_message event = {.args = args};
|
|
|
|
for (int n = 0; n < cmd->num_args; n++)
|
|
|
|
event.args[event.num_args++] = cmd->args[n].v.s;
|
|
|
|
mp_client_broadcast_event(mpctx, MPV_EVENT_CLIENT_MESSAGE, &event);
|
|
|
|
talloc_free(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_ignore(void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_write_watch_later_config(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
|
|
|
}
|
|
|
|
|
command: add delete-watch-later-config
This introduces the delete-watch-later-config command, to complement
write-watch-later-config. This is an alternative to #8141.
The general problem that this change is attempting to help solve has
been described in #336, #3169 and #6574. Though persistent playback
position of a single file is generally a solved problem, this is not
the case for playlists, as described in #8138.
The motivation is facilitating intermittent playback of very large
playlists, consisting of hundreds of entries each many hours
long. Though the current "watch later" mechanism works well - provided
that the files each occur only once in that playlist, and are played
only via that playlist - the biggest issue is that the position is
lost completely should mpv exit uncleanly (e.g. due to a power
failure). Existing workarounds (in the form of Lua scripts which call
write-watch-later-config periodically) fail in the playlist case, due
to the mechanism used by mpv to determine where within a playlist to
resume playback from.
The missing puzzle piece needed to allow scripts to implement a
complete solution to this problem is simply a way to clean up the
watch-later configuration that the script asked mpv to write using
write-watch-later-config. With that in place, scripts can then
register an end-file event listener, check the stop playback reason,
and in the "eof" and "stop" case, invoke delete-watch-later-config to
delete any saved positions written by write-watch-later-config. The
script can then proceed to immediately write a new one when the next
file is loaded, which altogether allows mpv to resume from the correct
playlist and file position upon next startup.
Because events are delivered and executed asynchronously,
delete-watch-later-config takes an optional filename argument, to
allow scripts to clear watch-later configuration for files after mpv
had already moved on from playing them and proceeded to another file.
A Lua script which makes use of this change can be found here:
https://gist.github.com/CyberShadow/2f71a97fb85ed42146f6d9f522bc34ef
(A modification of the one written by @Hakkin, in that this one takes
advantage of the new command, and also saves the state immediately
when a new file is loaded.)
2020-10-22 16:25:20 +00:00
|
|
|
static void cmd_delete_watch_later_config(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
char *filename = cmd->args[0].v.s;
|
|
|
|
if (filename && !*filename)
|
|
|
|
filename = NULL;
|
|
|
|
mp_delete_watch_later_conf(mpctx, filename);
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_mouse(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2020-07-26 11:16:08 +00:00
|
|
|
int pre_key = 0;
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
const int x = cmd->args[0].v.i, y = cmd->args[1].v.i;
|
|
|
|
int button = cmd->args[2].v.i;
|
2020-07-26 11:16:08 +00:00
|
|
|
|
|
|
|
if (mpctx->video_out && mpctx->video_out->config_ok) {
|
|
|
|
int oldx, oldy, oldhover;
|
|
|
|
mp_input_get_mouse_pos(mpctx->input, &oldx, &oldy, &oldhover);
|
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd);
|
|
|
|
|
|
|
|
// TODO: VOs don't send outside positions. should we abort if outside?
|
|
|
|
int hover = x >= 0 && y >= 0 && x < vo_res.w && y < vo_res.h;
|
|
|
|
|
|
|
|
if (vo_res.w && vo_res.h && hover != oldhover)
|
|
|
|
pre_key = hover ? MP_KEY_MOUSE_ENTER : MP_KEY_MOUSE_LEAVE;
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
if (button == -1) {// no button
|
2020-07-26 11:16:08 +00:00
|
|
|
if (pre_key)
|
|
|
|
mp_input_put_key_artificial(mpctx->input, pre_key);
|
2016-02-04 22:01:15 +00:00
|
|
|
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
return;
|
2015-01-23 20:45:13 +00:00
|
|
|
}
|
2018-05-10 13:57:36 +00:00
|
|
|
if (button < 0 || button >= MP_KEY_MOUSE_BTN_COUNT) {// invalid button
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
MP_ERR(mpctx, "%d is not a valid mouse button number.\n", button);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const bool dbc = cmd->args[3].v.i;
|
|
|
|
if (dbc && button > (MP_MBTN_RIGHT - MP_MBTN_BASE)) {
|
|
|
|
MP_ERR(mpctx, "%d is not a valid mouse button for double-clicks.\n",
|
|
|
|
button);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
button += dbc ? MP_MBTN_DBL_BASE : MP_MBTN_BASE;
|
2020-07-26 11:16:08 +00:00
|
|
|
if (pre_key)
|
|
|
|
mp_input_put_key_artificial(mpctx->input, pre_key);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_input_set_mouse_pos_artificial(mpctx->input, x, y);
|
|
|
|
mp_input_put_key_artificial(mpctx->input, button);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_key(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
int action = *(int *)cmd->priv;
|
2015-01-23 20:45:13 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
const char *key_name = cmd->args[0].v.s;
|
|
|
|
if (key_name[0] == '\0' && action == MP_KEY_STATE_UP) {
|
|
|
|
mp_input_put_key_artificial(mpctx->input, MP_INPUT_RELEASE_ALL);
|
|
|
|
} else {
|
2015-06-10 23:56:56 +00:00
|
|
|
int code = mp_input_get_key_from_name(key_name);
|
|
|
|
if (code < 0) {
|
|
|
|
MP_ERR(mpctx, "%s is not a valid input name.\n", key_name);
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
|
|
|
return;
|
2015-06-10 23:56:56 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
mp_input_put_key_artificial(mpctx->input, code | action);
|
2015-06-10 23:56:56 +00:00
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2015-06-10 23:56:56 +00:00
|
|
|
|
2019-09-02 02:06:09 +00:00
|
|
|
static void cmd_key_bind(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
int code = mp_input_get_key_from_name(cmd->args[0].v.s);
|
|
|
|
if (code < 0) {
|
|
|
|
MP_ERR(mpctx, "%s is not a valid input name.\n", cmd->args[0].v.s);
|
|
|
|
cmd->success = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const char *target_cmd = cmd->args[1].v.s;
|
|
|
|
mp_input_bind_key(mpctx->input, code, bstr0(target_cmd));
|
|
|
|
}
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_apply_profile(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2015-06-10 23:56:56 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
char *profile = cmd->args[0].v.s;
|
2020-08-07 17:39:46 +00:00
|
|
|
int mode = cmd->args[1].v.i;
|
|
|
|
if (mode == 0) {
|
|
|
|
cmd->success = m_config_set_profile(mpctx->mconfig, profile, 0) >= 0;
|
|
|
|
} else {
|
|
|
|
cmd->success = m_config_restore_profile(mpctx->mconfig, profile) >= 0;
|
|
|
|
}
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
}
|
2016-09-17 19:01:59 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
static void cmd_load_script(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
2016-09-22 18:43:33 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
char *script = cmd->args[0].v.s;
|
2020-03-26 22:58:09 +00:00
|
|
|
int64_t id = mp_load_user_script(mpctx, script);
|
|
|
|
if (id > 0) {
|
|
|
|
struct mpv_node *res = &cmd->result;
|
|
|
|
node_init(res, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
node_map_add_int64(res, "client_id", id);
|
|
|
|
} else {
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
cmd->success = false;
|
2020-03-26 22:58:09 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
static void cache_dump_poll(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
struct mp_cmd_ctx *cmd = ctx->cache_dump_cmd;
|
|
|
|
|
|
|
|
if (!cmd)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Can't close demuxer without stopping dumping.
|
|
|
|
assert(mpctx->demuxer);
|
|
|
|
|
|
|
|
if (mp_cancel_test(cmd->abort->cancel)) {
|
|
|
|
// Synchronous abort. In particular, the dump command shall not report
|
|
|
|
// completion to the user before the dump target file was closed.
|
|
|
|
demux_cache_dump_set(mpctx->demuxer, 0, 0, NULL);
|
|
|
|
assert(demux_cache_dump_get_status(mpctx->demuxer) <= 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int status = demux_cache_dump_get_status(mpctx->demuxer);
|
|
|
|
if (status <= 0) {
|
|
|
|
if (status < 0) {
|
|
|
|
mp_cmd_msg(cmd, MSGL_ERR, "Cache dumping stopped due to error.");
|
|
|
|
cmd->success = false;
|
|
|
|
} else {
|
|
|
|
mp_cmd_msg(cmd, MSGL_INFO, "Cache dumping successfully ended.");
|
|
|
|
cmd->success = true;
|
|
|
|
}
|
|
|
|
ctx->cache_dump_cmd = NULL;
|
|
|
|
mp_cmd_ctx_complete(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mp_abort_cache_dumping(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
|
|
|
|
if (ctx->cache_dump_cmd)
|
|
|
|
mp_cancel_trigger(ctx->cache_dump_cmd->abort->cancel);
|
|
|
|
cache_dump_poll(mpctx);
|
|
|
|
assert(!ctx->cache_dump_cmd); // synchronous abort, must have worked
|
|
|
|
}
|
|
|
|
|
|
|
|
static void run_dump_cmd(struct mp_cmd_ctx *cmd, double start, double end,
|
|
|
|
char *filename)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
|
|
|
|
mp_abort_cache_dumping(mpctx);
|
|
|
|
|
|
|
|
if (!mpctx->demuxer) {
|
|
|
|
mp_cmd_msg(cmd, MSGL_ERR, "No demuxer open.");
|
|
|
|
cmd->success = false;
|
|
|
|
mp_cmd_ctx_complete(cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-10 19:34:38 +00:00
|
|
|
mp_cmd_msg(cmd, MSGL_INFO, "Cache dumping started.");
|
|
|
|
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
if (!demux_cache_dump_set(mpctx->demuxer, start, end, filename)) {
|
|
|
|
mp_cmd_msg(cmd, MSGL_INFO, "Cache dumping stopped.");
|
|
|
|
mp_cmd_ctx_complete(cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->cache_dump_cmd = cmd;
|
|
|
|
cache_dump_poll(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_dump_cache(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
|
|
|
|
run_dump_cmd(cmd, cmd->args[0].v.d, cmd->args[1].v.d, cmd->args[2].v.s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_dump_cache_ab(void *p)
|
|
|
|
{
|
|
|
|
struct mp_cmd_ctx *cmd = p;
|
|
|
|
struct MPContext *mpctx = cmd->mpctx;
|
|
|
|
|
|
|
|
run_dump_cmd(cmd, mpctx->opts->ab_loop[0], mpctx->opts->ab_loop[1],
|
|
|
|
cmd->args[0].v.s);
|
|
|
|
}
|
|
|
|
|
2018-04-30 18:07:53 +00:00
|
|
|
/* This array defines all known commands.
|
2018-05-17 18:10:39 +00:00
|
|
|
* The first field the command name used in libmpv and input.conf.
|
|
|
|
* The second field is the handler function (see mp_cmd_def.handler and
|
|
|
|
* run_command()).
|
|
|
|
* Then comes the definition of each argument. They are defined like options,
|
|
|
|
* except that the result is parsed into mp_cmd.args[] (thus the option variable
|
|
|
|
* is a field in the mp_cmd_arg union field). Arguments are optional if either
|
|
|
|
* defval is set (usually via OPTDEF_ macros), or the MP_CMD_OPT_ARG flag is
|
|
|
|
* set, or if it's the last argument and .vararg is set. If .vararg is set, the
|
|
|
|
* command has an arbitrary number of arguments, all using the type indicated by
|
|
|
|
* the last argument (they are appended to mp_cmd.args[] starting at the last
|
|
|
|
* argument's index).
|
2019-11-22 23:39:07 +00:00
|
|
|
* Arguments have names, which can be used by named argument functions, e.g. in
|
2018-05-17 18:10:39 +00:00
|
|
|
* Lua with mp.command_native().
|
2018-04-30 18:07:53 +00:00
|
|
|
*/
|
|
|
|
|
2018-05-17 18:10:39 +00:00
|
|
|
// This does not specify the real destination of the command parameter values,
|
|
|
|
// it just provides a dummy for the OPT_ macros. The real destination is an
|
|
|
|
// array item in mp_cmd.args[], using the index of the option definition.
|
|
|
|
#define OPT_BASE_STRUCT struct mp_cmd_arg
|
2018-04-30 18:07:53 +00:00
|
|
|
|
|
|
|
const struct mp_cmd_def mp_cmds[] = {
|
2019-12-19 11:50:10 +00:00
|
|
|
{ "ignore", cmd_ignore, .is_ignore = true, .is_noisy = true, },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "seek", cmd_seek,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"target", OPT_TIME(v.d)},
|
|
|
|
{"flags", OPT_FLAGS(v.i,
|
|
|
|
{"relative", 4|0}, {"-", 4|0},
|
|
|
|
{"absolute-percent", 4|1},
|
|
|
|
{"absolute", 4|2},
|
|
|
|
{"relative-percent", 4|3},
|
|
|
|
{"keyframes", 32|8},
|
|
|
|
{"exact", 32|16}),
|
|
|
|
OPTDEF_INT(4|0)},
|
2018-05-17 18:10:39 +00:00
|
|
|
// backwards compatibility only
|
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-14 20:28:01 +00:00
|
|
|
{"legacy", OPT_CHOICE(v.i,
|
|
|
|
{"unused", 0}, {"default-precise", 0},
|
|
|
|
{"keyframes", 32|8},
|
|
|
|
{"exact", 32|16}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-04-30 18:07:53 +00:00
|
|
|
},
|
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.scalable = true,
|
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "revert-seek", cmd_revert_seek,
|
2020-07-17 12:21:42 +00:00
|
|
|
{ {"flags", OPT_FLAGS(v.i, {"mark", 2|0}, {"mark-permanent", 2|1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG} },
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "quit", cmd_quit, { {"code", OPT_INT(v.i), .flags = MP_CMD_OPT_ARG} },
|
2018-05-19 16:44:03 +00:00
|
|
|
.priv = &(const bool){0} },
|
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-14 20:28:01 +00:00
|
|
|
{ "quit-watch-later", cmd_quit, { {"code", OPT_INT(v.i),
|
|
|
|
.flags = MP_CMD_OPT_ARG} },
|
2018-05-19 16:44:03 +00:00
|
|
|
.priv = &(const bool){1} },
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
{ "stop", cmd_stop,
|
|
|
|
{ {"flags", OPT_FLAGS(v.i, {"keep-playlist", 1}), .flags = MP_CMD_OPT_ARG} }
|
|
|
|
},
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "frame-step", cmd_frame_step, .allow_auto_repeat = true,
|
2018-04-30 18:07:53 +00:00
|
|
|
.on_updown = true },
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "frame-back-step", cmd_frame_back_step, .allow_auto_repeat = true },
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "playlist-next", cmd_playlist_next_prev,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"weak", 0},
|
|
|
|
{"force", 1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-04-30 18:33:05 +00:00
|
|
|
},
|
2018-05-19 16:44:03 +00:00
|
|
|
.priv = &(const int){1},
|
2018-04-30 18:33:05 +00:00
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "playlist-prev", cmd_playlist_next_prev,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"weak", 0},
|
|
|
|
{"force", 1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-04-30 18:33:05 +00:00
|
|
|
},
|
2018-05-19 16:44:03 +00:00
|
|
|
.priv = &(const int){-1},
|
2018-04-30 18:33:05 +00:00
|
|
|
},
|
player: add a number of new playlist contol commands/properties
Should give a good deal more explicit control and insight over the
player state.
Some feel a bit pointless, and/or expose internal weirdness. However,
it's not like the existing weirdness didn't exist before, or can be made
go away. (In part, the weirdness is because certain in-between states
are visible. Hiding them would make things simpler, but less flexible.)
Maybe this actually gives users a better idea how the API _should_ look
like, too.
On a side note, this tries to really guarantee that mpctx->playing is
set between playback start/end. For that, the loadfile.c changes assume
that mpctx->playing is set (guaranteed by code above the change), and
that playing->filename is set (probably could never be false; was broken
before and actually would have crashed if that could ever happen; in any
case, also add an assert to playlist.c for this).
playlist_entry_to_index() now tolerates playlist_entrys that are not
part of the playlist. This is also needed for mpctx->playing.
2020-03-21 16:08:43 +00:00
|
|
|
{ "playlist-play-index", cmd_playlist_play_index,
|
|
|
|
{
|
|
|
|
{"index", OPT_CHOICE(v.i, {"current", -2}, {"none", -1}),
|
|
|
|
M_RANGE(-1, INT_MAX)},
|
|
|
|
}
|
|
|
|
},
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "playlist-shuffle", cmd_playlist_shuffle, },
|
2019-12-28 20:32:03 +00:00
|
|
|
{ "playlist-unshuffle", cmd_playlist_unshuffle, },
|
2021-07-12 18:42:03 +00:00
|
|
|
{ "sub-step", cmd_sub_step_seek,
|
|
|
|
{
|
|
|
|
{"skip", OPT_INT(v.i)},
|
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"primary", 0},
|
|
|
|
{"secondary", 1}),
|
|
|
|
OPTDEF_INT(0)},
|
|
|
|
},
|
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.priv = &(const bool){true}
|
|
|
|
},
|
|
|
|
{ "sub-seek", cmd_sub_step_seek,
|
|
|
|
{
|
|
|
|
{"skip", OPT_INT(v.i)},
|
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"primary", 0},
|
|
|
|
{"secondary", 1}),
|
|
|
|
OPTDEF_INT(0)},
|
|
|
|
},
|
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.priv = &(const bool){false}
|
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "print-text", cmd_print_text, { {"text", OPT_STRING(v.s)} },
|
2019-12-19 11:50:10 +00:00
|
|
|
.is_noisy = true, .allow_auto_repeat = true },
|
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-14 20:28:01 +00:00
|
|
|
{ "show-text", cmd_show_text,
|
|
|
|
{
|
|
|
|
{"text", OPT_STRING(v.s)},
|
|
|
|
{"duration", OPT_INT(v.i), OPTDEF_INT(-1)},
|
|
|
|
{"level", OPT_INT(v.i), .flags = MP_CMD_OPT_ARG},
|
|
|
|
},
|
2019-12-19 11:50:10 +00:00
|
|
|
.is_noisy = true, .allow_auto_repeat = true},
|
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-14 20:28:01 +00:00
|
|
|
{ "expand-text", cmd_expand_text, { {"text", OPT_STRING(v.s)} },
|
2019-12-19 11:50:10 +00:00
|
|
|
.is_noisy = true },
|
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-14 20:28:01 +00:00
|
|
|
{ "expand-path", cmd_expand_path, { {"text", OPT_STRING(v.s)} },
|
2019-12-19 11:50:10 +00:00
|
|
|
.is_noisy = true },
|
|
|
|
{ "show-progress", cmd_show_progress, .allow_auto_repeat = true,
|
|
|
|
.is_noisy = true },
|
2018-05-17 18:10:39 +00:00
|
|
|
|
|
|
|
{ "sub-add", cmd_track_add,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"url", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"select", 0}, {"auto", 1}, {"cached", 2}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
|
|
|
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
|
|
|
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
},
|
|
|
|
.priv = &(const int){STREAM_SUB},
|
2018-05-06 19:23:28 +00:00
|
|
|
.spawn_thread = true,
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "audio-add", cmd_track_add,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"url", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"select", 0}, {"auto", 1}, {"cached", 2}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
|
|
|
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
|
|
|
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
|
|
|
.priv = &(const int){STREAM_AUDIO},
|
|
|
|
.spawn_thread = true,
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
2019-04-27 19:57:27 +00:00
|
|
|
{ "video-add", cmd_track_add,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"url", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_CHOICE(v.i, {"select", 0}, {"auto", 1}, {"cached", 2}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
|
|
|
{"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
|
|
|
{"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
2023-02-20 05:44:22 +00:00
|
|
|
{"albumart", OPT_BOOL(v.b), .flags = MP_CMD_OPT_ARG},
|
2019-04-27 19:57:27 +00:00
|
|
|
},
|
|
|
|
.priv = &(const int){STREAM_VIDEO},
|
|
|
|
.spawn_thread = true,
|
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "sub-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
.priv = &(const int){STREAM_SUB}, },
|
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-14 20:28:01 +00:00
|
|
|
{ "audio-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){STREAM_AUDIO}, },
|
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-14 20:28:01 +00:00
|
|
|
{ "video-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
|
2019-04-27 19:57:27 +00:00
|
|
|
.priv = &(const int){STREAM_VIDEO}, },
|
2018-05-17 18:10:39 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "sub-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
|
2018-05-07 18:36:17 +00:00
|
|
|
.priv = &(const int){STREAM_SUB},
|
|
|
|
.spawn_thread = true,
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
2018-05-07 18:36:17 +00:00
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "audio-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){STREAM_AUDIO},
|
|
|
|
.spawn_thread = true,
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "video-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
|
2019-04-27 19:57:27 +00:00
|
|
|
.priv = &(const int){STREAM_VIDEO},
|
|
|
|
.spawn_thread = true,
|
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
|
|
|
|
{ "rescan-external-files", cmd_rescan_external_files,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"keep-selection", 1},
|
|
|
|
{"reselect", 0}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
|
|
|
.spawn_thread = true,
|
player: make various commands for managing external tracks abortable
Until now, they could be aborted only by ending playback, and calling
mpv_abort_async_command didn't do anything.
This requires furthering the mess how playback abort is done. The main
reason why mp_cancel exists at all is to avoid that a "frozen" demuxer
(blocked on network I/O or whatever) cannot freeze the core. The core
should always get its way. Previously, there was a single mp_cancel
handle, that could be signaled, and all demuxers would unfreeze. With
external files, we might want to abort loading of a certain external
file, which automatically means they need a separate mp_cancel. So give
every demuxer its own mp_cancel, and "slave" it to whatever parent
mp_cancel handles aborting.
Since the mpv demuxer API conflates creating the demuxer and reading the
file headers, mp_cancel strictly need to be created before the demuxer
is created (or we couldn't abort loading). Although we give every
demuxer its own mp_cancel (as "enforced" by cancel_and_free_demuxer),
it's still rather messy to create/destroy it along with the demuxer.
2018-05-18 19:38:17 +00:00
|
|
|
.can_abort = true,
|
|
|
|
.abort_on_playback_end = true,
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
2018-04-30 18:07:53 +00:00
|
|
|
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "screenshot", cmd_screenshot,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"flags", OPT_FLAGS(v.i,
|
|
|
|
{"video", 4|0}, {"-", 4|0},
|
|
|
|
{"window", 4|1},
|
|
|
|
{"subtitles", 4|2},
|
|
|
|
{"each-frame", 8}),
|
|
|
|
OPTDEF_INT(4|2)},
|
2018-05-17 18:10:39 +00:00
|
|
|
// backwards compatibility
|
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-14 20:28:01 +00:00
|
|
|
{"legacy", OPT_CHOICE(v.i,
|
|
|
|
{"unused", 0}, {"single", 0},
|
|
|
|
{"each-frame", 8}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-05-09 20:38:21 +00:00
|
|
|
},
|
|
|
|
.spawn_thread = true,
|
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "screenshot-to-file", cmd_screenshot_to_file,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"filename", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"video", 0},
|
|
|
|
{"window", 1},
|
|
|
|
{"subtitles", 2}),
|
|
|
|
OPTDEF_INT(2)},
|
2018-05-09 20:38:21 +00:00
|
|
|
},
|
|
|
|
.spawn_thread = true,
|
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "screenshot-raw", cmd_screenshot_raw,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"video", 0},
|
|
|
|
{"window", 1},
|
|
|
|
{"subtitles", 2}),
|
|
|
|
OPTDEF_INT(2)},
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{ "loadfile", cmd_loadfile,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"url", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"replace", 0},
|
|
|
|
{"append", 1},
|
|
|
|
{"append-play", 2}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
|
|
|
{"options", OPT_KEYVALUELIST(v.str_list), .flags = MP_CMD_OPT_ARG},
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "loadlist", cmd_loadlist,
|
|
|
|
{
|
|
|
|
{"url", OPT_STRING(v.s)},
|
2021-06-26 15:36:06 +00:00
|
|
|
{"flags", OPT_CHOICE(v.i,
|
|
|
|
{"replace", 0},
|
|
|
|
{"append", 1},
|
|
|
|
{"append-play", 2}),
|
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-14 20:28:01 +00:00
|
|
|
.flags = MP_CMD_OPT_ARG},
|
|
|
|
},
|
2018-05-18 20:19:10 +00:00
|
|
|
.spawn_thread = true,
|
|
|
|
.can_abort = true,
|
|
|
|
},
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "playlist-clear", cmd_playlist_clear },
|
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-14 20:28:01 +00:00
|
|
|
{ "playlist-remove", cmd_playlist_remove, {
|
|
|
|
{"index", OPT_CHOICE(v.i, {"current", -1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG, M_RANGE(0, INT_MAX)}, }},
|
|
|
|
{ "playlist-move", cmd_playlist_move, { {"index1", OPT_INT(v.i)},
|
|
|
|
{"index2", OPT_INT(v.i)}, }},
|
|
|
|
{ "run", cmd_run, { {"command", OPT_STRING(v.s)},
|
|
|
|
{"args", OPT_STRING(v.s)}, },
|
2018-05-17 18:10:39 +00:00
|
|
|
.vararg = true,
|
|
|
|
},
|
2018-05-12 13:14:07 +00:00
|
|
|
{ "subprocess", cmd_subprocess,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"args", OPT_STRINGLIST(v.str_list)},
|
2023-02-20 05:44:22 +00:00
|
|
|
{"playback_only", OPT_BOOL(v.b), OPTDEF_INT(1)},
|
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-14 20:28:01 +00:00
|
|
|
{"capture_size", OPT_BYTE_SIZE(v.i64), M_RANGE(0, INT_MAX),
|
|
|
|
OPTDEF_INT64(64 * 1024 * 1024)},
|
2023-02-20 05:44:22 +00:00
|
|
|
{"capture_stdout", OPT_BOOL(v.b), .flags = MP_CMD_OPT_ARG},
|
|
|
|
{"capture_stderr", OPT_BOOL(v.b), .flags = MP_CMD_OPT_ARG},
|
|
|
|
{"detach", OPT_BOOL(v.b), .flags = MP_CMD_OPT_ARG},
|
2020-07-16 23:34:46 +00:00
|
|
|
{"env", OPT_STRINGLIST(v.str_list), .flags = MP_CMD_OPT_ARG},
|
2020-08-16 00:54:44 +00:00
|
|
|
{"stdin_data", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
|
2023-02-20 05:44:22 +00:00
|
|
|
{"passthrough_stdin", OPT_BOOL(v.b), .flags = MP_CMD_OPT_ARG},
|
2018-05-12 13:14:07 +00:00
|
|
|
},
|
|
|
|
.spawn_thread = true,
|
2018-05-12 16:47:43 +00:00
|
|
|
.can_abort = true,
|
2018-05-12 13:14:07 +00:00
|
|
|
},
|
2018-04-30 18:07:53 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "set", cmd_set, {{"name", OPT_STRING(v.s)}, {"value", OPT_STRING(v.s)}}},
|
2022-12-16 21:01:54 +00:00
|
|
|
{ "del", cmd_del, {{"name", OPT_STRING(v.s)}}},
|
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-14 20:28:01 +00:00
|
|
|
{ "change-list", cmd_change_list, { {"name", OPT_STRING(v.s)},
|
|
|
|
{"operation", OPT_STRING(v.s)},
|
|
|
|
{"value", OPT_STRING(v.s)} }},
|
|
|
|
{ "add", cmd_add_cycle, { {"name", OPT_STRING(v.s)},
|
|
|
|
{"value", OPT_DOUBLE(v.d), OPTDEF_DOUBLE(1)}, },
|
2018-04-30 18:07:53 +00:00
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.scalable = true,
|
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "cycle", cmd_add_cycle, { {"name", OPT_STRING(v.s)},
|
|
|
|
{"value", OPT_CYCLEDIR(v.d), OPTDEF_DOUBLE(1)}, },
|
2018-04-30 18:07:53 +00:00
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.scalable = true,
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
.priv = "",
|
2018-04-30 18:07:53 +00:00
|
|
|
},
|
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-14 20:28:01 +00:00
|
|
|
{ "multiply", cmd_multiply, { {"name", OPT_STRING(v.s)},
|
|
|
|
{"value", OPT_DOUBLE(v.d)}},
|
2018-04-30 18:07:53 +00:00
|
|
|
.allow_auto_repeat = true},
|
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "cycle-values", cmd_cycle_values, { {"arg0", OPT_STRING(v.s)},
|
|
|
|
{"arg1", OPT_STRING(v.s)},
|
|
|
|
{"argN", OPT_STRING(v.s)}, },
|
2018-04-30 18:07:53 +00:00
|
|
|
.vararg = true},
|
|
|
|
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "enable-section", cmd_enable_input_section,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"name", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_FLAGS(v.i,
|
|
|
|
{"default", 0},
|
|
|
|
{"exclusive", MP_INPUT_EXCLUSIVE},
|
|
|
|
{"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
|
|
|
|
{"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-05-17 18:10:39 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{ "disable-section", cmd_disable_input_section,
|
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-14 20:28:01 +00:00
|
|
|
{{"name", OPT_STRING(v.s)} }},
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "define-section", cmd_define_input_section,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"name", OPT_STRING(v.s)},
|
|
|
|
{"contents", OPT_STRING(v.s)},
|
|
|
|
{"flags", OPT_CHOICE(v.i, {"default", 0}, {"force", 1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG},
|
2018-05-17 18:10:39 +00:00
|
|
|
},
|
|
|
|
},
|
2018-04-30 18:07:53 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "ab-loop", cmd_ab_loop },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "drop-buffers", cmd_drop_buffers, },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "af", cmd_filter, { {"operation", OPT_STRING(v.s)},
|
|
|
|
{"value", OPT_STRING(v.s)}, },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){STREAM_AUDIO} },
|
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-14 20:28:01 +00:00
|
|
|
{ "vf", cmd_filter, { {"operation", OPT_STRING(v.s)},
|
|
|
|
{"value", OPT_STRING(v.s)}, },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){STREAM_VIDEO} },
|
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "af-command", cmd_filter_command, { {"label", OPT_STRING(v.s)},
|
|
|
|
{"command", OPT_STRING(v.s)},
|
|
|
|
{"argument", OPT_STRING(v.s)}, },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){STREAM_AUDIO} },
|
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-14 20:28:01 +00:00
|
|
|
{ "vf-command", cmd_filter_command, { {"label", OPT_STRING(v.s)},
|
|
|
|
{"command", OPT_STRING(v.s)},
|
|
|
|
{"argument", OPT_STRING(v.s)}, },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){STREAM_VIDEO} },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
2018-05-17 18:10:39 +00:00
|
|
|
{ "ao-reload", cmd_ao_reload },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "script-binding", cmd_script_binding, { {"name", OPT_STRING(v.s)} },
|
2018-04-30 18:07:53 +00:00
|
|
|
.allow_auto_repeat = true, .on_updown = true},
|
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "script-message", cmd_script_message, { {"args", OPT_STRING(v.s)} },
|
2018-05-17 18:10:39 +00:00
|
|
|
.vararg = true },
|
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-14 20:28:01 +00:00
|
|
|
{ "script-message-to", cmd_script_message_to, { {"target", OPT_STRING(v.s)},
|
|
|
|
{"args", OPT_STRING(v.s)} },
|
2018-04-30 18:07:53 +00:00
|
|
|
.vararg = true },
|
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "overlay-add", cmd_overlay_add, { {"id", OPT_INT(v.i)},
|
|
|
|
{"x", OPT_INT(v.i)},
|
|
|
|
{"y", OPT_INT(v.i)},
|
|
|
|
{"file", OPT_STRING(v.s)},
|
|
|
|
{"offset", OPT_INT(v.i)},
|
|
|
|
{"fmt", OPT_STRING(v.s)},
|
|
|
|
{"w", OPT_INT(v.i)},
|
|
|
|
{"h", OPT_INT(v.i)},
|
|
|
|
{"stride", OPT_INT(v.i)}, }},
|
|
|
|
{ "overlay-remove", cmd_overlay_remove, { {"id", OPT_INT(v.i)} } },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
{ "osd-overlay", cmd_osd_overlay,
|
|
|
|
{
|
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-14 20:28:01 +00:00
|
|
|
{"id", OPT_INT64(v.i64)},
|
|
|
|
{"format", OPT_CHOICE(v.i, {"none", 0}, {"ass-events", 1})},
|
|
|
|
{"data", OPT_STRING(v.s)},
|
|
|
|
{"res_x", OPT_INT(v.i), OPTDEF_INT(0)},
|
|
|
|
{"res_y", OPT_INT(v.i), OPTDEF_INT(720)},
|
|
|
|
{"z", OPT_INT(v.i), OPTDEF_INT(0)},
|
2023-02-20 05:44:22 +00:00
|
|
|
{"hidden", OPT_BOOL(v.b), OPTDEF_INT(0)},
|
|
|
|
{"compute_bounds", OPT_BOOL(v.b), OPTDEF_INT(0)},
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
},
|
|
|
|
.is_noisy = true,
|
|
|
|
},
|
|
|
|
|
command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.
The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.
There should be no functional changes, but since this refactors 64
commands, regressions are possible.
The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-01 00:38:59 +00:00
|
|
|
{ "write-watch-later-config", cmd_write_watch_later_config },
|
command: add delete-watch-later-config
This introduces the delete-watch-later-config command, to complement
write-watch-later-config. This is an alternative to #8141.
The general problem that this change is attempting to help solve has
been described in #336, #3169 and #6574. Though persistent playback
position of a single file is generally a solved problem, this is not
the case for playlists, as described in #8138.
The motivation is facilitating intermittent playback of very large
playlists, consisting of hundreds of entries each many hours
long. Though the current "watch later" mechanism works well - provided
that the files each occur only once in that playlist, and are played
only via that playlist - the biggest issue is that the position is
lost completely should mpv exit uncleanly (e.g. due to a power
failure). Existing workarounds (in the form of Lua scripts which call
write-watch-later-config periodically) fail in the playlist case, due
to the mechanism used by mpv to determine where within a playlist to
resume playback from.
The missing puzzle piece needed to allow scripts to implement a
complete solution to this problem is simply a way to clean up the
watch-later configuration that the script asked mpv to write using
write-watch-later-config. With that in place, scripts can then
register an end-file event listener, check the stop playback reason,
and in the "eof" and "stop" case, invoke delete-watch-later-config to
delete any saved positions written by write-watch-later-config. The
script can then proceed to immediately write a new one when the next
file is loaded, which altogether allows mpv to resume from the correct
playlist and file position upon next startup.
Because events are delivered and executed asynchronously,
delete-watch-later-config takes an optional filename argument, to
allow scripts to clear watch-later configuration for files after mpv
had already moved on from playing them and proceeded to another file.
A Lua script which makes use of this change can be found here:
https://gist.github.com/CyberShadow/2f71a97fb85ed42146f6d9f522bc34ef
(A modification of the one written by @Hakkin, in that this one takes
advantage of the new command, and also saves the state immediately
when a new file is loaded.)
2020-10-22 16:25:20 +00:00
|
|
|
{ "delete-watch-later-config", cmd_delete_watch_later_config,
|
|
|
|
{{"filename", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG} }},
|
2018-04-30 18:07:53 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "mouse", cmd_mouse, { {"x", OPT_INT(v.i)},
|
|
|
|
{"y", OPT_INT(v.i)},
|
|
|
|
{"button", OPT_INT(v.i), OPTDEF_INT(-1)},
|
|
|
|
{"mode", OPT_CHOICE(v.i,
|
|
|
|
{"single", 0}, {"double", 1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG}}},
|
|
|
|
{ "keybind", cmd_key_bind, { {"name", OPT_STRING(v.s)},
|
|
|
|
{"cmd", OPT_STRING(v.s)} }},
|
|
|
|
{ "keypress", cmd_key, { {"name", OPT_STRING(v.s)} },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){0}},
|
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-14 20:28:01 +00:00
|
|
|
{ "keydown", cmd_key, { {"name", OPT_STRING(v.s)} },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){MP_KEY_STATE_DOWN}},
|
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-14 20:28:01 +00:00
|
|
|
{ "keyup", cmd_key, { {"name", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG} },
|
2018-05-17 18:10:39 +00:00
|
|
|
.priv = &(const int){MP_KEY_STATE_UP}},
|
|
|
|
|
2020-08-07 17:39:46 +00:00
|
|
|
{ "apply-profile", cmd_apply_profile, {
|
|
|
|
{"name", OPT_STRING(v.s)},
|
|
|
|
{"mode", OPT_CHOICE(v.i, {"apply", 0}, {"restore", 1}),
|
|
|
|
.flags = MP_CMD_OPT_ARG}, }
|
|
|
|
},
|
2018-05-17 18:10:39 +00:00
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "load-script", cmd_load_script, {{"filename", OPT_STRING(v.s)}} },
|
2018-04-30 18:07:53 +00:00
|
|
|
|
2020-05-23 02:15:11 +00:00
|
|
|
{ "dump-cache", cmd_dump_cache, { {"start", OPT_TIME(v.d),
|
|
|
|
.flags = M_OPT_ALLOW_NO},
|
|
|
|
{"end", OPT_TIME(v.d),
|
|
|
|
.flags = M_OPT_ALLOW_NO},
|
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-14 20:28:01 +00:00
|
|
|
{"filename", OPT_STRING(v.s)} },
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
.exec_async = true,
|
|
|
|
.can_abort = true,
|
|
|
|
},
|
|
|
|
|
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-14 20:28:01 +00:00
|
|
|
{ "ab-loop-dump-cache", cmd_dump_cache_ab, { {"filename", OPT_STRING(v.s)} },
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
.exec_async = true,
|
|
|
|
.can_abort = true,
|
|
|
|
},
|
|
|
|
|
2019-07-10 19:38:37 +00:00
|
|
|
{ "ab-loop-align-cache", cmd_align_cache_ab },
|
|
|
|
|
2018-04-30 18:07:53 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef OPT_BASE_STRUCT
|
|
|
|
#undef ARG
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
void command_uninit(struct MPContext *mpctx)
|
|
|
|
{
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
|
|
|
|
assert(!ctx->cache_dump_cmd); // closing the demuxer must have aborted it
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
overlay_uninit(mpctx);
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
ao_hotplug_destroy(ctx->hotplug);
|
|
|
|
|
2019-12-18 07:58:49 +00:00
|
|
|
m_option_free(&script_props_type, &ctx->script_props);
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
talloc_free(mpctx->command_ctx);
|
|
|
|
mpctx->command_ctx = NULL;
|
|
|
|
}
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
|
|
|
void command_init(struct MPContext *mpctx)
|
|
|
|
{
|
2016-09-01 18:00:43 +00:00
|
|
|
struct command_ctx *ctx = talloc(NULL, struct command_ctx);
|
|
|
|
*ctx = (struct command_ctx){
|
2013-12-01 01:07:32 +00:00
|
|
|
.last_seek_pts = MP_NOPTS_VALUE,
|
|
|
|
};
|
2016-09-01 18:00:43 +00:00
|
|
|
mpctx->command_ctx = ctx;
|
|
|
|
|
|
|
|
int num_base = MP_ARRAY_SIZE(mp_properties_base);
|
|
|
|
int num_opts = m_config_get_co_count(mpctx->mconfig);
|
|
|
|
ctx->properties =
|
|
|
|
talloc_zero_array(ctx, struct m_property, num_base + num_opts + 1);
|
|
|
|
memcpy(ctx->properties, mp_properties_base, sizeof(mp_properties_base));
|
|
|
|
|
|
|
|
int count = num_base;
|
|
|
|
for (int n = 0; n < num_opts; n++) {
|
|
|
|
struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n);
|
|
|
|
assert(co->name[0]);
|
2018-03-23 14:33:51 +00:00
|
|
|
if (co->opt->flags & M_OPT_NOPROP)
|
2016-09-01 18:00:43 +00:00
|
|
|
continue;
|
|
|
|
|
2018-05-01 01:51:14 +00:00
|
|
|
struct m_property prop = {
|
|
|
|
.name = co->name,
|
|
|
|
.call = mp_property_generic_option,
|
|
|
|
.is_option = true,
|
|
|
|
};
|
2016-10-04 11:19:21 +00:00
|
|
|
|
2017-06-15 13:22:06 +00:00
|
|
|
if (co->opt->type == &m_option_type_alias) {
|
2018-05-01 01:51:14 +00:00
|
|
|
prop.priv = co->opt->priv;
|
|
|
|
|
|
|
|
prop.call = co->opt->deprecation_message ?
|
|
|
|
mp_property_deprecated_alias : mp_property_alias;
|
2019-07-13 14:10:03 +00:00
|
|
|
|
|
|
|
// Check whether this eventually arrives at a real option. If not,
|
|
|
|
// it's some CLI special handling thing. For example, "nosound" is
|
|
|
|
// mapped to "no-audio", which has CLI special-handling, and cannot
|
|
|
|
// be set as property.
|
|
|
|
struct m_config_option *co2 = co;
|
|
|
|
while (co2 && co2->opt->type == &m_option_type_alias) {
|
|
|
|
const char *alias = (const char *)co2->opt->priv;
|
|
|
|
co2 = m_config_get_co_raw(mpctx->mconfig, bstr0(alias));
|
|
|
|
}
|
|
|
|
if (!co2)
|
|
|
|
continue;
|
2016-09-01 18:00:43 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 01:51:14 +00:00
|
|
|
// The option might be covered by a manual property already.
|
|
|
|
if (m_property_list_find(ctx->properties, prop.name))
|
|
|
|
continue;
|
2016-09-01 18:00:43 +00:00
|
|
|
|
2018-05-01 01:51:14 +00:00
|
|
|
ctx->properties[count++] = prop;
|
2016-09-01 18:00:43 +00:00
|
|
|
}
|
2022-12-16 01:20:43 +00:00
|
|
|
|
|
|
|
node_init(&ctx->udata, MPV_FORMAT_NODE_MAP, NULL);
|
|
|
|
talloc_steal(ctx, ctx->udata.u.list);
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
static void command_event(struct MPContext *mpctx, int event, void *arg)
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
2014-11-17 23:09:42 +00:00
|
|
|
|
2014-12-17 21:56:45 +00:00
|
|
|
if (event == MPV_EVENT_START_FILE) {
|
2014-02-10 20:01:35 +00:00
|
|
|
ctx->last_seek_pts = MP_NOPTS_VALUE;
|
2014-12-17 21:56:45 +00:00
|
|
|
ctx->marked_pts = MP_NOPTS_VALUE;
|
2020-07-17 12:21:42 +00:00
|
|
|
ctx->marked_permanent = false;
|
2014-12-17 21:56:45 +00:00
|
|
|
}
|
2014-02-10 20:01:35 +00:00
|
|
|
|
2020-03-26 21:50:21 +00:00
|
|
|
if (event == MPV_EVENT_PLAYBACK_RESTART)
|
|
|
|
ctx->last_seek_time = mp_time_sec();
|
|
|
|
|
2014-12-10 16:52:21 +00:00
|
|
|
if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) {
|
|
|
|
// Update chapters - does nothing if something else is visible.
|
|
|
|
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
|
|
|
|
}
|
2020-01-08 19:23:12 +00:00
|
|
|
if (event == MP_EVENT_WIN_STATE2)
|
|
|
|
ctx->cached_window_scale = 0;
|
2022-09-04 09:49:23 +00:00
|
|
|
|
2023-03-06 19:22:03 +00:00
|
|
|
if (event == MP_EVENT_METADATA_UPDATE) {
|
|
|
|
struct playlist_entry *const pe = mpctx->playing;
|
|
|
|
if (!pe->title) {
|
|
|
|
const char *const name = find_non_filename_media_title(mpctx);
|
|
|
|
if (name && name[0]) {
|
|
|
|
pe->title = talloc_strdup(pe, name);
|
|
|
|
mp_notify_property(mpctx, "playlist");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-14 14:13:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void handle_command_updates(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
2015-02-12 15:53:56 +00:00
|
|
|
|
|
|
|
// This is a bit messy: ao_hotplug wakes up the player, and then we have
|
|
|
|
// to recheck the state. Then the client(s) will read the property.
|
2017-10-09 13:48:47 +00:00
|
|
|
if (ctx->hotplug && ao_hotplug_check_update(ctx->hotplug))
|
2015-02-12 15:53:56 +00:00
|
|
|
mp_notify_property(mpctx, "audio-device-list");
|
demux, command: add a third stream recording mechanism
That's right, and it's probably not the end of it. I'll just claim that
I have no idea how to create a proper user interface for this, so I'm
creating multiple partially-orthogonal, of which some may work better in
each of its special use cases.
Until now, there was --record-file. You get relatively good control
about what is muxed, and it can use the cache. But it sucks that it's
bound to playback. If you pause while it's set, muxing stops. If you
seek while it's set, the output will be sort-of trashed, and that's by
design.
Then --stream-record was added. This is a bit better (especially for
live streams), but you can't really control well when muxing stops or
ends. In particular, it can't use the cache (it just dumps whatever the
underlying demuxer returns).
Today, the idea is that the user should just be able to select a time
range to dump to a file, and it should not affected by the user seeking
around in the cache. In addition, the stream may still be running, so
there's some need to continue dumping, even if it's redundant to
--stream-record.
One notable thing is that it uses the async command shit. Not sure
whether this is a good idea. Maybe not, but whatever. Also, a user can
always use the "async" prefix to pretend it doesn't.
Much of this was barely tested (especially the reinterleaving crap),
let's just hope it mostly works. I'm sure you can tolerate the one or
other crash?
2019-07-07 18:38:22 +00:00
|
|
|
|
|
|
|
// Depends on polling demuxer wakeup callback notifications.
|
|
|
|
cache_dump_poll(mpctx);
|
2014-11-17 23:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mp_notify(struct MPContext *mpctx, int event, void *arg)
|
|
|
|
{
|
player: do not update OSD all the time when paused
Normally, OSD is updated every time the playloop is run. This has to be
done, because the OSD may implicitly reference various properties,
without knowing whether they really need to be updated or not. (There's
a property update mechanism, but it's mostly unavailable, because OSD is
special-cased and can not use the client API mechanism properly.)
Normally, these updates are no problem, because the OSD is only actually
printed when the OSD text actually changes.
But commit d23ffd24 added a rate-limiting mechanism, which tries to
limit OSD updates at most every 50ms (or the next video frame). Since it
can't know in advance whether the OSD is going to change or not, this
simply waked up the player every 50ms.
Change this so that the player is updated only as part of general
updates determined through mp_notify(). (This function also notifies the
client API of changed properties.) The desired result is that the player
will not wake up at all in normal idle mode, but still update properties
that can change when paused, such as the cache.
This is mostly a cosmetic change (in the sense of making runtime
behavior just slightly better). It has the slightly more negative
consequence that properties which update implicitly (such as "clock")
will not update periodically anymore.
2016-06-11 16:40:08 +00:00
|
|
|
// The OSD can implicitly reference some properties.
|
|
|
|
mpctx->osd_idle_update = true;
|
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
command_event(mpctx, event, arg);
|
|
|
|
|
2014-08-01 23:39:28 +00:00
|
|
|
mp_client_broadcast_event(mpctx, event, arg);
|
2014-04-05 21:54:21 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 11:47:30 +00:00
|
|
|
static void update_priority(struct MPContext *mpctx)
|
|
|
|
{
|
2017-08-03 07:44:36 +00:00
|
|
|
#if HAVE_WIN32_DESKTOP
|
2016-09-28 11:47:30 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
if (opts->w32_priority > 0)
|
|
|
|
SetPriorityClass(GetCurrentProcess(), opts->w32_priority);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-01-16 14:13:34 +00:00
|
|
|
static void update_track_switch(struct MPContext *mpctx, int order, int type)
|
|
|
|
{
|
|
|
|
if (!mpctx->playback_initialized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int tid = mpctx->opts->stream_id[order][type];
|
|
|
|
struct track *track;
|
|
|
|
if (tid == -1) {
|
|
|
|
// If "auto" reset to default track selection
|
|
|
|
track = select_default_track(mpctx, order, type);
|
|
|
|
mark_track_selection(mpctx, order, type, -1);
|
|
|
|
} else {
|
|
|
|
track = mp_track_by_tid(mpctx, type, tid);
|
|
|
|
}
|
|
|
|
mp_switch_track_n(mpctx, order, type, track, (tid == -1) ? 0 : FLAG_MARK_SELECTION);
|
|
|
|
print_track_list(mpctx, "Track switched:");
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
player: change m_config to use new option handling mechanisms
Instead of making m_config a special-case, it more or less uses the
underlying m_config_cache/m_config_shadow APIs properly. This makes the
player core a (relatively) equivalent user of the core option API. In
particular, this means that other threads can change core options with
m_config_cache_write_opt() calls (before this commit, this merely led to
diverging option values).
An important change is that before this commit, mpctx->opts contained
the "master copy" of all option data. Now it's just another copy of the
option data, and the shadow copy is considered the master. This is why
whenever mpctx->opts is written, the change needs to be copied to the
master (thus why this commits add a bunch of m_config_notify... calls).
If another thread (e.g. a VO) changes an option, async_change_cb is now
invoked, which funnels the change notification through the player's
layers.
The new self_notification parameter on mp_option_change_callback is so
that m_config_notify... doesn't trigger recursion, and it's used in
cases where the change was already "processed". It's still needed to
trigger libmpv property updates. (I considered using an extra
m_config_cache for that, but it'd only cause problems with no
advantages.)
I think the recent changes actually forgot to send libmpv property
updates in some cases. This should fix this anyway. In some cases,
property updates are reworked, and the potential for bugs should be
lower (probably).
The primary point of this change is to allow external updates, for
example by a VO writing the fullscreen option if the window state is
changed by the window manager (rather than mpv changing it). This is not
used yet, but the following commits will.
2019-11-29 11:49:15 +00:00
|
|
|
void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
|
|
|
|
bool self_update)
|
2016-09-19 17:51:26 +00:00
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
2019-11-24 23:26:36 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2019-12-17 21:06:29 +00:00
|
|
|
bool init = !co;
|
|
|
|
void *opt_ptr = init ? NULL : co->data; // NULL on start
|
2016-09-19 17:51:26 +00:00
|
|
|
|
player: change m_config to use new option handling mechanisms
Instead of making m_config a special-case, it more or less uses the
underlying m_config_cache/m_config_shadow APIs properly. This makes the
player core a (relatively) equivalent user of the core option API. In
particular, this means that other threads can change core options with
m_config_cache_write_opt() calls (before this commit, this merely led to
diverging option values).
An important change is that before this commit, mpctx->opts contained
the "master copy" of all option data. Now it's just another copy of the
option data, and the shadow copy is considered the master. This is why
whenever mpctx->opts is written, the change needs to be copied to the
master (thus why this commits add a bunch of m_config_notify... calls).
If another thread (e.g. a VO) changes an option, async_change_cb is now
invoked, which funnels the change notification through the player's
layers.
The new self_notification parameter on mp_option_change_callback is so
that m_config_notify... doesn't trigger recursion, and it's used in
cases where the change was already "processed". It's still needed to
trigger libmpv property updates. (I considered using an extra
m_config_cache for that, but it'd only cause problems with no
advantages.)
I think the recent changes actually forgot to send libmpv property
updates in some cases. This should fix this anyway. In some cases,
property updates are reworked, and the potential for bugs should be
lower (probably).
The primary point of this change is to allow external updates, for
example by a VO writing the fullscreen option if the window state is
changed by the window manager (rather than mpv changing it). This is not
used yet, but the following commits will.
2019-11-29 11:49:15 +00:00
|
|
|
if (co)
|
|
|
|
mp_notify_property(mpctx, co->name);
|
|
|
|
|
|
|
|
if (self_update)
|
|
|
|
return;
|
|
|
|
|
2016-09-19 17:51:26 +00:00
|
|
|
if (flags & UPDATE_TERM)
|
2016-09-29 14:26:54 +00:00
|
|
|
mp_update_logging(mpctx, false);
|
2016-09-19 17:51:26 +00:00
|
|
|
|
2020-08-12 15:28:08 +00:00
|
|
|
if (flags & (UPDATE_OSD | UPDATE_SUB_FILT | UPDATE_SUB_HARD)) {
|
2020-04-15 15:03:37 +00:00
|
|
|
for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
|
2017-04-10 19:22:26 +00:00
|
|
|
struct track *track = mpctx->current_track[n][STREAM_SUB];
|
|
|
|
struct dec_sub *sub = track ? track->d_sub : NULL;
|
sub: make filter_sdh a "proper" filter, allow runtime changes
Until now, filter_sdh was simply a function that was called by sd_ass
directly (if enabled).
I want to add another filter, so it's time to turn this into a somewhat
more general subtitle filtering infrastructure.
I pondered whether to reuse the audio/video filtering stuff - but better
not. Also, since subtitles are horrible and tend to refuse proper
abstraction, it's still messed into sd_ass, instead of working on the
dec_sub.c level. Actually mpv used to have subtitle "filters" and even
made subtitle converters part of it, but it was fairly horrible, so
don't do that again.
In addition, make runtime changes possible. Since this was supposed to
be a quick hack, I just decided to put all subtitle filter options into
a separate option group (=> simpler change notification), to manually
push the change through the playloop (like it was sort of before for OSD
options), and to recreate the sub filter chain completely in every
change. Should be good enough.
One strangeness is that due to prefetching and such, most subtitle
packets (or those some time ahead) are actually done filtering when we
change, so the user still needs to manually seek to actually refresh
everything. And since subtitle data is usually cached in ASS_Track (for
other terrible but user-friendly reasons), we also must clear the
subtitle data, but of course only on seek, since otherwise all subtitles
would just disappear. What a fucking mess, but such is life. We could
trigger a "refresh seek" to make this more automatic, but I don't feel
like it currently.
This is slightly inefficient (lots of allocations and copying), but I
decided that it doesn't matter. Could matter slightly for crazy ASS
subtitles that render with thousands of events.
Not very well tested. Still seems to work, but I didn't have many test
cases.
2020-02-16 00:02:17 +00:00
|
|
|
if (sub) {
|
|
|
|
sub_control(track->d_sub, SD_CTRL_UPDATE_OPTS,
|
|
|
|
(void *)(uintptr_t)flags);
|
|
|
|
}
|
2017-04-10 19:22:26 +00:00
|
|
|
}
|
2017-12-29 16:19:25 +00:00
|
|
|
osd_changed(mpctx->osd);
|
2022-02-15 11:47:53 +00:00
|
|
|
if (mpctx->video_out)
|
|
|
|
vo_control_async(mpctx->video_out, VOCTRL_OSD_CHANGED, NULL);
|
2020-08-12 15:28:08 +00:00
|
|
|
if (flags & (UPDATE_SUB_FILT | UPDATE_SUB_HARD))
|
|
|
|
mp_force_video_refresh(mpctx);
|
2016-09-19 18:16:44 +00:00
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
2016-09-19 22:59:54 +00:00
|
|
|
|
|
|
|
if (flags & UPDATE_BUILTIN_SCRIPTS)
|
|
|
|
mp_load_builtin_scripts(mpctx);
|
2016-09-20 13:34:31 +00:00
|
|
|
|
|
|
|
if (flags & UPDATE_IMGPAR) {
|
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
2018-01-28 09:08:45 +00:00
|
|
|
if (track && track->dec) {
|
|
|
|
mp_decoder_wrapper_reset_params(track->dec);
|
2016-09-20 13:34:31 +00:00
|
|
|
mp_force_video_refresh(mpctx);
|
|
|
|
}
|
|
|
|
}
|
2016-09-21 13:56:54 +00:00
|
|
|
|
2019-12-17 21:06:29 +00:00
|
|
|
if (flags & UPDATE_INPUT)
|
2016-09-21 13:56:54 +00:00
|
|
|
mp_input_update_opts(mpctx->input);
|
|
|
|
|
2020-04-08 23:05:51 +00:00
|
|
|
if (init || opt_ptr == &opts->ipc_path || opt_ptr == &opts->ipc_client) {
|
2019-12-17 21:06:29 +00:00
|
|
|
mp_uninit_ipc(mpctx->ipc_ctx);
|
|
|
|
mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
|
2016-09-21 13:56:54 +00:00
|
|
|
}
|
2016-09-22 18:56:34 +00:00
|
|
|
|
2020-11-19 14:12:04 +00:00
|
|
|
if (opt_ptr == &opts->vo->video_driver_list) {
|
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
|
|
|
uninit_video_out(mpctx);
|
|
|
|
reinit_video_chain(mpctx);
|
|
|
|
if (track)
|
|
|
|
reselect_demux_stream(mpctx, track, true);
|
|
|
|
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:42:43 +00:00
|
|
|
if (flags & UPDATE_AUDIO)
|
|
|
|
reload_audio_output(mpctx);
|
2016-09-28 11:47:30 +00:00
|
|
|
|
|
|
|
if (flags & UPDATE_PRIORITY)
|
|
|
|
update_priority(mpctx);
|
2016-10-02 10:33:34 +00:00
|
|
|
|
|
|
|
if (flags & UPDATE_SCREENSAVER)
|
|
|
|
update_screensaver_state(mpctx);
|
2017-04-26 19:45:50 +00:00
|
|
|
|
|
|
|
if (flags & UPDATE_VOL)
|
|
|
|
audio_update_volume(mpctx);
|
2017-08-12 21:08:48 +00:00
|
|
|
|
|
|
|
if (flags & UPDATE_LAVFI_COMPLEX)
|
|
|
|
update_lavfi_complex(mpctx);
|
2018-01-02 20:14:24 +00:00
|
|
|
|
2020-09-20 10:04:25 +00:00
|
|
|
if (opt_ptr == &opts->vo->android_surface_size) {
|
2018-01-02 20:14:24 +00:00
|
|
|
if (mpctx->video_out)
|
|
|
|
vo_control(mpctx->video_out, VOCTRL_EXTERNAL_RESIZE, NULL);
|
|
|
|
}
|
2019-11-24 23:26:36 +00:00
|
|
|
|
|
|
|
if (opt_ptr == &opts->playback_speed) {
|
|
|
|
update_playback_speed(mpctx);
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_ptr == &opts->play_dir) {
|
|
|
|
if (mpctx->play_dir != opts->play_dir) {
|
2023-08-10 01:11:07 +00:00
|
|
|
// Some weird things for play_dir.
|
|
|
|
// 1. The option must be set before we seek.
|
|
|
|
// 2. queue_seek can change the stop_play value; always keep the old one.
|
|
|
|
mpctx->play_dir = opts->play_dir;
|
|
|
|
int old_stop_play = mpctx->stop_play;
|
2019-11-24 23:26:36 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, get_current_time(mpctx),
|
|
|
|
MPSEEK_EXACT, 0);
|
2023-08-10 01:11:07 +00:00
|
|
|
mpctx->stop_play = old_stop_play;
|
2019-11-24 23:26:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_ptr == &opts->edition_id) {
|
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (mpctx->playback_initialized && demuxer && demuxer->num_editions > 0) {
|
|
|
|
if (opts->edition_id != demuxer->edition) {
|
|
|
|
if (!mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_CURRENT_ENTRY;
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-11 22:09:20 +00:00
|
|
|
if (opt_ptr == &opts->pause)
|
|
|
|
set_pause_state(mpctx, opts->pause);
|
2019-11-24 23:26:36 +00:00
|
|
|
|
|
|
|
if (opt_ptr == &opts->audio_delay) {
|
|
|
|
if (mpctx->ao_chain) {
|
|
|
|
mpctx->delay += mpctx->opts->audio_delay - mpctx->ao_chain->delay;
|
|
|
|
mpctx->ao_chain->delay = mpctx->opts->audio_delay;
|
|
|
|
}
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & UPDATE_HWDEC) {
|
|
|
|
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
|
|
|
struct mp_decoder_wrapper *dec = track ? track->dec : NULL;
|
|
|
|
if (dec) {
|
|
|
|
mp_decoder_wrapper_control(dec, VDCTRL_REINIT, NULL);
|
player: set playback_pts in hr-seek past EOF case
Hr-seek past the last frame instantly enters EOF, which means
handle_playback_time() will not set playback_pts to the video PTS (as
all video frames are skipped), which leads to the playback time being
taken from the last seek target. This results in confusing behavior,
especially since the seek time will be clipped to the file duration for
display, but not for further relative seeks.
Obviously, the time should be set to the last video frame, so use the
last video frame as fallback if both audio and video have ended. Also,
since the same problem exists with audio-only playback, add a fallback
for audio PTS too. We don't know which was the "last" fragment of media
played (to decide whether to use the audio or video PTS as the
fallback), but it doesn't matter since the maximum works.
This could lead to some undesired effects. In particular the audio PTS
is basically a bad guess, and is for example not clipped against --end.
(But the ridiculous way audio syncing and clamping currently works, I'm
not going to touch that shit unless I rewrite it completely.) The cover
art case is slightly broken: using --keep-open with keyframe seeks will
result in 0 as playback PTS (the video PTS). OK, who cares, it got late.
Also casually get rid of last_vo_pts, since that barely made any sense
at all.
Fixes: #7487
2020-02-28 00:37:41 +00:00
|
|
|
double last_pts = mpctx->video_pts;
|
2019-11-24 23:26:36 +00:00
|
|
|
if (last_pts != MP_NOPTS_VALUE)
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_ptr == &opts->vo->window_scale)
|
2021-08-07 11:59:47 +00:00
|
|
|
update_window_scale(mpctx);
|
2019-11-24 23:26:36 +00:00
|
|
|
|
2020-01-12 00:32:13 +00:00
|
|
|
if (opt_ptr == &opts->cursor_autohide_delay)
|
2019-11-24 23:26:36 +00:00
|
|
|
mpctx->mouse_timer = 0;
|
|
|
|
|
|
|
|
if (flags & UPDATE_DVB_PROG) {
|
|
|
|
if (!mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_CURRENT_ENTRY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_ptr == &opts->ab_loop[0] || opt_ptr == &opts->ab_loop[1]) {
|
|
|
|
update_ab_loop_clip(mpctx);
|
|
|
|
// Update if visible
|
|
|
|
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
|
|
|
|
mp_wakeup_core(mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_ptr == &opts->record_file)
|
|
|
|
open_recorder(mpctx, false);
|
2019-11-25 00:16:03 +00:00
|
|
|
|
|
|
|
if (opt_ptr == &opts->vf_settings)
|
|
|
|
set_filters(mpctx, STREAM_VIDEO, opts->vf_settings);
|
|
|
|
|
|
|
|
if (opt_ptr == &opts->af_settings)
|
|
|
|
set_filters(mpctx, STREAM_AUDIO, opts->af_settings);
|
2019-11-25 18:49:09 +00:00
|
|
|
|
2020-04-15 15:03:37 +00:00
|
|
|
for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
|
|
|
|
for (int order = 0; order < num_ptracks[type]; order++) {
|
2021-01-16 14:13:34 +00:00
|
|
|
if (opt_ptr == &opts->stream_id[order][type])
|
|
|
|
update_track_switch(mpctx, order, type);
|
2019-11-25 18:49:09 +00:00
|
|
|
}
|
|
|
|
}
|
command: shuffle around even more crap
Convert some remaining properties to work without the option-to-property
bridge. Behavior shouldn't change (except for the corner case that it
tries to reapply the new state when setting a property, while it used to
ignore redundant sets).
As it is the case with many of these changes, much of the code is not in
its final proper state yet, but is rather a temporary workaround. For
example, these "VO flag" properties should just be fully handled in the
VO backend. (Currently, the config or VO layers don't provide enough
mechanism yet as that all the backends like x11, win32, etc. could be
changed yet, but that's another refactoring mess for another time.)
Now nothing relies on this option-to-property bridge anymore, which
opens the way to even more refactoring, which eventually may result in
tiny improvements for the end user.
2019-11-25 19:17:29 +00:00
|
|
|
|
2019-12-17 22:18:17 +00:00
|
|
|
if (opt_ptr == &opts->vo->fullscreen && !opts->vo->fullscreen)
|
|
|
|
mpctx->mouse_event_ts--; // Show mouse cursor
|
command: shuffle around even more crap
Convert some remaining properties to work without the option-to-property
bridge. Behavior shouldn't change (except for the corner case that it
tries to reapply the new state when setting a property, while it used to
ignore redundant sets).
As it is the case with many of these changes, much of the code is not in
its final proper state yet, but is rather a temporary workaround. For
example, these "VO flag" properties should just be fully handled in the
VO backend. (Currently, the config or VO layers don't provide enough
mechanism yet as that all the backends like x11, win32, etc. could be
changed yet, but that's another refactoring mess for another time.)
Now nothing relies on this option-to-property bridge anymore, which
opens the way to even more refactoring, which eventually may result in
tiny improvements for the end user.
2019-11-25 19:17:29 +00:00
|
|
|
|
|
|
|
if (opt_ptr == &opts->vo->taskbar_progress)
|
|
|
|
update_vo_playback_state(mpctx);
|
2021-07-24 17:11:30 +00:00
|
|
|
|
|
|
|
if (opt_ptr == &opts->image_display_duration && mpctx->vo_chain
|
|
|
|
&& mpctx->vo_chain->is_sparse && !mpctx->ao_chain
|
|
|
|
&& mpctx->video_status == STATUS_DRAINING)
|
|
|
|
mpctx->time_frame = opts->image_display_duration;
|
2016-09-19 17:51:26 +00:00
|
|
|
}
|
2016-09-02 13:59:40 +00:00
|
|
|
|
2014-06-01 01:41:36 +00:00
|
|
|
void mp_notify_property(struct MPContext *mpctx, const char *property)
|
2014-04-05 21:54:21 +00:00
|
|
|
{
|
2014-08-01 23:39:28 +00:00
|
|
|
mp_client_property_change(mpctx, property);
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
}
|