Mercurial > mplayer.hg
annotate command.c @ 35076:77a90f0b02b1
Minor simplification of rescale_input_coordinates.
author | reimar |
---|---|
date | Wed, 12 Sep 2012 20:48:08 +0000 |
parents | bdf9478e9374 |
children | c9d302e5e4be |
rev | line source |
---|---|
30429
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
1 /* |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
2 * This file is part of MPlayer. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
3 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
7 * (at your option) any later version. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
8 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
12 * GNU General Public License for more details. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
13 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
17 */ |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
30345
diff
changeset
|
18 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
19 #include <stdlib.h> |
22478 | 20 #include <inttypes.h> |
21 #include <unistd.h> | |
22483 | 22 #include <string.h> |
22478 | 23 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
24 #include "config.h" |
26263 | 25 #include "command.h" |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
26 #include "input/input.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
27 #include "stream/stream.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
28 #include "libmpdemux/demuxer.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
29 #include "libmpdemux/stheader.h" |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
30 #include "codec-cfg.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
33731
diff
changeset
|
31 #include "mp_msg.h" |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
32 #include "mplayer.h" |
32467 | 33 #include "sub/sub.h" |
22478 | 34 #include "m_option.h" |
35 #include "m_property.h" | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
36 #include "help_mp.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
37 #include "metadata.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
38 #include "libmpcodecs/vf.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
39 #include "libmpcodecs/vd.h" |
22478 | 40 #include "libvo/video_out.h" |
32466
9e627a1793b1
Move font_load.[ch], font_load_ft.c and osd_font.h from libvo to sub.
cigaes
parents:
32461
diff
changeset
|
41 #include "sub/font_load.h" |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
42 #include "playtree.h" |
22478 | 43 #include "libao2/audio_out.h" |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
44 #include "mpcommon.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
45 #include "mixer.h" |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
46 #include "libmpcodecs/dec_video.h" |
29759
d287e2785570
Move teletext specific code from stream into libmpcodecs.
cehoyos
parents:
29668
diff
changeset
|
47 #include "libmpcodecs/dec_teletext.h" |
33251
7d13ed4e80f2
Add missing osdep/strsep.h #include where strsep() is used.
diego
parents:
33230
diff
changeset
|
48 #include "osdep/strsep.h" |
32459
1a605463f62b
Move vobsub.[ch] and unrar_exec.[ch] to the sub directory.
cigaes
parents:
32456
diff
changeset
|
49 #include "sub/vobsub.h" |
32456 | 50 #include "sub/spudec.h" |
30901 | 51 #include "path.h" |
22478 | 52 #include "stream/tv.h" |
53 #include "stream/stream_radio.h" | |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
54 #include "stream/pvr.h" |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
55 #ifdef CONFIG_DVBIN |
22478 | 56 #include "stream/dvbin.h" |
57 #endif | |
31877
e30fe0cb79cd
Add incomplete clipinf reading support to display audio
reimar
parents:
31805
diff
changeset
|
58 #include "stream/stream_bd.h" |
29433
3495ccd3aef8
Only #include stream/stream_dvd.h when libdvdread is enabled.
diego
parents:
29429
diff
changeset
|
59 #ifdef CONFIG_DVDREAD |
22478 | 60 #include "stream/stream_dvd.h" |
29433
3495ccd3aef8
Only #include stream/stream_dvd.h when libdvdread is enabled.
diego
parents:
29429
diff
changeset
|
61 #endif |
22478 | 62 #include "stream/stream_dvdnav.h" |
32461 | 63 #include "sub/ass_mp.h" |
25461 | 64 #include "m_struct.h" |
65 #include "libmenu/menu.h" | |
23077 | 66 #include "gui/interface.h" |
32460 | 67 #include "sub/eosd.h" |
32442
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
68 #include "pnm_loader.h" |
22478 | 69 |
70 #include "mp_core.h" | |
24162 | 71 #include "mp_fifo.h" |
26095 | 72 #include "libavutil/avstring.h" |
31957
49848f9a8f30
Add -edl-start-pts option to Adjust positions in EDL records according
reynaldo
parents:
31904
diff
changeset
|
73 #include "edl.h" |
22478 | 74 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
75 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
76 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
77 //remove the borders, if any, and rescale to the range [0,1],[0,1] |
31077 | 78 if (vo_fs) { //we are in full-screen mode |
79 if (vo_screenwidth > vo_dwidth) //there are borders along the x axis | |
80 ix -= (vo_screenwidth - vo_dwidth) / 2; | |
81 if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way) | |
82 iy -= (vo_screenheight - vo_dheight) / 2; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
83 |
35076
77a90f0b02b1
Minor simplification of rescale_input_coordinates.
reimar
parents:
34987
diff
changeset
|
84 if (ix < 0 || ix > vo_dwidth || iy < 0 || iy > vo_dheight) { |
31077 | 85 *dx = *dy = -1.0; |
86 return; | |
87 } //we are on one of the borders | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
88 } |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
89 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
90 *dx = (double) ix / (double) vo_dwidth; |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
91 *dy = (double) iy / (double) vo_dheight; |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
92 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
93 mp_msg(MSGT_CPLAYER, MSGL_V, |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
32209
diff
changeset
|
94 "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n", |
31077 | 95 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, |
96 vo_dheight, vo_fs); | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
97 } |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
98 |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
99 static int sub_pos_by_source(MPContext *mpctx, int src) |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
100 { |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
101 int i, cnt = 0; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
102 if (src >= SUB_SOURCES || mpctx->sub_counts[src] == 0) |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
103 return -1; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
104 for (i = 0; i < src; i++) |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
105 cnt += mpctx->sub_counts[i]; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
106 return cnt; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
107 } |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
108 |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
109 static int sub_source_and_index_by_pos(MPContext *mpctx, int *pos) |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
110 { |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
111 int start = 0; |
22478 | 112 int i; |
113 for (i = 0; i < SUB_SOURCES; i++) { | |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
114 int cnt = mpctx->sub_counts[i]; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
115 if (*pos >= start && *pos < start + cnt) { |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
116 *pos -= start; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
117 return i; |
31077 | 118 } |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
119 start += cnt; |
22478 | 120 } |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
121 *pos = -1; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
122 return -1; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
123 } |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
124 |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
125 static int sub_source_by_pos(MPContext *mpctx, int pos) |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
126 { |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
127 return sub_source_and_index_by_pos(mpctx, &pos); |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
128 } |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
129 |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
130 static int sub_source_pos(MPContext *mpctx) |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
131 { |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
132 int pos = mpctx->global_sub_pos; |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
133 sub_source_and_index_by_pos(mpctx, &pos); |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
134 return pos; |
22478 | 135 } |
136 | |
31156 | 137 static int sub_source(MPContext *mpctx) |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
138 { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
139 return sub_source_by_pos(mpctx, mpctx->global_sub_pos); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
140 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
141 |
31788 | 142 static void update_global_sub_size(MPContext *mpctx) |
143 { | |
144 int i; | |
145 int cnt = 0; | |
146 | |
147 // update number of demuxer sub streams | |
148 for (i = 0; i < MAX_S_STREAMS; i++) | |
149 if (mpctx->demuxer->s_streams[i]) | |
150 cnt++; | |
151 if (cnt > mpctx->sub_counts[SUB_SOURCE_DEMUX]) | |
152 mpctx->sub_counts[SUB_SOURCE_DEMUX] = cnt; | |
153 | |
154 // update global size | |
155 mpctx->global_sub_size = 0; | |
156 for (i = 0; i < SUB_SOURCES; i++) | |
157 mpctx->global_sub_size += mpctx->sub_counts[i]; | |
158 | |
159 // update global_sub_pos if we auto-detected a demuxer sub | |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
160 if (mpctx->global_sub_pos == -1) { |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
161 int sub_id = -1; |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
162 if (mpctx->demuxer->sub) |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
163 sub_id = mpctx->demuxer->sub->id; |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
164 if (sub_id < 0) |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
165 sub_id = dvdsub_id; |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
166 if (sub_id >= 0 && sub_id < mpctx->sub_counts[SUB_SOURCE_DEMUX]) |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
167 mpctx->global_sub_pos = sub_pos_by_source(mpctx, SUB_SOURCE_DEMUX) + |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
168 sub_id; |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
169 } |
31788 | 170 } |
171 | |
22478 | 172 /** |
173 * \brief Log the currently displayed subtitle to a file | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
174 * |
22478 | 175 * Logs the current or last displayed subtitle together with filename |
176 * and time information to ~/.mplayer/subtitle_log | |
177 * | |
178 * Intended purpose is to allow convenient marking of bogus subtitles | |
179 * which need to be fixed while watching the movie. | |
180 */ | |
181 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
182 static void log_sub(void) |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
183 { |
22478 | 184 char *fname; |
185 FILE *f; | |
186 int i; | |
187 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
188 if (subdata == NULL || vo_sub_last == NULL) |
31077 | 189 return; |
22478 | 190 fname = get_path("subtitle_log"); |
191 f = fopen(fname, "a"); | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
192 if (!f) |
31077 | 193 return; |
22478 | 194 fprintf(f, "----------------------------------------------------------\n"); |
195 if (subdata->sub_uses_time) { | |
31077 | 196 fprintf(f, |
197 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", | |
198 filename, vo_sub_last->start / 360000, | |
199 (vo_sub_last->start / 6000) % 60, | |
200 (vo_sub_last->start / 100) % 60, vo_sub_last->start % 100, | |
201 vo_sub_last->end / 360000, (vo_sub_last->end / 6000) % 60, | |
202 (vo_sub_last->end / 100) % 60, vo_sub_last->end % 100); | |
22478 | 203 } else { |
31077 | 204 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start, |
205 vo_sub_last->end); | |
22478 | 206 } |
207 for (i = 0; i < vo_sub_last->lines; i++) { | |
31077 | 208 fprintf(f, "%s\n", vo_sub_last->text[i]); |
22478 | 209 } |
210 fclose(f); | |
211 } | |
212 | |
213 | |
34200
87a1b3a11b33
Fix a bunch of Doxygen syntax errors that caused warnings.
diego
parents:
34174
diff
changeset
|
214 /// \defgroup properties Properties |
22478 | 215 ///@{ |
216 | |
217 /// \defgroup GeneralProperties General properties | |
218 /// \ingroup Properties | |
219 ///@{ | |
220 | |
221 /// OSD level (RW) | |
31156 | 222 static int mp_property_osdlevel(m_option_t *prop, int action, void *arg, |
223 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
224 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
225 return m_property_choice(prop, action, arg, &osd_level); |
22478 | 226 } |
227 | |
23727 | 228 /// Loop (RW) |
31156 | 229 static int mp_property_loop(m_option_t *prop, int action, void *arg, |
230 MPContext *mpctx) | |
23727 | 231 { |
232 switch (action) { | |
233 case M_PROPERTY_PRINT: | |
234 if (!arg) return M_PROPERTY_ERROR; | |
235 if (mpctx->loop_times < 0) | |
236 *(char**)arg = strdup("off"); | |
237 else if (mpctx->loop_times == 0) | |
238 *(char**)arg = strdup("inf"); | |
239 else | |
240 break; | |
241 return M_PROPERTY_OK; | |
242 } | |
243 return m_property_int_range(prop, action, arg, &mpctx->loop_times); | |
244 } | |
245 | |
22478 | 246 /// Playback speed (RW) |
31156 | 247 static int mp_property_playback_speed(m_option_t *prop, int action, |
248 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
249 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
250 switch (action) { |
22478 | 251 case M_PROPERTY_SET: |
31077 | 252 if (!arg) |
253 return M_PROPERTY_ERROR; | |
254 M_PROPERTY_CLAMP(prop, *(float *) arg); | |
255 playback_speed = *(float *) arg; | |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
256 reinit_audio_chain(); |
31077 | 257 return M_PROPERTY_OK; |
22478 | 258 case M_PROPERTY_STEP_UP: |
259 case M_PROPERTY_STEP_DOWN: | |
31077 | 260 playback_speed += (arg ? *(float *) arg : 0.1) * |
261 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); | |
262 M_PROPERTY_CLAMP(prop, playback_speed); | |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
263 reinit_audio_chain(); |
31077 | 264 return M_PROPERTY_OK; |
22478 | 265 } |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
266 return m_property_float_range(prop, action, arg, &playback_speed); |
22478 | 267 } |
268 | |
269 /// filename with path (RO) | |
31156 | 270 static int mp_property_path(m_option_t *prop, int action, void *arg, |
271 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
272 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
273 return m_property_string_ro(prop, action, arg, filename); |
22478 | 274 } |
275 | |
276 /// filename without path (RO) | |
31156 | 277 static int mp_property_filename(m_option_t *prop, int action, void *arg, |
278 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
279 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
280 char *f; |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
281 if (!filename) |
31077 | 282 return M_PROPERTY_UNAVAILABLE; |
32588 | 283 f = (char *)mp_basename(filename); |
284 if (!*f) | |
31077 | 285 f = filename; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
286 return m_property_string_ro(prop, action, arg, f); |
22478 | 287 } |
288 | |
289 /// Demuxer name (RO) | |
31156 | 290 static int mp_property_demuxer(m_option_t *prop, int action, void *arg, |
291 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
292 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
293 if (!mpctx->demuxer) |
31077 | 294 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
295 return m_property_string_ro(prop, action, arg, |
31077 | 296 (char *) mpctx->demuxer->desc->name); |
22478 | 297 } |
298 | |
299 /// Position in the stream (RW) | |
31156 | 300 static int mp_property_stream_pos(m_option_t *prop, int action, void *arg, |
301 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
302 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
303 if (!mpctx->demuxer || !mpctx->demuxer->stream) |
31077 | 304 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
305 if (!arg) |
31077 | 306 return M_PROPERTY_ERROR; |
22478 | 307 switch (action) { |
308 case M_PROPERTY_GET: | |
31077 | 309 *(off_t *) arg = stream_tell(mpctx->demuxer->stream); |
310 return M_PROPERTY_OK; | |
22478 | 311 case M_PROPERTY_SET: |
31077 | 312 M_PROPERTY_CLAMP(prop, *(off_t *) arg); |
313 stream_seek(mpctx->demuxer->stream, *(off_t *) arg); | |
314 return M_PROPERTY_OK; | |
22478 | 315 } |
316 return M_PROPERTY_NOT_IMPLEMENTED; | |
317 } | |
318 | |
319 /// Stream start offset (RO) | |
31156 | 320 static int mp_property_stream_start(m_option_t *prop, int action, |
321 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
322 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
323 if (!mpctx->demuxer || !mpctx->demuxer->stream) |
31077 | 324 return M_PROPERTY_UNAVAILABLE; |
22478 | 325 switch (action) { |
326 case M_PROPERTY_GET: | |
31077 | 327 *(off_t *) arg = mpctx->demuxer->stream->start_pos; |
328 return M_PROPERTY_OK; | |
22478 | 329 } |
330 return M_PROPERTY_NOT_IMPLEMENTED; | |
331 } | |
332 | |
333 /// Stream end offset (RO) | |
31156 | 334 static int mp_property_stream_end(m_option_t *prop, int action, void *arg, |
335 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
336 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
337 if (!mpctx->demuxer || !mpctx->demuxer->stream) |
31077 | 338 return M_PROPERTY_UNAVAILABLE; |
22478 | 339 switch (action) { |
340 case M_PROPERTY_GET: | |
31077 | 341 *(off_t *) arg = mpctx->demuxer->stream->end_pos; |
342 return M_PROPERTY_OK; | |
22478 | 343 } |
344 return M_PROPERTY_NOT_IMPLEMENTED; | |
345 } | |
346 | |
347 /// Stream length (RO) | |
31156 | 348 static int mp_property_stream_length(m_option_t *prop, int action, |
349 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
350 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
351 if (!mpctx->demuxer || !mpctx->demuxer->stream) |
31077 | 352 return M_PROPERTY_UNAVAILABLE; |
22478 | 353 switch (action) { |
354 case M_PROPERTY_GET: | |
31077 | 355 *(off_t *) arg = |
356 mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos; | |
357 return M_PROPERTY_OK; | |
22478 | 358 } |
359 return M_PROPERTY_NOT_IMPLEMENTED; | |
360 } | |
361 | |
31728 | 362 /// Current stream position in seconds (RO) |
363 static int mp_property_stream_time_pos(m_option_t *prop, int action, | |
364 void *arg, MPContext *mpctx) | |
365 { | |
366 if (!mpctx->demuxer || mpctx->demuxer->stream_pts == MP_NOPTS_VALUE) | |
367 return M_PROPERTY_UNAVAILABLE; | |
368 | |
369 return m_property_time_ro(prop, action, arg, mpctx->demuxer->stream_pts); | |
370 } | |
371 | |
372 | |
22478 | 373 /// Media length in seconds (RO) |
31156 | 374 static int mp_property_length(m_option_t *prop, int action, void *arg, |
375 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
376 { |
22478 | 377 double len; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
378 |
22478 | 379 if (!mpctx->demuxer || |
31077 | 380 !(int) (len = demuxer_get_time_length(mpctx->demuxer))) |
381 return M_PROPERTY_UNAVAILABLE; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
382 |
23416
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23412
diff
changeset
|
383 return m_property_time_ro(prop, action, arg, len); |
22478 | 384 } |
385 | |
23418 | 386 /// Current position in percent (RW) |
31156 | 387 static int mp_property_percent_pos(m_option_t *prop, int action, |
388 void *arg, MPContext *mpctx) { | |
23418 | 389 int pos; |
390 | |
391 if (!mpctx->demuxer) | |
31077 | 392 return M_PROPERTY_UNAVAILABLE; |
23418 | 393 |
394 switch(action) { | |
395 case M_PROPERTY_SET: | |
396 if(!arg) return M_PROPERTY_ERROR; | |
397 M_PROPERTY_CLAMP(prop, *(int*)arg); | |
398 pos = *(int*)arg; | |
399 break; | |
400 case M_PROPERTY_STEP_UP: | |
401 case M_PROPERTY_STEP_DOWN: | |
402 pos = demuxer_get_percent_pos(mpctx->demuxer); | |
403 pos += (arg ? *(int*)arg : 10) * | |
404 (action == M_PROPERTY_STEP_UP ? 1 : -1); | |
405 M_PROPERTY_CLAMP(prop, pos); | |
406 break; | |
407 default: | |
408 return m_property_int_ro(prop, action, arg, | |
409 demuxer_get_percent_pos(mpctx->demuxer)); | |
410 } | |
411 | |
25884
f6697d25b040
More places that should use SEEK_ABSOLUTE / SEEK_FACTOR
reimar
parents:
25878
diff
changeset
|
412 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; |
23418 | 413 rel_seek_secs = pos / 100.0; |
414 return M_PROPERTY_OK; | |
415 } | |
416 | |
417 /// Current position in seconds (RW) | |
31156 | 418 static int mp_property_time_pos(m_option_t *prop, int action, |
419 void *arg, MPContext *mpctx) { | |
23418 | 420 if (!(mpctx->sh_video || (mpctx->sh_audio && mpctx->audio_out))) |
421 return M_PROPERTY_UNAVAILABLE; | |
422 | |
423 switch(action) { | |
424 case M_PROPERTY_SET: | |
425 if(!arg) return M_PROPERTY_ERROR; | |
426 M_PROPERTY_CLAMP(prop, *(double*)arg); | |
25884
f6697d25b040
More places that should use SEEK_ABSOLUTE / SEEK_FACTOR
reimar
parents:
25878
diff
changeset
|
427 abs_seek_pos = SEEK_ABSOLUTE; |
23418 | 428 rel_seek_secs = *(double*)arg; |
429 return M_PROPERTY_OK; | |
430 case M_PROPERTY_STEP_UP: | |
431 case M_PROPERTY_STEP_DOWN: | |
432 rel_seek_secs += (arg ? *(double*)arg : 10.0) * | |
433 (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); | |
434 return M_PROPERTY_OK; | |
435 } | |
436 return m_property_time_ro(prop, action, arg, | |
437 mpctx->sh_video ? mpctx->sh_video->pts : | |
438 playing_audio_pts(mpctx->sh_audio, | |
439 mpctx->d_audio, | |
440 mpctx->audio_out)); | |
441 } | |
442 | |
25363 | 443 /// Current chapter (RW) |
444 static int mp_property_chapter(m_option_t *prop, int action, void *arg, | |
445 MPContext *mpctx) | |
446 { | |
27382
aff29422c652
Fixes unsafe 'chapter' command with get_property() call.
ben
parents:
27381
diff
changeset
|
447 int chapter = -1; |
25363 | 448 float next_pts = 0; |
449 int chapter_num; | |
450 int step_all; | |
451 char *chapter_name = NULL; | |
452 | |
27382
aff29422c652
Fixes unsafe 'chapter' command with get_property() call.
ben
parents:
27381
diff
changeset
|
453 if (mpctx->demuxer) |
27383 | 454 chapter = demuxer_get_current_chapter(mpctx->demuxer); |
25462
3e033aabc9d2
Combine common code for check whether chapter is available.
ulion
parents:
25461
diff
changeset
|
455 if (chapter < 0) |
3e033aabc9d2
Combine common code for check whether chapter is available.
ulion
parents:
25461
diff
changeset
|
456 return M_PROPERTY_UNAVAILABLE; |
3e033aabc9d2
Combine common code for check whether chapter is available.
ulion
parents:
25461
diff
changeset
|
457 |
25363 | 458 switch (action) { |
459 case M_PROPERTY_GET: | |
460 if (!arg) | |
461 return M_PROPERTY_ERROR; | |
25402
f8f596bad3bd
Modified for using chapter property for $(NAME:TEXT) or ?(NAME:TEXT).
ulion
parents:
25377
diff
changeset
|
462 *(int *) arg = chapter; |
25363 | 463 return M_PROPERTY_OK; |
464 case M_PROPERTY_PRINT: { | |
465 if (!arg) | |
466 return M_PROPERTY_ERROR; | |
467 chapter_name = demuxer_chapter_display_name(mpctx->demuxer, chapter); | |
468 if (!chapter_name) | |
469 return M_PROPERTY_UNAVAILABLE; | |
470 *(char **) arg = chapter_name; | |
471 return M_PROPERTY_OK; | |
472 } | |
473 case M_PROPERTY_SET: | |
474 if (!arg) | |
475 return M_PROPERTY_ERROR; | |
476 M_PROPERTY_CLAMP(prop, *(int*)arg); | |
29365
794a26e68c2c
Make set_property chapter 0-based like all other chapter-related
reimar
parents:
29333
diff
changeset
|
477 step_all = *(int *)arg - chapter; |
25363 | 478 chapter += step_all; |
479 break; | |
480 case M_PROPERTY_STEP_UP: | |
481 case M_PROPERTY_STEP_DOWN: { | |
482 step_all = (arg && *(int*)arg != 0 ? *(int*)arg : 1) | |
483 * (action == M_PROPERTY_STEP_UP ? 1 : -1); | |
484 chapter += step_all; | |
485 if (chapter < 0) | |
486 chapter = 0; | |
487 break; | |
488 } | |
489 default: | |
490 return M_PROPERTY_NOT_IMPLEMENTED; | |
491 } | |
492 rel_seek_secs = 0; | |
493 abs_seek_pos = 0; | |
494 chapter = demuxer_seek_chapter(mpctx->demuxer, chapter, 1, | |
495 &next_pts, &chapter_num, &chapter_name); | |
496 if (chapter >= 0) { | |
497 if (next_pts > -1.0) { | |
25884
f6697d25b040
More places that should use SEEK_ABSOLUTE / SEEK_FACTOR
reimar
parents:
25878
diff
changeset
|
498 abs_seek_pos = SEEK_ABSOLUTE; |
25363 | 499 rel_seek_secs = next_pts; |
500 } | |
501 if (chapter_name) | |
502 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, | |
503 MSGTR_OSDChapter, chapter + 1, chapter_name); | |
504 } | |
505 else if (step_all > 0) | |
506 rel_seek_secs = 1000000000.; | |
507 else | |
508 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, | |
509 MSGTR_OSDChapter, 0, MSGTR_Unknown); | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32467
diff
changeset
|
510 free(chapter_name); |
25363 | 511 return M_PROPERTY_OK; |
512 } | |
513 | |
34386
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
514 /// Number of titles in file |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
515 static int mp_property_titles(m_option_t *prop, int action, void *arg, |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
516 MPContext *mpctx) |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
517 { |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
518 if (!mpctx->demuxer) |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
519 return M_PROPERTY_UNAVAILABLE; |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
520 if (mpctx->demuxer->num_titles == 0) |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
521 stream_control(mpctx->demuxer->stream, STREAM_CTRL_GET_NUM_TITLES, &mpctx->demuxer->num_titles); |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
522 return m_property_int_ro(prop, action, arg, mpctx->demuxer->num_titles); |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
523 } |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
524 |
27635
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
525 /// Number of chapters in file |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
526 static int mp_property_chapters(m_option_t *prop, int action, void *arg, |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
527 MPContext *mpctx) |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
528 { |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
529 if (!mpctx->demuxer) |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
530 return M_PROPERTY_UNAVAILABLE; |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
531 if (mpctx->demuxer->num_chapters == 0) |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
532 stream_control(mpctx->demuxer->stream, STREAM_CTRL_GET_NUM_CHAPTERS, &mpctx->demuxer->num_chapters); |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
533 return m_property_int_ro(prop, action, arg, mpctx->demuxer->num_chapters); |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
534 } |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
535 |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
536 /// Current dvd angle (RW) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
537 static int mp_property_angle(m_option_t *prop, int action, void *arg, |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
538 MPContext *mpctx) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
539 { |
27380
843db879a6b2
Fixes unsafe 'angle' command with get_property() call.
ben
parents:
27379
diff
changeset
|
540 int angle = -1; |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
541 int angles; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
542 char *angle_name = NULL; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
543 |
27380
843db879a6b2
Fixes unsafe 'angle' command with get_property() call.
ben
parents:
27379
diff
changeset
|
544 if (mpctx->demuxer) |
27381 | 545 angle = demuxer_get_current_angle(mpctx->demuxer); |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
546 if (angle < 0) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
547 return M_PROPERTY_UNAVAILABLE; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
548 angles = demuxer_angles_count(mpctx->demuxer); |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
549 if (angles <= 1) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
550 return M_PROPERTY_UNAVAILABLE; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
551 |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
552 switch (action) { |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
553 case M_PROPERTY_GET: |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
554 if (!arg) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
555 return M_PROPERTY_ERROR; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
556 *(int *) arg = angle; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
557 return M_PROPERTY_OK; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
558 case M_PROPERTY_PRINT: { |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
559 if (!arg) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
560 return M_PROPERTY_ERROR; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
561 angle_name = calloc(1, 64); |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
562 if (!angle_name) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
563 return M_PROPERTY_UNAVAILABLE; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
564 snprintf(angle_name, 64, "%d/%d", angle, angles); |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
565 *(char **) arg = angle_name; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
566 return M_PROPERTY_OK; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
567 } |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
568 case M_PROPERTY_SET: |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
569 if (!arg) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
570 return M_PROPERTY_ERROR; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
571 angle = *(int *)arg; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
572 M_PROPERTY_CLAMP(prop, angle); |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
573 break; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
574 case M_PROPERTY_STEP_UP: |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
575 case M_PROPERTY_STEP_DOWN: { |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
576 int step = 0; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
577 if(arg) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
578 step = *(int*)arg; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
579 if(!step) |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
580 step = 1; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
581 step *= (action == M_PROPERTY_STEP_UP ? 1 : -1); |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
582 angle += step; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
583 if (angle < 1) //cycle |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
584 angle = angles; |
33230 | 585 else if (angle > angles) |
586 angle = 1; | |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
587 break; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
588 } |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
589 default: |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
590 return M_PROPERTY_NOT_IMPLEMENTED; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
591 } |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
592 angle = demuxer_set_angle(mpctx->demuxer, angle); |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
593 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
594 MSGTR_OSDAngle, angle, angles); |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32467
diff
changeset
|
595 free(angle_name); |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
596 return M_PROPERTY_OK; |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
597 } |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
598 |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
599 /// Demuxer meta data |
31156 | 600 static int mp_property_metadata(m_option_t *prop, int action, void *arg, |
601 MPContext *mpctx) { | |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
602 m_property_action_t* ka; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
603 char* meta; |
31200 | 604 static const m_option_t key_type = |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
605 { "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL }; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
606 if (!mpctx->demuxer) |
31077 | 607 return M_PROPERTY_UNAVAILABLE; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
608 |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
609 switch(action) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
610 case M_PROPERTY_GET: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
611 if(!arg) return M_PROPERTY_ERROR; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
612 *(char***)arg = mpctx->demuxer->info; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
613 return M_PROPERTY_OK; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
614 case M_PROPERTY_KEY_ACTION: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
615 if(!arg) return M_PROPERTY_ERROR; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
616 ka = arg; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
617 if(!(meta = demux_info_get(mpctx->demuxer,ka->key))) |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
618 return M_PROPERTY_UNKNOWN; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
619 switch(ka->action) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
620 case M_PROPERTY_GET: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
621 if(!ka->arg) return M_PROPERTY_ERROR; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
622 *(char**)ka->arg = meta; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
623 return M_PROPERTY_OK; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
624 case M_PROPERTY_GET_TYPE: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
625 if(!ka->arg) return M_PROPERTY_ERROR; |
31729 | 626 *(const m_option_t**)ka->arg = &key_type; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
627 return M_PROPERTY_OK; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
628 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
629 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
630 return M_PROPERTY_NOT_IMPLEMENTED; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
631 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
632 |
31156 | 633 static int mp_property_pause(m_option_t *prop, int action, void *arg, |
634 MPContext *mpctx) | |
27648
427fec163870
Add a "pause" property to allow checking if MPlayer is paused.
reimar
parents:
27635
diff
changeset
|
635 { |
427fec163870
Add a "pause" property to allow checking if MPlayer is paused.
reimar
parents:
27635
diff
changeset
|
636 return m_property_flag_ro(prop, action, arg, mpctx->osd_function == OSD_PAUSE); |
427fec163870
Add a "pause" property to allow checking if MPlayer is paused.
reimar
parents:
27635
diff
changeset
|
637 } |
427fec163870
Add a "pause" property to allow checking if MPlayer is paused.
reimar
parents:
27635
diff
changeset
|
638 |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
639 |
22478 | 640 ///@} |
641 | |
642 /// \defgroup AudioProperties Audio properties | |
643 /// \ingroup Properties | |
644 ///@{ | |
645 | |
646 /// Volume (RW) | |
31156 | 647 static int mp_property_volume(m_option_t *prop, int action, void *arg, |
648 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
649 { |
22478 | 650 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
651 if (!mpctx->sh_audio) |
31077 | 652 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
653 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
654 switch (action) { |
22478 | 655 case M_PROPERTY_GET: |
31077 | 656 if (!arg) |
657 return M_PROPERTY_ERROR; | |
658 mixer_getbothvolume(&mpctx->mixer, arg); | |
659 return M_PROPERTY_OK; | |
22478 | 660 case M_PROPERTY_PRINT:{ |
31077 | 661 float vol; |
662 if (!arg) | |
663 return M_PROPERTY_ERROR; | |
664 mixer_getbothvolume(&mpctx->mixer, &vol); | |
665 return m_property_float_range(prop, action, arg, &vol); | |
666 } | |
22478 | 667 case M_PROPERTY_STEP_UP: |
668 case M_PROPERTY_STEP_DOWN: | |
669 case M_PROPERTY_SET: | |
31077 | 670 break; |
22478 | 671 default: |
31077 | 672 return M_PROPERTY_NOT_IMPLEMENTED; |
22478 | 673 } |
674 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
675 if (mpctx->edl_muted) |
31077 | 676 return M_PROPERTY_DISABLED; |
22478 | 677 mpctx->user_muted = 0; |
678 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
679 switch (action) { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
680 case M_PROPERTY_SET: |
31077 | 681 if (!arg) |
682 return M_PROPERTY_ERROR; | |
683 M_PROPERTY_CLAMP(prop, *(float *) arg); | |
684 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg); | |
685 return M_PROPERTY_OK; | |
22478 | 686 case M_PROPERTY_STEP_UP: |
31077 | 687 if (arg && *(float *) arg <= 0) |
688 mixer_decvolume(&mpctx->mixer); | |
689 else | |
690 mixer_incvolume(&mpctx->mixer); | |
691 return M_PROPERTY_OK; | |
22478 | 692 case M_PROPERTY_STEP_DOWN: |
31077 | 693 if (arg && *(float *) arg <= 0) |
694 mixer_incvolume(&mpctx->mixer); | |
695 else | |
696 mixer_decvolume(&mpctx->mixer); | |
697 return M_PROPERTY_OK; | |
22478 | 698 } |
699 return M_PROPERTY_NOT_IMPLEMENTED; | |
700 } | |
701 | |
702 /// Mute (RW) | |
31156 | 703 static int mp_property_mute(m_option_t *prop, int action, void *arg, |
704 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
705 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
706 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
707 if (!mpctx->sh_audio) |
31077 | 708 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
709 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
710 switch (action) { |
22478 | 711 case M_PROPERTY_SET: |
31077 | 712 if (mpctx->edl_muted) |
713 return M_PROPERTY_DISABLED; | |
714 if (!arg) | |
715 return M_PROPERTY_ERROR; | |
716 if ((!!*(int *) arg) != mpctx->mixer.muted) | |
717 mixer_mute(&mpctx->mixer); | |
718 mpctx->user_muted = mpctx->mixer.muted; | |
719 return M_PROPERTY_OK; | |
22478 | 720 case M_PROPERTY_STEP_UP: |
721 case M_PROPERTY_STEP_DOWN: | |
31077 | 722 if (mpctx->edl_muted) |
723 return M_PROPERTY_DISABLED; | |
724 mixer_mute(&mpctx->mixer); | |
725 mpctx->user_muted = mpctx->mixer.muted; | |
726 return M_PROPERTY_OK; | |
22478 | 727 case M_PROPERTY_PRINT: |
31077 | 728 if (!arg) |
729 return M_PROPERTY_ERROR; | |
730 if (mpctx->edl_muted) { | |
731 *(char **) arg = strdup(MSGTR_EnabledEdl); | |
732 return M_PROPERTY_OK; | |
733 } | |
22478 | 734 default: |
31077 | 735 return m_property_flag(prop, action, arg, &mpctx->mixer.muted); |
22478 | 736 |
737 } | |
738 } | |
739 | |
740 /// Audio delay (RW) | |
31156 | 741 static int mp_property_audio_delay(m_option_t *prop, int action, |
742 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
743 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
744 if (!(mpctx->sh_audio && mpctx->sh_video)) |
31077 | 745 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
746 switch (action) { |
22478 | 747 case M_PROPERTY_SET: |
748 case M_PROPERTY_STEP_UP: | |
25567
ca62d466a9fc
Fix property audio_delay bug when step up/down with arg value NULL.
ulion
parents:
25495
diff
changeset
|
749 case M_PROPERTY_STEP_DOWN: { |
31077 | 750 int ret; |
751 float delay = audio_delay; | |
752 ret = m_property_delay(prop, action, arg, &audio_delay); | |
753 if (ret != M_PROPERTY_OK) | |
754 return ret; | |
755 if (mpctx->sh_audio) | |
756 mpctx->delay -= audio_delay - delay; | |
757 } | |
758 return M_PROPERTY_OK; | |
22478 | 759 default: |
31077 | 760 return m_property_delay(prop, action, arg, &audio_delay); |
22478 | 761 } |
762 } | |
763 | |
764 /// Audio codec tag (RO) | |
31156 | 765 static int mp_property_audio_format(m_option_t *prop, int action, |
766 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
767 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
768 if (!mpctx->sh_audio) |
31077 | 769 return M_PROPERTY_UNAVAILABLE; |
22478 | 770 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format); |
771 } | |
772 | |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
773 /// Audio codec name (RO) |
31156 | 774 static int mp_property_audio_codec(m_option_t *prop, int action, |
775 void *arg, MPContext *mpctx) | |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
776 { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
777 if (!mpctx->sh_audio || !mpctx->sh_audio->codec) |
31077 | 778 return M_PROPERTY_UNAVAILABLE; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
779 return m_property_string_ro(prop, action, arg, mpctx->sh_audio->codec->name); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
780 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
781 |
22478 | 782 /// Audio bitrate (RO) |
31156 | 783 static int mp_property_audio_bitrate(m_option_t *prop, int action, |
784 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
785 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
786 if (!mpctx->sh_audio) |
31077 | 787 return M_PROPERTY_UNAVAILABLE; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
788 return m_property_bitrate(prop, action, arg, mpctx->sh_audio->i_bps); |
22478 | 789 } |
790 | |
791 /// Samplerate (RO) | |
31156 | 792 static int mp_property_samplerate(m_option_t *prop, int action, void *arg, |
793 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
794 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
795 if (!mpctx->sh_audio) |
31077 | 796 return M_PROPERTY_UNAVAILABLE; |
23396 | 797 switch(action) { |
798 case M_PROPERTY_PRINT: | |
799 if(!arg) return M_PROPERTY_ERROR; | |
800 *(char**)arg = malloc(16); | |
801 sprintf(*(char**)arg,"%d kHz",mpctx->sh_audio->samplerate/1000); | |
802 return M_PROPERTY_OK; | |
803 } | |
22478 | 804 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate); |
805 } | |
806 | |
807 /// Number of channels (RO) | |
31156 | 808 static int mp_property_channels(m_option_t *prop, int action, void *arg, |
809 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
810 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
811 if (!mpctx->sh_audio) |
31077 | 812 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
813 switch (action) { |
22478 | 814 case M_PROPERTY_PRINT: |
31077 | 815 if (!arg) |
816 return M_PROPERTY_ERROR; | |
817 switch (mpctx->sh_audio->channels) { | |
818 case 1: | |
819 *(char **) arg = strdup("mono"); | |
820 break; | |
821 case 2: | |
822 *(char **) arg = strdup("stereo"); | |
823 break; | |
824 default: | |
825 *(char **) arg = malloc(32); | |
826 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels); | |
827 } | |
828 return M_PROPERTY_OK; | |
22478 | 829 } |
830 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels); | |
831 } | |
832 | |
23568 | 833 /// Balance (RW) |
31156 | 834 static int mp_property_balance(m_option_t *prop, int action, void *arg, |
835 MPContext *mpctx) | |
23568 | 836 { |
837 float bal; | |
838 | |
839 if (!mpctx->sh_audio || mpctx->sh_audio->channels < 2) | |
31077 | 840 return M_PROPERTY_UNAVAILABLE; |
23568 | 841 |
842 switch (action) { | |
843 case M_PROPERTY_GET: | |
31077 | 844 if (!arg) |
845 return M_PROPERTY_ERROR; | |
846 mixer_getbalance(&mpctx->mixer, arg); | |
847 return M_PROPERTY_OK; | |
23568 | 848 case M_PROPERTY_PRINT: { |
31077 | 849 char** str = arg; |
850 if (!arg) | |
851 return M_PROPERTY_ERROR; | |
852 mixer_getbalance(&mpctx->mixer, &bal); | |
853 if (bal == 0.f) | |
854 *str = strdup("center"); | |
855 else if (bal == -1.f) | |
856 *str = strdup("left only"); | |
857 else if (bal == 1.f) | |
858 *str = strdup("right only"); | |
859 else { | |
860 unsigned right = (bal + 1.f) / 2.f * 100.f; | |
861 *str = malloc(sizeof("left xxx%, right xxx%")); | |
862 sprintf(*str, "left %d%%, right %d%%", 100 - right, right); | |
863 } | |
864 return M_PROPERTY_OK; | |
865 } | |
23568 | 866 case M_PROPERTY_STEP_UP: |
867 case M_PROPERTY_STEP_DOWN: | |
31077 | 868 mixer_getbalance(&mpctx->mixer, &bal); |
869 bal += (arg ? *(float*)arg : .1f) * | |
870 (action == M_PROPERTY_STEP_UP ? 1.f : -1.f); | |
871 M_PROPERTY_CLAMP(prop, bal); | |
872 mixer_setbalance(&mpctx->mixer, bal); | |
873 return M_PROPERTY_OK; | |
23568 | 874 case M_PROPERTY_SET: |
31077 | 875 if (!arg) |
876 return M_PROPERTY_ERROR; | |
877 M_PROPERTY_CLAMP(prop, *(float*)arg); | |
878 mixer_setbalance(&mpctx->mixer, *(float*)arg); | |
879 return M_PROPERTY_OK; | |
23568 | 880 } |
881 return M_PROPERTY_NOT_IMPLEMENTED; | |
882 } | |
883 | |
22478 | 884 /// Selected audio id (RW) |
31156 | 885 static int mp_property_audio(m_option_t *prop, int action, void *arg, |
886 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
887 { |
30082
446f2ea148a4
Return the actually playing audio/video id for get_property, not the one
reimar
parents:
30080
diff
changeset
|
888 int current_id, tmp; |
30079
4bd9b89b2b85
Use the same condition to decide if the audio/video id property is
reimar
parents:
30078
diff
changeset
|
889 if (!mpctx->demuxer || !mpctx->demuxer->audio) |
4bd9b89b2b85
Use the same condition to decide if the audio/video id property is
reimar
parents:
30078
diff
changeset
|
890 return M_PROPERTY_UNAVAILABLE; |
30082
446f2ea148a4
Return the actually playing audio/video id for get_property, not the one
reimar
parents:
30080
diff
changeset
|
891 current_id = mpctx->demuxer->audio->id; |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
892 if (current_id >= 0) |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
893 audio_id = ((sh_audio_t *)mpctx->demuxer->a_streams[current_id])->aid; |
22478 | 894 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
895 switch (action) { |
22478 | 896 case M_PROPERTY_GET: |
31077 | 897 if (!arg) |
898 return M_PROPERTY_ERROR; | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
899 *(int *) arg = audio_id; |
31077 | 900 return M_PROPERTY_OK; |
22478 | 901 case M_PROPERTY_PRINT: |
31077 | 902 if (!arg) |
903 return M_PROPERTY_ERROR; | |
22478 | 904 |
31077 | 905 if (current_id < 0) |
906 *(char **) arg = strdup(MSGTR_Disabled); | |
907 else { | |
908 char lang[40] = MSGTR_Unknown; | |
34648
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34386
diff
changeset
|
909 demuxer_audio_lang(mpctx->demuxer, current_id, lang, sizeof(lang)); |
31077 | 910 *(char **) arg = malloc(64); |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
911 snprintf(*(char **) arg, 64, "(%d) %s", audio_id, lang); |
31077 | 912 } |
913 return M_PROPERTY_OK; | |
22478 | 914 |
915 case M_PROPERTY_STEP_UP: | |
916 case M_PROPERTY_SET: | |
31077 | 917 if (action == M_PROPERTY_SET && arg) |
918 tmp = *((int *) arg); | |
919 else | |
920 tmp = -1; | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
921 tmp = demuxer_switch_audio(mpctx->demuxer, tmp); |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
922 if (tmp == -2 |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
923 || (tmp > -1 |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
924 && mpctx->demuxer->audio->id != current_id && current_id != -2)) { |
31077 | 925 uninit_player(INITIALIZED_AO | INITIALIZED_ACODEC); |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
926 audio_id = tmp; |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
927 } |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
928 if (tmp > -1 && mpctx->demuxer->audio->id != current_id) { |
31077 | 929 sh_audio_t *sh2; |
930 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id]; | |
931 if (sh2) { | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
932 audio_id = sh2->aid; |
31077 | 933 sh2->ds = mpctx->demuxer->audio; |
934 mpctx->sh_audio = sh2; | |
935 reinit_audio_chain(); | |
936 } | |
937 } | |
938 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id); | |
939 return M_PROPERTY_OK; | |
22478 | 940 default: |
31077 | 941 return M_PROPERTY_NOT_IMPLEMENTED; |
22478 | 942 } |
943 | |
944 } | |
945 | |
946 /// Selected video id (RW) | |
31156 | 947 static int mp_property_video(m_option_t *prop, int action, void *arg, |
948 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
949 { |
30082
446f2ea148a4
Return the actually playing audio/video id for get_property, not the one
reimar
parents:
30080
diff
changeset
|
950 int current_id, tmp; |
30079
4bd9b89b2b85
Use the same condition to decide if the audio/video id property is
reimar
parents:
30078
diff
changeset
|
951 if (!mpctx->demuxer || !mpctx->demuxer->video) |
4bd9b89b2b85
Use the same condition to decide if the audio/video id property is
reimar
parents:
30078
diff
changeset
|
952 return M_PROPERTY_UNAVAILABLE; |
30082
446f2ea148a4
Return the actually playing audio/video id for get_property, not the one
reimar
parents:
30080
diff
changeset
|
953 current_id = mpctx->demuxer->video->id; |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
954 if (current_id >= 0) |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
955 video_id = ((sh_video_t *)mpctx->demuxer->v_streams[current_id])->vid; |
22478 | 956 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
957 switch (action) { |
22478 | 958 case M_PROPERTY_GET: |
31077 | 959 if (!arg) |
960 return M_PROPERTY_ERROR; | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
961 *(int *) arg = video_id; |
31077 | 962 return M_PROPERTY_OK; |
22478 | 963 case M_PROPERTY_PRINT: |
31077 | 964 if (!arg) |
965 return M_PROPERTY_ERROR; | |
22478 | 966 |
31077 | 967 if (current_id < 0) |
968 *(char **) arg = strdup(MSGTR_Disabled); | |
969 else { | |
970 char lang[40] = MSGTR_Unknown; | |
971 *(char **) arg = malloc(64); | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
972 snprintf(*(char **) arg, 64, "(%d) %s", video_id, lang); |
31077 | 973 } |
974 return M_PROPERTY_OK; | |
22478 | 975 |
976 case M_PROPERTY_STEP_UP: | |
977 case M_PROPERTY_SET: | |
31077 | 978 if (action == M_PROPERTY_SET && arg) |
979 tmp = *((int *) arg); | |
980 else | |
981 tmp = -1; | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
982 tmp = demuxer_switch_video(mpctx->demuxer, tmp); |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
983 if (tmp == -2 |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
984 || (tmp > -1 && mpctx->demuxer->video->id != current_id |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
985 && current_id != -2)) { |
31077 | 986 uninit_player(INITIALIZED_VCODEC | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
987 (fixed_vo && tmp != -2 ? 0 : INITIALIZED_VO)); |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
988 video_id = tmp; |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
989 } |
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
990 if (tmp > -1 && mpctx->demuxer->video->id != current_id) { |
31077 | 991 sh_video_t *sh2; |
992 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id]; | |
993 if (sh2) { | |
33229
71c65ab3c204
Fix audio/video ID mapping for slave commands to correspond to the
reimar
parents:
32738
diff
changeset
|
994 video_id = sh2->vid; |
31077 | 995 sh2->ds = mpctx->demuxer->video; |
996 mpctx->sh_video = sh2; | |
997 reinit_video_chain(); | |
998 } | |
999 } | |
1000 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id); | |
1001 return M_PROPERTY_OK; | |
22478 | 1002 |
1003 default: | |
31077 | 1004 return M_PROPERTY_NOT_IMPLEMENTED; |
22478 | 1005 } |
1006 } | |
1007 | |
31156 | 1008 static int mp_property_program(m_option_t *prop, int action, void *arg, |
1009 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1010 { |
22478 | 1011 demux_program_t prog; |
1012 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1013 switch (action) { |
22478 | 1014 case M_PROPERTY_STEP_UP: |
1015 case M_PROPERTY_SET: | |
31077 | 1016 if (action == M_PROPERTY_SET && arg) |
1017 prog.progid = *((int *) arg); | |
1018 else | |
1019 prog.progid = -1; | |
1020 if (demux_control | |
1021 (mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, | |
1022 &prog) == DEMUXER_CTRL_NOTIMPL) | |
1023 return M_PROPERTY_ERROR; | |
22478 | 1024 |
31077 | 1025 if (prog.aid < 0 && prog.vid < 0) { |
1026 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Selected program contains no audio or video streams!\n"); | |
1027 return M_PROPERTY_ERROR; | |
1028 } | |
1029 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx); | |
1030 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx); | |
1031 return M_PROPERTY_OK; | |
22478 | 1032 |
1033 default: | |
31077 | 1034 return M_PROPERTY_NOT_IMPLEMENTED; |
22478 | 1035 } |
1036 } | |
1037 | |
1038 ///@} | |
1039 | |
1040 /// \defgroup VideoProperties Video properties | |
1041 /// \ingroup Properties | |
1042 ///@{ | |
1043 | |
1044 /// Fullscreen state (RW) | |
31156 | 1045 static int mp_property_fullscreen(m_option_t *prop, int action, void *arg, |
1046 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1047 { |
22478 | 1048 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1049 if (!mpctx->video_out) |
31077 | 1050 return M_PROPERTY_UNAVAILABLE; |
22478 | 1051 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1052 switch (action) { |
22478 | 1053 case M_PROPERTY_SET: |
31077 | 1054 if (!arg) |
1055 return M_PROPERTY_ERROR; | |
1056 M_PROPERTY_CLAMP(prop, *(int *) arg); | |
1057 if (vo_fs == !!*(int *) arg) | |
1058 return M_PROPERTY_OK; | |
22478 | 1059 case M_PROPERTY_STEP_UP: |
1060 case M_PROPERTY_STEP_DOWN: | |
27343 | 1061 #ifdef CONFIG_GUI |
31077 | 1062 if (use_gui) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
1063 gui(GUI_RUN_COMMAND, (void *) MP_CMD_VO_FULLSCREEN); |
31077 | 1064 else |
22478 | 1065 #endif |
31077 | 1066 if (vo_config_count) |
1067 mpctx->video_out->control(VOCTRL_FULLSCREEN, 0); | |
1068 return M_PROPERTY_OK; | |
22478 | 1069 default: |
31077 | 1070 return m_property_flag(prop, action, arg, &vo_fs); |
22478 | 1071 } |
1072 } | |
1073 | |
31156 | 1074 static int mp_property_deinterlace(m_option_t *prop, int action, |
1075 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1076 { |
22478 | 1077 int deinterlace; |
1078 vf_instance_t *vf; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1079 if (!mpctx->sh_video || !mpctx->sh_video->vfilter) |
31077 | 1080 return M_PROPERTY_UNAVAILABLE; |
22478 | 1081 vf = mpctx->sh_video->vfilter; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1082 switch (action) { |
22478 | 1083 case M_PROPERTY_GET: |
31077 | 1084 if (!arg) |
1085 return M_PROPERTY_ERROR; | |
1086 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg); | |
1087 return M_PROPERTY_OK; | |
22478 | 1088 case M_PROPERTY_SET: |
31077 | 1089 if (!arg) |
1090 return M_PROPERTY_ERROR; | |
1091 M_PROPERTY_CLAMP(prop, *(int *) arg); | |
1092 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg); | |
1093 return M_PROPERTY_OK; | |
22478 | 1094 case M_PROPERTY_STEP_UP: |
1095 case M_PROPERTY_STEP_DOWN: | |
31077 | 1096 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace); |
1097 deinterlace = !deinterlace; | |
1098 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace); | |
1099 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDDeinterlace, | |
1100 deinterlace ? MSGTR_Enabled : MSGTR_Disabled); | |
1101 return M_PROPERTY_OK; | |
22478 | 1102 } |
1103 return M_PROPERTY_NOT_IMPLEMENTED; | |
1104 } | |
1105 | |
32438
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1106 static int mp_property_capture(m_option_t *prop, int action, |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1107 void *arg, MPContext *mpctx) |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1108 { |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1109 int ret; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1110 int capturing = !!mpctx->stream->capture_file; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1111 |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1112 if (!mpctx->stream) |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1113 return M_PROPERTY_UNAVAILABLE; |
32443
5aae26f4bb59
Simplify and fix capture feature to not always return an error.
reimar
parents:
32442
diff
changeset
|
1114 if (!capture_dump) { |
5aae26f4bb59
Simplify and fix capture feature to not always return an error.
reimar
parents:
32442
diff
changeset
|
1115 mp_msg(MSGT_GLOBAL, MSGL_ERR, |
5aae26f4bb59
Simplify and fix capture feature to not always return an error.
reimar
parents:
32442
diff
changeset
|
1116 "Capturing not enabled (forgot -capture parameter?)\n"); |
5aae26f4bb59
Simplify and fix capture feature to not always return an error.
reimar
parents:
32442
diff
changeset
|
1117 return M_PROPERTY_ERROR; |
5aae26f4bb59
Simplify and fix capture feature to not always return an error.
reimar
parents:
32442
diff
changeset
|
1118 } |
32438
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1119 |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1120 ret = m_property_flag(prop, action, arg, &capturing); |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1121 if (ret == M_PROPERTY_OK && capturing != !!mpctx->stream->capture_file) { |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1122 if (capturing) { |
32444
99efb38a4f4e
Change capture feature to append to file instead of overwriting.
reimar
parents:
32443
diff
changeset
|
1123 mpctx->stream->capture_file = fopen(stream_dump_name, "ab"); |
32443
5aae26f4bb59
Simplify and fix capture feature to not always return an error.
reimar
parents:
32442
diff
changeset
|
1124 if (!mpctx->stream->capture_file) { |
32438
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1125 mp_msg(MSGT_GLOBAL, MSGL_ERR, |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1126 "Error opening capture file: %s\n", strerror(errno)); |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1127 ret = M_PROPERTY_ERROR; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1128 } |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1129 } else { |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1130 fclose(mpctx->stream->capture_file); |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1131 mpctx->stream->capture_file = NULL; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1132 } |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1133 } |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1134 |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1135 switch (ret) { |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1136 case M_PROPERTY_ERROR: |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1137 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDCapturingFailure); |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1138 break; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1139 case M_PROPERTY_OK: |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1140 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDCapturing, |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1141 mpctx->stream->capture_file ? MSGTR_Enabled : MSGTR_Disabled); |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1142 break; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1143 default: |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1144 break; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1145 } |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1146 |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1147 return ret; |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1148 } |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
1149 |
22478 | 1150 /// Panscan (RW) |
31156 | 1151 static int mp_property_panscan(m_option_t *prop, int action, void *arg, |
1152 MPContext *mpctx) | |
22478 | 1153 { |
1154 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1155 if (!mpctx->video_out |
31077 | 1156 || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE) |
1157 return M_PROPERTY_UNAVAILABLE; | |
22478 | 1158 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1159 switch (action) { |
22478 | 1160 case M_PROPERTY_SET: |
31077 | 1161 if (!arg) |
1162 return M_PROPERTY_ERROR; | |
1163 M_PROPERTY_CLAMP(prop, *(float *) arg); | |
1164 vo_panscan = *(float *) arg; | |
1165 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); | |
1166 return M_PROPERTY_OK; | |
22478 | 1167 case M_PROPERTY_STEP_UP: |
1168 case M_PROPERTY_STEP_DOWN: | |
31077 | 1169 vo_panscan += (arg ? *(float *) arg : 0.1) * |
1170 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); | |
1171 if (vo_panscan > 1) | |
1172 vo_panscan = 1; | |
1173 else if (vo_panscan < 0) | |
1174 vo_panscan = 0; | |
1175 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); | |
1176 return M_PROPERTY_OK; | |
22478 | 1177 default: |
31077 | 1178 return m_property_float_range(prop, action, arg, &vo_panscan); |
22478 | 1179 } |
1180 } | |
1181 | |
1182 /// Helper to set vo flags. | |
1183 /** \ingroup PropertyImplHelper | |
1184 */ | |
31156 | 1185 static int mp_property_vo_flag(m_option_t *prop, int action, void *arg, |
1186 int vo_ctrl, int *vo_var, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1187 { |
22478 | 1188 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1189 if (!mpctx->video_out) |
31077 | 1190 return M_PROPERTY_UNAVAILABLE; |
22478 | 1191 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1192 switch (action) { |
22478 | 1193 case M_PROPERTY_SET: |
31077 | 1194 if (!arg) |
1195 return M_PROPERTY_ERROR; | |
1196 M_PROPERTY_CLAMP(prop, *(int *) arg); | |
1197 if (*vo_var == !!*(int *) arg) | |
1198 return M_PROPERTY_OK; | |
22478 | 1199 case M_PROPERTY_STEP_UP: |
1200 case M_PROPERTY_STEP_DOWN: | |
31077 | 1201 if (vo_config_count) |
1202 mpctx->video_out->control(vo_ctrl, 0); | |
1203 return M_PROPERTY_OK; | |
22478 | 1204 default: |
31077 | 1205 return m_property_flag(prop, action, arg, vo_var); |
22478 | 1206 } |
1207 } | |
1208 | |
1209 /// Window always on top (RW) | |
31156 | 1210 static int mp_property_ontop(m_option_t *prop, int action, void *arg, |
1211 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1212 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1213 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop, |
31077 | 1214 mpctx); |
22478 | 1215 } |
1216 | |
1217 /// Display in the root window (RW) | |
31156 | 1218 static int mp_property_rootwin(m_option_t *prop, int action, void *arg, |
1219 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1220 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1221 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN, |
31077 | 1222 &vo_rootwin, mpctx); |
22478 | 1223 } |
1224 | |
1225 /// Show window borders (RW) | |
31156 | 1226 static int mp_property_border(m_option_t *prop, int action, void *arg, |
1227 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1228 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1229 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, |
31077 | 1230 &vo_border, mpctx); |
22478 | 1231 } |
1232 | |
1233 /// Framedropping state (RW) | |
31156 | 1234 static int mp_property_framedropping(m_option_t *prop, int action, |
1235 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1236 { |
22478 | 1237 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1238 if (!mpctx->sh_video) |
31077 | 1239 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1240 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1241 switch (action) { |
22478 | 1242 case M_PROPERTY_PRINT: |
31077 | 1243 if (!arg) |
1244 return M_PROPERTY_ERROR; | |
1245 *(char **) arg = strdup(frame_dropping == 1 ? MSGTR_Enabled : | |
1246 (frame_dropping == 2 ? MSGTR_HardFrameDrop : | |
1247 MSGTR_Disabled)); | |
1248 return M_PROPERTY_OK; | |
22478 | 1249 default: |
31077 | 1250 return m_property_choice(prop, action, arg, &frame_dropping); |
22478 | 1251 } |
1252 } | |
1253 | |
1254 /// Color settings, try to use vf/vo then fall back on TV. (RW) | |
31156 | 1255 static int mp_property_gamma(m_option_t *prop, int action, void *arg, |
1256 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1257 { |
25465
6b9447dc7590
Check availability before check argument for getting gamma properties.
ulion
parents:
25464
diff
changeset
|
1258 int *gamma = prop->priv, r, val; |
22478 | 1259 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1260 if (!mpctx->sh_video) |
31077 | 1261 return M_PROPERTY_UNAVAILABLE; |
22478 | 1262 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1263 if (gamma[0] == 1000) { |
31077 | 1264 gamma[0] = 0; |
1265 get_video_colors(mpctx->sh_video, prop->name, gamma); | |
22478 | 1266 } |
1267 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1268 switch (action) { |
22478 | 1269 case M_PROPERTY_SET: |
31077 | 1270 if (!arg) |
1271 return M_PROPERTY_ERROR; | |
1272 M_PROPERTY_CLAMP(prop, *(int *) arg); | |
1273 *gamma = *(int *) arg; | |
1274 r = set_video_colors(mpctx->sh_video, prop->name, *gamma); | |
1275 if (r <= 0) | |
1276 break; | |
1277 return r; | |
22478 | 1278 case M_PROPERTY_GET: |
31077 | 1279 if (get_video_colors(mpctx->sh_video, prop->name, &val) > 0) { |
1280 if (!arg) | |
1281 return M_PROPERTY_ERROR; | |
1282 *(int *)arg = val; | |
1283 return M_PROPERTY_OK; | |
1284 } | |
1285 break; | |
22478 | 1286 case M_PROPERTY_STEP_UP: |
1287 case M_PROPERTY_STEP_DOWN: | |
31077 | 1288 *gamma += (arg ? *(int *) arg : 1) * |
1289 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); | |
1290 M_PROPERTY_CLAMP(prop, *gamma); | |
1291 r = set_video_colors(mpctx->sh_video, prop->name, *gamma); | |
1292 if (r <= 0) | |
1293 break; | |
1294 return r; | |
22478 | 1295 default: |
31077 | 1296 return M_PROPERTY_NOT_IMPLEMENTED; |
22478 | 1297 } |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1298 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1299 #ifdef CONFIG_TV |
22478 | 1300 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) { |
31077 | 1301 int l = strlen(prop->name); |
1302 char tv_prop[3 + l + 1]; | |
1303 sprintf(tv_prop, "tv_%s", prop->name); | |
1304 return mp_property_do(tv_prop, action, arg, mpctx); | |
22478 | 1305 } |
1306 #endif | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1307 |
22478 | 1308 return M_PROPERTY_UNAVAILABLE; |
1309 } | |
1310 | |
1311 /// VSync (RW) | |
31156 | 1312 static int mp_property_vsync(m_option_t *prop, int action, void *arg, |
1313 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1314 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1315 return m_property_flag(prop, action, arg, &vo_vsync); |
22478 | 1316 } |
1317 | |
1318 /// Video codec tag (RO) | |
31156 | 1319 static int mp_property_video_format(m_option_t *prop, int action, |
1320 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1321 { |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1322 char* meta; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1323 if (!mpctx->sh_video) |
31077 | 1324 return M_PROPERTY_UNAVAILABLE; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1325 switch(action) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1326 case M_PROPERTY_PRINT: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1327 if (!arg) |
31077 | 1328 return M_PROPERTY_ERROR; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1329 switch(mpctx->sh_video->format) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1330 case 0x10000001: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1331 meta = strdup ("mpeg1"); break; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1332 case 0x10000002: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1333 meta = strdup ("mpeg2"); break; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1334 case 0x10000004: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1335 meta = strdup ("mpeg4"); break; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1336 case 0x10000005: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1337 meta = strdup ("h264"); break; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1338 default: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1339 if(mpctx->sh_video->format >= 0x20202020) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1340 meta = malloc(5); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1341 sprintf (meta, "%.4s", (char *) &mpctx->sh_video->format); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1342 } else { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1343 meta = malloc(20); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1344 sprintf (meta, "0x%08X", mpctx->sh_video->format); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1345 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1346 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1347 *(char**)arg = meta; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1348 return M_PROPERTY_OK; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1349 } |
22478 | 1350 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format); |
1351 } | |
1352 | |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1353 /// Video codec name (RO) |
31156 | 1354 static int mp_property_video_codec(m_option_t *prop, int action, |
1355 void *arg, MPContext *mpctx) | |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1356 { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1357 if (!mpctx->sh_video || !mpctx->sh_video->codec) |
31077 | 1358 return M_PROPERTY_UNAVAILABLE; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1359 return m_property_string_ro(prop, action, arg, mpctx->sh_video->codec->name); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1360 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1361 |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1362 |
22478 | 1363 /// Video bitrate (RO) |
31156 | 1364 static int mp_property_video_bitrate(m_option_t *prop, int action, |
1365 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1366 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1367 if (!mpctx->sh_video) |
31077 | 1368 return M_PROPERTY_UNAVAILABLE; |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
1369 return m_property_bitrate(prop, action, arg, mpctx->sh_video->i_bps); |
22478 | 1370 } |
1371 | |
1372 /// Video display width (RO) | |
31156 | 1373 static int mp_property_width(m_option_t *prop, int action, void *arg, |
1374 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1375 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1376 if (!mpctx->sh_video) |
31077 | 1377 return M_PROPERTY_UNAVAILABLE; |
22478 | 1378 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w); |
1379 } | |
1380 | |
1381 /// Video display height (RO) | |
31156 | 1382 static int mp_property_height(m_option_t *prop, int action, void *arg, |
1383 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1384 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1385 if (!mpctx->sh_video) |
31077 | 1386 return M_PROPERTY_UNAVAILABLE; |
22478 | 1387 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h); |
1388 } | |
1389 | |
1390 /// Video fps (RO) | |
31156 | 1391 static int mp_property_fps(m_option_t *prop, int action, void *arg, |
1392 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1393 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1394 if (!mpctx->sh_video) |
31077 | 1395 return M_PROPERTY_UNAVAILABLE; |
22478 | 1396 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps); |
1397 } | |
1398 | |
1399 /// Video aspect (RO) | |
31156 | 1400 static int mp_property_aspect(m_option_t *prop, int action, void *arg, |
1401 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1402 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1403 if (!mpctx->sh_video) |
31077 | 1404 return M_PROPERTY_UNAVAILABLE; |
22478 | 1405 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect); |
1406 } | |
1407 | |
1408 ///@} | |
1409 | |
1410 /// \defgroup SubProprties Subtitles properties | |
1411 /// \ingroup Properties | |
1412 ///@{ | |
1413 | |
1414 /// Text subtitle position (RW) | |
31156 | 1415 static int mp_property_sub_pos(m_option_t *prop, int action, void *arg, |
1416 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1417 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1418 switch (action) { |
22478 | 1419 case M_PROPERTY_SET: |
31077 | 1420 if (!arg) |
1421 return M_PROPERTY_ERROR; | |
22478 | 1422 case M_PROPERTY_STEP_UP: |
1423 case M_PROPERTY_STEP_DOWN: | |
31077 | 1424 vo_osd_changed(OSDTYPE_SUBTITLE); |
22478 | 1425 default: |
31077 | 1426 return m_property_int_range(prop, action, arg, &sub_pos); |
22478 | 1427 } |
1428 } | |
1429 | |
1430 /// Selected subtitles (RW) | |
31156 | 1431 static int mp_property_sub(m_option_t *prop, int action, void *arg, |
1432 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1433 { |
22478 | 1434 demux_stream_t *const d_sub = mpctx->d_sub; |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1435 int global_sub_size; |
22478 | 1436 int source = -1, reset_spu = 0; |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1437 int source_pos = -1; |
29668
ecc719c6d7a9
Make update_subtitles work without sh_video for text subtitles.
reimar
parents:
29617
diff
changeset
|
1438 double pts = 0; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1439 char *sub_name; |
22478 | 1440 |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1441 update_global_sub_size(mpctx); |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1442 global_sub_size = mpctx->global_sub_size; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1443 if (global_sub_size <= 0) |
31077 | 1444 return M_PROPERTY_UNAVAILABLE; |
22478 | 1445 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1446 switch (action) { |
22478 | 1447 case M_PROPERTY_GET: |
31077 | 1448 if (!arg) |
1449 return M_PROPERTY_ERROR; | |
1450 *(int *) arg = mpctx->global_sub_pos; | |
1451 return M_PROPERTY_OK; | |
22478 | 1452 case M_PROPERTY_PRINT: |
31077 | 1453 if (!arg) |
1454 return M_PROPERTY_ERROR; | |
1455 *(char **) arg = malloc(64); | |
1456 (*(char **) arg)[63] = 0; | |
1457 sub_name = 0; | |
1458 if (subdata) | |
1459 sub_name = subdata->filename; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1460 #ifdef CONFIG_ASS |
31077 | 1461 if (ass_track && ass_track->name) |
1462 sub_name = ass_track->name; | |
22478 | 1463 #endif |
31077 | 1464 if (sub_name) { |
32588 | 1465 const char *tmp = mp_basename(sub_name); |
22478 | 1466 |
31077 | 1467 snprintf(*(char **) arg, 63, "(%d) %s%s", |
1468 mpctx->set_of_sub_pos + 1, | |
1469 strlen(tmp) < 20 ? "" : "...", | |
1470 strlen(tmp) < 20 ? tmp : tmp + strlen(tmp) - 19); | |
1471 return M_PROPERTY_OK; | |
1472 } | |
26084
ec5749eb6f5f
Fill sh_sub_t.lang in lavf, mkv and ogg demuxers. Use it for printing subtitle
eugeni
parents:
26083
diff
changeset
|
1473 |
31077 | 1474 if (vo_vobsub && vobsub_id >= 0) { |
1475 const char *language = MSGTR_Unknown; | |
1476 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id); | |
1477 snprintf(*(char **) arg, 63, "(%d) %s", | |
1478 vobsub_id, language ? language : MSGTR_Unknown); | |
1479 return M_PROPERTY_OK; | |
1480 } | |
34648
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34386
diff
changeset
|
1481 if (dvdsub_id >= 0) { |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34386
diff
changeset
|
1482 char lang[40] = MSGTR_Unknown; |
26eddbd6353a
Code cleanup: Use a stream_control instead of global functions to
reimar
parents:
34386
diff
changeset
|
1483 demuxer_sub_lang(mpctx->demuxer, dvdsub_id, lang, sizeof(lang)); |
31077 | 1484 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); |
1485 return M_PROPERTY_OK; | |
1486 } | |
1487 snprintf(*(char **) arg, 63, MSGTR_Disabled); | |
1488 return M_PROPERTY_OK; | |
22478 | 1489 |
1490 case M_PROPERTY_SET: | |
31077 | 1491 if (!arg) |
1492 return M_PROPERTY_ERROR; | |
1493 if (*(int *) arg < -1) | |
1494 *(int *) arg = -1; | |
1495 else if (*(int *) arg >= global_sub_size) | |
1496 *(int *) arg = global_sub_size - 1; | |
1497 mpctx->global_sub_pos = *(int *) arg; | |
1498 break; | |
22478 | 1499 case M_PROPERTY_STEP_UP: |
31077 | 1500 mpctx->global_sub_pos += 2; |
1501 mpctx->global_sub_pos = | |
1502 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; | |
1503 break; | |
22478 | 1504 case M_PROPERTY_STEP_DOWN: |
31077 | 1505 mpctx->global_sub_pos += global_sub_size + 1; |
1506 mpctx->global_sub_pos = | |
1507 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; | |
1508 break; | |
22478 | 1509 default: |
31077 | 1510 return M_PROPERTY_NOT_IMPLEMENTED; |
22478 | 1511 } |
1512 | |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1513 if (mpctx->global_sub_pos >= 0) { |
31077 | 1514 source = sub_source(mpctx); |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1515 source_pos = sub_source_pos(mpctx); |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1516 } |
22478 | 1517 |
1518 mp_msg(MSGT_CPLAYER, MSGL_DBG3, | |
31077 | 1519 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n", |
1520 global_sub_size, | |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1521 mpctx->sub_counts[SUB_SOURCE_VOBSUB], |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1522 mpctx->sub_counts[SUB_SOURCE_SUBS], |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1523 mpctx->sub_counts[SUB_SOURCE_DEMUX], |
31077 | 1524 mpctx->global_sub_pos, source); |
22478 | 1525 |
1526 mpctx->set_of_sub_pos = -1; | |
1527 subdata = NULL; | |
1528 | |
1529 vobsub_id = -1; | |
1530 dvdsub_id = -1; | |
1531 if (d_sub) { | |
31077 | 1532 if (d_sub->id > -2) |
1533 reset_spu = 1; | |
1534 d_sub->id = -2; | |
22478 | 1535 } |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1536 #ifdef CONFIG_ASS |
22478 | 1537 ass_track = 0; |
1538 #endif | |
1539 | |
1540 if (source == SUB_SOURCE_VOBSUB) { | |
31904
f8af1068e397
100l, re-add vobsub_get_id_by_index call accidentally removed in
reimar
parents:
31877
diff
changeset
|
1541 vobsub_id = vobsub_get_id_by_index(vo_vobsub, source_pos); |
22478 | 1542 } else if (source == SUB_SOURCE_SUBS) { |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1543 mpctx->set_of_sub_pos = source_pos; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1544 #ifdef CONFIG_ASS |
31077 | 1545 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]) |
1546 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]; | |
1547 else | |
22478 | 1548 #endif |
31077 | 1549 { |
1550 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos]; | |
1551 vo_osd_changed(OSDTYPE_SUBTITLE); | |
1552 } | |
22478 | 1553 } else if (source == SUB_SOURCE_DEMUX) { |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1554 dvdsub_id = source_pos; |
31077 | 1555 if (d_sub && dvdsub_id < MAX_S_STREAMS) { |
1556 int i = 0; | |
1557 // default: assume 1:1 mapping of sid and stream id | |
1558 d_sub->id = dvdsub_id; | |
1559 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id]; | |
1560 ds_free_packs(d_sub); | |
1561 for (i = 0; i < MAX_S_STREAMS; i++) { | |
1562 sh_sub_t *sh = mpctx->demuxer->s_streams[i]; | |
1563 if (sh && sh->sid == dvdsub_id) { | |
1564 d_sub->id = i; | |
1565 d_sub->sh = sh; | |
1566 break; | |
1567 } | |
1568 } | |
1569 if (d_sub->sh && d_sub->id >= 0) { | |
1570 sh_sub_t *sh = d_sub->sh; | |
1571 if (sh->type == 'v') | |
33577
c111d9e9cfb0
Move init_vo_spudec to mp_common.c and reuse it in mencoder.
reimar
parents:
33555
diff
changeset
|
1572 init_vo_spudec(mpctx->stream, mpctx->sh_video, sh); |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1573 #ifdef CONFIG_ASS |
31077 | 1574 else if (ass_enabled) |
1575 ass_track = sh->ass_track; | |
22478 | 1576 #endif |
23766
f0c2f9de85ba
Make sure that sub->id is -2 and sub->sh is NULL if subtitle doesn't
reimar
parents:
23758
diff
changeset
|
1577 } else { |
f0c2f9de85ba
Make sure that sub->id is -2 and sub->sh is NULL if subtitle doesn't
reimar
parents:
23758
diff
changeset
|
1578 d_sub->id = -2; |
f0c2f9de85ba
Make sure that sub->id is -2 and sub->sh is NULL if subtitle doesn't
reimar
parents:
23758
diff
changeset
|
1579 d_sub->sh = NULL; |
31077 | 1580 } |
1581 } | |
22478 | 1582 } |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1583 #ifdef CONFIG_DVDREAD |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1584 if (vo_spudec |
31077 | 1585 && (mpctx->stream->type == STREAMTYPE_DVD |
1586 || mpctx->stream->type == STREAMTYPE_DVDNAV) | |
1587 && dvdsub_id < 0 && reset_spu) { | |
1588 d_sub->id = -2; | |
1589 d_sub->sh = NULL; | |
22478 | 1590 } |
1591 #endif | |
29668
ecc719c6d7a9
Make update_subtitles work without sh_video for text subtitles.
reimar
parents:
29617
diff
changeset
|
1592 if (mpctx->sh_audio) |
ecc719c6d7a9
Make update_subtitles work without sh_video for text subtitles.
reimar
parents:
29617
diff
changeset
|
1593 pts = mpctx->sh_audio->pts; |
ecc719c6d7a9
Make update_subtitles work without sh_video for text subtitles.
reimar
parents:
29617
diff
changeset
|
1594 if (mpctx->sh_video) |
ecc719c6d7a9
Make update_subtitles work without sh_video for text subtitles.
reimar
parents:
29617
diff
changeset
|
1595 pts = mpctx->sh_video->pts; |
ecc719c6d7a9
Make update_subtitles work without sh_video for text subtitles.
reimar
parents:
29617
diff
changeset
|
1596 update_subtitles(mpctx->sh_video, pts, d_sub, 1); |
22478 | 1597 |
1598 return M_PROPERTY_OK; | |
1599 } | |
1600 | |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1601 /// Selected sub source (RW) |
31156 | 1602 static int mp_property_sub_source(m_option_t *prop, int action, void *arg, |
1603 MPContext *mpctx) | |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1604 { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1605 int source; |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1606 update_global_sub_size(mpctx); |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1607 if (!mpctx->sh_video || mpctx->global_sub_size <= 0) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1608 return M_PROPERTY_UNAVAILABLE; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1609 |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1610 switch (action) { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1611 case M_PROPERTY_GET: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1612 if (!arg) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1613 return M_PROPERTY_ERROR; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1614 *(int *) arg = sub_source(mpctx); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1615 return M_PROPERTY_OK; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1616 case M_PROPERTY_PRINT: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1617 if (!arg) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1618 return M_PROPERTY_ERROR; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1619 *(char **) arg = malloc(64); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1620 (*(char **) arg)[63] = 0; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1621 switch (sub_source(mpctx)) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1622 { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1623 case SUB_SOURCE_SUBS: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1624 snprintf(*(char **) arg, 63, MSGTR_SubSourceFile); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1625 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1626 case SUB_SOURCE_VOBSUB: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1627 snprintf(*(char **) arg, 63, MSGTR_SubSourceVobsub); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1628 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1629 case SUB_SOURCE_DEMUX: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1630 snprintf(*(char **) arg, 63, MSGTR_SubSourceDemux); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1631 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1632 default: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1633 snprintf(*(char **) arg, 63, MSGTR_Disabled); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1634 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1635 return M_PROPERTY_OK; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1636 case M_PROPERTY_SET: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1637 if (!arg) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1638 return M_PROPERTY_ERROR; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1639 M_PROPERTY_CLAMP(prop, *(int*)arg); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1640 if (*(int *) arg < 0) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1641 mpctx->global_sub_pos = -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1642 else if (*(int *) arg != sub_source(mpctx)) { |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1643 int new_pos = sub_pos_by_source(mpctx, *(int *)arg); |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1644 if (new_pos == -1) |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1645 return M_PROPERTY_UNAVAILABLE; |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1646 mpctx->global_sub_pos = new_pos; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1647 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1648 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1649 case M_PROPERTY_STEP_UP: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1650 case M_PROPERTY_STEP_DOWN: { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1651 int step_all = (arg && *(int*)arg != 0 ? *(int*)arg : 1) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1652 * (action == M_PROPERTY_STEP_UP ? 1 : -1); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1653 int step = (step_all > 0) ? 1 : -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1654 int cur_source = sub_source(mpctx); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1655 source = cur_source; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1656 while (step_all) { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1657 source += step; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1658 if (source >= SUB_SOURCES) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1659 source = -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1660 else if (source < -1) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1661 source = SUB_SOURCES - 1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1662 if (source == cur_source || source == -1 || |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1663 mpctx->sub_counts[source]) |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1664 step_all -= step; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1665 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1666 if (source == cur_source) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1667 return M_PROPERTY_OK; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1668 if (source == -1) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1669 mpctx->global_sub_pos = -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1670 else |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1671 mpctx->global_sub_pos = sub_pos_by_source(mpctx, source); |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1672 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1673 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1674 default: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1675 return M_PROPERTY_NOT_IMPLEMENTED; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1676 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1677 --mpctx->global_sub_pos; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1678 return mp_property_sub(prop, M_PROPERTY_STEP_UP, NULL, mpctx); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1679 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1680 |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1681 /// Selected subtitles from specific source (RW) |
31156 | 1682 static int mp_property_sub_by_type(m_option_t *prop, int action, void *arg, |
1683 MPContext *mpctx) | |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1684 { |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1685 int source, is_cur_source, offset, new_pos; |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1686 update_global_sub_size(mpctx); |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1687 if (!mpctx->sh_video || mpctx->global_sub_size <= 0) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1688 return M_PROPERTY_UNAVAILABLE; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1689 |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1690 if (!strcmp(prop->name, "sub_file")) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1691 source = SUB_SOURCE_SUBS; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1692 else if (!strcmp(prop->name, "sub_vob")) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1693 source = SUB_SOURCE_VOBSUB; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1694 else if (!strcmp(prop->name, "sub_demux")) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1695 source = SUB_SOURCE_DEMUX; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1696 else |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1697 return M_PROPERTY_ERROR; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1698 |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1699 offset = sub_pos_by_source(mpctx, source); |
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1700 if (offset < 0) |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1701 return M_PROPERTY_UNAVAILABLE; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1702 |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1703 is_cur_source = sub_source(mpctx) == source; |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1704 new_pos = mpctx->global_sub_pos; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1705 switch (action) { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1706 case M_PROPERTY_GET: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1707 if (!arg) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1708 return M_PROPERTY_ERROR; |
25251
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1709 if (is_cur_source) { |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1710 *(int *) arg = sub_source_pos(mpctx); |
25251
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1711 if (source == SUB_SOURCE_VOBSUB) |
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1712 *(int *) arg = vobsub_get_id_by_index(vo_vobsub, *(int *) arg); |
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1713 } |
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1714 else |
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1715 *(int *) arg = -1; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1716 return M_PROPERTY_OK; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1717 case M_PROPERTY_PRINT: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1718 if (!arg) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1719 return M_PROPERTY_ERROR; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1720 if (is_cur_source) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1721 return mp_property_sub(prop, M_PROPERTY_PRINT, arg, mpctx); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1722 *(char **) arg = malloc(64); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1723 (*(char **) arg)[63] = 0; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1724 snprintf(*(char **) arg, 63, MSGTR_Disabled); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1725 return M_PROPERTY_OK; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1726 case M_PROPERTY_SET: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1727 if (!arg) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1728 return M_PROPERTY_ERROR; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1729 if (*(int *) arg >= 0) { |
25251
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1730 int index = *(int *)arg; |
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1731 if (source == SUB_SOURCE_VOBSUB) |
80804f0631f4
Skip empty vobsub streams when selecting subtitles.
ulion
parents:
25215
diff
changeset
|
1732 index = vobsub_get_index_by_id(vo_vobsub, index); |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1733 new_pos = offset + index; |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
1734 if (index < 0 || index > mpctx->sub_counts[source]) { |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1735 new_pos = -1; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1736 *(int *) arg = -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1737 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1738 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1739 else |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1740 new_pos = -1; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1741 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1742 case M_PROPERTY_STEP_UP: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1743 case M_PROPERTY_STEP_DOWN: { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1744 int step_all = (arg && *(int*)arg != 0 ? *(int*)arg : 1) |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1745 * (action == M_PROPERTY_STEP_UP ? 1 : -1); |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1746 int step = (step_all > 0) ? 1 : -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1747 int max_sub_pos_for_source = -1; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1748 if (!is_cur_source) |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1749 new_pos = -1; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1750 while (step_all) { |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1751 if (new_pos == -1) { |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1752 if (step > 0) |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1753 new_pos = offset; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1754 else if (max_sub_pos_for_source == -1) { |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1755 // Find max pos for specific source |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1756 new_pos = mpctx->global_sub_size - 1; |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1757 while (new_pos >= 0 |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1758 && sub_source(mpctx) != source) |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1759 new_pos--; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1760 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1761 else |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1762 new_pos = max_sub_pos_for_source; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1763 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1764 else { |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1765 new_pos += step; |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1766 if (new_pos < offset || |
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1767 new_pos >= mpctx->global_sub_size || |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1768 sub_source(mpctx) != source) |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1769 new_pos = -1; |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1770 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1771 step_all -= step; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1772 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1773 break; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1774 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1775 default: |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1776 return M_PROPERTY_NOT_IMPLEMENTED; |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1777 } |
31805
05ca6dd36faf
Fix subtitle selection: make selecting -sid 0 work again by replacing the
reimar
parents:
31792
diff
changeset
|
1778 return mp_property_sub(prop, M_PROPERTY_SET, &new_pos, mpctx); |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1779 } |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
1780 |
22478 | 1781 /// Subtitle delay (RW) |
31156 | 1782 static int mp_property_sub_delay(m_option_t *prop, int action, void *arg, |
1783 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1784 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1785 if (!mpctx->sh_video) |
31077 | 1786 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1787 return m_property_delay(prop, action, arg, &sub_delay); |
22478 | 1788 } |
1789 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1790 /// Alignment of text subtitles (RW) |
31156 | 1791 static int mp_property_sub_alignment(m_option_t *prop, int action, |
1792 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1793 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1794 char *name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom }; |
22478 | 1795 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1796 if (!mpctx->sh_video || mpctx->global_sub_pos < 0 |
31077 | 1797 || sub_source(mpctx) != SUB_SOURCE_SUBS) |
1798 return M_PROPERTY_UNAVAILABLE; | |
22478 | 1799 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1800 switch (action) { |
22478 | 1801 case M_PROPERTY_PRINT: |
31077 | 1802 if (!arg) |
1803 return M_PROPERTY_ERROR; | |
1804 M_PROPERTY_CLAMP(prop, sub_alignment); | |
1805 *(char **) arg = strdup(name[sub_alignment]); | |
1806 return M_PROPERTY_OK; | |
22478 | 1807 case M_PROPERTY_SET: |
31077 | 1808 if (!arg) |
1809 return M_PROPERTY_ERROR; | |
22478 | 1810 case M_PROPERTY_STEP_UP: |
1811 case M_PROPERTY_STEP_DOWN: | |
31077 | 1812 vo_osd_changed(OSDTYPE_SUBTITLE); |
22478 | 1813 default: |
31077 | 1814 return m_property_choice(prop, action, arg, &sub_alignment); |
22478 | 1815 } |
1816 } | |
1817 | |
1818 /// Subtitle visibility (RW) | |
31156 | 1819 static int mp_property_sub_visibility(m_option_t *prop, int action, |
1820 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1821 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1822 if (!mpctx->sh_video) |
31077 | 1823 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1824 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1825 switch (action) { |
22478 | 1826 case M_PROPERTY_SET: |
31077 | 1827 if (!arg) |
1828 return M_PROPERTY_ERROR; | |
22478 | 1829 case M_PROPERTY_STEP_UP: |
1830 case M_PROPERTY_STEP_DOWN: | |
31077 | 1831 vo_osd_changed(OSDTYPE_SUBTITLE); |
1832 if (vo_spudec) | |
1833 vo_osd_changed(OSDTYPE_SPU); | |
22478 | 1834 default: |
31077 | 1835 return m_property_flag(prop, action, arg, &sub_visibility); |
22478 | 1836 } |
1837 } | |
1838 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1839 #ifdef CONFIG_ASS |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1840 /// Use margins for libass subtitles (RW) |
31156 | 1841 static int mp_property_ass_use_margins(m_option_t *prop, int action, |
1842 void *arg, MPContext *mpctx) | |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1843 { |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1844 if (!mpctx->sh_video) |
31077 | 1845 return M_PROPERTY_UNAVAILABLE; |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1846 |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1847 switch (action) { |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1848 case M_PROPERTY_SET: |
31077 | 1849 if (!arg) |
1850 return M_PROPERTY_ERROR; | |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1851 case M_PROPERTY_STEP_UP: |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1852 case M_PROPERTY_STEP_DOWN: |
31077 | 1853 ass_force_reload = 1; |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1854 default: |
31077 | 1855 return m_property_flag(prop, action, arg, &ass_use_margins); |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1856 } |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1857 } |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1858 #endif |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
1859 |
22478 | 1860 /// Show only forced subtitles (RW) |
31156 | 1861 static int mp_property_sub_forced_only(m_option_t *prop, int action, |
1862 void *arg, MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1863 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1864 if (!vo_spudec) |
31077 | 1865 return M_PROPERTY_UNAVAILABLE; |
22478 | 1866 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1867 switch (action) { |
22478 | 1868 case M_PROPERTY_SET: |
31077 | 1869 if (!arg) |
1870 return M_PROPERTY_ERROR; | |
22478 | 1871 case M_PROPERTY_STEP_UP: |
1872 case M_PROPERTY_STEP_DOWN: | |
31077 | 1873 m_property_flag(prop, action, arg, &forced_subs_only); |
1874 spudec_set_forced_subs_only(vo_spudec, forced_subs_only); | |
1875 return M_PROPERTY_OK; | |
22478 | 1876 default: |
31077 | 1877 return m_property_flag(prop, action, arg, &forced_subs_only); |
22478 | 1878 } |
1879 | |
1880 } | |
1881 | |
27393 | 1882 #ifdef CONFIG_FREETYPE |
23725 | 1883 /// Subtitle scale (RW) |
31156 | 1884 static int mp_property_sub_scale(m_option_t *prop, int action, void *arg, |
1885 MPContext *mpctx) | |
23725 | 1886 { |
1887 | |
1888 switch (action) { | |
1889 case M_PROPERTY_SET: | |
1890 if (!arg) | |
1891 return M_PROPERTY_ERROR; | |
1892 M_PROPERTY_CLAMP(prop, *(float *) arg); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1893 #ifdef CONFIG_ASS |
25815
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1894 if (ass_enabled) { |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1895 ass_font_scale = *(float *) arg; |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1896 ass_force_reload = 1; |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1897 } |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1898 #endif |
25854 | 1899 text_font_scale_factor = *(float *) arg; |
1900 force_load_font = 1; | |
32738
abcf963fbd2c
Force subtitles to be redrawn on sub_scale change.
reimar
parents:
32664
diff
changeset
|
1901 vo_osd_changed(OSDTYPE_SUBTITLE); |
23725 | 1902 return M_PROPERTY_OK; |
1903 case M_PROPERTY_STEP_UP: | |
1904 case M_PROPERTY_STEP_DOWN: | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1905 #ifdef CONFIG_ASS |
25815
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1906 if (ass_enabled) { |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1907 ass_font_scale += (arg ? *(float *) arg : 0.1)* |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1908 (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1909 M_PROPERTY_CLAMP(prop, ass_font_scale); |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1910 ass_force_reload = 1; |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1911 } |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1912 #endif |
25854 | 1913 text_font_scale_factor += (arg ? *(float *) arg : 0.1)* |
1914 (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); | |
1915 M_PROPERTY_CLAMP(prop, text_font_scale_factor); | |
1916 force_load_font = 1; | |
32738
abcf963fbd2c
Force subtitles to be redrawn on sub_scale change.
reimar
parents:
32664
diff
changeset
|
1917 vo_osd_changed(OSDTYPE_SUBTITLE); |
23725 | 1918 return M_PROPERTY_OK; |
1919 default: | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1920 #ifdef CONFIG_ASS |
25815
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1921 if (ass_enabled) |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1922 return m_property_float_ro(prop, action, arg, ass_font_scale); |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1923 else |
8920f8a26c05
sub_scale command now works with ass subtitles renderer
ben
parents:
25814
diff
changeset
|
1924 #endif |
25816 | 1925 return m_property_float_ro(prop, action, arg, text_font_scale_factor); |
23725 | 1926 } |
1927 } | |
23740 | 1928 #endif |
23725 | 1929 |
22478 | 1930 ///@} |
1931 | |
1932 /// \defgroup TVProperties TV properties | |
1933 /// \ingroup Properties | |
1934 ///@{ | |
1935 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
1936 #ifdef CONFIG_TV |
22478 | 1937 |
1938 /// TV color settings (RW) | |
31156 | 1939 static int mp_property_tv_color(m_option_t *prop, int action, void *arg, |
1940 MPContext *mpctx) | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1941 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1942 int r, val; |
22478 | 1943 tvi_handle_t *tvh = mpctx->demuxer->priv; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1944 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) |
31077 | 1945 return M_PROPERTY_UNAVAILABLE; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1946 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
1947 switch (action) { |
22478 | 1948 case M_PROPERTY_SET: |
31077 | 1949 if (!arg) |
1950 return M_PROPERTY_ERROR; | |
1951 M_PROPERTY_CLAMP(prop, *(int *) arg); | |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
1952 return tv_set_color_options(tvh, (intptr_t) prop->priv, *(int *) arg); |
22478 | 1953 case M_PROPERTY_GET: |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
1954 return tv_get_color_options(tvh, (intptr_t) prop->priv, arg); |
22478 | 1955 case M_PROPERTY_STEP_UP: |
1956 case M_PROPERTY_STEP_DOWN: | |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
1957 if ((r = tv_get_color_options(tvh, (intptr_t) prop->priv, &val)) >= 0) { |
31077 | 1958 if (!r) |
1959 return M_PROPERTY_ERROR; | |
1960 val += (arg ? *(int *) arg : 1) * | |
1961 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); | |
1962 M_PROPERTY_CLAMP(prop, val); | |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
1963 return tv_set_color_options(tvh, (intptr_t) prop->priv, val); |
31077 | 1964 } |
1965 return M_PROPERTY_ERROR; | |
22478 | 1966 } |
1967 return M_PROPERTY_NOT_IMPLEMENTED; | |
1968 } | |
1969 | |
1970 #endif | |
1971 | |
31156 | 1972 static int mp_property_teletext_common(m_option_t *prop, int action, void *arg, |
1973 MPContext *mpctx) | |
23900 | 1974 { |
1975 int val,result; | |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
1976 int base_ioctl=(intptr_t)prop->priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28368
diff
changeset
|
1977 /* |
23900 | 1978 for teletext's GET,SET,STEP ioctls this is not 0 |
1979 SET is GET+1 | |
1980 STEP is GET+2 | |
1981 */ | |
29820
b33846197f5c
Make sure the teletext property stuff does not crash if no demuxer is available.
reimar
parents:
29809
diff
changeset
|
1982 if (!mpctx->demuxer || !mpctx->demuxer->teletext) |
23900 | 1983 return M_PROPERTY_UNAVAILABLE; |
1984 if(!base_ioctl) | |
1985 return M_PROPERTY_ERROR; | |
1986 | |
1987 switch (action) { | |
1988 case M_PROPERTY_GET: | |
1989 if (!arg) | |
1990 return M_PROPERTY_ERROR; | |
29806 | 1991 result=teletext_control(mpctx->demuxer->teletext, base_ioctl, arg); |
23900 | 1992 break; |
1993 case M_PROPERTY_SET: | |
1994 if (!arg) | |
1995 return M_PROPERTY_ERROR; | |
1996 M_PROPERTY_CLAMP(prop, *(int *) arg); | |
29806 | 1997 result=teletext_control(mpctx->demuxer->teletext, base_ioctl+1, arg); |
23900 | 1998 break; |
1999 case M_PROPERTY_STEP_UP: | |
2000 case M_PROPERTY_STEP_DOWN: | |
29806 | 2001 result=teletext_control(mpctx->demuxer->teletext, base_ioctl, &val); |
23900 | 2002 val += (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1); |
29806 | 2003 result=teletext_control(mpctx->demuxer->teletext, base_ioctl+1, &val); |
23900 | 2004 break; |
2005 default: | |
2006 return M_PROPERTY_NOT_IMPLEMENTED; | |
2007 } | |
2008 | |
29806 | 2009 return result == VBI_CONTROL_TRUE ? M_PROPERTY_OK : M_PROPERTY_ERROR; |
23900 | 2010 } |
2011 | |
31156 | 2012 static int mp_property_teletext_mode(m_option_t *prop, int action, void *arg, |
2013 MPContext *mpctx) | |
23900 | 2014 { |
2015 int result; | |
2016 int val; | |
2017 | |
2018 //with tvh==NULL will fail too | |
2019 result=mp_property_teletext_common(prop,action,arg,mpctx); | |
2020 if(result!=M_PROPERTY_OK) | |
2021 return result; | |
2022 | |
29806 | 2023 if(teletext_control(mpctx->demuxer->teletext, |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
2024 (intptr_t)prop->priv, &val)==VBI_CONTROL_TRUE && val) |
23900 | 2025 mp_input_set_section("teletext"); |
2026 else | |
2027 mp_input_set_section("tv"); | |
2028 return M_PROPERTY_OK; | |
2029 } | |
2030 | |
31156 | 2031 static int mp_property_teletext_page(m_option_t *prop, int action, void *arg, |
2032 MPContext *mpctx) | |
23900 | 2033 { |
2034 int result; | |
2035 int val; | |
29806 | 2036 if (!mpctx->demuxer->teletext) |
27806
26c27a80b8af
Disallow the modification of teletext properties when the tv demuxer is
faust3
parents:
27650
diff
changeset
|
2037 return M_PROPERTY_UNAVAILABLE; |
23900 | 2038 switch(action){ |
2039 case M_PROPERTY_STEP_UP: | |
2040 case M_PROPERTY_STEP_DOWN: | |
2041 //This should be handled separately | |
2042 val = (arg ? *(int *) arg : 1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1); | |
29806 | 2043 result=teletext_control(mpctx->demuxer->teletext, |
2044 TV_VBI_CONTROL_STEP_PAGE, &val); | |
23900 | 2045 break; |
2046 default: | |
2047 result=mp_property_teletext_common(prop,action,arg,mpctx); | |
2048 } | |
2049 return result; | |
2050 } | |
2051 | |
22478 | 2052 ///@} |
2053 | |
2054 /// All properties available in MPlayer. | |
2055 /** \ingroup Properties | |
2056 */ | |
25717 | 2057 static const m_option_t mp_properties[] = { |
22478 | 2058 // General |
2059 { "osdlevel", mp_property_osdlevel, CONF_TYPE_INT, | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2060 M_OPT_RANGE, 0, 3, NULL }, |
23727 | 2061 { "loop", mp_property_loop, CONF_TYPE_INT, |
2062 M_OPT_MIN, -1, 0, NULL }, | |
22478 | 2063 { "speed", mp_property_playback_speed, CONF_TYPE_FLOAT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2064 M_OPT_RANGE, 0.01, 100.0, NULL }, |
22478 | 2065 { "filename", mp_property_filename, CONF_TYPE_STRING, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2066 0, 0, 0, NULL }, |
22478 | 2067 { "path", mp_property_path, CONF_TYPE_STRING, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2068 0, 0, 0, NULL }, |
22478 | 2069 { "demuxer", mp_property_demuxer, CONF_TYPE_STRING, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2070 0, 0, 0, NULL }, |
22478 | 2071 { "stream_pos", mp_property_stream_pos, CONF_TYPE_POSITION, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2072 M_OPT_MIN, 0, 0, NULL }, |
22478 | 2073 { "stream_start", mp_property_stream_start, CONF_TYPE_POSITION, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2074 M_OPT_MIN, 0, 0, NULL }, |
22478 | 2075 { "stream_end", mp_property_stream_end, CONF_TYPE_POSITION, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2076 M_OPT_MIN, 0, 0, NULL }, |
22478 | 2077 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2078 M_OPT_MIN, 0, 0, NULL }, |
31728 | 2079 { "stream_time_pos", mp_property_stream_time_pos, CONF_TYPE_TIME, |
2080 M_OPT_MIN, 0, 0, NULL }, | |
23417 | 2081 { "length", mp_property_length, CONF_TYPE_TIME, |
2082 M_OPT_MIN, 0, 0, NULL }, | |
23418 | 2083 { "percent_pos", mp_property_percent_pos, CONF_TYPE_INT, |
2084 M_OPT_RANGE, 0, 100, NULL }, | |
2085 { "time_pos", mp_property_time_pos, CONF_TYPE_TIME, | |
2086 M_OPT_MIN, 0, 0, NULL }, | |
25363 | 2087 { "chapter", mp_property_chapter, CONF_TYPE_INT, |
29365
794a26e68c2c
Make set_property chapter 0-based like all other chapter-related
reimar
parents:
29333
diff
changeset
|
2088 M_OPT_MIN, 0, 0, NULL }, |
34386
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
2089 { "titles", mp_property_titles, CONF_TYPE_INT, |
206264c532f5
Add new stream control command STREAM_CTRL_GET_NUM_TITLES.
ib
parents:
34339
diff
changeset
|
2090 0, 0, 0, NULL }, |
27635
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
2091 { "chapters", mp_property_chapters, CONF_TYPE_INT, |
22bdd7ba8892
slave command to get the number of chapters; patch by Kevin DeKorte - kdekorte gmail com
nicodvb
parents:
27457
diff
changeset
|
2092 0, 0, 0, NULL }, |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
2093 { "angle", mp_property_angle, CONF_TYPE_INT, |
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
2094 CONF_RANGE, -2, 10, NULL }, |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
2095 { "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST, |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
2096 0, 0, 0, NULL }, |
27648
427fec163870
Add a "pause" property to allow checking if MPlayer is paused.
reimar
parents:
27635
diff
changeset
|
2097 { "pause", mp_property_pause, CONF_TYPE_FLAG, |
427fec163870
Add a "pause" property to allow checking if MPlayer is paused.
reimar
parents:
27635
diff
changeset
|
2098 M_OPT_RANGE, 0, 1, NULL }, |
32438
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
2099 { "capturing", mp_property_capture, CONF_TYPE_FLAG, |
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
2100 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2101 |
2102 // Audio | |
2103 { "volume", mp_property_volume, CONF_TYPE_FLOAT, | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2104 M_OPT_RANGE, 0, 100, NULL }, |
22478 | 2105 { "mute", mp_property_mute, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2106 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2107 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2108 M_OPT_RANGE, -100, 100, NULL }, |
22478 | 2109 { "audio_format", mp_property_audio_format, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2110 0, 0, 0, NULL }, |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
2111 { "audio_codec", mp_property_audio_codec, CONF_TYPE_STRING, |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
2112 0, 0, 0, NULL }, |
22478 | 2113 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2114 0, 0, 0, NULL }, |
22478 | 2115 { "samplerate", mp_property_samplerate, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2116 0, 0, 0, NULL }, |
22478 | 2117 { "channels", mp_property_channels, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2118 0, 0, 0, NULL }, |
22478 | 2119 { "switch_audio", mp_property_audio, CONF_TYPE_INT, |
29333
09938ba82991
Do not use MAX_A/V_STREAMS as upper limit for switch_audio/switch_video
reimar
parents:
29263
diff
changeset
|
2120 CONF_RANGE, -2, 65535, NULL }, |
23568 | 2121 { "balance", mp_property_balance, CONF_TYPE_FLOAT, |
2122 M_OPT_RANGE, -1, 1, NULL }, | |
22478 | 2123 |
2124 // Video | |
2125 { "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG, | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2126 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2127 { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2128 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2129 { "ontop", mp_property_ontop, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2130 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2131 { "rootwin", mp_property_rootwin, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2132 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2133 { "border", mp_property_border, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2134 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2135 { "framedropping", mp_property_framedropping, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2136 M_OPT_RANGE, 0, 2, NULL }, |
22478 | 2137 { "gamma", mp_property_gamma, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2138 M_OPT_RANGE, -100, 100, &vo_gamma_gamma }, |
22478 | 2139 { "brightness", mp_property_gamma, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2140 M_OPT_RANGE, -100, 100, &vo_gamma_brightness }, |
22478 | 2141 { "contrast", mp_property_gamma, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2142 M_OPT_RANGE, -100, 100, &vo_gamma_contrast }, |
22478 | 2143 { "saturation", mp_property_gamma, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2144 M_OPT_RANGE, -100, 100, &vo_gamma_saturation }, |
22478 | 2145 { "hue", mp_property_gamma, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2146 M_OPT_RANGE, -100, 100, &vo_gamma_hue }, |
22478 | 2147 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2148 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2149 { "vsync", mp_property_vsync, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2150 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2151 { "video_format", mp_property_video_format, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2152 0, 0, 0, NULL }, |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
2153 { "video_codec", mp_property_video_codec, CONF_TYPE_STRING, |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
2154 0, 0, 0, NULL }, |
22478 | 2155 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2156 0, 0, 0, NULL }, |
22478 | 2157 { "width", mp_property_width, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2158 0, 0, 0, NULL }, |
22478 | 2159 { "height", mp_property_height, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2160 0, 0, 0, NULL }, |
22478 | 2161 { "fps", mp_property_fps, CONF_TYPE_FLOAT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2162 0, 0, 0, NULL }, |
22478 | 2163 { "aspect", mp_property_aspect, CONF_TYPE_FLOAT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2164 0, 0, 0, NULL }, |
22478 | 2165 { "switch_video", mp_property_video, CONF_TYPE_INT, |
29333
09938ba82991
Do not use MAX_A/V_STREAMS as upper limit for switch_audio/switch_video
reimar
parents:
29263
diff
changeset
|
2166 CONF_RANGE, -2, 65535, NULL }, |
22478 | 2167 { "switch_program", mp_property_program, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2168 CONF_RANGE, -1, 65535, NULL }, |
22478 | 2169 |
2170 // Subs | |
2171 { "sub", mp_property_sub, CONF_TYPE_INT, | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2172 M_OPT_MIN, -1, 0, NULL }, |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2173 { "sub_source", mp_property_sub_source, CONF_TYPE_INT, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2174 M_OPT_RANGE, -1, SUB_SOURCES - 1, NULL }, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2175 { "sub_vob", mp_property_sub_by_type, CONF_TYPE_INT, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2176 M_OPT_MIN, -1, 0, NULL }, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2177 { "sub_demux", mp_property_sub_by_type, CONF_TYPE_INT, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2178 M_OPT_MIN, -1, 0, NULL }, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2179 { "sub_file", mp_property_sub_by_type, CONF_TYPE_INT, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2180 M_OPT_MIN, -1, 0, NULL }, |
22478 | 2181 { "sub_delay", mp_property_sub_delay, CONF_TYPE_FLOAT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2182 0, 0, 0, NULL }, |
22478 | 2183 { "sub_pos", mp_property_sub_pos, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2184 M_OPT_RANGE, 0, 100, NULL }, |
22478 | 2185 { "sub_alignment", mp_property_sub_alignment, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2186 M_OPT_RANGE, 0, 2, NULL }, |
22478 | 2187 { "sub_visibility", mp_property_sub_visibility, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2188 M_OPT_RANGE, 0, 1, NULL }, |
22478 | 2189 { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2190 M_OPT_RANGE, 0, 1, NULL }, |
27393 | 2191 #ifdef CONFIG_FREETYPE |
23725 | 2192 { "sub_scale", mp_property_sub_scale, CONF_TYPE_FLOAT, |
2193 M_OPT_RANGE, 0, 100, NULL }, | |
23740 | 2194 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2195 #ifdef CONFIG_ASS |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
2196 { "ass_use_margins", mp_property_ass_use_margins, CONF_TYPE_FLAG, |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
2197 M_OPT_RANGE, 0, 1, NULL }, |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
2198 #endif |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2199 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2200 #ifdef CONFIG_TV |
22478 | 2201 { "tv_brightness", mp_property_tv_color, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2202 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_BRIGHTNESS }, |
22478 | 2203 { "tv_contrast", mp_property_tv_color, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2204 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_CONTRAST }, |
22478 | 2205 { "tv_saturation", mp_property_tv_color, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2206 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_SATURATION }, |
22478 | 2207 { "tv_hue", mp_property_tv_color, CONF_TYPE_INT, |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2208 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_HUE }, |
22478 | 2209 #endif |
23900 | 2210 { "teletext_page", mp_property_teletext_page, CONF_TYPE_INT, |
2211 M_OPT_RANGE, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE }, | |
2212 { "teletext_subpage", mp_property_teletext_common, CONF_TYPE_INT, | |
2213 M_OPT_RANGE, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE }, | |
2214 { "teletext_mode", mp_property_teletext_mode, CONF_TYPE_FLAG, | |
2215 M_OPT_RANGE, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE }, | |
2216 { "teletext_format", mp_property_teletext_common, CONF_TYPE_INT, | |
2217 M_OPT_RANGE, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT }, | |
2218 { "teletext_half_page", mp_property_teletext_common, CONF_TYPE_INT, | |
2219 M_OPT_RANGE, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE }, | |
22478 | 2220 { NULL, NULL, NULL, 0, 0, 0, NULL } |
2221 }; | |
2222 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2223 |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2224 int mp_property_do(const char *name, int action, void *val, void *ctx) |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2225 { |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2226 return m_property_do(mp_properties, name, action, val, ctx); |
22478 | 2227 } |
2228 | |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2229 char* mp_property_print(const char *name, void* ctx) |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2230 { |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2231 char* ret = NULL; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2232 if(mp_property_do(name,M_PROPERTY_PRINT,&ret,ctx) <= 0) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2233 return NULL; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2234 return ret; |
22478 | 2235 } |
2236 | |
31156 | 2237 char *property_expand_string(MPContext *mpctx, char *str) |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2238 { |
22478 | 2239 return m_properties_expand_string(mp_properties, str, mpctx); |
2240 } | |
2241 | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2242 void property_print_help(void) |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2243 { |
22478 | 2244 m_properties_print_help_list(mp_properties); |
2245 } | |
2246 | |
2247 | |
2248 ///@} | |
2249 // Properties group | |
2250 | |
2251 | |
2252 /** | |
2253 * \defgroup Command2Property Command to property bridge | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2254 * |
22478 | 2255 * It is used to handle most commands that just set a property |
2256 * and optionally display something on the OSD. | |
2257 * Two kinds of commands are handled: adjust or toggle. | |
2258 * | |
2259 * Adjust commands take 1 or 2 parameters: <value> <abs> | |
2260 * If <abs> is non-zero the property is set to the given value | |
2261 * otherwise it is adjusted. | |
2262 * | |
2263 * Toggle commands take 0 or 1 parameters. With no parameter | |
2264 * or a value less than the property minimum it just steps the | |
32593 | 2265 * property to its next or previous value respectively. |
2266 * Otherwise it sets it to the given value. | |
22478 | 2267 * |
2268 *@{ | |
2269 */ | |
2270 | |
2271 /// List of the commands that can be handled by setting a property. | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2272 static struct { |
22478 | 2273 /// property name |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2274 const char *name; |
22478 | 2275 /// cmd id |
2276 int cmd; | |
2277 /// set/adjust or toggle command | |
2278 int toggle; | |
2279 /// progressbar type | |
2280 int osd_progbar; | |
2281 /// osd msg id if it must be shared | |
2282 int osd_id; | |
2283 /// osd msg template | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2284 const char *osd_msg; |
22478 | 2285 } set_prop_cmd[] = { |
23727 | 2286 // general |
2287 { "loop", MP_CMD_LOOP, 0, 0, -1, MSGTR_LoopStatus }, | |
25363 | 2288 { "chapter", MP_CMD_SEEK_CHAPTER, 0, 0, -1, NULL }, |
25577
f1ea96323643
properties to get and set angle; patch by oattila chello hu
nicodvb
parents:
25567
diff
changeset
|
2289 { "angle", MP_CMD_SWITCH_ANGLE, 0, 0, -1, NULL }, |
32438
faefba58f413
Implement a basic capture feature, available through -capture.
diego
parents:
32419
diff
changeset
|
2290 { "capturing", MP_CMD_CAPTURING, 1, 0, -1, NULL }, |
22478 | 2291 // audio |
2292 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume }, | |
2293 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus }, | |
2294 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus }, | |
2295 { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio }, | |
23568 | 2296 { "balance", MP_CMD_BALANCE, 0, OSD_BALANCE, -1, MSGTR_Balance }, |
22478 | 2297 // video |
2298 { "fullscreen", MP_CMD_VO_FULLSCREEN, 1, 0, -1, NULL }, | |
2299 { "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, MSGTR_Panscan }, | |
2300 { "ontop", MP_CMD_VO_ONTOP, 1, 0, -1, MSGTR_OnTopStatus }, | |
2301 { "rootwin", MP_CMD_VO_ROOTWIN, 1, 0, -1, MSGTR_RootwinStatus }, | |
2302 { "border", MP_CMD_VO_BORDER, 1, 0, -1, MSGTR_BorderStatus }, | |
2303 { "framedropping", MP_CMD_FRAMEDROPPING, 1, 0, -1, MSGTR_FramedroppingStatus }, | |
2304 { "gamma", MP_CMD_GAMMA, 0, OSD_BRIGHTNESS, -1, MSGTR_Gamma }, | |
2305 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness }, | |
2306 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast }, | |
2307 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation }, | |
2308 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue }, | |
2309 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus }, | |
31077 | 2310 // subs |
22478 | 2311 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus }, |
25129
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2312 { "sub_source", MP_CMD_SUB_SOURCE, 1, 0, -1, MSGTR_SubSourceStatus }, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2313 { "sub_vob", MP_CMD_SUB_VOB, 1, 0, -1, MSGTR_SubSelectStatus }, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2314 { "sub_demux", MP_CMD_SUB_DEMUX, 1, 0, -1, MSGTR_SubSelectStatus }, |
c04b64054255
Support select subtitle by source, add 4 properties:
ulion
parents:
25032
diff
changeset
|
2315 { "sub_file", MP_CMD_SUB_FILE, 1, 0, -1, MSGTR_SubSelectStatus }, |
22478 | 2316 { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus }, |
2317 { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus }, | |
2318 { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus }, | |
2319 { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus }, | |
2320 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, MSGTR_SubForcedOnlyStatus }, | |
27393 | 2321 #ifdef CONFIG_FREETYPE |
23725 | 2322 { "sub_scale", MP_CMD_SUB_SCALE, 0, 0, -1, MSGTR_SubScale}, |
23740 | 2323 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2324 #ifdef CONFIG_ASS |
25814
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
2325 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS, 1, 0, -1, NULL }, |
4ba9b9bdf123
Add ass_use_margins command and property to shift subtitles to margins and back
eugeni
parents:
25717
diff
changeset
|
2326 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2327 #ifdef CONFIG_TV |
22478 | 2328 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness }, |
2329 { "tv_hue", MP_CMD_TV_SET_HUE, 0, OSD_HUE, -1, MSGTR_Hue }, | |
2330 { "tv_saturation", MP_CMD_TV_SET_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation }, | |
2331 { "tv_contrast", MP_CMD_TV_SET_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast }, | |
2332 #endif | |
2333 { NULL, 0, 0, 0, -1, NULL } | |
2334 }; | |
2335 | |
2336 | |
2337 /// Handle commands that set a property. | |
31156 | 2338 static int set_property_command(MPContext *mpctx, mp_cmd_t *cmd) |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2339 { |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2340 int i, r; |
31156 | 2341 m_option_t *prop; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2342 const char *pname; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2343 |
22478 | 2344 // look for the command |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2345 for (i = 0; set_prop_cmd[i].name; i++) |
31077 | 2346 if (set_prop_cmd[i].cmd == cmd->id) |
2347 break; | |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2348 if (!(pname = set_prop_cmd[i].name)) |
31077 | 2349 return 0; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2350 |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2351 if (mp_property_do(pname,M_PROPERTY_GET_TYPE,&prop,mpctx) <= 0 || !prop) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
23259
diff
changeset
|
2352 return 0; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2353 |
22478 | 2354 // toggle command |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2355 if (set_prop_cmd[i].toggle) { |
31077 | 2356 // set to value |
2357 if (cmd->nargs > 0 && cmd->args[0].v.i >= prop->min) | |
2358 r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx); | |
32593 | 2359 else if (cmd->nargs > 0) |
2360 r = mp_property_do(pname, M_PROPERTY_STEP_DOWN, NULL, mpctx); | |
31077 | 2361 else |
2362 r = mp_property_do(pname, M_PROPERTY_STEP_UP, NULL, mpctx); | |
2363 } else if (cmd->args[1].v.i) //set | |
2364 r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v, mpctx); | |
2365 else // adjust | |
2366 r = mp_property_do(pname, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx); | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2367 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2368 if (r <= 0) |
31077 | 2369 return 1; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2370 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2371 if (set_prop_cmd[i].osd_progbar) { |
31077 | 2372 if (prop->type == CONF_TYPE_INT) { |
2373 if (mp_property_do(pname, M_PROPERTY_GET, &r, mpctx) > 0) | |
2374 set_osd_bar(set_prop_cmd[i].osd_progbar, | |
2375 set_prop_cmd[i].osd_msg, prop->min, prop->max, r); | |
2376 } else if (prop->type == CONF_TYPE_FLOAT) { | |
2377 float f; | |
2378 if (mp_property_do(pname, M_PROPERTY_GET, &f, mpctx) > 0) | |
2379 set_osd_bar(set_prop_cmd[i].osd_progbar, | |
2380 set_prop_cmd[i].osd_msg, prop->min, prop->max, f); | |
2381 } else | |
2382 mp_msg(MSGT_CPLAYER, MSGL_ERR, | |
2383 "Property use an unsupported type.\n"); | |
2384 return 1; | |
22478 | 2385 } |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2386 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2387 if (set_prop_cmd[i].osd_msg) { |
31077 | 2388 char *val = mp_property_print(pname, mpctx); |
2389 if (val) { | |
2390 set_osd_msg(set_prop_cmd[i].osd_id >= | |
2391 0 ? set_prop_cmd[i].osd_id : OSD_MSG_PROPERTY + i, | |
2392 1, osd_duration, set_prop_cmd[i].osd_msg, val); | |
2393 free(val); | |
2394 } | |
22478 | 2395 } |
2396 return 1; | |
2397 } | |
2398 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2399 #ifdef CONFIG_DVDNAV |
27068 | 2400 static const struct { |
2401 const char *name; | |
2402 const mp_command_type cmd; | |
2403 } mp_dvdnav_bindings[] = { | |
2404 { "up", MP_CMD_DVDNAV_UP }, | |
2405 { "down", MP_CMD_DVDNAV_DOWN }, | |
2406 { "left", MP_CMD_DVDNAV_LEFT }, | |
2407 { "right", MP_CMD_DVDNAV_RIGHT }, | |
2408 { "menu", MP_CMD_DVDNAV_MENU }, | |
2409 { "select", MP_CMD_DVDNAV_SELECT }, | |
2410 { "prev", MP_CMD_DVDNAV_PREVMENU }, | |
2411 { "mouse", MP_CMD_DVDNAV_MOUSECLICK }, | |
27069
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2412 |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2413 /* |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2414 * keep old dvdnav sub-command options for a while in order not to |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2415 * break slave-mode API too suddenly. |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2416 */ |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2417 { "1", MP_CMD_DVDNAV_UP }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2418 { "2", MP_CMD_DVDNAV_DOWN }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2419 { "3", MP_CMD_DVDNAV_LEFT }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2420 { "4", MP_CMD_DVDNAV_RIGHT }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2421 { "5", MP_CMD_DVDNAV_MENU }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2422 { "6", MP_CMD_DVDNAV_SELECT }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2423 { "7", MP_CMD_DVDNAV_PREVMENU }, |
1a6930933140
Keep old dvdnav sub-command options for a while in order
ben
parents:
27068
diff
changeset
|
2424 { "8", MP_CMD_DVDNAV_MOUSECLICK }, |
27068 | 2425 { NULL, 0 } |
2426 }; | |
2427 #endif | |
22478 | 2428 |
30077
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2429 static const char *property_error_string(int error_value) |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2430 { |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2431 switch (error_value) { |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2432 case M_PROPERTY_ERROR: |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2433 return "ERROR"; |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2434 case M_PROPERTY_UNAVAILABLE: |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2435 return "PROPERTY_UNAVAILABLE"; |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2436 case M_PROPERTY_NOT_IMPLEMENTED: |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2437 return "NOT_IMPLEMENTED"; |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2438 case M_PROPERTY_UNKNOWN: |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2439 return "PROPERTY_UNKNOWN"; |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2440 case M_PROPERTY_DISABLED: |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2441 return "DISABLED"; |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2442 } |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2443 return "UNKNOWN"; |
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2444 } |
34200
87a1b3a11b33
Fix a bunch of Doxygen syntax errors that caused warnings.
diego
parents:
34174
diff
changeset
|
2445 ///@} |
30077
72e4567e7a0a
Print a ANS_ERROR reply if one of the *_property slave command fails.
reimar
parents:
30025
diff
changeset
|
2446 |
30344
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2447 static void remove_subtitle_range(MPContext *mpctx, int start, int count) |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2448 { |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2449 int idx; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2450 int end = start + count; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2451 int after = mpctx->set_of_sub_size - end; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2452 sub_data **subs = mpctx->set_of_subtitles; |
30345
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2453 #ifdef CONFIG_ASS |
31792
55dacfca4a43
Rename libass types to match upstream libass >= 0.9.7
greg
parents:
31788
diff
changeset
|
2454 ASS_Track **ass_tracks = mpctx->set_of_ass_tracks; |
30345
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2455 #endif |
30344
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2456 if (count < 0 || count > mpctx->set_of_sub_size || |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2457 start < 0 || start > mpctx->set_of_sub_size - count) { |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2458 mp_msg(MSGT_CPLAYER, MSGL_ERR, |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2459 "Cannot remove invalid subtitle range %i +%i\n", start, count); |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2460 return; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2461 } |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2462 for (idx = start; idx < end; idx++) { |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2463 sub_data *subd = subs[idx]; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2464 mp_msg(MSGT_CPLAYER, MSGL_STATUS, |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2465 MSGTR_RemovedSubtitleFile, idx + 1, |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2466 filename_recode(subd->filename)); |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2467 sub_free(subd); |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2468 subs[idx] = NULL; |
30345
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2469 #ifdef CONFIG_ASS |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2470 if (ass_tracks[idx]) |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2471 ass_free_track(ass_tracks[idx]); |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2472 ass_tracks[idx] = NULL; |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2473 #endif |
30344
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2474 } |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2475 |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2476 mpctx->global_sub_size -= count; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2477 mpctx->set_of_sub_size -= count; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2478 if (mpctx->set_of_sub_size <= 0) |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
2479 mpctx->sub_counts[SUB_SOURCE_SUBS] = 0; |
30344
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2480 |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2481 memmove(subs + start, subs + end, after * sizeof(*subs)); |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2482 memset(subs + start + after, 0, count * sizeof(*subs)); |
30345
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2483 #ifdef CONFIG_ASS |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2484 memmove(ass_tracks + start, ass_tracks + end, after * sizeof(*ass_tracks)); |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2485 memset(ass_tracks + start + after, 0, count * sizeof(*ass_tracks)); |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2486 #endif |
30344
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2487 |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2488 if (mpctx->set_of_sub_pos >= start && mpctx->set_of_sub_pos < end) { |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2489 mpctx->global_sub_pos = -2; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2490 subdata = NULL; |
30345
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2491 #ifdef CONFIG_ASS |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2492 ass_track = NULL; |
ea015e0ab0c6
Also handle ASS subtitles when removing subtitles via sub_remove slave command.
reimar
parents:
30344
diff
changeset
|
2493 #endif |
30344
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2494 mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2495 } else if (mpctx->set_of_sub_pos >= end) { |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2496 mpctx->set_of_sub_pos -= count; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2497 mpctx->global_sub_pos -= count; |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2498 } |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2499 } |
4752e3cbe7be
Avoid duplicating code to remove subtitles (sub_remove slave command).
reimar
parents:
30082
diff
changeset
|
2500 |
32392 | 2501 static int overlay_source_registered = 0; |
2502 static struct mp_eosd_source overlay_source = { | |
2503 .z_index = 5, | |
2504 }; | |
2505 | |
2506 static void overlay_add(char *file, int id, int x, int y, unsigned col) | |
2507 { | |
2508 FILE *f; | |
33708 | 2509 int w, h, bpp, maxval; |
32442
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2510 uint8_t *data; |
32392 | 2511 struct mp_eosd_image *img; |
2512 | |
32442
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2513 f = fopen(file, "rb"); |
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2514 if (!f) { |
32392 | 2515 mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to open file.\n"); |
2516 return; | |
2517 } | |
32442
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2518 data = read_pnm(f, &w, &h, &bpp, &maxval); |
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2519 fclose(f); |
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2520 if (!data) { |
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2521 mp_msg(MSGT_CPLAYER, MSGL_ERR, "overlay_add: unable to load file.\n"); |
32392 | 2522 return; |
2523 } | |
32442
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2524 if (bpp != 1 || maxval != 255) { |
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2525 mp_msg(MSGT_CPLAYER, MSGL_ERR, |
bf593e3827d9
EOSD: overlay_add: use read_pnm instead of the internal reimplementation.
cigaes
parents:
32438
diff
changeset
|
2526 "overlay_add: file format not supported.\n"); |
32392 | 2527 return; |
2528 } | |
2529 if (!overlay_source_registered) { | |
2530 eosd_register(&overlay_source); | |
2531 eosd_image_remove_all(&overlay_source); | |
2532 overlay_source_registered = 1; | |
2533 } | |
2534 img = eosd_image_alloc(); | |
2535 img->w = w; | |
2536 img->h = h; | |
2537 img->stride = w; | |
2538 img->bitmap = data; | |
2539 img->color = col ^ 0xFF; /* col is RGBA, img->color is RGBT */ | |
2540 img->dst_x = x; | |
2541 img->dst_y = y; | |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
2542 img->opaque = (void *)(intptr_t)id; |
32392 | 2543 eosd_image_append(&overlay_source, img); |
2544 overlay_source.changed = EOSD_CHANGED_BITMAP; | |
2545 } | |
2546 | |
2547 static void overlay_remove(int id) | |
2548 { | |
2549 struct mp_eosd_image *img, **prev, *next; | |
2550 prev = &overlay_source.images; | |
2551 img = overlay_source.images; | |
2552 while (img) { | |
2553 next = img->next; | |
32405
ad86352b7c6b
Use intptr_t for integers stored in opaque pointers.
cigaes
parents:
32392
diff
changeset
|
2554 if ((intptr_t)img->opaque == id) { |
32392 | 2555 free(img->bitmap); |
2556 eosd_image_remove(&overlay_source, img, prev); | |
2557 overlay_source.changed = EOSD_CHANGED_BITMAP; | |
2558 } else { | |
2559 prev = &img->next; | |
2560 } | |
2561 img = next; | |
2562 } | |
2563 } | |
2564 | |
31156 | 2565 int run_command(MPContext *mpctx, mp_cmd_t *cmd) |
22478 | 2566 { |
2567 sh_audio_t * const sh_audio = mpctx->sh_audio; | |
2568 sh_video_t * const sh_video = mpctx->sh_video; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2569 int brk_cmd = 0; |
22478 | 2570 if (!set_property_command(mpctx, cmd)) |
31077 | 2571 switch (cmd->id) { |
2572 case MP_CMD_SEEK:{ | |
2573 float v; | |
2574 int abs; | |
2575 if (sh_video) | |
2576 mpctx->osd_show_percentage = sh_video->fps; | |
2577 v = cmd->args[0].v.f; | |
2578 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0; | |
2579 if (abs == 2) { /* Absolute seek to a specific timestamp in seconds */ | |
2580 abs_seek_pos = SEEK_ABSOLUTE; | |
2581 if (sh_video) | |
2582 mpctx->osd_function = | |
2583 (v > sh_video->pts) ? OSD_FFW : OSD_REW; | |
2584 rel_seek_secs = v; | |
2585 } else if (abs) { /* Absolute seek by percentage */ | |
2586 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; | |
2587 if (sh_video) | |
2588 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly | |
2589 rel_seek_secs = v / 100.0; | |
2590 } else { | |
2591 rel_seek_secs += v; | |
2592 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW; | |
2593 } | |
2594 brk_cmd = 1; | |
2595 } | |
2596 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2597 |
31077 | 2598 case MP_CMD_SET_PROPERTY:{ |
2599 int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_PARSE, | |
2600 cmd->args[1].v.s, mpctx); | |
2601 if (r == M_PROPERTY_UNKNOWN) | |
2602 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
2603 "Unknown property: '%s'\n", cmd->args[0].v.s); | |
2604 else if (r <= 0) | |
2605 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
2606 "Failed to set property '%s' to '%s'.\n", | |
2607 cmd->args[0].v.s, cmd->args[1].v.s); | |
2608 if (r <= 0) | |
2609 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r)); | |
2610 } | |
2611 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2612 |
31077 | 2613 case MP_CMD_STEP_PROPERTY:{ |
2614 void* arg = NULL; | |
2615 int r,i; | |
2616 double d; | |
2617 off_t o; | |
2618 if (cmd->args[1].v.f) { | |
31156 | 2619 m_option_t *prop; |
31077 | 2620 if((r = mp_property_do(cmd->args[0].v.s, |
2621 M_PROPERTY_GET_TYPE, | |
2622 &prop, mpctx)) <= 0) | |
2623 goto step_prop_err; | |
2624 if(prop->type == CONF_TYPE_INT || | |
2625 prop->type == CONF_TYPE_FLAG) | |
2626 i = cmd->args[1].v.f, arg = &i; | |
2627 else if(prop->type == CONF_TYPE_FLOAT) | |
2628 arg = &cmd->args[1].v.f; | |
2629 else if(prop->type == CONF_TYPE_DOUBLE || | |
2630 prop->type == CONF_TYPE_TIME) | |
2631 d = cmd->args[1].v.f, arg = &d; | |
2632 else if(prop->type == CONF_TYPE_POSITION) | |
2633 o = cmd->args[1].v.f, arg = &o; | |
2634 else | |
2635 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
2636 "Ignoring step size stepping property '%s'.\n", | |
2637 cmd->args[0].v.s); | |
2638 } | |
2639 r = mp_property_do(cmd->args[0].v.s, | |
2640 cmd->args[2].v.i < 0 ? | |
2641 M_PROPERTY_STEP_DOWN : M_PROPERTY_STEP_UP, | |
2642 arg, mpctx); | |
2643 step_prop_err: | |
2644 if (r == M_PROPERTY_UNKNOWN) | |
2645 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
2646 "Unknown property: '%s'\n", cmd->args[0].v.s); | |
2647 else if (r <= 0) | |
2648 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
2649 "Failed to increment property '%s' by %f.\n", | |
2650 cmd->args[0].v.s, cmd->args[1].v.f); | |
2651 if (r <= 0) | |
2652 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r)); | |
2653 } | |
2654 break; | |
22478 | 2655 |
31077 | 2656 case MP_CMD_GET_PROPERTY:{ |
2657 char *tmp; | |
2658 int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_TO_STRING, | |
2659 &tmp, mpctx); | |
2660 if (r <= 0) { | |
2661 mp_msg(MSGT_CPLAYER, MSGL_WARN, | |
2662 "Failed to get value of property '%s'.\n", | |
2663 cmd->args[0].v.s); | |
2664 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r)); | |
2665 break; | |
2666 } | |
2667 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_%s=%s\n", | |
2668 cmd->args[0].v.s, tmp); | |
2669 free(tmp); | |
2670 } | |
2671 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2672 |
31077 | 2673 case MP_CMD_EDL_MARK: |
2674 if (edl_fd) { | |
2675 float v = sh_video ? sh_video->pts : | |
2676 playing_audio_pts(sh_audio, mpctx->d_audio, | |
2677 mpctx->audio_out); | |
22478 | 2678 |
31077 | 2679 if (mpctx->begin_skip == MP_NOPTS_VALUE) { |
2680 mpctx->begin_skip = v; | |
2681 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip); | |
2682 } else { | |
2683 if (mpctx->begin_skip > v) | |
2684 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop); | |
2685 else { | |
31957
49848f9a8f30
Add -edl-start-pts option to Adjust positions in EDL records according
reynaldo
parents:
31904
diff
changeset
|
2686 double pts = edl_start_pts ? start_pts : 0; |
49848f9a8f30
Add -edl-start-pts option to Adjust positions in EDL records according
reynaldo
parents:
31904
diff
changeset
|
2687 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip - pts, v - pts, 0); |
31077 | 2688 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip); |
2689 } | |
2690 mpctx->begin_skip = MP_NOPTS_VALUE; | |
2691 } | |
2692 } | |
2693 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2694 |
31077 | 2695 case MP_CMD_SWITCH_RATIO: |
28368
c616bf5d520b
command.c: Fix some commands crashing during audio-only playback
uau
parents:
28032
diff
changeset
|
2696 if (!sh_video) |
c616bf5d520b
command.c: Fix some commands crashing during audio-only playback
uau
parents:
28032
diff
changeset
|
2697 break; |
31077 | 2698 if (cmd->nargs == 0 || cmd->args[0].v.f == -1) |
2699 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h; | |
2700 else | |
2701 movie_aspect = cmd->args[0].v.f; | |
2702 mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0); | |
2703 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2704 |
31077 | 2705 case MP_CMD_SPEED_INCR:{ |
2706 float v = cmd->args[0].v.f; | |
2707 playback_speed += v; | |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
2708 reinit_audio_chain(); |
31077 | 2709 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed, |
2710 playback_speed); | |
2711 } break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2712 |
31077 | 2713 case MP_CMD_SPEED_MULT:{ |
2714 float v = cmd->args[0].v.f; | |
2715 playback_speed *= v; | |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
2716 reinit_audio_chain(); |
31077 | 2717 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed, |
2718 playback_speed); | |
2719 } break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2720 |
31077 | 2721 case MP_CMD_SPEED_SET:{ |
2722 float v = cmd->args[0].v.f; | |
2723 playback_speed = v; | |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
2724 reinit_audio_chain(); |
31077 | 2725 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed, |
2726 playback_speed); | |
2727 } break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2728 |
31077 | 2729 case MP_CMD_FRAME_STEP: |
2730 case MP_CMD_PAUSE: | |
2731 cmd->pausing = 1; | |
2732 brk_cmd = 1; | |
2733 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2734 |
31077 | 2735 case MP_CMD_FILE_FILTER: |
2736 file_filter = cmd->args[0].v.i; | |
2737 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2738 |
31077 | 2739 case MP_CMD_QUIT: |
2740 exit_player_with_rc(EXIT_QUIT, | |
2741 (cmd->nargs > 0) ? cmd->args[0].v.i : 0); | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2742 |
31077 | 2743 case MP_CMD_PLAY_TREE_STEP:{ |
2744 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i; | |
2745 int force = cmd->args[1].v.i; | |
22478 | 2746 |
27343 | 2747 #ifdef CONFIG_GUI |
31077 | 2748 if (use_gui) { |
2749 int i = 0; | |
2750 if (n > 0) | |
2751 for (i = 0; i < n; i++) | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
2752 gui(GUI_RUN_COMMAND, (void *)MP_CMD_PLAY_TREE_STEP); |
31077 | 2753 else |
2754 for (i = 0; i < -1 * n; i++) | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
2755 gui(GUI_RUN_COMMAND, (void *)-MP_CMD_PLAY_TREE_STEP); |
31077 | 2756 } else |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2757 #endif |
31077 | 2758 { |
2759 if (!force && mpctx->playtree_iter) { | |
2760 play_tree_iter_t *i = | |
2761 play_tree_iter_new_copy(mpctx->playtree_iter); | |
2762 if (play_tree_iter_step(i, n, 0) == | |
2763 PLAY_TREE_ITER_ENTRY) | |
2764 mpctx->eof = | |
2765 (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; | |
2766 play_tree_iter_free(i); | |
2767 } else | |
2768 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; | |
2769 if (mpctx->eof) | |
2770 mpctx->play_tree_step = n; | |
2771 brk_cmd = 1; | |
2772 } | |
2773 } | |
2774 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2775 |
31077 | 2776 case MP_CMD_PLAY_TREE_UP_STEP:{ |
2777 int n = cmd->args[0].v.i > 0 ? 1 : -1; | |
2778 int force = cmd->args[1].v.i; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2779 |
31077 | 2780 if (!force && mpctx->playtree_iter) { |
2781 play_tree_iter_t *i = | |
2782 play_tree_iter_new_copy(mpctx->playtree_iter); | |
2783 if (play_tree_iter_up_step(i, n, 0) == PLAY_TREE_ITER_ENTRY) | |
2784 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV; | |
2785 play_tree_iter_free(i); | |
2786 } else | |
2787 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV; | |
2788 brk_cmd = 1; | |
2789 } | |
2790 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2791 |
31077 | 2792 case MP_CMD_PLAY_ALT_SRC_STEP: |
2793 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) { | |
2794 int v = cmd->args[0].v.i; | |
2795 if (v > 0 | |
2796 && mpctx->playtree_iter->file < | |
2797 mpctx->playtree_iter->num_files) | |
2798 mpctx->eof = PT_NEXT_SRC; | |
2799 else if (v < 0 && mpctx->playtree_iter->file > 1) | |
2800 mpctx->eof = PT_PREV_SRC; | |
2801 } | |
2802 brk_cmd = 1; | |
2803 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2804 |
31077 | 2805 case MP_CMD_SUB_STEP: |
2806 if (sh_video) { | |
2807 int movement = cmd->args[0].v.i; | |
2808 step_sub(subdata, sh_video->pts, movement); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2809 #ifdef CONFIG_ASS |
31077 | 2810 if (ass_track) |
2811 sub_delay += | |
2812 ass_step_sub(ass_track, | |
2813 (sh_video->pts + | |
2814 sub_delay) * 1000 + .5, movement) / 1000.; | |
22478 | 2815 #endif |
31077 | 2816 set_osd_msg(OSD_MSG_SUB_DELAY, 1, osd_duration, |
2817 MSGTR_OSDSubDelay, ROUND(sub_delay * 1000)); | |
2818 } | |
2819 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2820 |
31077 | 2821 case MP_CMD_SUB_LOG: |
2822 log_sub(); | |
2823 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2824 |
31077 | 2825 case MP_CMD_OSD:{ |
2826 int v = cmd->args[0].v.i; | |
2827 int max = (term_osd | |
2828 && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL; | |
2829 if (osd_level > max) | |
2830 osd_level = max; | |
2831 if (v < 0) | |
2832 osd_level = (osd_level + 1) % (max + 1); | |
2833 else | |
2834 osd_level = v > max ? max : v; | |
2835 /* Show OSD state when disabled, but not when an explicit | |
2836 argument is given to the OSD command, i.e. in slave mode. */ | |
2837 if (v == -1 && osd_level <= 1) | |
2838 set_osd_msg(OSD_MSG_OSD_STATUS, 0, osd_duration, | |
2839 MSGTR_OSDosd, | |
2840 osd_level ? MSGTR_OSDenabled : | |
2841 MSGTR_OSDdisabled); | |
2842 else | |
2843 rm_osd_msg(OSD_MSG_OSD_STATUS); | |
2844 } | |
2845 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2846 |
31077 | 2847 case MP_CMD_OSD_SHOW_TEXT: |
2848 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i, | |
2849 (cmd->args[1].v.i < | |
2850 0 ? osd_duration : cmd->args[1].v.i), | |
2851 "%-.63s", cmd->args[0].v.s); | |
2852 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2853 |
31077 | 2854 case MP_CMD_OSD_SHOW_PROPERTY_TEXT:{ |
2855 char *txt = m_properties_expand_string(mp_properties, | |
2856 cmd->args[0].v.s, | |
2857 mpctx); | |
2858 /* if no argument supplied take default osd_duration, else <arg> ms. */ | |
2859 if (txt) { | |
2860 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i, | |
2861 (cmd->args[1].v.i < | |
2862 0 ? osd_duration : cmd->args[1].v.i), | |
2863 "%-.63s", txt); | |
2864 free(txt); | |
2865 } | |
2866 } | |
2867 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2868 |
31077 | 2869 case MP_CMD_LOADFILE:{ |
2870 play_tree_t *e = play_tree_new(); | |
2871 play_tree_add_file(e, cmd->args[0].v.s); | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2872 |
31077 | 2873 if (cmd->args[1].v.i) // append |
2874 play_tree_append_entry(mpctx->playtree->child, e); | |
2875 else { | |
2876 // Go back to the starting point. | |
2877 while (play_tree_iter_up_step | |
2878 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) | |
2879 /* NOP */ ; | |
2880 play_tree_free_list(mpctx->playtree->child, 1); | |
2881 play_tree_set_child(mpctx->playtree, e); | |
2882 pt_iter_goto_head(mpctx->playtree_iter); | |
2883 mpctx->eof = PT_NEXT_SRC; | |
2884 } | |
2885 brk_cmd = 1; | |
2886 } | |
2887 break; | |
22478 | 2888 |
31077 | 2889 case MP_CMD_LOADLIST:{ |
2890 play_tree_t *e = parse_playlist_file(cmd->args[0].v.s); | |
2891 if (!e) | |
2892 mp_msg(MSGT_CPLAYER, MSGL_ERR, | |
2893 MSGTR_PlaylistLoadUnable, cmd->args[0].v.s); | |
2894 else { | |
2895 if (cmd->args[1].v.i) // append | |
2896 play_tree_append_entry(mpctx->playtree->child, e); | |
2897 else { | |
2898 // Go back to the starting point. | |
2899 while (play_tree_iter_up_step | |
2900 (mpctx->playtree_iter, 0, 1) | |
2901 != PLAY_TREE_ITER_END) | |
2902 /* NOP */ ; | |
2903 play_tree_free_list(mpctx->playtree->child, 1); | |
2904 play_tree_set_child(mpctx->playtree, e); | |
2905 pt_iter_goto_head(mpctx->playtree_iter); | |
2906 mpctx->eof = PT_NEXT_SRC; | |
2907 } | |
2908 } | |
2909 brk_cmd = 1; | |
2910 } | |
2911 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2912 |
31077 | 2913 case MP_CMD_STOP: |
33482
7e41f14e7778
Fix segmentation fault when pressing U (stop playing) in GUI.
ib
parents:
33251
diff
changeset
|
2914 #ifdef CONFIG_GUI |
7e41f14e7778
Fix segmentation fault when pressing U (stop playing) in GUI.
ib
parents:
33251
diff
changeset
|
2915 // playtree_iter isn't used by the GUI |
7e41f14e7778
Fix segmentation fault when pressing U (stop playing) in GUI.
ib
parents:
33251
diff
changeset
|
2916 if (use_gui) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
2917 gui(GUI_RUN_COMMAND, (void *)MP_CMD_STOP); |
33482
7e41f14e7778
Fix segmentation fault when pressing U (stop playing) in GUI.
ib
parents:
33251
diff
changeset
|
2918 else |
7e41f14e7778
Fix segmentation fault when pressing U (stop playing) in GUI.
ib
parents:
33251
diff
changeset
|
2919 #endif |
31077 | 2920 // Go back to the starting point. |
2921 while (play_tree_iter_up_step | |
2922 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) | |
2923 /* NOP */ ; | |
2924 mpctx->eof = PT_STOP; | |
2925 brk_cmd = 1; | |
2926 break; | |
26877 | 2927 |
31077 | 2928 case MP_CMD_OSD_SHOW_PROGRESSION:{ |
2929 int len = demuxer_get_time_length(mpctx->demuxer); | |
2930 int pts = demuxer_get_current_time(mpctx->demuxer); | |
2931 set_osd_bar(0, "Position", 0, 100, demuxer_get_percent_pos(mpctx->demuxer)); | |
2932 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, | |
2933 "%c %02d:%02d:%02d / %02d:%02d:%02d", | |
2934 mpctx->osd_function, pts/3600, (pts/60)%60, pts%60, | |
2935 len/3600, (len/60)%60, len%60); | |
2936 } | |
2937 break; | |
30986
2186c040f9e0
Add osd_show_progression: Show progress bar and elapsed/total time.
cehoyos
parents:
30901
diff
changeset
|
2938 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2939 #ifdef CONFIG_RADIO |
31077 | 2940 case MP_CMD_RADIO_STEP_CHANNEL: |
2941 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { | |
2942 int v = cmd->args[0].v.i; | |
2943 if (v > 0) | |
2944 radio_step_channel(mpctx->demuxer->stream, | |
2945 RADIO_CHANNEL_HIGHER); | |
2946 else | |
2947 radio_step_channel(mpctx->demuxer->stream, | |
2948 RADIO_CHANNEL_LOWER); | |
2949 if (radio_get_channel_name(mpctx->demuxer->stream)) { | |
2950 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration, | |
2951 MSGTR_OSDChannel, | |
2952 radio_get_channel_name(mpctx->demuxer->stream)); | |
2953 } | |
2954 } | |
2955 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2956 |
31077 | 2957 case MP_CMD_RADIO_SET_CHANNEL: |
2958 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { | |
2959 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s); | |
2960 if (radio_get_channel_name(mpctx->demuxer->stream)) { | |
2961 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration, | |
2962 MSGTR_OSDChannel, | |
2963 radio_get_channel_name(mpctx->demuxer->stream)); | |
2964 } | |
2965 } | |
2966 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2967 |
31077 | 2968 case MP_CMD_RADIO_SET_FREQ: |
2969 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) | |
2970 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f); | |
2971 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2972 |
31077 | 2973 case MP_CMD_RADIO_STEP_FREQ: |
2974 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) | |
2975 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f); | |
2976 break; | |
22478 | 2977 #endif |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2978 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
2979 #ifdef CONFIG_TV |
31077 | 2980 case MP_CMD_TV_START_SCAN: |
2981 if (mpctx->file_format == DEMUXER_TYPE_TV) | |
2982 tv_start_scan((tvi_handle_t *) (mpctx->demuxer->priv),1); | |
2983 break; | |
2984 case MP_CMD_TV_SET_FREQ: | |
2985 if (mpctx->file_format == DEMUXER_TYPE_TV) | |
2986 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv), | |
2987 cmd->args[0].v.f * 16.0); | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
2988 #ifdef CONFIG_PVR |
23258
1d86fb12e4ae
cosmetic: use K&R coding style, as in reste of the file
ben
parents:
23244
diff
changeset
|
2989 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
2990 pvr_set_freq (mpctx->stream, ROUND (cmd->args[0].v.f)); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
2991 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
2992 pvr_get_current_channelname (mpctx->stream), |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
2993 pvr_get_current_stationname (mpctx->stream)); |
23259 | 2994 } |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
2995 #endif /* CONFIG_PVR */ |
31077 | 2996 break; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
2997 |
31077 | 2998 case MP_CMD_TV_STEP_FREQ: |
2999 if (mpctx->file_format == DEMUXER_TYPE_TV) | |
3000 tv_step_freq((tvi_handle_t *) (mpctx->demuxer->priv), | |
3001 cmd->args[0].v.f * 16.0); | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3002 #ifdef CONFIG_PVR |
23258
1d86fb12e4ae
cosmetic: use K&R coding style, as in reste of the file
ben
parents:
23244
diff
changeset
|
3003 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3004 pvr_force_freq_step (mpctx->stream, ROUND (cmd->args[0].v.f)); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3005 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: f %d", |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3006 pvr_get_current_channelname (mpctx->stream), |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3007 pvr_get_current_frequency (mpctx->stream)); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3008 } |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3009 #endif /* CONFIG_PVR */ |
31077 | 3010 break; |
22667 | 3011 |
31077 | 3012 case MP_CMD_TV_SET_NORM: |
3013 if (mpctx->file_format == DEMUXER_TYPE_TV) | |
3014 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv), | |
3015 cmd->args[0].v.s); | |
3016 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3017 |
31077 | 3018 case MP_CMD_TV_STEP_CHANNEL:{ |
3019 if (mpctx->file_format == DEMUXER_TYPE_TV) { | |
3020 int v = cmd->args[0].v.i; | |
3021 if (v > 0) { | |
3022 tv_step_channel((tvi_handle_t *) (mpctx-> | |
3023 demuxer->priv), | |
3024 TV_CHANNEL_HIGHER); | |
3025 } else { | |
3026 tv_step_channel((tvi_handle_t *) (mpctx-> | |
3027 demuxer->priv), | |
3028 TV_CHANNEL_LOWER); | |
3029 } | |
3030 if (tv_channel_list) { | |
3031 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration, | |
3032 MSGTR_OSDChannel, tv_channel_current->name); | |
3033 //vo_osd_changed(OSDTYPE_SUBTITLE); | |
3034 } | |
3035 } | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3036 #ifdef CONFIG_PVR |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3037 else if (mpctx->stream && |
23258
1d86fb12e4ae
cosmetic: use K&R coding style, as in reste of the file
ben
parents:
23244
diff
changeset
|
3038 mpctx->stream->type == STREAMTYPE_PVR) { |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3039 pvr_set_channel_step (mpctx->stream, cmd->args[0].v.i); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3040 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3041 pvr_get_current_channelname (mpctx->stream), |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3042 pvr_get_current_stationname (mpctx->stream)); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3043 } |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3044 #endif /* CONFIG_PVR */ |
31077 | 3045 } |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3046 #ifdef CONFIG_DVBIN |
31077 | 3047 if (mpctx->stream->type == STREAMTYPE_DVB) { |
3048 int dir; | |
3049 int v = cmd->args[0].v.i; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3050 |
31077 | 3051 mpctx->last_dvb_step = v; |
3052 if (v > 0) | |
3053 dir = DVB_CHANNEL_HIGHER; | |
3054 else | |
3055 dir = DVB_CHANNEL_LOWER; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3056 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3057 |
31077 | 3058 if (dvb_step_channel(mpctx->stream, dir)) |
3059 mpctx->eof = mpctx->dvbin_reopen = 1; | |
3060 } | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3061 #endif /* CONFIG_DVBIN */ |
31077 | 3062 break; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3063 |
31077 | 3064 case MP_CMD_TV_SET_CHANNEL: |
3065 if (mpctx->file_format == DEMUXER_TYPE_TV) { | |
3066 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv), | |
3067 cmd->args[0].v.s); | |
3068 if (tv_channel_list) { | |
3069 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration, | |
3070 MSGTR_OSDChannel, tv_channel_current->name); | |
3071 //vo_osd_changed(OSDTYPE_SUBTITLE); | |
3072 } | |
3073 } | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3074 #ifdef CONFIG_PVR |
23258
1d86fb12e4ae
cosmetic: use K&R coding style, as in reste of the file
ben
parents:
23244
diff
changeset
|
3075 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3076 pvr_set_channel (mpctx->stream, cmd->args[0].v.s); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3077 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3078 pvr_get_current_channelname (mpctx->stream), |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3079 pvr_get_current_stationname (mpctx->stream)); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3080 } |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3081 #endif /* CONFIG_PVR */ |
31077 | 3082 break; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3083 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3084 #ifdef CONFIG_DVBIN |
31077 | 3085 case MP_CMD_DVB_SET_CHANNEL: |
3086 if (mpctx->stream->type == STREAMTYPE_DVB) { | |
3087 mpctx->last_dvb_step = 1; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3088 |
31077 | 3089 if (dvb_set_channel |
3090 (mpctx->stream, cmd->args[1].v.i, cmd->args[0].v.i)) | |
3091 mpctx->eof = mpctx->dvbin_reopen = 1; | |
3092 } | |
3093 break; | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3094 #endif /* CONFIG_DVBIN */ |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3095 |
31077 | 3096 case MP_CMD_TV_LAST_CHANNEL: |
3097 if (mpctx->file_format == DEMUXER_TYPE_TV) { | |
3098 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv)); | |
3099 if (tv_channel_list) { | |
3100 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration, | |
3101 MSGTR_OSDChannel, tv_channel_current->name); | |
3102 //vo_osd_changed(OSDTYPE_SUBTITLE); | |
3103 } | |
3104 } | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3105 #ifdef CONFIG_PVR |
23258
1d86fb12e4ae
cosmetic: use K&R coding style, as in reste of the file
ben
parents:
23244
diff
changeset
|
3106 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { |
23244
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3107 pvr_set_lastchannel (mpctx->stream); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3108 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3109 pvr_get_current_channelname (mpctx->stream), |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3110 pvr_get_current_stationname (mpctx->stream)); |
e5e8ac0bd7fc
support for PVR channel navigation (patch by Sven Gothel <sgothel at jausoft dot com>)
ben
parents:
23077
diff
changeset
|
3111 } |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27345
diff
changeset
|
3112 #endif /* CONFIG_PVR */ |
31077 | 3113 break; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3114 |
31077 | 3115 case MP_CMD_TV_STEP_NORM: |
3116 if (mpctx->file_format == DEMUXER_TYPE_TV) | |
3117 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv)); | |
3118 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3119 |
31077 | 3120 case MP_CMD_TV_STEP_CHANNEL_LIST: |
3121 if (mpctx->file_format == DEMUXER_TYPE_TV) | |
3122 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv)); | |
3123 break; | |
29806 | 3124 #endif /* CONFIG_TV */ |
31077 | 3125 case MP_CMD_TV_TELETEXT_ADD_DEC: |
3126 if (mpctx->demuxer->teletext) | |
3127 teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_ADD_DEC, | |
3128 &(cmd->args[0].v.s)); | |
3129 break; | |
3130 case MP_CMD_TV_TELETEXT_GO_LINK: | |
3131 if (mpctx->demuxer->teletext) | |
3132 teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_GO_LINK, | |
3133 &(cmd->args[0].v.i)); | |
3134 break; | |
32406 | 3135 |
32392 | 3136 case MP_CMD_OVERLAY_ADD: |
3137 overlay_add(cmd->args[0].v.s, cmd->args[1].v.i, | |
3138 cmd->args[2].v.i, cmd->args[3].v.i, cmd->args[4].v.i); | |
3139 break; | |
3140 case MP_CMD_OVERLAY_REMOVE: | |
3141 overlay_remove(cmd->args[0].v.i); | |
3142 break; | |
22478 | 3143 |
31077 | 3144 case MP_CMD_SUB_LOAD: |
3145 if (sh_video) { | |
3146 int n = mpctx->set_of_sub_size; | |
3147 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0); | |
3148 if (n != mpctx->set_of_sub_size) { | |
31612
7fc1f051a19f
Change global subtitle numbering scheme so that demuxers can "asynchronously"
reimar
parents:
31312
diff
changeset
|
3149 mpctx->sub_counts[SUB_SOURCE_SUBS]++; |
31077 | 3150 ++mpctx->global_sub_size; |
3151 } | |
3152 } | |
3153 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3154 |
31077 | 3155 case MP_CMD_SUB_REMOVE: |
3156 if (sh_video) { | |
3157 int v = cmd->args[0].v.i; | |
3158 if (v < 0) { | |
3159 remove_subtitle_range(mpctx, 0, mpctx->set_of_sub_size); | |
3160 } else if (v < mpctx->set_of_sub_size) { | |
3161 remove_subtitle_range(mpctx, v, 1); | |
3162 } | |
3163 } | |
3164 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3165 |
31077 | 3166 case MP_CMD_GET_SUB_VISIBILITY: |
3167 if (sh_video) { | |
3168 mp_msg(MSGT_GLOBAL, MSGL_INFO, | |
3169 "ANS_SUB_VISIBILITY=%d\n", sub_visibility); | |
3170 } | |
3171 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3172 |
31077 | 3173 case MP_CMD_SCREENSHOT: |
3174 if (vo_config_count) { | |
3175 mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n"); | |
3176 if (CONTROL_OK != | |
3177 ((vf_instance_t *) sh_video->vfilter)-> | |
3178 control(sh_video->vfilter, VFCTRL_SCREENSHOT, | |
3179 &cmd->args[0].v.i)) | |
3180 mp_msg(MSGT_CPLAYER, MSGL_INFO, "failed (forgot -vf screenshot?)\n"); | |
3181 } | |
3182 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3183 |
31077 | 3184 case MP_CMD_VF_CHANGE_RECTANGLE: |
28368
c616bf5d520b
command.c: Fix some commands crashing during audio-only playback
uau
parents:
28032
diff
changeset
|
3185 if (!sh_video) |
c616bf5d520b
command.c: Fix some commands crashing during audio-only playback
uau
parents:
28032
diff
changeset
|
3186 break; |
31077 | 3187 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i); |
3188 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3189 |
31077 | 3190 case MP_CMD_GET_TIME_LENGTH:{ |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
32209
diff
changeset
|
3191 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2f\n", |
31077 | 3192 demuxer_get_time_length(mpctx->demuxer)); |
3193 } | |
3194 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3195 |
31077 | 3196 case MP_CMD_GET_FILENAME:{ |
3197 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_FILENAME='%s'\n", | |
3198 get_metadata(META_NAME)); | |
3199 } | |
3200 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3201 |
31077 | 3202 case MP_CMD_GET_VIDEO_CODEC:{ |
3203 char *inf = get_metadata(META_VIDEO_CODEC); | |
3204 if (!inf) | |
3205 inf = strdup(""); | |
3206 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf); | |
3207 free(inf); | |
3208 } | |
3209 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3210 |
31077 | 3211 case MP_CMD_GET_VIDEO_BITRATE:{ |
3212 char *inf = get_metadata(META_VIDEO_BITRATE); | |
3213 if (!inf) | |
3214 inf = strdup(""); | |
3215 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf); | |
3216 free(inf); | |
3217 } | |
3218 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3219 |
31077 | 3220 case MP_CMD_GET_VIDEO_RESOLUTION:{ |
3221 char *inf = get_metadata(META_VIDEO_RESOLUTION); | |
3222 if (!inf) | |
3223 inf = strdup(""); | |
3224 mp_msg(MSGT_GLOBAL, MSGL_INFO, | |
3225 "ANS_VIDEO_RESOLUTION='%s'\n", inf); | |
3226 free(inf); | |
3227 } | |
3228 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3229 |
31077 | 3230 case MP_CMD_GET_AUDIO_CODEC:{ |
3231 char *inf = get_metadata(META_AUDIO_CODEC); | |
3232 if (!inf) | |
3233 inf = strdup(""); | |
3234 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf); | |
3235 free(inf); | |
3236 } | |
3237 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3238 |
31077 | 3239 case MP_CMD_GET_AUDIO_BITRATE:{ |
3240 char *inf = get_metadata(META_AUDIO_BITRATE); | |
3241 if (!inf) | |
3242 inf = strdup(""); | |
3243 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf); | |
3244 free(inf); | |
3245 } | |
3246 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3247 |
31077 | 3248 case MP_CMD_GET_AUDIO_SAMPLES:{ |
3249 char *inf = get_metadata(META_AUDIO_SAMPLES); | |
3250 if (!inf) | |
3251 inf = strdup(""); | |
3252 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf); | |
3253 free(inf); | |
3254 } | |
3255 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3256 |
31077 | 3257 case MP_CMD_GET_META_TITLE:{ |
3258 char *inf = get_metadata(META_INFO_TITLE); | |
3259 if (!inf) | |
3260 inf = strdup(""); | |
3261 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TITLE='%s'\n", inf); | |
3262 free(inf); | |
3263 } | |
3264 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3265 |
31077 | 3266 case MP_CMD_GET_META_ARTIST:{ |
3267 char *inf = get_metadata(META_INFO_ARTIST); | |
3268 if (!inf) | |
3269 inf = strdup(""); | |
3270 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf); | |
3271 free(inf); | |
3272 } | |
3273 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3274 |
31077 | 3275 case MP_CMD_GET_META_ALBUM:{ |
3276 char *inf = get_metadata(META_INFO_ALBUM); | |
3277 if (!inf) | |
3278 inf = strdup(""); | |
3279 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf); | |
3280 free(inf); | |
3281 } | |
3282 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3283 |
31077 | 3284 case MP_CMD_GET_META_YEAR:{ |
3285 char *inf = get_metadata(META_INFO_YEAR); | |
3286 if (!inf) | |
3287 inf = strdup(""); | |
3288 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_YEAR='%s'\n", inf); | |
3289 free(inf); | |
3290 } | |
3291 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3292 |
31077 | 3293 case MP_CMD_GET_META_COMMENT:{ |
3294 char *inf = get_metadata(META_INFO_COMMENT); | |
3295 if (!inf) | |
3296 inf = strdup(""); | |
3297 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf); | |
3298 free(inf); | |
3299 } | |
3300 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3301 |
31077 | 3302 case MP_CMD_GET_META_TRACK:{ |
3303 char *inf = get_metadata(META_INFO_TRACK); | |
3304 if (!inf) | |
3305 inf = strdup(""); | |
3306 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TRACK='%s'\n", inf); | |
3307 free(inf); | |
3308 } | |
3309 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3310 |
31077 | 3311 case MP_CMD_GET_META_GENRE:{ |
3312 char *inf = get_metadata(META_INFO_GENRE); | |
3313 if (!inf) | |
3314 inf = strdup(""); | |
3315 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_GENRE='%s'\n", inf); | |
3316 free(inf); | |
3317 } | |
3318 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3319 |
31077 | 3320 case MP_CMD_GET_VO_FULLSCREEN: |
3321 if (mpctx->video_out && vo_config_count) | |
3322 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs); | |
3323 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3324 |
31077 | 3325 case MP_CMD_GET_PERCENT_POS: |
3326 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n", | |
3327 demuxer_get_percent_pos(mpctx->demuxer)); | |
3328 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3329 |
31077 | 3330 case MP_CMD_GET_TIME_POS:{ |
3331 float pos = 0; | |
3332 if (sh_video) | |
3333 pos = sh_video->pts; | |
3334 else if (sh_audio && mpctx->audio_out) | |
3335 pos = | |
3336 playing_audio_pts(sh_audio, mpctx->d_audio, | |
3337 mpctx->audio_out); | |
3338 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos); | |
3339 } | |
3340 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3341 |
31077 | 3342 case MP_CMD_RUN: |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3343 #ifndef __MINGW32__ |
31077 | 3344 if (!fork()) { |
34987 | 3345 char *exp_cmd = property_expand_string(mpctx, cmd->args[0].v.s); |
3346 if (exp_cmd) { | |
3347 execl("/bin/sh", "sh", "-c", exp_cmd, NULL); | |
3348 free(exp_cmd); | |
3349 } | |
31077 | 3350 exit(0); |
3351 } | |
22478 | 3352 #endif |
31077 | 3353 break; |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3354 |
31077 | 3355 case MP_CMD_KEYDOWN_EVENTS: |
3356 mplayer_put_key(cmd->args[0].v.i); | |
3357 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3358 |
31077 | 3359 case MP_CMD_SET_MOUSE_POS:{ |
3360 int pointer_x, pointer_y; | |
3361 double dx, dy; | |
3362 pointer_x = cmd->args[0].v.i; | |
3363 pointer_y = cmd->args[1].v.i; | |
3364 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
3365 #ifdef CONFIG_DVDNAV |
31077 | 3366 if (mpctx->stream->type == STREAMTYPE_DVDNAV |
3367 && dx > 0.0 && dy > 0.0) { | |
3368 int button = -1; | |
3369 pointer_x = (int) (dx * (double) sh_video->disp_w); | |
3370 pointer_y = (int) (dy * (double) sh_video->disp_h); | |
3371 mp_dvdnav_update_mouse_pos(mpctx->stream, | |
3372 pointer_x, pointer_y, &button); | |
3373 if (osd_level > 1 && button > 0) | |
3374 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, | |
3375 "Selected button number %d", button); | |
3376 } | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3377 #endif |
27345
b597fd2924b4
Rename preprocessor directive HAVE_MENU --> CONFIG_MENU.
diego
parents:
27343
diff
changeset
|
3378 #ifdef CONFIG_MENU |
31077 | 3379 if (use_menu && dx >= 0.0 && dy >= 0.0) |
3380 menu_update_mouse_pos(dx, dy); | |
25461 | 3381 #endif |
31077 | 3382 } |
3383 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3384 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27069
diff
changeset
|
3385 #ifdef CONFIG_DVDNAV |
31077 | 3386 case MP_CMD_DVDNAV:{ |
3387 int button = -1; | |
3388 int i; | |
3389 mp_command_type command = 0; | |
3390 if (mpctx->stream->type != STREAMTYPE_DVDNAV) | |
3391 break; | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3392 |
31077 | 3393 for (i = 0; mp_dvdnav_bindings[i].name; i++) |
3394 if (cmd->args[0].v.s && | |
3395 !strcasecmp (cmd->args[0].v.s, | |
3396 mp_dvdnav_bindings[i].name)) | |
3397 command = mp_dvdnav_bindings[i].cmd; | |
27068 | 3398 |
31077 | 3399 mp_dvdnav_handle_input(mpctx->stream,command,&button); |
3400 if (osd_level > 1 && button > 0) | |
3401 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, | |
3402 "Selected button number %d", button); | |
3403 } | |
3404 break; | |
25817 | 3405 |
31077 | 3406 case MP_CMD_SWITCH_TITLE: |
3407 if (mpctx->stream->type == STREAMTYPE_DVDNAV) | |
3408 mp_dvdnav_switch_title(mpctx->stream, cmd->args[0].v.i); | |
3409 break; | |
25817 | 3410 |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3411 #endif |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3412 |
30988
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3413 case MP_CMD_AF_SWITCH: |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3414 if (sh_audio) |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3415 { |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3416 af_uninit(mpctx->mixer.afilter); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3417 af_init(mpctx->mixer.afilter); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3418 } |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3419 case MP_CMD_AF_ADD: |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3420 case MP_CMD_AF_DEL: |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3421 if (!sh_audio) |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3422 break; |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3423 { |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3424 char* af_args = strdup(cmd->args[0].v.s); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3425 char* af_commands = af_args; |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3426 char* af_command; |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3427 af_instance_t* af; |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3428 while ((af_command = strsep(&af_commands, ",")) != NULL) |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3429 { |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3430 if (cmd->id == MP_CMD_AF_DEL) |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3431 { |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3432 af = af_get(mpctx->mixer.afilter, af_command); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3433 if (af != NULL) |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3434 af_remove(mpctx->mixer.afilter, af); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3435 } |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3436 else |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3437 af_add(mpctx->mixer.afilter, af_command); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3438 } |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
3439 reinit_audio_chain(); |
30988
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3440 free(af_args); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3441 } |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3442 break; |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3443 case MP_CMD_AF_CLR: |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3444 if (!sh_audio) |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3445 break; |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3446 af_uninit(mpctx->mixer.afilter); |
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3447 af_init(mpctx->mixer.afilter); |
32561
17bb5a38ae2e
build_afilter_chain is not safe to use directly, thus make it
reimar
parents:
32511
diff
changeset
|
3448 reinit_audio_chain(); |
30988
8d840754a921
Add slave commands for loading and unloading audio filters at runtime.
cehoyos
parents:
30986
diff
changeset
|
3449 break; |
32419
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3450 case MP_CMD_AF_CMDLINE: |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3451 if (sh_audio) { |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3452 af_instance_t *af = af_get(sh_audio->afilter, cmd->args[0].v.s); |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3453 if (!af) { |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3454 mp_msg(MSGT_CPLAYER, MSGL_WARN, |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3455 "Filter '%s' not found in chain.\n", cmd->args[0].v.s); |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3456 break; |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3457 } |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3458 af->control(af, AF_CONTROL_COMMAND_LINE, cmd->args[1].v.s); |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3459 af_reinit(sh_audio->afilter, af); |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3460 } |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3461 break; |
8f35fc25523f
Add experimental af_cmdline slave command to allow changing filter options at runtime.
reimar
parents:
32406
diff
changeset
|
3462 |
31077 | 3463 default: |
34339 | 3464 #ifdef CONFIG_GUI |
3465 if (use_gui && cmd->id == MP_CMD_GUI) | |
3466 gui(GUI_RUN_MESSAGE, cmd->args[0].v.s); | |
3467 else | |
3468 #endif | |
31077 | 3469 mp_msg(MSGT_CPLAYER, MSGL_V, |
3470 "Received unknown cmd %s\n", cmd->name); | |
3471 } | |
22479
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3472 |
a99ddf2ece25
Change to match current command.c (same functionality).
uau
parents:
22478
diff
changeset
|
3473 switch (cmd->pausing) { |
31077 | 3474 case 1: // "pausing" |
3475 mpctx->osd_function = OSD_PAUSE; | |
3476 break; | |
3477 case 3: // "pausing_toggle" | |
3478 mpctx->was_paused = !mpctx->was_paused; | |
3479 if (mpctx->was_paused) | |
3480 mpctx->osd_function = OSD_PAUSE; | |
3481 else if (mpctx->osd_function == OSD_PAUSE) | |
3482 mpctx->osd_function = OSD_PLAY; | |
3483 break; | |
3484 case 2: // "pausing_keep" | |
3485 if (mpctx->was_paused) | |
3486 mpctx->osd_function = OSD_PAUSE; | |
22478 | 3487 } |
3488 return brk_cmd; | |
3489 } |