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