comparison command.c.tmp @ 22479:a99ddf2ece25

Change to match current command.c (same functionality). The versions compile to the same code on my machine except for one test instruction that has its operands swapped and conditional jump changed accordingly.
author uau
date Fri, 09 Mar 2007 12:39:34 +0000
parents 3501ae650b23
children
comparison
equal deleted inserted replaced
22478:3501ae650b23 22479:a99ddf2ece25
1 #include <stdlib.h>
1 #include <inttypes.h> 2 #include <inttypes.h>
2 #include <stdlib.h> 3 #include <unistd.h>
4
3 #include "config.h" 5 #include "config.h"
4
5 #include <unistd.h>
6
7 #include "help_mp.h"
8
9 #include "m_option.h"
10 #include "m_property.h"
11
12 #include "libvo/video_out.h"
13
14 #include "libvo/sub.h"
15
16 #include "libao2/audio_out.h"
17
18 #include "spudec.h"
19 #include "vobsub.h"
20
21 #ifdef HAVE_NEW_GUI
22 #include "Gui/interface.h"
23 #endif
24
25 #include "input/input.h" 6 #include "input/input.h"
26
27 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
28
29 #ifdef USE_TV
30 #include "stream/tv.h"
31 #endif
32 #ifdef USE_RADIO
33 #include "stream/stream_radio.h"
34 #endif
35
36 #ifdef HAS_DVBIN_SUPPORT
37 #include "stream/dvbin.h"
38 #endif
39 #include "playtree.h"
40
41 #include "stream/stream.h" 7 #include "stream/stream.h"
42 #include "libmpdemux/demuxer.h" 8 #include "libmpdemux/demuxer.h"
43 #include "libmpdemux/stheader.h" 9 #include "libmpdemux/stheader.h"
44 #include "libmpdemux/matroska.h" 10 #include "mplayer.h"
45 11 #include "libvo/sub.h"
46 #ifdef USE_DVDREAD 12 #include "m_option.h"
47 #include "stream/stream_dvd.h" 13 #include "m_property.h"
48 #endif 14 #include "help_mp.h"
49 15 #include "metadata.h"
50 #ifdef USE_DVDNAV
51 #include "stream/stream_dvdnav.h"
52 #endif
53
54 #include "libmpcodecs/dec_video.h"
55 #include "libmpcodecs/mp_image.h" 16 #include "libmpcodecs/mp_image.h"
56 #include "libmpcodecs/vf.h" 17 #include "libmpcodecs/vf.h"
57 #include "libmpcodecs/vd.h" 18 #include "libmpcodecs/vd.h"
19 #include "libvo/video_out.h"
20 #include "playtree.h"
21 #include "libao2/audio_out.h"
22 #include "mpcommon.h"
23 #include "mixer.h"
24 #include "libmpdemux/matroska.h"
25 #include "libmpcodecs/dec_video.h"
26 #include "vobsub.h"
27 #include "spudec.h"
28 #ifdef USE_TV
29 #include "stream/tv.h"
30 #endif
31 #ifdef USE_RADIO
32 #include "stream/stream_radio.h"
33 #endif
34 #ifdef HAS_DVBIN_SUPPORT
35 #include "stream/dvbin.h"
36 #endif
37 #ifdef USE_DVDREAD
38 #include "stream/stream_dvd.h"
39 #endif
40 #ifdef USE_DVDNAV
41 #include "stream/stream_dvdnav.h"
42 #endif
58 #ifdef USE_ASS 43 #ifdef USE_ASS
59 #include "libass/ass.h" 44 #include "libass/ass.h"
60 #include "libass/ass_mp.h" 45 #include "libass/ass_mp.h"
61 #endif 46 #endif
62 #include "mpcommon.h" 47 #ifdef HAVE_NEW_GUI
63 #include "metadata.h" 48 #include "Gui/interface.h"
64 #include "mixer.h" 49 #endif
65
66 #include "mplayer.h"
67 50
68 #include "mp_core.h" 51 #include "mp_core.h"
52
53 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
54
55 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy)
56 {
57 //remove the borders, if any, and rescale to the range [0,1],[0,1]
58 if (vo_fs) { //we are in full-screen mode
59 if (vo_screenwidth > vo_dwidth) //there are borders along the x axis
60 ix -= (vo_screenwidth - vo_dwidth) / 2;
61 if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
62 iy -= (vo_screenheight - vo_dheight) / 2;
63
64 if (ix < 0 || ix > vo_dwidth) {
65 *dx = *dy = -1.0;
66 return;
67 } //we are on one of the borders
68 if (iy < 0 || iy > vo_dheight) {
69 *dx = *dy = -1.0;
70 return;
71 } //we are on one of the borders
72 }
73
74 *dx = (double) ix / (double) vo_dwidth;
75 *dy = (double) iy / (double) vo_dheight;
76
77 mp_msg(MSGT_CPLAYER, MSGL_V,
78 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
79 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth,
80 vo_dheight, vo_fs);
81 }
69 82
70 static int sub_source(MPContext * mpctx) 83 static int sub_source(MPContext * mpctx)
71 { 84 {
72 int source = -1; 85 int source = -1;
73 int top = -1; 86 int top = -1;
74 int i; 87 int i;
75 for (i = 0; i < SUB_SOURCES; i++) { 88 for (i = 0; i < SUB_SOURCES; i++) {
76 int j = mpctx->global_sub_indices[i]; 89 int j = mpctx->global_sub_indices[i];
77 if ((j >= 0) && (j > top) && (mpctx->global_sub_pos >= j)) { 90 if ((j >= 0) && (j > top) && (mpctx->global_sub_pos >= j)) {
78 source = i; 91 source = i;
79 top = j; 92 top = j;
80 } 93 }
81 } 94 }
82 return source; 95 return source;
83 } 96 }
84 97
85 /** 98 /**
86 * \brief Log the currently displayed subtitle to a file 99 * \brief Log the currently displayed subtitle to a file
87 * 100 *
88 * Logs the current or last displayed subtitle together with filename 101 * Logs the current or last displayed subtitle together with filename
89 * and time information to ~/.mplayer/subtitle_log 102 * and time information to ~/.mplayer/subtitle_log
90 * 103 *
91 * Intended purpose is to allow convenient marking of bogus subtitles 104 * Intended purpose is to allow convenient marking of bogus subtitles
92 * which need to be fixed while watching the movie. 105 * which need to be fixed while watching the movie.
93 */ 106 */
94 107
95 static void log_sub(void){ 108 static void log_sub(void)
109 {
96 char *fname; 110 char *fname;
97 FILE *f; 111 FILE *f;
98 int i; 112 int i;
99 113
100 if (subdata == NULL || vo_sub_last == NULL) return; 114 if (subdata == NULL || vo_sub_last == NULL)
115 return;
101 fname = get_path("subtitle_log"); 116 fname = get_path("subtitle_log");
102 f = fopen(fname, "a"); 117 f = fopen(fname, "a");
103 if (!f) return; 118 if (!f)
119 return;
104 fprintf(f, "----------------------------------------------------------\n"); 120 fprintf(f, "----------------------------------------------------------\n");
105 if (subdata->sub_uses_time) { 121 if (subdata->sub_uses_time) {
106 fprintf(f, "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", filename, 122 fprintf(f,
107 vo_sub_last->start/360000, (vo_sub_last->start/6000)%60, 123 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
108 (vo_sub_last->start/100)%60, vo_sub_last->start%100, 124 filename, vo_sub_last->start / 360000,
109 vo_sub_last->end/360000, (vo_sub_last->end/6000)%60, 125 (vo_sub_last->start / 6000) % 60,
110 (vo_sub_last->end/100)%60, vo_sub_last->end%100); 126 (vo_sub_last->start / 100) % 60, vo_sub_last->start % 100,
127 vo_sub_last->end / 360000, (vo_sub_last->end / 6000) % 60,
128 (vo_sub_last->end / 100) % 60, vo_sub_last->end % 100);
111 } else { 129 } else {
112 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start, vo_sub_last->end); 130 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start,
131 vo_sub_last->end);
113 } 132 }
114 for (i = 0; i < vo_sub_last->lines; i++) { 133 for (i = 0; i < vo_sub_last->lines; i++) {
115 fprintf(f, "%s\n", vo_sub_last->text[i]); 134 fprintf(f, "%s\n", vo_sub_last->text[i]);
116 } 135 }
117 fclose(f); 136 fclose(f);
124 /// \defgroup GeneralProperties General properties 143 /// \defgroup GeneralProperties General properties
125 /// \ingroup Properties 144 /// \ingroup Properties
126 ///@{ 145 ///@{
127 146
128 /// OSD level (RW) 147 /// OSD level (RW)
129 static int mp_property_osdlevel(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 148 static int mp_property_osdlevel(m_option_t * prop, int action, void *arg,
130 return m_property_choice(prop,action,arg,&osd_level); 149 MPContext * mpctx)
150 {
151 return m_property_choice(prop, action, arg, &osd_level);
131 } 152 }
132 153
133 /// Playback speed (RW) 154 /// Playback speed (RW)
134 static int mp_property_playback_speed(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 155 static int mp_property_playback_speed(m_option_t * prop, int action,
135 switch(action) { 156 void *arg, MPContext * mpctx)
157 {
158 switch (action) {
136 case M_PROPERTY_SET: 159 case M_PROPERTY_SET:
137 if(!arg) return M_PROPERTY_ERROR; 160 if (!arg)
138 M_PROPERTY_CLAMP(prop,*(float*)arg); 161 return M_PROPERTY_ERROR;
139 playback_speed = *(float*)arg; 162 M_PROPERTY_CLAMP(prop, *(float *) arg);
140 build_afilter_chain(mpctx->sh_audio, &ao_data); 163 playback_speed = *(float *) arg;
141 return M_PROPERTY_OK; 164 build_afilter_chain(mpctx->sh_audio, &ao_data);
165 return M_PROPERTY_OK;
142 case M_PROPERTY_STEP_UP: 166 case M_PROPERTY_STEP_UP:
143 case M_PROPERTY_STEP_DOWN: 167 case M_PROPERTY_STEP_DOWN:
144 playback_speed += (arg ? *(float*)arg : 0.1) * 168 playback_speed += (arg ? *(float *) arg : 0.1) *
145 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 169 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
146 M_PROPERTY_CLAMP(prop,playback_speed); 170 M_PROPERTY_CLAMP(prop, playback_speed);
147 build_afilter_chain(mpctx->sh_audio, &ao_data); 171 build_afilter_chain(mpctx->sh_audio, &ao_data);
148 return M_PROPERTY_OK; 172 return M_PROPERTY_OK;
149 } 173 }
150 return m_property_float_range(prop,action,arg,&playback_speed); 174 return m_property_float_range(prop, action, arg, &playback_speed);
151 } 175 }
152 176
153 /// filename with path (RO) 177 /// filename with path (RO)
154 static int mp_property_path(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 178 static int mp_property_path(m_option_t * prop, int action, void *arg,
155 return m_property_string_ro(prop,action,arg,filename); 179 MPContext * mpctx)
180 {
181 return m_property_string_ro(prop, action, arg, filename);
156 } 182 }
157 183
158 /// filename without path (RO) 184 /// filename without path (RO)
159 static int mp_property_filename(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 185 static int mp_property_filename(m_option_t * prop, int action, void *arg,
160 char* f; 186 MPContext * mpctx)
161 if(!filename) return M_PROPERTY_UNAVAILABLE; 187 {
162 if(((f = strrchr(filename,'/')) || (f = strrchr(filename,'\\'))) && f[1]) 188 char *f;
163 f++; 189 if (!filename)
190 return M_PROPERTY_UNAVAILABLE;
191 if (((f = strrchr(filename, '/')) || (f = strrchr(filename, '\\'))) && f[1])
192 f++;
164 else 193 else
165 f = filename; 194 f = filename;
166 return m_property_string_ro(prop,action,arg,f); 195 return m_property_string_ro(prop, action, arg, f);
167 } 196 }
168 197
169 /// Demuxer name (RO) 198 /// Demuxer name (RO)
170 static int mp_property_demuxer(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 199 static int mp_property_demuxer(m_option_t * prop, int action, void *arg,
171 if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; 200 MPContext * mpctx)
172 return m_property_string_ro(prop, action, arg, (char *) mpctx->demuxer->desc->name); 201 {
202 if (!mpctx->demuxer)
203 return M_PROPERTY_UNAVAILABLE;
204 return m_property_string_ro(prop, action, arg,
205 (char *) mpctx->demuxer->desc->name);
173 } 206 }
174 207
175 /// Position in the stream (RW) 208 /// Position in the stream (RW)
176 static int mp_property_stream_pos(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 209 static int mp_property_stream_pos(m_option_t * prop, int action, void *arg,
177 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; 210 MPContext * mpctx)
178 if (!arg) return M_PROPERTY_ERROR; 211 {
212 if (!mpctx->demuxer || !mpctx->demuxer->stream)
213 return M_PROPERTY_UNAVAILABLE;
214 if (!arg)
215 return M_PROPERTY_ERROR;
179 switch (action) { 216 switch (action) {
180 case M_PROPERTY_GET: 217 case M_PROPERTY_GET:
181 *(off_t *) arg = stream_tell(mpctx->demuxer->stream); 218 *(off_t *) arg = stream_tell(mpctx->demuxer->stream);
182 return M_PROPERTY_OK; 219 return M_PROPERTY_OK;
183 case M_PROPERTY_SET: 220 case M_PROPERTY_SET:
184 M_PROPERTY_CLAMP(prop,*(off_t*)arg); 221 M_PROPERTY_CLAMP(prop, *(off_t *) arg);
185 stream_seek(mpctx->demuxer->stream, *(off_t *) arg); 222 stream_seek(mpctx->demuxer->stream, *(off_t *) arg);
186 return M_PROPERTY_OK; 223 return M_PROPERTY_OK;
187 } 224 }
188 return M_PROPERTY_NOT_IMPLEMENTED; 225 return M_PROPERTY_NOT_IMPLEMENTED;
189 } 226 }
190 227
191 /// Stream start offset (RO) 228 /// Stream start offset (RO)
192 static int mp_property_stream_start(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 229 static int mp_property_stream_start(m_option_t * prop, int action,
193 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; 230 void *arg, MPContext * mpctx)
231 {
232 if (!mpctx->demuxer || !mpctx->demuxer->stream)
233 return M_PROPERTY_UNAVAILABLE;
194 switch (action) { 234 switch (action) {
195 case M_PROPERTY_GET: 235 case M_PROPERTY_GET:
196 *(off_t *) arg = mpctx->demuxer->stream->start_pos; 236 *(off_t *) arg = mpctx->demuxer->stream->start_pos;
197 return M_PROPERTY_OK; 237 return M_PROPERTY_OK;
198 } 238 }
199 return M_PROPERTY_NOT_IMPLEMENTED; 239 return M_PROPERTY_NOT_IMPLEMENTED;
200 } 240 }
201 241
202 /// Stream end offset (RO) 242 /// Stream end offset (RO)
203 static int mp_property_stream_end(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 243 static int mp_property_stream_end(m_option_t * prop, int action, void *arg,
204 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; 244 MPContext * mpctx)
245 {
246 if (!mpctx->demuxer || !mpctx->demuxer->stream)
247 return M_PROPERTY_UNAVAILABLE;
205 switch (action) { 248 switch (action) {
206 case M_PROPERTY_GET: 249 case M_PROPERTY_GET:
207 *(off_t *) arg = mpctx->demuxer->stream->end_pos; 250 *(off_t *) arg = mpctx->demuxer->stream->end_pos;
208 return M_PROPERTY_OK; 251 return M_PROPERTY_OK;
209 } 252 }
210 return M_PROPERTY_NOT_IMPLEMENTED; 253 return M_PROPERTY_NOT_IMPLEMENTED;
211 } 254 }
212 255
213 /// Stream length (RO) 256 /// Stream length (RO)
214 static int mp_property_stream_length(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 257 static int mp_property_stream_length(m_option_t * prop, int action,
215 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; 258 void *arg, MPContext * mpctx)
259 {
260 if (!mpctx->demuxer || !mpctx->demuxer->stream)
261 return M_PROPERTY_UNAVAILABLE;
216 switch (action) { 262 switch (action) {
217 case M_PROPERTY_GET: 263 case M_PROPERTY_GET:
218 *(off_t *) arg = mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos; 264 *(off_t *) arg =
219 return M_PROPERTY_OK; 265 mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos;
266 return M_PROPERTY_OK;
220 } 267 }
221 return M_PROPERTY_NOT_IMPLEMENTED; 268 return M_PROPERTY_NOT_IMPLEMENTED;
222 } 269 }
223 270
224 /// Media length in seconds (RO) 271 /// Media length in seconds (RO)
225 static int mp_property_length(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 272 static int mp_property_length(m_option_t * prop, int action, void *arg,
273 MPContext * mpctx)
274 {
226 double len; 275 double len;
227 276
228 if (!mpctx->demuxer || 277 if (!mpctx->demuxer ||
229 !(int) (len = demuxer_get_time_length(mpctx->demuxer))) 278 !(int) (len = demuxer_get_time_length(mpctx->demuxer)))
230 return M_PROPERTY_UNAVAILABLE; 279 return M_PROPERTY_UNAVAILABLE;
231 280
232 switch(action) { 281 switch (action) {
233 case M_PROPERTY_PRINT: 282 case M_PROPERTY_PRINT:
234 if(!arg) return M_PROPERTY_ERROR; 283 if (!arg)
235 else { 284 return M_PROPERTY_ERROR;
236 int h, m, s = len; 285 else {
237 h = s/3600; 286 int h, m, s = len;
238 s -= h*3600; 287 h = s / 3600;
239 m = s/60; 288 s -= h * 3600;
240 s -= m*60; 289 m = s / 60;
241 *(char**)arg = malloc(20); 290 s -= m * 60;
242 if(h > 0) sprintf(*(char**)arg,"%d:%02d:%02d",h,m,s); 291 *(char **) arg = malloc(20);
243 else if(m > 0) sprintf(*(char**)arg,"%d:%02d",m,s); 292 if (h > 0)
244 else sprintf(*(char**)arg,"%d",s); 293 sprintf(*(char **) arg, "%d:%02d:%02d", h, m, s);
245 return M_PROPERTY_OK; 294 else if (m > 0)
246 } 295 sprintf(*(char **) arg, "%d:%02d", m, s);
247 break; 296 else
248 } 297 sprintf(*(char **) arg, "%d", s);
249 return m_property_double_ro(prop,action,arg,len); 298 return M_PROPERTY_OK;
299 }
300 break;
301 }
302 return m_property_double_ro(prop, action, arg, len);
250 } 303 }
251 304
252 ///@} 305 ///@}
253 306
254 /// \defgroup AudioProperties Audio properties 307 /// \defgroup AudioProperties Audio properties
255 /// \ingroup Properties 308 /// \ingroup Properties
256 ///@{ 309 ///@{
257 310
258 /// Volume (RW) 311 /// Volume (RW)
259 static int mp_property_volume(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 312 static int mp_property_volume(m_option_t * prop, int action, void *arg,
260 313 MPContext * mpctx)
261 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 314 {
262 315
263 switch(action) { 316 if (!mpctx->sh_audio)
317 return M_PROPERTY_UNAVAILABLE;
318
319 switch (action) {
264 case M_PROPERTY_GET: 320 case M_PROPERTY_GET:
265 if(!arg) return M_PROPERTY_ERROR; 321 if (!arg)
266 mixer_getbothvolume(&mpctx->mixer, arg); 322 return M_PROPERTY_ERROR;
267 return M_PROPERTY_OK; 323 mixer_getbothvolume(&mpctx->mixer, arg);
324 return M_PROPERTY_OK;
268 case M_PROPERTY_PRINT:{ 325 case M_PROPERTY_PRINT:{
269 float vol; 326 float vol;
270 if(!arg) return M_PROPERTY_ERROR; 327 if (!arg)
271 mixer_getbothvolume(&mpctx->mixer, &vol); 328 return M_PROPERTY_ERROR;
272 return m_property_float_range(prop,action,arg,&vol); 329 mixer_getbothvolume(&mpctx->mixer, &vol);
273 } 330 return m_property_float_range(prop, action, arg, &vol);
331 }
274 case M_PROPERTY_STEP_UP: 332 case M_PROPERTY_STEP_UP:
275 case M_PROPERTY_STEP_DOWN: 333 case M_PROPERTY_STEP_DOWN:
276 case M_PROPERTY_SET: 334 case M_PROPERTY_SET:
277 break; 335 break;
278 default: 336 default:
279 return M_PROPERTY_NOT_IMPLEMENTED; 337 return M_PROPERTY_NOT_IMPLEMENTED;
280 } 338 }
281 339
282 if (mpctx->edl_muted) return M_PROPERTY_DISABLED; 340 if (mpctx->edl_muted)
341 return M_PROPERTY_DISABLED;
283 mpctx->user_muted = 0; 342 mpctx->user_muted = 0;
284 343
285 switch(action) { 344 switch (action) {
286 case M_PROPERTY_SET: 345 case M_PROPERTY_SET:
287 if(!arg) return M_PROPERTY_ERROR; 346 if (!arg)
288 M_PROPERTY_CLAMP(prop,*(float*)arg); 347 return M_PROPERTY_ERROR;
289 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg); 348 M_PROPERTY_CLAMP(prop, *(float *) arg);
290 return M_PROPERTY_OK; 349 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg);
350 return M_PROPERTY_OK;
291 case M_PROPERTY_STEP_UP: 351 case M_PROPERTY_STEP_UP:
292 if(arg && *(float*)arg <= 0) 352 if (arg && *(float *) arg <= 0)
293 mixer_decvolume(&mpctx->mixer); 353 mixer_decvolume(&mpctx->mixer);
294 else 354 else
295 mixer_incvolume(&mpctx->mixer); 355 mixer_incvolume(&mpctx->mixer);
296 return M_PROPERTY_OK; 356 return M_PROPERTY_OK;
297 case M_PROPERTY_STEP_DOWN: 357 case M_PROPERTY_STEP_DOWN:
298 if(arg && *(float*)arg <= 0) 358 if (arg && *(float *) arg <= 0)
299 mixer_incvolume(&mpctx->mixer); 359 mixer_incvolume(&mpctx->mixer);
300 else 360 else
301 mixer_decvolume(&mpctx->mixer); 361 mixer_decvolume(&mpctx->mixer);
302 return M_PROPERTY_OK; 362 return M_PROPERTY_OK;
303 } 363 }
304 return M_PROPERTY_NOT_IMPLEMENTED; 364 return M_PROPERTY_NOT_IMPLEMENTED;
305 } 365 }
306 366
307 /// Mute (RW) 367 /// Mute (RW)
308 static int mp_property_mute(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 368 static int mp_property_mute(m_option_t * prop, int action, void *arg,
309 369 MPContext * mpctx)
310 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 370 {
311 371
312 switch(action) { 372 if (!mpctx->sh_audio)
373 return M_PROPERTY_UNAVAILABLE;
374
375 switch (action) {
313 case M_PROPERTY_SET: 376 case M_PROPERTY_SET:
314 if (mpctx->edl_muted) return M_PROPERTY_DISABLED; 377 if (mpctx->edl_muted)
315 if(!arg) return M_PROPERTY_ERROR; 378 return M_PROPERTY_DISABLED;
316 if ((!!*(int *) arg) != mpctx->mixer.muted) 379 if (!arg)
317 mixer_mute(&mpctx->mixer); 380 return M_PROPERTY_ERROR;
318 mpctx->user_muted = mpctx->mixer.muted; 381 if ((!!*(int *) arg) != mpctx->mixer.muted)
319 return M_PROPERTY_OK; 382 mixer_mute(&mpctx->mixer);
383 mpctx->user_muted = mpctx->mixer.muted;
384 return M_PROPERTY_OK;
320 case M_PROPERTY_STEP_UP: 385 case M_PROPERTY_STEP_UP:
321 case M_PROPERTY_STEP_DOWN: 386 case M_PROPERTY_STEP_DOWN:
322 if (mpctx->edl_muted) return M_PROPERTY_DISABLED; 387 if (mpctx->edl_muted)
323 mixer_mute(&mpctx->mixer); 388 return M_PROPERTY_DISABLED;
324 mpctx->user_muted = mpctx->mixer.muted; 389 mixer_mute(&mpctx->mixer);
325 return M_PROPERTY_OK; 390 mpctx->user_muted = mpctx->mixer.muted;
391 return M_PROPERTY_OK;
326 case M_PROPERTY_PRINT: 392 case M_PROPERTY_PRINT:
327 if(!arg) return M_PROPERTY_ERROR; 393 if (!arg)
328 if (mpctx->edl_muted) { 394 return M_PROPERTY_ERROR;
329 *(char**)arg = strdup(MSGTR_EnabledEdl); 395 if (mpctx->edl_muted) {
330 return M_PROPERTY_OK; 396 *(char **) arg = strdup(MSGTR_EnabledEdl);
331 } 397 return M_PROPERTY_OK;
398 }
332 default: 399 default:
333 return m_property_flag(prop, action, arg, &mpctx->mixer.muted); 400 return m_property_flag(prop, action, arg, &mpctx->mixer.muted);
334 401
335 } 402 }
336 } 403 }
337 404
338 /// Audio delay (RW) 405 /// Audio delay (RW)
339 static int mp_property_audio_delay(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 406 static int mp_property_audio_delay(m_option_t * prop, int action,
340 if (!(mpctx->sh_audio && mpctx->sh_video)) return M_PROPERTY_UNAVAILABLE; 407 void *arg, MPContext * mpctx)
341 switch(action) { 408 {
409 if (!(mpctx->sh_audio && mpctx->sh_video))
410 return M_PROPERTY_UNAVAILABLE;
411 switch (action) {
342 case M_PROPERTY_SET: 412 case M_PROPERTY_SET:
343 case M_PROPERTY_STEP_UP: 413 case M_PROPERTY_STEP_UP:
344 case M_PROPERTY_STEP_DOWN: 414 case M_PROPERTY_STEP_DOWN:
345 if(!arg) return M_PROPERTY_ERROR; 415 if (!arg)
346 else { 416 return M_PROPERTY_ERROR;
347 float delay = audio_delay; 417 else {
348 m_property_delay(prop,action,arg,&audio_delay); 418 float delay = audio_delay;
349 if (mpctx->sh_audio) mpctx->sh_audio->delay -= audio_delay - delay; 419 m_property_delay(prop, action, arg, &audio_delay);
350 } 420 if (mpctx->sh_audio)
351 return M_PROPERTY_OK; 421 mpctx->sh_audio->delay -= audio_delay - delay;
422 }
423 return M_PROPERTY_OK;
352 default: 424 default:
353 return m_property_delay(prop,action,arg,&audio_delay); 425 return m_property_delay(prop, action, arg, &audio_delay);
354 } 426 }
355 } 427 }
356 428
357 /// Audio codec tag (RO) 429 /// Audio codec tag (RO)
358 static int mp_property_audio_format(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 430 static int mp_property_audio_format(m_option_t * prop, int action,
359 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 431 void *arg, MPContext * mpctx)
432 {
433 if (!mpctx->sh_audio)
434 return M_PROPERTY_UNAVAILABLE;
360 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format); 435 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format);
361 } 436 }
362 437
363 /// Audio bitrate (RO) 438 /// Audio bitrate (RO)
364 static int mp_property_audio_bitrate(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 439 static int mp_property_audio_bitrate(m_option_t * prop, int action,
365 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 440 void *arg, MPContext * mpctx)
441 {
442 if (!mpctx->sh_audio)
443 return M_PROPERTY_UNAVAILABLE;
366 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->i_bps); 444 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->i_bps);
367 } 445 }
368 446
369 /// Samplerate (RO) 447 /// Samplerate (RO)
370 static int mp_property_samplerate(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 448 static int mp_property_samplerate(m_option_t * prop, int action, void *arg,
371 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 449 MPContext * mpctx)
450 {
451 if (!mpctx->sh_audio)
452 return M_PROPERTY_UNAVAILABLE;
372 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate); 453 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate);
373 } 454 }
374 455
375 /// Number of channels (RO) 456 /// Number of channels (RO)
376 static int mp_property_channels(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 457 static int mp_property_channels(m_option_t * prop, int action, void *arg,
377 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 458 MPContext * mpctx)
378 switch(action) { 459 {
460 if (!mpctx->sh_audio)
461 return M_PROPERTY_UNAVAILABLE;
462 switch (action) {
379 case M_PROPERTY_PRINT: 463 case M_PROPERTY_PRINT:
380 if(!arg) return M_PROPERTY_ERROR; 464 if (!arg)
381 switch (mpctx->sh_audio->channels) { 465 return M_PROPERTY_ERROR;
382 case 1: *(char**)arg = strdup("mono"); break; 466 switch (mpctx->sh_audio->channels) {
383 case 2: *(char**)arg = strdup("stereo"); break; 467 case 1:
384 default: 468 *(char **) arg = strdup("mono");
385 *(char**)arg = malloc(32); 469 break;
386 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels); 470 case 2:
387 } 471 *(char **) arg = strdup("stereo");
388 return M_PROPERTY_OK; 472 break;
473 default:
474 *(char **) arg = malloc(32);
475 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels);
476 }
477 return M_PROPERTY_OK;
389 } 478 }
390 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels); 479 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels);
391 } 480 }
392 481
393 /// Selected audio id (RW) 482 /// Selected audio id (RW)
394 static int mp_property_audio(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 483 static int mp_property_audio(m_option_t * prop, int action, void *arg,
484 MPContext * mpctx)
485 {
395 int current_id = -1, tmp; 486 int current_id = -1, tmp;
396 487
397 switch(action) { 488 switch (action) {
398 case M_PROPERTY_GET: 489 case M_PROPERTY_GET:
399 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 490 if (!mpctx->sh_audio)
400 if(!arg) return M_PROPERTY_ERROR; 491 return M_PROPERTY_UNAVAILABLE;
401 *(int*)arg = audio_id; 492 if (!arg)
402 return M_PROPERTY_OK; 493 return M_PROPERTY_ERROR;
494 *(int *) arg = audio_id;
495 return M_PROPERTY_OK;
403 case M_PROPERTY_PRINT: 496 case M_PROPERTY_PRINT:
404 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; 497 if (!mpctx->sh_audio)
405 if(!arg) return M_PROPERTY_ERROR; 498 return M_PROPERTY_UNAVAILABLE;
406 499 if (!arg)
407 if (audio_id < 0) 500 return M_PROPERTY_ERROR;
408 *(char**)arg = strdup(MSGTR_Disabled); 501
409 else { 502 if (audio_id < 0)
410 char lang[40] = MSGTR_Unknown; 503 *(char **) arg = strdup(MSGTR_Disabled);
411 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA) 504 else {
412 demux_mkv_get_audio_lang(mpctx->demuxer, audio_id, lang, 9); 505 char lang[40] = MSGTR_Unknown;
506 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
507 demux_mkv_get_audio_lang(mpctx->demuxer, audio_id, lang, 9);
413 #ifdef USE_DVDREAD 508 #ifdef USE_DVDREAD
414 else if (mpctx->stream->type == STREAMTYPE_DVD) { 509 else if (mpctx->stream->type == STREAMTYPE_DVD) {
415 int code = dvd_lang_from_aid(mpctx->stream, audio_id); 510 int code = dvd_lang_from_aid(mpctx->stream, audio_id);
416 if (code) { 511 if (code) {
417 lang[0] = code >> 8; 512 lang[0] = code >> 8;
418 lang[1] = code; 513 lang[1] = code;
419 lang[2] = 0; 514 lang[2] = 0;
420 } 515 }
421 } 516 }
422 #endif 517 #endif
423 518
424 #ifdef USE_DVDNAV 519 #ifdef USE_DVDNAV
425 else if (mpctx->stream->type == STREAMTYPE_DVDNAV) 520 else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
426 dvdnav_lang_from_aid(mpctx->stream, audio_id, lang); 521 dvdnav_lang_from_aid(mpctx->stream, audio_id, lang);
427 #endif 522 #endif
428 *(char**)arg = malloc(64); 523 *(char **) arg = malloc(64);
429 snprintf(*(char**)arg, 64, "(%d) %s", audio_id, lang); 524 snprintf(*(char **) arg, 64, "(%d) %s", audio_id, lang);
430 } 525 }
431 return M_PROPERTY_OK; 526 return M_PROPERTY_OK;
432 527
433 case M_PROPERTY_STEP_UP: 528 case M_PROPERTY_STEP_UP:
434 case M_PROPERTY_SET: 529 case M_PROPERTY_SET:
435 if(action==M_PROPERTY_SET && arg) 530 if (action == M_PROPERTY_SET && arg)
436 tmp = *((int*)arg); 531 tmp = *((int *) arg);
437 else 532 else
438 tmp = -1; 533 tmp = -1;
439 current_id = mpctx->demuxer->audio->id; 534 current_id = mpctx->demuxer->audio->id;
440 audio_id = demuxer_switch_audio(mpctx->demuxer, tmp); 535 audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
441 if (audio_id == -2 || (audio_id > -1 && mpctx->demuxer->audio->id != current_id && current_id != -2)) 536 if (audio_id == -2
442 uninit_player(INITED_AO | INITED_ACODEC); 537 || (audio_id > -1
443 if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) { 538 && mpctx->demuxer->audio->id != current_id && current_id != -2))
444 sh_audio_t *sh2; 539 uninit_player(INITED_AO | INITED_ACODEC);
445 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id]; 540 if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
446 if(sh2) { 541 sh_audio_t *sh2;
447 sh2->ds = mpctx->demuxer->audio; 542 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
448 mpctx->sh_audio = sh2; 543 if (sh2) {
449 reinit_audio_chain(); 544 sh2->ds = mpctx->demuxer->audio;
450 } 545 mpctx->sh_audio = sh2;
451 } 546 reinit_audio_chain();
452 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id); 547 }
453 return M_PROPERTY_OK; 548 }
549 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
550 return M_PROPERTY_OK;
454 default: 551 default:
455 return M_PROPERTY_NOT_IMPLEMENTED; 552 return M_PROPERTY_NOT_IMPLEMENTED;
456 } 553 }
457 554
458 } 555 }
459 556
460 /// Selected video id (RW) 557 /// Selected video id (RW)
461 static int mp_property_video(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 558 static int mp_property_video(m_option_t * prop, int action, void *arg,
559 MPContext * mpctx)
560 {
462 int current_id = -1, tmp; 561 int current_id = -1, tmp;
463 562
464 switch(action) { 563 switch (action) {
465 case M_PROPERTY_GET: 564 case M_PROPERTY_GET:
466 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 565 if (!mpctx->sh_video)
467 if(!arg) return M_PROPERTY_ERROR; 566 return M_PROPERTY_UNAVAILABLE;
468 *(int*)arg = video_id; 567 if (!arg)
469 return M_PROPERTY_OK; 568 return M_PROPERTY_ERROR;
569 *(int *) arg = video_id;
570 return M_PROPERTY_OK;
470 case M_PROPERTY_PRINT: 571 case M_PROPERTY_PRINT:
471 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 572 if (!mpctx->sh_video)
472 if(!arg) return M_PROPERTY_ERROR; 573 return M_PROPERTY_UNAVAILABLE;
473 574 if (!arg)
474 if (video_id < 0) 575 return M_PROPERTY_ERROR;
475 *(char**)arg = strdup(MSGTR_Disabled); 576
476 else { 577 if (video_id < 0)
477 char lang[40] = MSGTR_Unknown; 578 *(char **) arg = strdup(MSGTR_Disabled);
478 *(char**)arg = malloc(64); 579 else {
479 snprintf(*(char**)arg, 64, "(%d) %s", video_id, lang); 580 char lang[40] = MSGTR_Unknown;
480 } 581 *(char **) arg = malloc(64);
481 return M_PROPERTY_OK; 582 snprintf(*(char **) arg, 64, "(%d) %s", video_id, lang);
583 }
584 return M_PROPERTY_OK;
482 585
483 case M_PROPERTY_STEP_UP: 586 case M_PROPERTY_STEP_UP:
484 case M_PROPERTY_SET: 587 case M_PROPERTY_SET:
485 current_id = mpctx->demuxer->video->id; 588 current_id = mpctx->demuxer->video->id;
486 if(action==M_PROPERTY_SET && arg) 589 if (action == M_PROPERTY_SET && arg)
487 tmp = *((int*)arg); 590 tmp = *((int *) arg);
488 else 591 else
489 tmp = -1; 592 tmp = -1;
490 video_id = demuxer_switch_video(mpctx->demuxer, tmp); 593 video_id = demuxer_switch_video(mpctx->demuxer, tmp);
491 if (video_id == -2 || (video_id > -1 && mpctx->demuxer->video->id != current_id && current_id != -2)) 594 if (video_id == -2
492 uninit_player(INITED_VCODEC | (fixed_vo && video_id != -2 ? 0 : INITED_VO)); 595 || (video_id > -1 && mpctx->demuxer->video->id != current_id
493 if (video_id > -1 && mpctx->demuxer->video->id != current_id) { 596 && current_id != -2))
494 sh_video_t *sh2; 597 uninit_player(INITED_VCODEC |
495 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id]; 598 (fixed_vo && video_id != -2 ? 0 : INITED_VO));
496 if(sh2) { 599 if (video_id > -1 && mpctx->demuxer->video->id != current_id) {
497 sh2->ds = mpctx->demuxer->video; 600 sh_video_t *sh2;
498 mpctx->sh_video = sh2; 601 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
499 reinit_video_chain(); 602 if (sh2) {
500 } 603 sh2->ds = mpctx->demuxer->video;
501 } 604 mpctx->sh_video = sh2;
502 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id); 605 reinit_video_chain();
503 return M_PROPERTY_OK; 606 }
607 }
608 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id);
609 return M_PROPERTY_OK;
504 610
505 default: 611 default:
506 return M_PROPERTY_NOT_IMPLEMENTED; 612 return M_PROPERTY_NOT_IMPLEMENTED;
507 } 613 }
508 } 614 }
509 615
510 static int mp_property_program(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 616 static int mp_property_program(m_option_t * prop, int action, void *arg,
617 MPContext * mpctx)
618 {
511 demux_program_t prog; 619 demux_program_t prog;
512 620
513 switch(action) { 621 switch (action) {
514 case M_PROPERTY_STEP_UP: 622 case M_PROPERTY_STEP_UP:
515 case M_PROPERTY_SET: 623 case M_PROPERTY_SET:
516 if(action==M_PROPERTY_SET && arg) 624 if (action == M_PROPERTY_SET && arg)
517 prog.progid = *((int*)arg); 625 prog.progid = *((int *) arg);
518 else 626 else
519 prog.progid = -1; 627 prog.progid = -1;
520 if (demux_control(mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) == DEMUXER_CTRL_NOTIMPL) 628 if (demux_control
521 return M_PROPERTY_ERROR; 629 (mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM,
522 630 &prog) == DEMUXER_CTRL_NOTIMPL)
523 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx); 631 return M_PROPERTY_ERROR;
524 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx); 632
525 return M_PROPERTY_OK; 633 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx);
634 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx);
635 return M_PROPERTY_OK;
526 636
527 default: 637 default:
528 return M_PROPERTY_NOT_IMPLEMENTED; 638 return M_PROPERTY_NOT_IMPLEMENTED;
529 } 639 }
530 } 640 }
531 641
532 ///@} 642 ///@}
533 643
534 /// \defgroup VideoProperties Video properties 644 /// \defgroup VideoProperties Video properties
535 /// \ingroup Properties 645 /// \ingroup Properties
536 ///@{ 646 ///@{
537 647
538 /// Fullscreen state (RW) 648 /// Fullscreen state (RW)
539 static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 649 static int mp_property_fullscreen(m_option_t * prop, int action, void *arg,
540 650 MPContext * mpctx)
541 if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE; 651 {
542 652
543 switch(action) { 653 if (!mpctx->video_out)
654 return M_PROPERTY_UNAVAILABLE;
655
656 switch (action) {
544 case M_PROPERTY_SET: 657 case M_PROPERTY_SET:
545 if(!arg) return M_PROPERTY_ERROR; 658 if (!arg)
546 M_PROPERTY_CLAMP(prop,*(int*)arg); 659 return M_PROPERTY_ERROR;
547 if(vo_fs == !!*(int*)arg) return M_PROPERTY_OK; 660 M_PROPERTY_CLAMP(prop, *(int *) arg);
661 if (vo_fs == !!*(int *) arg)
662 return M_PROPERTY_OK;
548 case M_PROPERTY_STEP_UP: 663 case M_PROPERTY_STEP_UP:
549 case M_PROPERTY_STEP_DOWN: 664 case M_PROPERTY_STEP_DOWN:
550 #ifdef HAVE_NEW_GUI 665 #ifdef HAVE_NEW_GUI
551 if(use_gui) guiGetEvent(guiIEvent,(char*)MP_CMD_GUI_FULLSCREEN); 666 if (use_gui)
552 else 667 guiGetEvent(guiIEvent, (char *) MP_CMD_GUI_FULLSCREEN);
553 #endif 668 else
554 if (vo_config_count) mpctx->video_out->control(VOCTRL_FULLSCREEN, 0); 669 #endif
555 return M_PROPERTY_OK; 670 if (vo_config_count)
671 mpctx->video_out->control(VOCTRL_FULLSCREEN, 0);
672 return M_PROPERTY_OK;
556 default: 673 default:
557 return m_property_flag(prop,action,arg,&vo_fs); 674 return m_property_flag(prop, action, arg, &vo_fs);
558 } 675 }
559 } 676 }
560 677
561 static int mp_property_deinterlace(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 678 static int mp_property_deinterlace(m_option_t * prop, int action,
679 void *arg, MPContext * mpctx)
680 {
562 int deinterlace; 681 int deinterlace;
563 vf_instance_t *vf; 682 vf_instance_t *vf;
564 if (!mpctx->sh_video || !mpctx->sh_video->vfilter) return M_PROPERTY_UNAVAILABLE; 683 if (!mpctx->sh_video || !mpctx->sh_video->vfilter)
684 return M_PROPERTY_UNAVAILABLE;
565 vf = mpctx->sh_video->vfilter; 685 vf = mpctx->sh_video->vfilter;
566 switch(action) { 686 switch (action) {
567 case M_PROPERTY_GET: 687 case M_PROPERTY_GET:
568 if(!arg) return M_PROPERTY_ERROR; 688 if (!arg)
569 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg); 689 return M_PROPERTY_ERROR;
570 return M_PROPERTY_OK; 690 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg);
691 return M_PROPERTY_OK;
571 case M_PROPERTY_SET: 692 case M_PROPERTY_SET:
572 if(!arg) return M_PROPERTY_ERROR; 693 if (!arg)
573 M_PROPERTY_CLAMP(prop,*(int*)arg); 694 return M_PROPERTY_ERROR;
574 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg); 695 M_PROPERTY_CLAMP(prop, *(int *) arg);
575 return M_PROPERTY_OK; 696 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg);
697 return M_PROPERTY_OK;
576 case M_PROPERTY_STEP_UP: 698 case M_PROPERTY_STEP_UP:
577 case M_PROPERTY_STEP_DOWN: 699 case M_PROPERTY_STEP_DOWN:
578 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace); 700 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace);
579 deinterlace = !deinterlace; 701 deinterlace = !deinterlace;
580 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace); 702 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace);
581 return M_PROPERTY_OK; 703 return M_PROPERTY_OK;
582 } 704 }
583 return M_PROPERTY_NOT_IMPLEMENTED; 705 return M_PROPERTY_NOT_IMPLEMENTED;
584 } 706 }
585 707
586 /// Panscan (RW) 708 /// Panscan (RW)
587 static int mp_property_panscan(m_option_t * prop, int action, void *arg, MPContext * mpctx) 709 static int mp_property_panscan(m_option_t * prop, int action, void *arg,
588 { 710 MPContext * mpctx)
589 711 {
590 if (!mpctx->video_out || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE) 712
591 return M_PROPERTY_UNAVAILABLE; 713 if (!mpctx->video_out
592 714 || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
593 switch(action) { 715 return M_PROPERTY_UNAVAILABLE;
716
717 switch (action) {
594 case M_PROPERTY_SET: 718 case M_PROPERTY_SET:
595 if(!arg) return M_PROPERTY_ERROR; 719 if (!arg)
596 M_PROPERTY_CLAMP(prop,*(float*)arg); 720 return M_PROPERTY_ERROR;
597 vo_panscan = *(float*)arg; 721 M_PROPERTY_CLAMP(prop, *(float *) arg);
598 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); 722 vo_panscan = *(float *) arg;
599 return M_PROPERTY_OK; 723 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
724 return M_PROPERTY_OK;
600 case M_PROPERTY_STEP_UP: 725 case M_PROPERTY_STEP_UP:
601 case M_PROPERTY_STEP_DOWN: 726 case M_PROPERTY_STEP_DOWN:
602 vo_panscan += (arg ? *(float*)arg : 0.1) * 727 vo_panscan += (arg ? *(float *) arg : 0.1) *
603 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 728 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
604 if(vo_panscan > 1) vo_panscan = 1; 729 if (vo_panscan > 1)
605 else if(vo_panscan < 0) vo_panscan = 0; 730 vo_panscan = 1;
606 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); 731 else if (vo_panscan < 0)
607 return M_PROPERTY_OK; 732 vo_panscan = 0;
733 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
734 return M_PROPERTY_OK;
608 default: 735 default:
609 return m_property_float_range(prop,action,arg,&vo_panscan); 736 return m_property_float_range(prop, action, arg, &vo_panscan);
610 } 737 }
611 } 738 }
612 739
613 /// Helper to set vo flags. 740 /// Helper to set vo flags.
614 /** \ingroup PropertyImplHelper 741 /** \ingroup PropertyImplHelper
615 */ 742 */
616 static int mp_property_vo_flag(m_option_t* prop,int action,void* arg, 743 static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
617 int vo_ctrl, int *vo_var, MPContext * mpctx) { 744 int vo_ctrl, int *vo_var, MPContext * mpctx)
618 745 {
619 if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE; 746
620 747 if (!mpctx->video_out)
621 switch(action) { 748 return M_PROPERTY_UNAVAILABLE;
749
750 switch (action) {
622 case M_PROPERTY_SET: 751 case M_PROPERTY_SET:
623 if(!arg) return M_PROPERTY_ERROR; 752 if (!arg)
624 M_PROPERTY_CLAMP(prop,*(int*)arg); 753 return M_PROPERTY_ERROR;
625 if(*vo_var == !!*(int*)arg) return M_PROPERTY_OK; 754 M_PROPERTY_CLAMP(prop, *(int *) arg);
755 if (*vo_var == !!*(int *) arg)
756 return M_PROPERTY_OK;
626 case M_PROPERTY_STEP_UP: 757 case M_PROPERTY_STEP_UP:
627 case M_PROPERTY_STEP_DOWN: 758 case M_PROPERTY_STEP_DOWN:
628 if (vo_config_count) mpctx->video_out->control(vo_ctrl, 0); 759 if (vo_config_count)
629 return M_PROPERTY_OK; 760 mpctx->video_out->control(vo_ctrl, 0);
761 return M_PROPERTY_OK;
630 default: 762 default:
631 return m_property_flag(prop,action,arg,vo_var); 763 return m_property_flag(prop, action, arg, vo_var);
632 } 764 }
633 } 765 }
634 766
635 /// Window always on top (RW) 767 /// Window always on top (RW)
636 static int mp_property_ontop(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 768 static int mp_property_ontop(m_option_t * prop, int action, void *arg,
637 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop, mpctx); 769 MPContext * mpctx)
770 {
771 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop,
772 mpctx);
638 } 773 }
639 774
640 /// Display in the root window (RW) 775 /// Display in the root window (RW)
641 static int mp_property_rootwin(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 776 static int mp_property_rootwin(m_option_t * prop, int action, void *arg,
642 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN, &vo_rootwin, mpctx); 777 MPContext * mpctx)
778 {
779 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN,
780 &vo_rootwin, mpctx);
643 } 781 }
644 782
645 /// Show window borders (RW) 783 /// Show window borders (RW)
646 static int mp_property_border(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 784 static int mp_property_border(m_option_t * prop, int action, void *arg,
647 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, &vo_border, mpctx); 785 MPContext * mpctx)
786 {
787 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER,
788 &vo_border, mpctx);
648 } 789 }
649 790
650 /// Framedropping state (RW) 791 /// Framedropping state (RW)
651 static int mp_property_framedropping(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 792 static int mp_property_framedropping(m_option_t * prop, int action,
652 793 void *arg, MPContext * mpctx)
653 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 794 {
654 795
655 switch(action) { 796 if (!mpctx->sh_video)
797 return M_PROPERTY_UNAVAILABLE;
798
799 switch (action) {
656 case M_PROPERTY_PRINT: 800 case M_PROPERTY_PRINT:
657 if(!arg) return M_PROPERTY_ERROR; 801 if (!arg)
658 *(char**)arg = strdup(frame_dropping == 1 ? MSGTR_Enabled : 802 return M_PROPERTY_ERROR;
659 (frame_dropping == 2 ? MSGTR_HardFrameDrop : MSGTR_Disabled)); 803 *(char **) arg = strdup(frame_dropping == 1 ? MSGTR_Enabled :
660 return M_PROPERTY_OK; 804 (frame_dropping == 2 ? MSGTR_HardFrameDrop :
805 MSGTR_Disabled));
806 return M_PROPERTY_OK;
661 default: 807 default:
662 return m_property_choice(prop,action,arg,&frame_dropping); 808 return m_property_choice(prop, action, arg, &frame_dropping);
663 } 809 }
664 } 810 }
665 811
666 /// Color settings, try to use vf/vo then fall back on TV. (RW) 812 /// Color settings, try to use vf/vo then fall back on TV. (RW)
667 static int mp_property_gamma(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 813 static int mp_property_gamma(m_option_t * prop, int action, void *arg,
668 int* gamma = prop->priv, r; 814 MPContext * mpctx)
669 815 {
670 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 816 int *gamma = prop->priv, r;
671 817
672 if(gamma[0] == 1000) { 818 if (!mpctx->sh_video)
673 gamma[0] = 0; 819 return M_PROPERTY_UNAVAILABLE;
674 get_video_colors(mpctx->sh_video, prop->name, gamma); 820
675 } 821 if (gamma[0] == 1000) {
676 822 gamma[0] = 0;
677 switch(action) { 823 get_video_colors(mpctx->sh_video, prop->name, gamma);
824 }
825
826 switch (action) {
678 case M_PROPERTY_SET: 827 case M_PROPERTY_SET:
679 if(!arg) return M_PROPERTY_ERROR; 828 if (!arg)
680 M_PROPERTY_CLAMP(prop,*(int*)arg); 829 return M_PROPERTY_ERROR;
681 *gamma = *(int*)arg; 830 M_PROPERTY_CLAMP(prop, *(int *) arg);
682 r = set_video_colors(mpctx->sh_video, prop->name, *gamma); 831 *gamma = *(int *) arg;
683 if(r <= 0) break; 832 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
684 return r; 833 if (r <= 0)
834 break;
835 return r;
685 case M_PROPERTY_GET: 836 case M_PROPERTY_GET:
686 if(!arg) return M_PROPERTY_ERROR; 837 if (!arg)
687 r = get_video_colors(mpctx->sh_video, prop->name, arg); 838 return M_PROPERTY_ERROR;
688 if(r <= 0) break; 839 r = get_video_colors(mpctx->sh_video, prop->name, arg);
689 return r; 840 if (r <= 0)
841 break;
842 return r;
690 case M_PROPERTY_STEP_UP: 843 case M_PROPERTY_STEP_UP:
691 case M_PROPERTY_STEP_DOWN: 844 case M_PROPERTY_STEP_DOWN:
692 *gamma += (arg ? *(int*)arg : 1) * 845 *gamma += (arg ? *(int *) arg : 1) *
693 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 846 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
694 M_PROPERTY_CLAMP(prop,*gamma); 847 M_PROPERTY_CLAMP(prop, *gamma);
695 r = set_video_colors(mpctx->sh_video, prop->name, *gamma); 848 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
696 if(r <= 0) break; 849 if (r <= 0)
697 return r; 850 break;
851 return r;
698 default: 852 default:
699 return M_PROPERTY_NOT_IMPLEMENTED; 853 return M_PROPERTY_NOT_IMPLEMENTED;
700 } 854 }
701 855
702 #ifdef USE_TV 856 #ifdef USE_TV
703 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) { 857 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) {
704 int l = strlen(prop->name); 858 int l = strlen(prop->name);
705 char tv_prop[3+l+1]; 859 char tv_prop[3 + l + 1];
706 sprintf(tv_prop,"tv_%s",prop->name); 860 sprintf(tv_prop, "tv_%s", prop->name);
707 return mp_property_do(tv_prop, action, arg, mpctx); 861 return mp_property_do(tv_prop, action, arg, mpctx);
708 } 862 }
709 #endif 863 #endif
710 864
711 return M_PROPERTY_UNAVAILABLE; 865 return M_PROPERTY_UNAVAILABLE;
712 } 866 }
713 867
714 /// VSync (RW) 868 /// VSync (RW)
715 static int mp_property_vsync(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 869 static int mp_property_vsync(m_option_t * prop, int action, void *arg,
716 return m_property_flag(prop,action,arg,&vo_vsync); 870 MPContext * mpctx)
871 {
872 return m_property_flag(prop, action, arg, &vo_vsync);
717 } 873 }
718 874
719 /// Video codec tag (RO) 875 /// Video codec tag (RO)
720 static int mp_property_video_format(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 876 static int mp_property_video_format(m_option_t * prop, int action,
721 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 877 void *arg, MPContext * mpctx)
878 {
879 if (!mpctx->sh_video)
880 return M_PROPERTY_UNAVAILABLE;
722 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format); 881 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format);
723 } 882 }
724 883
725 /// Video bitrate (RO) 884 /// Video bitrate (RO)
726 static int mp_property_video_bitrate(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 885 static int mp_property_video_bitrate(m_option_t * prop, int action,
727 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 886 void *arg, MPContext * mpctx)
887 {
888 if (!mpctx->sh_video)
889 return M_PROPERTY_UNAVAILABLE;
728 return m_property_int_ro(prop, action, arg, mpctx->sh_video->i_bps); 890 return m_property_int_ro(prop, action, arg, mpctx->sh_video->i_bps);
729 } 891 }
730 892
731 /// Video display width (RO) 893 /// Video display width (RO)
732 static int mp_property_width(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 894 static int mp_property_width(m_option_t * prop, int action, void *arg,
733 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 895 MPContext * mpctx)
896 {
897 if (!mpctx->sh_video)
898 return M_PROPERTY_UNAVAILABLE;
734 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w); 899 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w);
735 } 900 }
736 901
737 /// Video display height (RO) 902 /// Video display height (RO)
738 static int mp_property_height(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 903 static int mp_property_height(m_option_t * prop, int action, void *arg,
739 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 904 MPContext * mpctx)
905 {
906 if (!mpctx->sh_video)
907 return M_PROPERTY_UNAVAILABLE;
740 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h); 908 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h);
741 } 909 }
742 910
743 /// Video fps (RO) 911 /// Video fps (RO)
744 static int mp_property_fps(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 912 static int mp_property_fps(m_option_t * prop, int action, void *arg,
745 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 913 MPContext * mpctx)
914 {
915 if (!mpctx->sh_video)
916 return M_PROPERTY_UNAVAILABLE;
746 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps); 917 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps);
747 } 918 }
748 919
749 /// Video aspect (RO) 920 /// Video aspect (RO)
750 static int mp_property_aspect(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 921 static int mp_property_aspect(m_option_t * prop, int action, void *arg,
751 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 922 MPContext * mpctx)
923 {
924 if (!mpctx->sh_video)
925 return M_PROPERTY_UNAVAILABLE;
752 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect); 926 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect);
753 } 927 }
754 928
755 ///@} 929 ///@}
756 930
757 /// \defgroup SubProprties Subtitles properties 931 /// \defgroup SubProprties Subtitles properties
758 /// \ingroup Properties 932 /// \ingroup Properties
759 ///@{ 933 ///@{
760 934
761 /// Text subtitle position (RW) 935 /// Text subtitle position (RW)
762 static int mp_property_sub_pos(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 936 static int mp_property_sub_pos(m_option_t * prop, int action, void *arg,
763 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 937 MPContext * mpctx)
764 938 {
765 switch(action) { 939 if (!mpctx->sh_video)
940 return M_PROPERTY_UNAVAILABLE;
941
942 switch (action) {
766 case M_PROPERTY_SET: 943 case M_PROPERTY_SET:
767 if(!arg) return M_PROPERTY_ERROR; 944 if (!arg)
945 return M_PROPERTY_ERROR;
768 case M_PROPERTY_STEP_UP: 946 case M_PROPERTY_STEP_UP:
769 case M_PROPERTY_STEP_DOWN: 947 case M_PROPERTY_STEP_DOWN:
770 vo_osd_changed(OSDTYPE_SUBTITLE); 948 vo_osd_changed(OSDTYPE_SUBTITLE);
771 default: 949 default:
772 return m_property_int_range(prop,action,arg,&sub_pos); 950 return m_property_int_range(prop, action, arg, &sub_pos);
773 } 951 }
774 } 952 }
775 953
776 /// Selected subtitles (RW) 954 /// Selected subtitles (RW)
777 static int mp_property_sub(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 955 static int mp_property_sub(m_option_t * prop, int action, void *arg,
956 MPContext * mpctx)
957 {
778 demux_stream_t *const d_sub = mpctx->d_sub; 958 demux_stream_t *const d_sub = mpctx->d_sub;
779 const int global_sub_size = mpctx->global_sub_size; 959 const int global_sub_size = mpctx->global_sub_size;
780 int source = -1, reset_spu = 0; 960 int source = -1, reset_spu = 0;
781 char* sub_name; 961 char *sub_name;
782 962
783 if(global_sub_size <= 0) return M_PROPERTY_UNAVAILABLE; 963 if (global_sub_size <= 0)
784 964 return M_PROPERTY_UNAVAILABLE;
785 switch(action) { 965
966 switch (action) {
786 case M_PROPERTY_GET: 967 case M_PROPERTY_GET:
787 if(!arg) return M_PROPERTY_ERROR; 968 if (!arg)
788 *(int *) arg = mpctx->global_sub_pos; 969 return M_PROPERTY_ERROR;
789 return M_PROPERTY_OK; 970 *(int *) arg = mpctx->global_sub_pos;
971 return M_PROPERTY_OK;
790 case M_PROPERTY_PRINT: 972 case M_PROPERTY_PRINT:
791 if(!arg) return M_PROPERTY_ERROR; 973 if (!arg)
792 *(char**)arg = malloc(64); 974 return M_PROPERTY_ERROR;
793 (*(char**)arg)[63] = 0; 975 *(char **) arg = malloc(64);
794 sub_name = 0; 976 (*(char **) arg)[63] = 0;
795 if(subdata) 977 sub_name = 0;
796 sub_name = subdata->filename; 978 if (subdata)
979 sub_name = subdata->filename;
797 #ifdef USE_ASS 980 #ifdef USE_ASS
798 if (ass_track && ass_track->name) 981 if (ass_track && ass_track->name)
799 sub_name = ass_track->name; 982 sub_name = ass_track->name;
800 #endif 983 #endif
801 if(sub_name) { 984 if (sub_name) {
802 char *tmp,*tmp2; 985 char *tmp, *tmp2;
803 tmp = sub_name; 986 tmp = sub_name;
804 if ((tmp2 = strrchr(tmp, '/'))) 987 if ((tmp2 = strrchr(tmp, '/')))
805 tmp = tmp2+1; 988 tmp = tmp2 + 1;
806 989
807 snprintf(*(char**)arg, 63, "(%d) %s%s", 990 snprintf(*(char **) arg, 63, "(%d) %s%s",
808 mpctx->set_of_sub_pos + 1, 991 mpctx->set_of_sub_pos + 1,
809 strlen(tmp) < 20 ? "" : "...", 992 strlen(tmp) < 20 ? "" : "...",
810 strlen(tmp) < 20 ? tmp : tmp+strlen(tmp)-19); 993 strlen(tmp) < 20 ? tmp : tmp + strlen(tmp) - 19);
811 return M_PROPERTY_OK; 994 return M_PROPERTY_OK;
812 } 995 }
813 #ifdef USE_DVDNAV 996 #ifdef USE_DVDNAV
814 if (mpctx->stream->type == STREAMTYPE_DVDNAV) { 997 if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
815 if(vo_spudec && dvdsub_id >= 0) { 998 if (vo_spudec && dvdsub_id >= 0) {
816 unsigned char lang[3]; 999 unsigned char lang[3];
817 if (dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) { 1000 if (dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) {
818 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, lang); 1001 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
819 return M_PROPERTY_OK; 1002 return M_PROPERTY_OK;
820 } 1003 }
821 } 1004 }
822 } 1005 }
823 #endif 1006 #endif
824 1007
825 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA && dvdsub_id >= 0) { 1008 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA && dvdsub_id >= 0) {
826 char lang[40] = MSGTR_Unknown; 1009 char lang[40] = MSGTR_Unknown;
827 demux_mkv_get_sub_lang(mpctx->demuxer, dvdsub_id, lang, 9); 1010 demux_mkv_get_sub_lang(mpctx->demuxer, dvdsub_id, lang, 9);
828 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, lang); 1011 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
829 return M_PROPERTY_OK; 1012 return M_PROPERTY_OK;
830 } 1013 }
831 #ifdef HAVE_OGGVORBIS 1014 #ifdef HAVE_OGGVORBIS
832 if (mpctx->demuxer->type == DEMUXER_TYPE_OGG && d_sub && dvdsub_id >= 0) { 1015 if (mpctx->demuxer->type == DEMUXER_TYPE_OGG && d_sub && dvdsub_id >= 0) {
833 char *lang = demux_ogg_sub_lang(mpctx->demuxer, dvdsub_id); 1016 char *lang = demux_ogg_sub_lang(mpctx->demuxer, dvdsub_id);
834 if (!lang) lang = MSGTR_Unknown; 1017 if (!lang)
835 snprintf(*(char**)arg, 63, "(%d) %s", 1018 lang = MSGTR_Unknown;
836 dvdsub_id, lang); 1019 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
837 return M_PROPERTY_OK; 1020 return M_PROPERTY_OK;
838 } 1021 }
839 #endif 1022 #endif
840 if (vo_vobsub && vobsub_id >= 0) { 1023 if (vo_vobsub && vobsub_id >= 0) {
841 const char *language = MSGTR_Unknown; 1024 const char *language = MSGTR_Unknown;
842 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id); 1025 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
843 snprintf(*(char**)arg, 63, "(%d) %s", 1026 snprintf(*(char **) arg, 63, "(%d) %s",
844 vobsub_id, language ? language : MSGTR_Unknown); 1027 vobsub_id, language ? language : MSGTR_Unknown);
845 return M_PROPERTY_OK; 1028 return M_PROPERTY_OK;
846 } 1029 }
847 #ifdef USE_DVDREAD 1030 #ifdef USE_DVDREAD
848 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD && dvdsub_id >= 0) { 1031 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD
849 char lang[3]; 1032 && dvdsub_id >= 0) {
850 int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id); 1033 char lang[3];
851 lang[0] = code >> 8; 1034 int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id);
852 lang[1] = code; 1035 lang[0] = code >> 8;
853 lang[2] = 0; 1036 lang[1] = code;
854 snprintf(*(char**)arg, 63, "(%d) %s", 1037 lang[2] = 0;
855 dvdsub_id, lang); 1038 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
856 return M_PROPERTY_OK; 1039 return M_PROPERTY_OK;
857 } 1040 }
858 #endif 1041 #endif
859 if (dvdsub_id >= 0) { 1042 if (dvdsub_id >= 0) {
860 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown); 1043 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
861 return M_PROPERTY_OK; 1044 return M_PROPERTY_OK;
862 } 1045 }
863 snprintf(*(char**)arg, 63, MSGTR_Disabled); 1046 snprintf(*(char **) arg, 63, MSGTR_Disabled);
864 return M_PROPERTY_OK; 1047 return M_PROPERTY_OK;
865 1048
866 case M_PROPERTY_SET: 1049 case M_PROPERTY_SET:
867 if(!arg) return M_PROPERTY_ERROR; 1050 if (!arg)
868 if(*(int*)arg < -1) *(int*)arg = -1; 1051 return M_PROPERTY_ERROR;
869 else if(*(int*)arg >= global_sub_size) *(int*)arg = global_sub_size-1; 1052 if (*(int *) arg < -1)
870 mpctx->global_sub_pos = *(int *) arg; 1053 *(int *) arg = -1;
871 break; 1054 else if (*(int *) arg >= global_sub_size)
1055 *(int *) arg = global_sub_size - 1;
1056 mpctx->global_sub_pos = *(int *) arg;
1057 break;
872 case M_PROPERTY_STEP_UP: 1058 case M_PROPERTY_STEP_UP:
873 mpctx->global_sub_pos += 2; 1059 mpctx->global_sub_pos += 2;
874 mpctx->global_sub_pos = (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; 1060 mpctx->global_sub_pos =
875 break; 1061 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
1062 break;
876 case M_PROPERTY_STEP_DOWN: 1063 case M_PROPERTY_STEP_DOWN:
877 mpctx->global_sub_pos += global_sub_size + 1; 1064 mpctx->global_sub_pos += global_sub_size + 1;
878 mpctx->global_sub_pos = (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; 1065 mpctx->global_sub_pos =
879 break; 1066 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
1067 break;
880 default: 1068 default:
881 return M_PROPERTY_NOT_IMPLEMENTED; 1069 return M_PROPERTY_NOT_IMPLEMENTED;
882 } 1070 }
883 1071
884 if (mpctx->global_sub_pos >= 0) 1072 if (mpctx->global_sub_pos >= 0)
885 source = sub_source(mpctx); 1073 source = sub_source(mpctx);
886 1074
887 mp_msg(MSGT_CPLAYER, MSGL_DBG3, 1075 mp_msg(MSGT_CPLAYER, MSGL_DBG3,
888 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n", 1076 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
889 global_sub_size, 1077 global_sub_size,
890 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB], 1078 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB],
891 mpctx->global_sub_indices[SUB_SOURCE_SUBS], 1079 mpctx->global_sub_indices[SUB_SOURCE_SUBS],
892 mpctx->global_sub_indices[SUB_SOURCE_DEMUX], 1080 mpctx->global_sub_indices[SUB_SOURCE_DEMUX],
893 mpctx->global_sub_pos, source); 1081 mpctx->global_sub_pos, source);
894 1082
895 mpctx->set_of_sub_pos = -1; 1083 mpctx->set_of_sub_pos = -1;
896 subdata = NULL; 1084 subdata = NULL;
897 vo_sub_last = vo_sub = NULL; 1085 vo_sub_last = vo_sub = NULL;
898 1086
899 vobsub_id = -1; 1087 vobsub_id = -1;
900 dvdsub_id = -1; 1088 dvdsub_id = -1;
901 if (d_sub) { 1089 if (d_sub) {
902 if (d_sub->id > -2) reset_spu = 1; 1090 if (d_sub->id > -2)
903 d_sub->id = -2; 1091 reset_spu = 1;
1092 d_sub->id = -2;
904 } 1093 }
905 #ifdef USE_ASS 1094 #ifdef USE_ASS
906 ass_track = 0; 1095 ass_track = 0;
907 #endif 1096 #endif
908 1097
909 if (source == SUB_SOURCE_VOBSUB) { 1098 if (source == SUB_SOURCE_VOBSUB) {
910 vobsub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_VOBSUB]; 1099 vobsub_id =
1100 mpctx->global_sub_pos -
1101 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB];
911 } else if (source == SUB_SOURCE_SUBS) { 1102 } else if (source == SUB_SOURCE_SUBS) {
912 mpctx->set_of_sub_pos = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS]; 1103 mpctx->set_of_sub_pos =
1104 mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS];
913 #ifdef USE_ASS 1105 #ifdef USE_ASS
914 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]) 1106 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos])
915 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]; 1107 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos];
916 else 1108 else
917 #endif 1109 #endif
918 { 1110 {
919 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos]; 1111 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos];
920 vo_osd_changed(OSDTYPE_SUBTITLE); 1112 vo_osd_changed(OSDTYPE_SUBTITLE);
921 } 1113 }
922 } else if (source == SUB_SOURCE_DEMUX) { 1114 } else if (source == SUB_SOURCE_DEMUX) {
923 dvdsub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX]; 1115 dvdsub_id =
924 if (d_sub) { 1116 mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX];
1117 if (d_sub) {
925 #ifdef USE_DVDREAD 1118 #ifdef USE_DVDREAD
926 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD) { 1119 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD) {
927 d_sub->id = dvdsub_id; 1120 d_sub->id = dvdsub_id;
928 } 1121 }
929 #endif 1122 #endif
930 1123
931 #ifdef USE_DVDNAV 1124 #ifdef USE_DVDNAV
932 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVDNAV) { 1125 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVDNAV) {
933 d_sub->id = dvdsub_id; 1126 d_sub->id = dvdsub_id;
934 } 1127 }
935 #endif 1128 #endif
936 if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_DVDNAV) { 1129 if (mpctx->stream->type != STREAMTYPE_DVD
937 int i = 0; 1130 && mpctx->stream->type != STREAMTYPE_DVDNAV) {
938 for (d_sub->id = 0; d_sub->id < MAX_S_STREAMS; d_sub->id++) { 1131 int i = 0;
939 if (mpctx->demuxer->s_streams[d_sub->id]) { 1132 for (d_sub->id = 0; d_sub->id < MAX_S_STREAMS; d_sub->id++) {
940 if (i == dvdsub_id) break; 1133 if (mpctx->demuxer->s_streams[d_sub->id]) {
941 i++; 1134 if (i == dvdsub_id)
942 } 1135 break;
943 } 1136 i++;
944 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id]; 1137 }
945 } 1138 }
946 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA) { 1139 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
947 d_sub->id = demux_mkv_change_subs(mpctx->demuxer, dvdsub_id); 1140 }
948 } 1141 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
949 if (d_sub->sh && d_sub->id >= 0) { 1142 d_sub->id = demux_mkv_change_subs(mpctx->demuxer, dvdsub_id);
950 sh_sub_t *sh = d_sub->sh; 1143 if (d_sub->sh && d_sub->id >= 0) {
951 if (sh->type == 'v') 1144 sh_sub_t *sh = d_sub->sh;
952 init_vo_spudec(); 1145 if (sh->type == 'v')
1146 init_vo_spudec();
953 #ifdef USE_ASS 1147 #ifdef USE_ASS
954 else if (ass_enabled && sh->type == 'a') 1148 else if (ass_enabled && sh->type == 'a')
955 ass_track = sh->ass_track; 1149 ass_track = sh->ass_track;
956 #endif 1150 #endif
957 } 1151 }
958 } 1152 }
959 } 1153 }
960 #ifdef USE_DVDREAD 1154 #ifdef USE_DVDREAD
961 if (vo_spudec && (mpctx->stream->type == STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV) && dvdsub_id < 0 && reset_spu) { 1155 if (vo_spudec
962 dvdsub_id = -2; 1156 && (mpctx->stream->type == STREAMTYPE_DVD
963 d_sub->id = dvdsub_id; 1157 || mpctx->stream->type == STREAMTYPE_DVDNAV)
1158 && dvdsub_id < 0 && reset_spu) {
1159 dvdsub_id = -2;
1160 d_sub->id = dvdsub_id;
964 } 1161 }
965 #endif 1162 #endif
966 update_subtitles(mpctx->sh_video, d_sub, 1); 1163 update_subtitles(mpctx->sh_video, d_sub, 1);
967 1164
968 return M_PROPERTY_OK; 1165 return M_PROPERTY_OK;
969 } 1166 }
970 1167
971 /// Subtitle delay (RW) 1168 /// Subtitle delay (RW)
972 static int mp_property_sub_delay(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 1169 static int mp_property_sub_delay(m_option_t * prop, int action, void *arg,
973 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 1170 MPContext * mpctx)
974 return m_property_delay(prop,action,arg,&sub_delay); 1171 {
975 } 1172 if (!mpctx->sh_video)
976 1173 return M_PROPERTY_UNAVAILABLE;
977 /// Alignment of text subtitles (RW) 1174 return m_property_delay(prop, action, arg, &sub_delay);
978 static int mp_property_sub_alignment(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 1175 }
979 char* name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom }; 1176
980 1177 /// Alignment of text subtitles (RW)
981 if (!mpctx->sh_video || mpctx->global_sub_pos < 0 || sub_source(mpctx) != SUB_SOURCE_SUBS) 1178 static int mp_property_sub_alignment(m_option_t * prop, int action,
982 return M_PROPERTY_UNAVAILABLE; 1179 void *arg, MPContext * mpctx)
983 1180 {
984 switch(action) { 1181 char *name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom };
1182
1183 if (!mpctx->sh_video || mpctx->global_sub_pos < 0
1184 || sub_source(mpctx) != SUB_SOURCE_SUBS)
1185 return M_PROPERTY_UNAVAILABLE;
1186
1187 switch (action) {
985 case M_PROPERTY_PRINT: 1188 case M_PROPERTY_PRINT:
986 if(!arg) return M_PROPERTY_ERROR; 1189 if (!arg)
987 M_PROPERTY_CLAMP(prop,sub_alignment); 1190 return M_PROPERTY_ERROR;
988 *(char**)arg = strdup(name[sub_alignment]); 1191 M_PROPERTY_CLAMP(prop, sub_alignment);
989 return M_PROPERTY_OK; 1192 *(char **) arg = strdup(name[sub_alignment]);
1193 return M_PROPERTY_OK;
990 case M_PROPERTY_SET: 1194 case M_PROPERTY_SET:
991 if(!arg) return M_PROPERTY_ERROR; 1195 if (!arg)
1196 return M_PROPERTY_ERROR;
992 case M_PROPERTY_STEP_UP: 1197 case M_PROPERTY_STEP_UP:
993 case M_PROPERTY_STEP_DOWN: 1198 case M_PROPERTY_STEP_DOWN:
994 vo_osd_changed(OSDTYPE_SUBTITLE); 1199 vo_osd_changed(OSDTYPE_SUBTITLE);
995 default: 1200 default:
996 return m_property_choice(prop,action,arg,&sub_alignment); 1201 return m_property_choice(prop, action, arg, &sub_alignment);
997 } 1202 }
998 } 1203 }
999 1204
1000 /// Subtitle visibility (RW) 1205 /// Subtitle visibility (RW)
1001 static int mp_property_sub_visibility(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 1206 static int mp_property_sub_visibility(m_option_t * prop, int action,
1002 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; 1207 void *arg, MPContext * mpctx)
1003 1208 {
1004 switch(action) { 1209 if (!mpctx->sh_video)
1210 return M_PROPERTY_UNAVAILABLE;
1211
1212 switch (action) {
1005 case M_PROPERTY_SET: 1213 case M_PROPERTY_SET:
1006 if(!arg) return M_PROPERTY_ERROR; 1214 if (!arg)
1215 return M_PROPERTY_ERROR;
1007 case M_PROPERTY_STEP_UP: 1216 case M_PROPERTY_STEP_UP:
1008 case M_PROPERTY_STEP_DOWN: 1217 case M_PROPERTY_STEP_DOWN:
1009 vo_osd_changed(OSDTYPE_SUBTITLE); 1218 vo_osd_changed(OSDTYPE_SUBTITLE);
1010 if(vo_spudec) vo_osd_changed(OSDTYPE_SPU); 1219 if (vo_spudec)
1220 vo_osd_changed(OSDTYPE_SPU);
1011 default: 1221 default:
1012 return m_property_flag(prop,action,arg,&sub_visibility); 1222 return m_property_flag(prop, action, arg, &sub_visibility);
1013 } 1223 }
1014 } 1224 }
1015 1225
1016 /// Show only forced subtitles (RW) 1226 /// Show only forced subtitles (RW)
1017 static int mp_property_sub_forced_only(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 1227 static int mp_property_sub_forced_only(m_option_t * prop, int action,
1018 if(!vo_spudec) return M_PROPERTY_UNAVAILABLE; 1228 void *arg, MPContext * mpctx)
1019 1229 {
1020 switch(action) { 1230 if (!vo_spudec)
1231 return M_PROPERTY_UNAVAILABLE;
1232
1233 switch (action) {
1021 case M_PROPERTY_SET: 1234 case M_PROPERTY_SET:
1022 if(!arg) return M_PROPERTY_ERROR; 1235 if (!arg)
1236 return M_PROPERTY_ERROR;
1023 case M_PROPERTY_STEP_UP: 1237 case M_PROPERTY_STEP_UP:
1024 case M_PROPERTY_STEP_DOWN: 1238 case M_PROPERTY_STEP_DOWN:
1025 m_property_flag(prop,action,arg,&forced_subs_only); 1239 m_property_flag(prop, action, arg, &forced_subs_only);
1026 spudec_set_forced_subs_only(vo_spudec,forced_subs_only); 1240 spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
1027 return M_PROPERTY_OK; 1241 return M_PROPERTY_OK;
1028 default: 1242 default:
1029 return m_property_flag(prop,action,arg,&forced_subs_only); 1243 return m_property_flag(prop, action, arg, &forced_subs_only);
1030 } 1244 }
1031 1245
1032 } 1246 }
1033 1247
1034 ///@} 1248 ///@}
1038 ///@{ 1252 ///@{
1039 1253
1040 #ifdef USE_TV 1254 #ifdef USE_TV
1041 1255
1042 /// TV color settings (RW) 1256 /// TV color settings (RW)
1043 static int mp_property_tv_color(m_option_t * prop, int action, void *arg, MPContext * mpctx) { 1257 static int mp_property_tv_color(m_option_t * prop, int action, void *arg,
1044 int r,val; 1258 MPContext * mpctx)
1259 {
1260 int r, val;
1045 tvi_handle_t *tvh = mpctx->demuxer->priv; 1261 tvi_handle_t *tvh = mpctx->demuxer->priv;
1046 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) return M_PROPERTY_UNAVAILABLE; 1262 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
1047 1263 return M_PROPERTY_UNAVAILABLE;
1048 switch(action) { 1264
1265 switch (action) {
1049 case M_PROPERTY_SET: 1266 case M_PROPERTY_SET:
1050 if(!arg) return M_PROPERTY_ERROR; 1267 if (!arg)
1051 M_PROPERTY_CLAMP(prop,*(int*)arg); 1268 return M_PROPERTY_ERROR;
1052 return tv_set_color_options(tvh,(int)prop->priv,*(int*)arg); 1269 M_PROPERTY_CLAMP(prop, *(int *) arg);
1270 return tv_set_color_options(tvh, (int) prop->priv, *(int *) arg);
1053 case M_PROPERTY_GET: 1271 case M_PROPERTY_GET:
1054 return tv_get_color_options(tvh,(int)prop->priv,arg); 1272 return tv_get_color_options(tvh, (int) prop->priv, arg);
1055 case M_PROPERTY_STEP_UP: 1273 case M_PROPERTY_STEP_UP:
1056 case M_PROPERTY_STEP_DOWN: 1274 case M_PROPERTY_STEP_DOWN:
1057 if((r = tv_get_color_options(tvh,(int)prop->priv,&val)) >= 0) { 1275 if ((r = tv_get_color_options(tvh, (int) prop->priv, &val)) >= 0) {
1058 if(!r) return M_PROPERTY_ERROR; 1276 if (!r)
1059 val += (arg ? *(int*)arg : 1) * 1277 return M_PROPERTY_ERROR;
1060 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 1278 val += (arg ? *(int *) arg : 1) *
1061 M_PROPERTY_CLAMP(prop,val); 1279 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
1062 return tv_set_color_options(tvh,(int)prop->priv,val); 1280 M_PROPERTY_CLAMP(prop, val);
1063 } 1281 return tv_set_color_options(tvh, (int) prop->priv, val);
1064 return M_PROPERTY_ERROR; 1282 }
1283 return M_PROPERTY_ERROR;
1065 } 1284 }
1066 return M_PROPERTY_NOT_IMPLEMENTED; 1285 return M_PROPERTY_NOT_IMPLEMENTED;
1067 } 1286 }
1068 1287
1069 #endif 1288 #endif
1074 /** \ingroup Properties 1293 /** \ingroup Properties
1075 */ 1294 */
1076 static m_option_t mp_properties[] = { 1295 static m_option_t mp_properties[] = {
1077 // General 1296 // General
1078 { "osdlevel", mp_property_osdlevel, CONF_TYPE_INT, 1297 { "osdlevel", mp_property_osdlevel, CONF_TYPE_INT,
1079 M_OPT_RANGE, 0, 3, NULL }, 1298 M_OPT_RANGE, 0, 3, NULL },
1080 { "speed", mp_property_playback_speed, CONF_TYPE_FLOAT, 1299 { "speed", mp_property_playback_speed, CONF_TYPE_FLOAT,
1081 M_OPT_RANGE, 0.01, 100.0, NULL }, 1300 M_OPT_RANGE, 0.01, 100.0, NULL },
1082 { "filename", mp_property_filename, CONF_TYPE_STRING, 1301 { "filename", mp_property_filename, CONF_TYPE_STRING,
1083 0, 0, 0, NULL }, 1302 0, 0, 0, NULL },
1084 { "path", mp_property_path, CONF_TYPE_STRING, 1303 { "path", mp_property_path, CONF_TYPE_STRING,
1085 0, 0, 0, NULL }, 1304 0, 0, 0, NULL },
1086 { "demuxer", mp_property_demuxer, CONF_TYPE_STRING, 1305 { "demuxer", mp_property_demuxer, CONF_TYPE_STRING,
1087 0, 0, 0, NULL }, 1306 0, 0, 0, NULL },
1088 { "stream_pos", mp_property_stream_pos, CONF_TYPE_POSITION, 1307 { "stream_pos", mp_property_stream_pos, CONF_TYPE_POSITION,
1089 M_OPT_MIN, 0, 0, NULL }, 1308 M_OPT_MIN, 0, 0, NULL },
1090 { "stream_start", mp_property_stream_start, CONF_TYPE_POSITION, 1309 { "stream_start", mp_property_stream_start, CONF_TYPE_POSITION,
1091 M_OPT_MIN, 0, 0, NULL }, 1310 M_OPT_MIN, 0, 0, NULL },
1092 { "stream_end", mp_property_stream_end, CONF_TYPE_POSITION, 1311 { "stream_end", mp_property_stream_end, CONF_TYPE_POSITION,
1093 M_OPT_MIN, 0, 0, NULL }, 1312 M_OPT_MIN, 0, 0, NULL },
1094 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION, 1313 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION,
1095 M_OPT_MIN, 0, 0, NULL }, 1314 M_OPT_MIN, 0, 0, NULL },
1096 { "length", mp_property_length, CONF_TYPE_DOUBLE, 1315 { "length", mp_property_length, CONF_TYPE_DOUBLE,
1097 0, 0, 0, NULL }, 1316 0, 0, 0, NULL },
1098 1317
1099 // Audio 1318 // Audio
1100 { "volume", mp_property_volume, CONF_TYPE_FLOAT, 1319 { "volume", mp_property_volume, CONF_TYPE_FLOAT,
1101 M_OPT_RANGE, 0, 100, NULL }, 1320 M_OPT_RANGE, 0, 100, NULL },
1102 { "mute", mp_property_mute, CONF_TYPE_FLAG, 1321 { "mute", mp_property_mute, CONF_TYPE_FLAG,
1103 M_OPT_RANGE, 0, 1, NULL }, 1322 M_OPT_RANGE, 0, 1, NULL },
1104 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT, 1323 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT,
1105 M_OPT_RANGE, -100, 100, NULL }, 1324 M_OPT_RANGE, -100, 100, NULL },
1106 { "audio_format", mp_property_audio_format, CONF_TYPE_INT, 1325 { "audio_format", mp_property_audio_format, CONF_TYPE_INT,
1107 0, 0, 0, NULL }, 1326 0, 0, 0, NULL },
1108 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT, 1327 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT,
1109 0, 0, 0, NULL }, 1328 0, 0, 0, NULL },
1110 { "samplerate", mp_property_samplerate, CONF_TYPE_INT, 1329 { "samplerate", mp_property_samplerate, CONF_TYPE_INT,
1111 0, 0, 0, NULL }, 1330 0, 0, 0, NULL },
1112 { "channels", mp_property_channels, CONF_TYPE_INT, 1331 { "channels", mp_property_channels, CONF_TYPE_INT,
1113 0, 0, 0, NULL }, 1332 0, 0, 0, NULL },
1114 { "switch_audio", mp_property_audio, CONF_TYPE_INT, 1333 { "switch_audio", mp_property_audio, CONF_TYPE_INT,
1115 CONF_RANGE, -2, MAX_A_STREAMS-1, NULL }, 1334 CONF_RANGE, -2, MAX_A_STREAMS - 1, NULL },
1116 1335
1117 // Video 1336 // Video
1118 { "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG, 1337 { "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG,
1119 M_OPT_RANGE, 0, 1, NULL }, 1338 M_OPT_RANGE, 0, 1, NULL },
1120 { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG, 1339 { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG,
1121 M_OPT_RANGE, 0, 1, NULL }, 1340 M_OPT_RANGE, 0, 1, NULL },
1122 { "ontop", mp_property_ontop, CONF_TYPE_FLAG, 1341 { "ontop", mp_property_ontop, CONF_TYPE_FLAG,
1123 M_OPT_RANGE, 0, 1, NULL }, 1342 M_OPT_RANGE, 0, 1, NULL },
1124 { "rootwin", mp_property_rootwin, CONF_TYPE_FLAG, 1343 { "rootwin", mp_property_rootwin, CONF_TYPE_FLAG,
1125 M_OPT_RANGE, 0, 1, NULL }, 1344 M_OPT_RANGE, 0, 1, NULL },
1126 { "border", mp_property_border, CONF_TYPE_FLAG, 1345 { "border", mp_property_border, CONF_TYPE_FLAG,
1127 M_OPT_RANGE, 0, 1, NULL }, 1346 M_OPT_RANGE, 0, 1, NULL },
1128 { "framedropping", mp_property_framedropping, CONF_TYPE_INT, 1347 { "framedropping", mp_property_framedropping, CONF_TYPE_INT,
1129 M_OPT_RANGE, 0, 2, NULL }, 1348 M_OPT_RANGE, 0, 2, NULL },
1130 { "gamma", mp_property_gamma, CONF_TYPE_INT, 1349 { "gamma", mp_property_gamma, CONF_TYPE_INT,
1131 M_OPT_RANGE, -100, 100, &vo_gamma_gamma }, 1350 M_OPT_RANGE, -100, 100, &vo_gamma_gamma },
1132 { "brightness", mp_property_gamma, CONF_TYPE_INT, 1351 { "brightness", mp_property_gamma, CONF_TYPE_INT,
1133 M_OPT_RANGE, -100, 100, &vo_gamma_brightness }, 1352 M_OPT_RANGE, -100, 100, &vo_gamma_brightness },
1134 { "contrast", mp_property_gamma, CONF_TYPE_INT, 1353 { "contrast", mp_property_gamma, CONF_TYPE_INT,
1135 M_OPT_RANGE, -100, 100, &vo_gamma_contrast }, 1354 M_OPT_RANGE, -100, 100, &vo_gamma_contrast },
1136 { "saturation", mp_property_gamma, CONF_TYPE_INT, 1355 { "saturation", mp_property_gamma, CONF_TYPE_INT,
1137 M_OPT_RANGE, -100, 100, &vo_gamma_saturation }, 1356 M_OPT_RANGE, -100, 100, &vo_gamma_saturation },
1138 { "hue", mp_property_gamma, CONF_TYPE_INT, 1357 { "hue", mp_property_gamma, CONF_TYPE_INT,
1139 M_OPT_RANGE, -100, 100, &vo_gamma_hue }, 1358 M_OPT_RANGE, -100, 100, &vo_gamma_hue },
1140 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT, 1359 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT,
1141 M_OPT_RANGE, 0, 1, NULL }, 1360 M_OPT_RANGE, 0, 1, NULL },
1142 { "vsync", mp_property_vsync, CONF_TYPE_FLAG, 1361 { "vsync", mp_property_vsync, CONF_TYPE_FLAG,
1143 M_OPT_RANGE, 0, 1, NULL }, 1362 M_OPT_RANGE, 0, 1, NULL },
1144 { "video_format", mp_property_video_format, CONF_TYPE_INT, 1363 { "video_format", mp_property_video_format, CONF_TYPE_INT,
1145 0, 0, 0, NULL }, 1364 0, 0, 0, NULL },
1146 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT, 1365 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT,
1147 0, 0, 0, NULL }, 1366 0, 0, 0, NULL },
1148 { "width", mp_property_width, CONF_TYPE_INT, 1367 { "width", mp_property_width, CONF_TYPE_INT,
1149 0, 0, 0, NULL }, 1368 0, 0, 0, NULL },
1150 { "height", mp_property_height, CONF_TYPE_INT, 1369 { "height", mp_property_height, CONF_TYPE_INT,
1151 0, 0, 0, NULL }, 1370 0, 0, 0, NULL },
1152 { "fps", mp_property_fps, CONF_TYPE_FLOAT, 1371 { "fps", mp_property_fps, CONF_TYPE_FLOAT,
1153 0, 0, 0, NULL }, 1372 0, 0, 0, NULL },
1154 { "aspect", mp_property_aspect, CONF_TYPE_FLOAT, 1373 { "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
1155 0, 0, 0, NULL }, 1374 0, 0, 0, NULL },
1156 { "switch_video", mp_property_video, CONF_TYPE_INT, 1375 { "switch_video", mp_property_video, CONF_TYPE_INT,
1157 CONF_RANGE, -2, MAX_V_STREAMS-1, NULL }, 1376 CONF_RANGE, -2, MAX_V_STREAMS - 1, NULL },
1158 { "switch_program", mp_property_program, CONF_TYPE_INT, 1377 { "switch_program", mp_property_program, CONF_TYPE_INT,
1159 CONF_RANGE, -1, 65535, NULL }, 1378 CONF_RANGE, -1, 65535, NULL },
1160 1379
1161 // Subs 1380 // Subs
1162 { "sub", mp_property_sub, CONF_TYPE_INT, 1381 { "sub", mp_property_sub, CONF_TYPE_INT,
1163 M_OPT_MIN, -1, 0, NULL }, 1382 M_OPT_MIN, -1, 0, NULL },
1164 { "sub_delay", mp_property_sub_delay, CONF_TYPE_FLOAT, 1383 { "sub_delay", mp_property_sub_delay, CONF_TYPE_FLOAT,
1165 0, 0, 0, NULL }, 1384 0, 0, 0, NULL },
1166 { "sub_pos", mp_property_sub_pos, CONF_TYPE_INT, 1385 { "sub_pos", mp_property_sub_pos, CONF_TYPE_INT,
1167 M_OPT_RANGE, 0, 100, NULL }, 1386 M_OPT_RANGE, 0, 100, NULL },
1168 { "sub_alignment", mp_property_sub_alignment, CONF_TYPE_INT, 1387 { "sub_alignment", mp_property_sub_alignment, CONF_TYPE_INT,
1169 M_OPT_RANGE, 0, 2, NULL }, 1388 M_OPT_RANGE, 0, 2, NULL },
1170 { "sub_visibility", mp_property_sub_visibility, CONF_TYPE_FLAG, 1389 { "sub_visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
1171 M_OPT_RANGE, 0, 1, NULL }, 1390 M_OPT_RANGE, 0, 1, NULL },
1172 { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG, 1391 { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG,
1173 M_OPT_RANGE, 0, 1, NULL }, 1392 M_OPT_RANGE, 0, 1, NULL },
1174 1393
1175 #ifdef USE_TV 1394 #ifdef USE_TV
1176 { "tv_brightness", mp_property_tv_color, CONF_TYPE_INT, 1395 { "tv_brightness", mp_property_tv_color, CONF_TYPE_INT,
1177 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_BRIGHTNESS }, 1396 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_BRIGHTNESS },
1178 { "tv_contrast", mp_property_tv_color, CONF_TYPE_INT, 1397 { "tv_contrast", mp_property_tv_color, CONF_TYPE_INT,
1179 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_CONTRAST }, 1398 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_CONTRAST },
1180 { "tv_saturation", mp_property_tv_color, CONF_TYPE_INT, 1399 { "tv_saturation", mp_property_tv_color, CONF_TYPE_INT,
1181 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_SATURATION }, 1400 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_SATURATION },
1182 { "tv_hue", mp_property_tv_color, CONF_TYPE_INT, 1401 { "tv_hue", mp_property_tv_color, CONF_TYPE_INT,
1183 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_HUE }, 1402 M_OPT_RANGE, -100, 100, (void *) TV_COLOR_HUE },
1184 #endif 1403 #endif
1185 1404
1186 { NULL, NULL, NULL, 0, 0, 0, NULL } 1405 { NULL, NULL, NULL, 0, 0, 0, NULL }
1187 }; 1406 };
1188 1407
1189 m_option_t* mp_property_find(const char* name) { 1408
1190 return m_option_list_find(mp_properties,name); 1409 m_option_t *mp_property_find(const char *name)
1191 } 1410 {
1192 1411 return m_option_list_find(mp_properties, name);
1193 int mp_property_do(const char *name, int action, void *val, void *ctx) { 1412 }
1194 m_option_t* p = mp_property_find(name); 1413
1195 if(!p) return M_PROPERTY_UNAVAILABLE; 1414 int mp_property_do(const char *name, int action, void *val, void *ctx)
1415 {
1416 m_option_t *p = mp_property_find(name);
1417 if (!p)
1418 return M_PROPERTY_UNAVAILABLE;
1196 return m_property_do(p, action, val, ctx); 1419 return m_property_do(p, action, val, ctx);
1197 } 1420 }
1198 1421
1199 char *property_expand_string(MPContext * mpctx, char *str) { 1422 char *property_expand_string(MPContext * mpctx, char *str)
1423 {
1200 return m_properties_expand_string(mp_properties, str, mpctx); 1424 return m_properties_expand_string(mp_properties, str, mpctx);
1201 } 1425 }
1202 1426
1203 void property_print_help(void) { 1427 void property_print_help(void)
1428 {
1204 m_properties_print_help_list(mp_properties); 1429 m_properties_print_help_list(mp_properties);
1205 } 1430 }
1206 1431
1207 1432
1208 ///@} 1433 ///@}
1209 // Properties group 1434 // Properties group
1210 1435
1211 1436
1212 /** 1437 /**
1213 * \defgroup Command2Property Command to property bridge 1438 * \defgroup Command2Property Command to property bridge
1214 * 1439 *
1215 * It is used to handle most commands that just set a property 1440 * It is used to handle most commands that just set a property
1216 * and optionally display something on the OSD. 1441 * and optionally display something on the OSD.
1217 * Two kinds of commands are handled: adjust or toggle. 1442 * Two kinds of commands are handled: adjust or toggle.
1218 * 1443 *
1219 * Adjust commands take 1 or 2 parameters: <value> <abs> 1444 * Adjust commands take 1 or 2 parameters: <value> <abs>
1227 * 1452 *
1228 *@{ 1453 *@{
1229 */ 1454 */
1230 1455
1231 /// List of the commands that can be handled by setting a property. 1456 /// List of the commands that can be handled by setting a property.
1232 static struct { 1457 static struct {
1233 /// property name 1458 /// property name
1234 const char* name; 1459 const char *name;
1235 /// cmd id 1460 /// cmd id
1236 int cmd; 1461 int cmd;
1237 /// set/adjust or toggle command 1462 /// set/adjust or toggle command
1238 int toggle; 1463 int toggle;
1239 /// progressbar type 1464 /// progressbar type
1240 int osd_progbar; 1465 int osd_progbar;
1241 /// osd msg id if it must be shared 1466 /// osd msg id if it must be shared
1242 int osd_id; 1467 int osd_id;
1243 /// osd msg template 1468 /// osd msg template
1244 const char* osd_msg; 1469 const char *osd_msg;
1245 } set_prop_cmd[] = { 1470 } set_prop_cmd[] = {
1246 // audio 1471 // audio
1247 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume }, 1472 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
1248 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus }, 1473 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
1249 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus }, 1474 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus },
1259 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness }, 1484 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
1260 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast }, 1485 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
1261 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation }, 1486 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
1262 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue }, 1487 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
1263 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus }, 1488 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus },
1264 // subs 1489 // subs
1265 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus }, 1490 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus },
1266 { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus }, 1491 { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus },
1267 { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus }, 1492 { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus },
1268 { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus }, 1493 { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus },
1269 { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus }, 1494 { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus },
1277 { NULL, 0, 0, 0, -1, NULL } 1502 { NULL, 0, 0, 0, -1, NULL }
1278 }; 1503 };
1279 1504
1280 1505
1281 /// Handle commands that set a property. 1506 /// Handle commands that set a property.
1282 static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd) { 1507 static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd)
1283 int i,r; 1508 {
1284 m_option_t* prop; 1509 int i, r;
1285 1510 m_option_t *prop;
1511
1286 // look for the command 1512 // look for the command
1287 for(i = 0 ; set_prop_cmd[i].name ; i++) 1513 for (i = 0; set_prop_cmd[i].name; i++)
1288 if(set_prop_cmd[i].cmd == cmd->id) break; 1514 if (set_prop_cmd[i].cmd == cmd->id)
1289 if(!set_prop_cmd[i].name) return 0; 1515 break;
1290 1516 if (!set_prop_cmd[i].name)
1517 return 0;
1518
1291 // get the property 1519 // get the property
1292 prop = mp_property_find(set_prop_cmd[i].name); 1520 prop = mp_property_find(set_prop_cmd[i].name);
1293 if(!prop) return 0; 1521 if (!prop)
1294 1522 return 0;
1523
1295 // toggle command 1524 // toggle command
1296 if(set_prop_cmd[i].toggle) { 1525 if (set_prop_cmd[i].toggle) {
1297 // set to value 1526 // set to value
1298 if(cmd->nargs > 0 && cmd->args[0].v.i >= prop->min) 1527 if (cmd->nargs > 0 && cmd->args[0].v.i >= prop->min)
1299 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx); 1528 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx);
1300 else 1529 else
1301 r = m_property_do(prop, M_PROPERTY_STEP_UP, NULL, mpctx); 1530 r = m_property_do(prop, M_PROPERTY_STEP_UP, NULL, mpctx);
1302 } else if(cmd->args[1].v.i) //set 1531 } else if (cmd->args[1].v.i) //set
1303 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v, mpctx); 1532 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v, mpctx);
1304 else // adjust 1533 else // adjust
1305 r = m_property_do(prop, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx); 1534 r = m_property_do(prop, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx);
1306 1535
1307 if(r <= 0) return 1; 1536 if (r <= 0)
1308 1537 return 1;
1309 if(set_prop_cmd[i].osd_progbar) { 1538
1310 if(prop->type == CONF_TYPE_INT) { 1539 if (set_prop_cmd[i].osd_progbar) {
1311 if (m_property_do(prop, M_PROPERTY_GET, &r, mpctx) > 0) 1540 if (prop->type == CONF_TYPE_INT) {
1312 set_osd_bar(set_prop_cmd[i].osd_progbar, 1541 if (m_property_do(prop, M_PROPERTY_GET, &r, mpctx) > 0)
1313 set_prop_cmd[i].osd_msg, 1542 set_osd_bar(set_prop_cmd[i].osd_progbar,
1314 prop->min,prop->max,r); 1543 set_prop_cmd[i].osd_msg, prop->min, prop->max, r);
1315 } else if(prop->type == CONF_TYPE_FLOAT) { 1544 } else if (prop->type == CONF_TYPE_FLOAT) {
1316 float f; 1545 float f;
1317 if (m_property_do(prop, M_PROPERTY_GET, &f, mpctx) > 0) 1546 if (m_property_do(prop, M_PROPERTY_GET, &f, mpctx) > 0)
1318 set_osd_bar(set_prop_cmd[i].osd_progbar,set_prop_cmd[i].osd_msg, 1547 set_osd_bar(set_prop_cmd[i].osd_progbar,
1319 prop->min,prop->max,f); 1548 set_prop_cmd[i].osd_msg, prop->min, prop->max, f);
1320 } else 1549 } else
1321 mp_msg(MSGT_CPLAYER,MSGL_ERR, "Property use an unsupported type.\n"); 1550 mp_msg(MSGT_CPLAYER, MSGL_ERR,
1322 return 1; 1551 "Property use an unsupported type.\n");
1323 } 1552 return 1;
1324 1553 }
1325 if(set_prop_cmd[i].osd_msg) { 1554
1326 char *val = m_property_print(prop, mpctx); 1555 if (set_prop_cmd[i].osd_msg) {
1327 if(val) { 1556 char *val = m_property_print(prop, mpctx);
1328 set_osd_msg(set_prop_cmd[i].osd_id >= 0 ? set_prop_cmd[i].osd_id : 1557 if (val) {
1329 OSD_MSG_PROPERTY+i,1,osd_duration, 1558 set_osd_msg(set_prop_cmd[i].osd_id >=
1330 set_prop_cmd[i].osd_msg,val); 1559 0 ? set_prop_cmd[i].osd_id : OSD_MSG_PROPERTY + i,
1331 free(val); 1560 1, osd_duration, set_prop_cmd[i].osd_msg, val);
1332 } 1561 free(val);
1562 }
1333 } 1563 }
1334 return 1; 1564 return 1;
1335 } 1565 }
1336 1566
1337 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) {
1338 //remove the borders, if any, and rescale to the range [0,1],[0,1]
1339 if(vo_fs) { //we are in full-screen mode
1340 if(vo_screenwidth > vo_dwidth) //there are borders along the x axis
1341 ix -= (vo_screenwidth - vo_dwidth) / 2;
1342 if(vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
1343 iy -= (vo_screenheight - vo_dheight) / 2;
1344
1345 if(ix < 0 || ix > vo_dwidth) {*dx = *dy = -1.0; return; } //we are on one of the borders
1346 if(iy < 0 || iy > vo_dheight) {*dx = *dy = -1.0; return; } //we are on one of the borders
1347 }
1348
1349 *dx = (double) ix / (double) vo_dwidth;
1350 *dy = (double) iy / (double) vo_dheight;
1351
1352 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
1353 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, vo_dheight, vo_fs);
1354 }
1355 1567
1356 int run_command(MPContext * mpctx, mp_cmd_t * cmd) 1568 int run_command(MPContext * mpctx, mp_cmd_t * cmd)
1357 { 1569 {
1358 sh_audio_t * const sh_audio = mpctx->sh_audio; 1570 sh_audio_t * const sh_audio = mpctx->sh_audio;
1359 sh_video_t * const sh_video = mpctx->sh_video; 1571 sh_video_t * const sh_video = mpctx->sh_video;
1360 int brk_cmd = 0; 1572 int brk_cmd = 0;
1361 if (!set_property_command(mpctx, cmd)) 1573 if (!set_property_command(mpctx, cmd))
1362 switch(cmd->id) { 1574 switch (cmd->id) {
1363 case MP_CMD_SEEK : { 1575 case MP_CMD_SEEK:{
1364 float v; 1576 float v;
1365 int abs; 1577 int abs;
1366 if(sh_video) 1578 if (sh_video)
1367 mpctx->osd_show_percentage = sh_video->fps; 1579 mpctx->osd_show_percentage = sh_video->fps;
1368 v = cmd->args[0].v.f; 1580 v = cmd->args[0].v.f;
1369 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0; 1581 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
1370 if(abs==2) { /* Absolute seek to a specific timestamp in seconds */ 1582 if (abs == 2) { /* Absolute seek to a specific timestamp in seconds */
1371 abs_seek_pos = 1; 1583 abs_seek_pos = 1;
1372 if(sh_video) 1584 if (sh_video)
1373 mpctx->osd_function = (v > sh_video->pts) ? OSD_FFW : OSD_REW; 1585 mpctx->osd_function =
1374 rel_seek_secs = v; 1586 (v > sh_video->pts) ? OSD_FFW : OSD_REW;
1375 } 1587 rel_seek_secs = v;
1376 else if(abs) { /* Absolute seek by percentage */ 1588 } else if (abs) { /* Absolute seek by percentage */
1377 abs_seek_pos = 3; 1589 abs_seek_pos = 3;
1378 if(sh_video) 1590 if (sh_video)
1379 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly 1591 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly
1380 rel_seek_secs = v/100.0; 1592 rel_seek_secs = v / 100.0;
1381 } 1593 } else {
1382 else { 1594 rel_seek_secs += v;
1383 rel_seek_secs+= v; 1595 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW;
1384 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW; 1596 }
1385 } 1597 brk_cmd = 1;
1386 brk_cmd = 1; 1598 }
1387 } break; 1599 break;
1388 case MP_CMD_SET_PROPERTY: { 1600
1389 m_option_t* prop = mp_property_find(cmd->args[0].v.s); 1601 case MP_CMD_SET_PROPERTY:{
1390 if(!prop) mp_msg(MSGT_CPLAYER,MSGL_WARN,"Unknown property: '%s'\n",cmd->args[0].v.s); 1602 m_option_t *prop = mp_property_find(cmd->args[0].v.s);
1391 else if (m_property_parse(prop, cmd->args[1].v.s, mpctx) <= 0) 1603 if (!prop)
1392 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to set property '%s' to '%s'.\n", 1604 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1393 cmd->args[0].v.s,cmd->args[1].v.s); 1605 "Unknown property: '%s'\n", cmd->args[0].v.s);
1394 1606 else if (m_property_parse(prop, cmd->args[1].v.s, mpctx) <= 0)
1395 } break; 1607 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1396 case MP_CMD_STEP_PROPERTY: { 1608 "Failed to set property '%s' to '%s'.\n",
1397 m_option_t* prop = mp_property_find(cmd->args[0].v.s); 1609 cmd->args[0].v.s, cmd->args[1].v.s);
1398 float arg = cmd->args[1].v.f; 1610 }
1399 if(!prop) mp_msg(MSGT_CPLAYER,MSGL_WARN, "Unknown property: '%s'\n",cmd->args[0].v.s); 1611 break;
1400 else if (m_property_do(prop, M_PROPERTY_STEP_UP, arg ? &arg : NULL, mpctx) <= 0) 1612
1401 mp_msg(MSGT_CPLAYER,MSGL_WARN, "Failed to increment property '%s' by %f.\n",cmd->args[0].v.s, arg); 1613 case MP_CMD_STEP_PROPERTY:{
1402 } break; 1614 m_option_t *prop = mp_property_find(cmd->args[0].v.s);
1403 1615 float arg = cmd->args[1].v.f;
1404 case MP_CMD_GET_PROPERTY: { 1616 if (!prop)
1405 m_option_t* prop; 1617 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1406 void* val; 1618 "Unknown property: '%s'\n", cmd->args[0].v.s);
1407 char* tmp; 1619 else if (m_property_do
1408 prop = mp_property_find(cmd->args[0].v.s); 1620 (prop, M_PROPERTY_STEP_UP,
1409 if(!prop) { 1621 arg ? &arg : NULL, mpctx) <= 0)
1410 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Unknown property: '%s'\n",cmd->args[0].v.s); 1622 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1411 break; 1623 "Failed to increment property '%s' by %f.\n",
1412 } 1624 cmd->args[0].v.s, arg);
1413 /* Use m_option_print directly to get easily parseable values. */ 1625 }
1414 val = calloc(1,prop->type->size); 1626 break;
1415 if (m_property_do(prop, M_PROPERTY_GET, val, mpctx) <= 0) { 1627
1416 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to get value of property '%s'.\n", 1628 case MP_CMD_GET_PROPERTY:{
1417 cmd->args[0].v.s); 1629 m_option_t *prop;
1418 break; 1630 void *val;
1419 } 1631 char *tmp;
1420 tmp = m_option_print(prop, val); 1632 prop = mp_property_find(cmd->args[0].v.s);
1421 if(!tmp || tmp == (char*)-1) { 1633 if (!prop) {
1422 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to print value of property '%s'.\n", 1634 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1423 cmd->args[0].v.s); 1635 "Unknown property: '%s'\n", cmd->args[0].v.s);
1424 break; 1636 break;
1425 } 1637 }
1426 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_%s=%s\n",cmd->args[0].v.s,tmp); 1638 /* Use m_option_print directly to get easily parseable values. */
1427 free(tmp); 1639 val = calloc(1, prop->type->size);
1428 } break; 1640 if (m_property_do(prop, M_PROPERTY_GET, val, mpctx) <= 0) {
1429 case MP_CMD_EDL_MARK: 1641 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1430 if( edl_fd ) { 1642 "Failed to get value of property '%s'.\n",
1431 float v = sh_video ? sh_video->pts : 1643 cmd->args[0].v.s);
1432 playing_audio_pts(sh_audio, mpctx->d_audio, mpctx->audio_out); 1644 break;
1433 1645 }
1434 if (mpctx->begin_skip == MP_NOPTS_VALUE) 1646 tmp = m_option_print(prop, val);
1435 { 1647 if (!tmp || tmp == (char *) -1) {
1436 mpctx->begin_skip = v; 1648 mp_msg(MSGT_CPLAYER, MSGL_WARN,
1437 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip); 1649 "Failed to print value of property '%s'.\n",
1438 }else{ 1650 cmd->args[0].v.s);
1439 if (mpctx->begin_skip > v) 1651 break;
1440 { 1652 }
1441 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop); 1653 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_%s=%s\n",
1442 }else{ 1654 cmd->args[0].v.s, tmp);
1443 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0); 1655 free(tmp);
1444 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip); 1656 }
1445 } 1657 break;
1446 mpctx->begin_skip = MP_NOPTS_VALUE; 1658
1659 case MP_CMD_EDL_MARK:
1660 if (edl_fd) {
1661 float v = sh_video ? sh_video->pts :
1662 playing_audio_pts(sh_audio, mpctx->d_audio,
1663 mpctx->audio_out);
1664
1665 if (mpctx->begin_skip == MP_NOPTS_VALUE) {
1666 mpctx->begin_skip = v;
1667 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip);
1668 } else {
1669 if (mpctx->begin_skip > v)
1670 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop);
1671 else {
1672 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0);
1673 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip);
1674 }
1675 mpctx->begin_skip = MP_NOPTS_VALUE;
1676 }
1677 }
1678 break;
1679
1680 case MP_CMD_SWITCH_RATIO:
1681 if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
1682 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
1683 else
1684 movie_aspect = cmd->args[0].v.f;
1685 mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0);
1686 break;
1687
1688 case MP_CMD_SPEED_INCR:{
1689 float v = cmd->args[0].v.f;
1690 playback_speed += v;
1691 build_afilter_chain(sh_audio, &ao_data);
1692 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
1693 playback_speed);
1694 } break;
1695
1696 case MP_CMD_SPEED_MULT:{
1697 float v = cmd->args[0].v.f;
1698 playback_speed *= v;
1699 build_afilter_chain(sh_audio, &ao_data);
1700 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
1701 playback_speed);
1702 } break;
1703
1704 case MP_CMD_SPEED_SET:{
1705 float v = cmd->args[0].v.f;
1706 playback_speed = v;
1707 build_afilter_chain(sh_audio, &ao_data);
1708 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
1709 playback_speed);
1710 } break;
1711
1712 case MP_CMD_FRAME_STEP:
1713 case MP_CMD_PAUSE:
1714 cmd->pausing = 1;
1715 brk_cmd = 1;
1716 break;
1717
1718 case MP_CMD_FILE_FILTER:
1719 file_filter = cmd->args[0].v.i;
1720 break;
1721
1722 case MP_CMD_QUIT:
1723 exit_player_with_rc(MSGTR_Exit_quit,
1724 (cmd->nargs > 0) ? cmd->args[0].v.i : 0);
1725
1726 case MP_CMD_PLAY_TREE_STEP:{
1727 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i;
1728 int force = cmd->args[1].v.i;
1729
1730 #ifdef HAVE_NEW_GUI
1731 if (use_gui) {
1732 int i = 0;
1733 if (n > 0)
1734 for (i = 0; i < n; i++)
1735 mplNext();
1736 else
1737 for (i = 0; i < -1 * n; i++)
1738 mplPrev();
1739 } else
1740 #endif
1741 {
1742 if (!force && mpctx->playtree_iter) {
1743 play_tree_iter_t *i =
1744 play_tree_iter_new_copy(mpctx->playtree_iter);
1745 if (play_tree_iter_step(i, n, 0) ==
1746 PLAY_TREE_ITER_ENTRY)
1747 mpctx->eof =
1748 (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
1749 play_tree_iter_free(i);
1750 } else
1751 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
1752 if (mpctx->eof)
1753 mpctx->play_tree_step = n;
1754 brk_cmd = 1;
1755 }
1756 }
1757 break;
1758
1759 case MP_CMD_PLAY_TREE_UP_STEP:{
1760 int n = cmd->args[0].v.i > 0 ? 1 : -1;
1761 int force = cmd->args[1].v.i;
1762
1763 if (!force && mpctx->playtree_iter) {
1764 play_tree_iter_t *i =
1765 play_tree_iter_new_copy(mpctx->playtree_iter);
1766 if (play_tree_iter_up_step(i, n, 0) == PLAY_TREE_ITER_ENTRY)
1767 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
1768 play_tree_iter_free(i);
1769 } else
1770 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
1771 brk_cmd = 1;
1772 }
1773 break;
1774
1775 case MP_CMD_PLAY_ALT_SRC_STEP:
1776 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) {
1777 int v = cmd->args[0].v.i;
1778 if (v > 0
1779 && mpctx->playtree_iter->file <
1780 mpctx->playtree_iter->num_files)
1781 mpctx->eof = PT_NEXT_SRC;
1782 else if (v < 0 && mpctx->playtree_iter->file > 1)
1783 mpctx->eof = PT_PREV_SRC;
1784 }
1785 brk_cmd = 1;
1786 break;
1787
1788 case MP_CMD_SUB_STEP:
1789 if (sh_video) {
1790 int movement = cmd->args[0].v.i;
1791 step_sub(subdata, sh_video->pts, movement);
1792 #ifdef USE_ASS
1793 if (ass_track)
1794 sub_delay +=
1795 ass_step_sub(ass_track,
1796 (sh_video->pts +
1797 sub_delay) * 1000 + .5, movement) / 1000.;
1798 #endif
1799 set_osd_msg(OSD_MSG_SUB_DELAY, 1, osd_duration,
1800 MSGTR_OSDSubDelay, ROUND(sub_delay * 1000));
1801 }
1802 break;
1803
1804 case MP_CMD_SUB_LOG:
1805 log_sub();
1806 break;
1807
1808 case MP_CMD_OSD:{
1809 int v = cmd->args[0].v.i;
1810 int max = (term_osd
1811 && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
1812 if (osd_level > max)
1813 osd_level = max;
1814 if (v < 0)
1815 osd_level = (osd_level + 1) % (max + 1);
1816 else
1817 osd_level = v > max ? max : v;
1818 /* Show OSD state when disabled, but not when an explicit
1819 argument is given to the OSD command, i.e. in slave mode. */
1820 if (v == -1 && osd_level <= 1)
1821 set_osd_msg(OSD_MSG_OSD_STATUS, 0, osd_duration,
1822 MSGTR_OSDosd,
1823 osd_level ? MSGTR_OSDenabled :
1824 MSGTR_OSDdisabled);
1825 else
1826 rm_osd_msg(OSD_MSG_OSD_STATUS);
1827 }
1828 break;
1829
1830 case MP_CMD_OSD_SHOW_TEXT:
1831 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i,
1832 (cmd->args[1].v.i <
1833 0 ? osd_duration : cmd->args[1].v.i),
1834 "%-.63s", cmd->args[0].v.s);
1835 break;
1836
1837 case MP_CMD_OSD_SHOW_PROPERTY_TEXT:{
1838 char *txt = m_properties_expand_string(mp_properties,
1839 cmd->args[0].v.s,
1840 mpctx);
1841 /* if no argument supplied take default osd_duration, else <arg> ms. */
1842 if (txt) {
1843 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i,
1844 (cmd->args[1].v.i <
1845 0 ? osd_duration : cmd->args[1].v.i),
1846 "%-.63s", txt);
1847 free(txt);
1848 }
1849 }
1850 break;
1851
1852 case MP_CMD_LOADFILE:{
1853 play_tree_t *e = play_tree_new();
1854 play_tree_add_file(e, cmd->args[0].v.s);
1855
1856 if (cmd->args[1].v.i) // append
1857 play_tree_append_entry(mpctx->playtree, e);
1858 else {
1859 // Go back to the starting point.
1860 while (play_tree_iter_up_step
1861 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
1862 /* NOP */ ;
1863 play_tree_free_list(mpctx->playtree->child, 1);
1864 play_tree_set_child(mpctx->playtree, e);
1865 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
1866 mpctx->eof = PT_NEXT_SRC;
1867 }
1868 brk_cmd = 1;
1869 }
1870 break;
1871
1872 case MP_CMD_LOADLIST:{
1873 play_tree_t *e = parse_playlist_file(cmd->args[0].v.s);
1874 if (!e)
1875 mp_msg(MSGT_CPLAYER, MSGL_ERR,
1876 MSGTR_PlaylistLoadUnable, cmd->args[0].v.s);
1877 else {
1878 if (cmd->args[1].v.i) // append
1879 play_tree_append_entry(mpctx->playtree, e);
1880 else {
1881 // Go back to the starting point.
1882 while (play_tree_iter_up_step
1883 (mpctx->playtree_iter, 0, 1)
1884 != PLAY_TREE_ITER_END)
1885 /* NOP */ ;
1886 play_tree_free_list(mpctx->playtree->child, 1);
1887 play_tree_set_child(mpctx->playtree, e);
1888 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
1889 mpctx->eof = PT_NEXT_SRC;
1890 }
1891 }
1892 brk_cmd = 1;
1893 }
1894 break;
1895
1896 #ifdef USE_RADIO
1897 case MP_CMD_RADIO_STEP_CHANNEL:
1898 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
1899 int v = cmd->args[0].v.i;
1900 if (v > 0)
1901 radio_step_channel(mpctx->demuxer->stream,
1902 RADIO_CHANNEL_HIGHER);
1903 else
1904 radio_step_channel(mpctx->demuxer->stream,
1905 RADIO_CHANNEL_LOWER);
1906 if (radio_get_channel_name(mpctx->demuxer->stream)) {
1907 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
1908 MSGTR_OSDChannel,
1909 radio_get_channel_name(mpctx->demuxer->stream));
1910 }
1911 }
1912 break;
1913
1914 case MP_CMD_RADIO_SET_CHANNEL:
1915 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
1916 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s);
1917 if (radio_get_channel_name(mpctx->demuxer->stream)) {
1918 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
1919 MSGTR_OSDChannel,
1920 radio_get_channel_name(mpctx->demuxer->stream));
1921 }
1922 }
1923 break;
1924
1925 case MP_CMD_RADIO_SET_FREQ:
1926 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
1927 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
1928 break;
1929
1930 case MP_CMD_RADIO_STEP_FREQ:
1931 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
1932 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
1933 break;
1934 #endif
1935
1936 #ifdef USE_TV
1937 case MP_CMD_TV_SET_FREQ:
1938 if (mpctx->file_format == DEMUXER_TYPE_TV)
1939 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv),
1940 cmd->args[0].v.f * 16.0);
1941 break;
1942
1943 case MP_CMD_TV_SET_NORM:
1944 if (mpctx->file_format == DEMUXER_TYPE_TV)
1945 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv),
1946 cmd->args[0].v.s);
1947 break;
1948
1949 case MP_CMD_TV_STEP_CHANNEL:{
1950 if (mpctx->file_format == DEMUXER_TYPE_TV) {
1951 int v = cmd->args[0].v.i;
1952 if (v > 0) {
1953 tv_step_channel((tvi_handle_t *) (mpctx->
1954 demuxer->priv),
1955 TV_CHANNEL_HIGHER);
1956 } else {
1957 tv_step_channel((tvi_handle_t *) (mpctx->
1958 demuxer->priv),
1959 TV_CHANNEL_LOWER);
1960 }
1961 if (tv_channel_list) {
1962 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
1963 MSGTR_OSDChannel, tv_channel_current->name);
1964 //vo_osd_changed(OSDTYPE_SUBTITLE);
1965 }
1966 }
1967 }
1968 #ifdef HAS_DVBIN_SUPPORT
1969 if ((mpctx->stream->type == STREAMTYPE_DVB)
1970 && mpctx->stream->priv) {
1971 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
1972 if (priv->is_on) {
1973 int dir;
1974 int v = cmd->args[0].v.i;
1975
1976 mpctx->last_dvb_step = v;
1977 if (v > 0)
1978 dir = DVB_CHANNEL_HIGHER;
1979 else
1980 dir = DVB_CHANNEL_LOWER;
1981
1982
1983 if (dvb_step_channel(priv, dir))
1984 mpctx->eof = mpctx->dvbin_reopen = 1;
1985 }
1986 }
1987 #endif /* HAS_DVBIN_SUPPORT */
1988 break;
1989
1990 case MP_CMD_TV_SET_CHANNEL:
1991 if (mpctx->file_format == DEMUXER_TYPE_TV) {
1992 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv),
1993 cmd->args[0].v.s);
1994 if (tv_channel_list) {
1995 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
1996 MSGTR_OSDChannel, tv_channel_current->name);
1997 //vo_osd_changed(OSDTYPE_SUBTITLE);
1998 }
1999 }
2000 break;
2001
2002 #ifdef HAS_DVBIN_SUPPORT
2003 case MP_CMD_DVB_SET_CHANNEL:
2004 if ((mpctx->stream->type == STREAMTYPE_DVB)
2005 && mpctx->stream->priv) {
2006 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
2007 if (priv->is_on) {
2008 if (priv->list->current <= cmd->args[0].v.i)
2009 mpctx->last_dvb_step = 1;
2010 else
2011 mpctx->last_dvb_step = -1;
2012
2013 if (dvb_set_channel
2014 (priv, cmd->args[1].v.i, cmd->args[0].v.i))
2015 mpctx->eof = mpctx->dvbin_reopen = 1;
2016 }
2017 }
2018 break;
2019 #endif /* HAS_DVBIN_SUPPORT */
2020
2021 case MP_CMD_TV_LAST_CHANNEL:
2022 if (mpctx->file_format == DEMUXER_TYPE_TV) {
2023 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
2024 if (tv_channel_list) {
2025 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
2026 MSGTR_OSDChannel, tv_channel_current->name);
2027 //vo_osd_changed(OSDTYPE_SUBTITLE);
2028 }
2029 }
2030 break;
2031
2032 case MP_CMD_TV_STEP_NORM:
2033 if (mpctx->file_format == DEMUXER_TYPE_TV)
2034 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv));
2035 break;
2036
2037 case MP_CMD_TV_STEP_CHANNEL_LIST:
2038 if (mpctx->file_format == DEMUXER_TYPE_TV)
2039 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
2040 break;
2041 #endif /* USE_TV */
2042
2043 case MP_CMD_SUB_LOAD:
2044 if (sh_video) {
2045 int n = mpctx->set_of_sub_size;
2046 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0);
2047 if (n != mpctx->set_of_sub_size) {
2048 if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0)
2049 mpctx->global_sub_indices[SUB_SOURCE_SUBS] =
2050 mpctx->global_sub_size;
2051 ++mpctx->global_sub_size;
2052 }
2053 }
2054 break;
2055
2056 case MP_CMD_SUB_REMOVE:
2057 if (sh_video) {
2058 int v = cmd->args[0].v.i;
2059 sub_data *subd;
2060 if (v < 0) {
2061 for (v = 0; v < mpctx->set_of_sub_size; ++v) {
2062 subd = mpctx->set_of_subtitles[v];
2063 mp_msg(MSGT_CPLAYER, MSGL_STATUS,
2064 MSGTR_RemovedSubtitleFile, v + 1,
2065 filename_recode(subd->filename));
2066 sub_free(subd);
2067 mpctx->set_of_subtitles[v] = NULL;
2068 }
2069 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
2070 mpctx->global_sub_size -= mpctx->set_of_sub_size;
2071 mpctx->set_of_sub_size = 0;
2072 if (mpctx->set_of_sub_pos >= 0) {
2073 mpctx->global_sub_pos = -2;
2074 vo_sub_last = vo_sub = NULL;
2075 vo_osd_changed(OSDTYPE_SUBTITLE);
2076 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
2077 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2078 }
2079 } else if (v < mpctx->set_of_sub_size) {
2080 subd = mpctx->set_of_subtitles[v];
2081 mp_msg(MSGT_CPLAYER, MSGL_STATUS,
2082 MSGTR_RemovedSubtitleFile, v + 1,
2083 filename_recode(subd->filename));
2084 sub_free(subd);
2085 if (mpctx->set_of_sub_pos == v) {
2086 mpctx->global_sub_pos = -2;
2087 vo_sub_last = vo_sub = NULL;
2088 vo_osd_changed(OSDTYPE_SUBTITLE);
2089 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
2090 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2091 } else if (mpctx->set_of_sub_pos > v) {
2092 --mpctx->set_of_sub_pos;
2093 --mpctx->global_sub_pos;
2094 }
2095 while (++v < mpctx->set_of_sub_size)
2096 mpctx->set_of_subtitles[v - 1] =
2097 mpctx->set_of_subtitles[v];
2098 --mpctx->set_of_sub_size;
2099 --mpctx->global_sub_size;
2100 if (mpctx->set_of_sub_size <= 0)
2101 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
2102 mpctx->set_of_subtitles[mpctx->set_of_sub_size] = NULL;
2103 }
2104 }
2105 break;
2106
2107 case MP_CMD_GET_SUB_VISIBILITY:
2108 if (sh_video) {
2109 mp_msg(MSGT_GLOBAL, MSGL_INFO,
2110 "ANS_SUB_VISIBILITY=%d\n", sub_visibility);
2111 }
2112 break;
2113
2114 case MP_CMD_SCREENSHOT:
2115 if (vo_config_count) {
2116 mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n");
2117 if (CONTROL_OK !=
2118 ((vf_instance_t *) sh_video->vfilter)->
2119 control(sh_video->vfilter, VFCTRL_SCREENSHOT,
2120 &cmd->args[0].v.i))
2121 mpctx->video_out->control(VOCTRL_SCREENSHOT, NULL);
2122 }
2123 break;
2124
2125 case MP_CMD_VF_CHANGE_RECTANGLE:
2126 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i);
2127 break;
2128
2129 case MP_CMD_GET_TIME_LENGTH:{
2130 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2lf\n",
2131 demuxer_get_time_length(mpctx->demuxer));
2132 }
2133 break;
2134
2135 case MP_CMD_GET_FILENAME:{
2136 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_FILENAME='%s'\n",
2137 get_metadata(META_NAME));
2138 }
2139 break;
2140
2141 case MP_CMD_GET_VIDEO_CODEC:{
2142 char *inf = get_metadata(META_VIDEO_CODEC);
2143 if (!inf)
2144 inf = strdup("");
2145 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf);
2146 free(inf);
2147 }
2148 break;
2149
2150 case MP_CMD_GET_VIDEO_BITRATE:{
2151 char *inf = get_metadata(META_VIDEO_BITRATE);
2152 if (!inf)
2153 inf = strdup("");
2154 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf);
2155 free(inf);
2156 }
2157 break;
2158
2159 case MP_CMD_GET_VIDEO_RESOLUTION:{
2160 char *inf = get_metadata(META_VIDEO_RESOLUTION);
2161 if (!inf)
2162 inf = strdup("");
2163 mp_msg(MSGT_GLOBAL, MSGL_INFO,
2164 "ANS_VIDEO_RESOLUTION='%s'\n", inf);
2165 free(inf);
2166 }
2167 break;
2168
2169 case MP_CMD_GET_AUDIO_CODEC:{
2170 char *inf = get_metadata(META_AUDIO_CODEC);
2171 if (!inf)
2172 inf = strdup("");
2173 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf);
2174 free(inf);
2175 }
2176 break;
2177
2178 case MP_CMD_GET_AUDIO_BITRATE:{
2179 char *inf = get_metadata(META_AUDIO_BITRATE);
2180 if (!inf)
2181 inf = strdup("");
2182 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf);
2183 free(inf);
2184 }
2185 break;
2186
2187 case MP_CMD_GET_AUDIO_SAMPLES:{
2188 char *inf = get_metadata(META_AUDIO_SAMPLES);
2189 if (!inf)
2190 inf = strdup("");
2191 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf);
2192 free(inf);
2193 }
2194 break;
2195
2196 case MP_CMD_GET_META_TITLE:{
2197 char *inf = get_metadata(META_INFO_TITLE);
2198 if (!inf)
2199 inf = strdup("");
2200 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TITLE='%s'\n", inf);
2201 free(inf);
2202 }
2203 break;
2204
2205 case MP_CMD_GET_META_ARTIST:{
2206 char *inf = get_metadata(META_INFO_ARTIST);
2207 if (!inf)
2208 inf = strdup("");
2209 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf);
2210 free(inf);
2211 }
2212 break;
2213
2214 case MP_CMD_GET_META_ALBUM:{
2215 char *inf = get_metadata(META_INFO_ALBUM);
2216 if (!inf)
2217 inf = strdup("");
2218 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf);
2219 free(inf);
2220 }
2221 break;
2222
2223 case MP_CMD_GET_META_YEAR:{
2224 char *inf = get_metadata(META_INFO_YEAR);
2225 if (!inf)
2226 inf = strdup("");
2227 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_YEAR='%s'\n", inf);
2228 free(inf);
2229 }
2230 break;
2231
2232 case MP_CMD_GET_META_COMMENT:{
2233 char *inf = get_metadata(META_INFO_COMMENT);
2234 if (!inf)
2235 inf = strdup("");
2236 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf);
2237 free(inf);
2238 }
2239 break;
2240
2241 case MP_CMD_GET_META_TRACK:{
2242 char *inf = get_metadata(META_INFO_TRACK);
2243 if (!inf)
2244 inf = strdup("");
2245 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TRACK='%s'\n", inf);
2246 free(inf);
2247 }
2248 break;
2249
2250 case MP_CMD_GET_META_GENRE:{
2251 char *inf = get_metadata(META_INFO_GENRE);
2252 if (!inf)
2253 inf = strdup("");
2254 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_GENRE='%s'\n", inf);
2255 free(inf);
2256 }
2257 break;
2258
2259 case MP_CMD_GET_VO_FULLSCREEN:
2260 if (mpctx->video_out && vo_config_count)
2261 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs);
2262 break;
2263
2264 case MP_CMD_GET_PERCENT_POS:
2265 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n",
2266 demuxer_get_percent_pos(mpctx->demuxer));
2267 break;
2268
2269 case MP_CMD_GET_TIME_POS:{
2270 float pos = 0;
2271 if (sh_video)
2272 pos = sh_video->pts;
2273 else if (sh_audio && mpctx->audio_out)
2274 pos =
2275 playing_audio_pts(sh_audio, mpctx->d_audio,
2276 mpctx->audio_out);
2277 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
2278 }
2279 break;
2280
2281 case MP_CMD_RUN:
2282 #ifndef __MINGW32__
2283 if (!fork()) {
2284 execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, NULL);
2285 exit(0);
2286 }
2287 #endif
2288 break;
2289
2290 case MP_CMD_KEYDOWN_EVENTS:
2291 mplayer_put_key(cmd->args[0].v.i);
2292 break;
2293
2294 case MP_CMD_SEEK_CHAPTER:{
2295 int seek = cmd->args[0].v.i;
2296 int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
2297 int chap;
2298 float next_pts = 0;
2299 int num_chapters;
2300 char *chapter_name;
2301
2302 rel_seek_secs = 0;
2303 abs_seek_pos = 0;
2304 chap =
2305 demuxer_seek_chapter(mpctx->demuxer, seek, abs,
2306 &next_pts, &num_chapters,
2307 &chapter_name);
2308 if (chap != -1) {
2309 if (next_pts > -1.0) {
2310 abs_seek_pos = 1;
2311 rel_seek_secs = next_pts;
2312 }
2313 if (chapter_name) {
2314 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
2315 MSGTR_OSDChapter, chap + 1, chapter_name);
2316 free(chapter_name);
2317 }
2318 } else {
2319 if (seek > 0)
2320 rel_seek_secs = 1000000000.;
2321 else
2322 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
2323 MSGTR_OSDChapter, 0, MSGTR_Unknown);
2324 }
2325 break;
2326 }
2327 break;
2328
2329 case MP_CMD_SET_MOUSE_POS:{
2330 int button = -1, pointer_x, pointer_y;
2331 double dx, dy;
2332 pointer_x = cmd->args[0].v.i;
2333 pointer_y = cmd->args[1].v.i;
2334 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
2335 #ifdef USE_DVDNAV
2336 if (mpctx->stream->type == STREAMTYPE_DVDNAV
2337 && dx > 0.0 && dy > 0.0) {
2338 pointer_x = (int) (dx * (double) sh_video->disp_w);
2339 pointer_y = (int) (dy * (double) sh_video->disp_h);
2340 mp_dvdnav_update_mouse_pos(mpctx->stream,
2341 pointer_x, pointer_y, &button);
2342 if (button > 0)
2343 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
2344 "Selected button number %d", button);
2345 }
2346 #endif
2347 }
2348 break;
2349
2350 #ifdef USE_DVDNAV
2351 case MP_CMD_DVDNAV:{
2352 int button = -1;
2353 if (mpctx->stream->type != STREAMTYPE_DVDNAV)
2354 break;
2355
2356 if (mp_dvdnav_handle_input
2357 (mpctx->stream, cmd->args[0].v.i, &button)) {
2358 uninit_player(INITED_ALL - (INITED_STREAM | INITED_INPUT |
2359 (fixed_vo ? INITED_VO : 0)));
2360 brk_cmd = 2;
2361 } else if (button > 0)
2362 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
2363 "Selected button number %d", button);
2364 }
2365 break;
2366 #endif
2367
2368 default:
2369 #ifdef HAVE_NEW_GUI
2370 if ((use_gui) && (cmd->id > MP_CMD_GUI_EVENTS))
2371 guiGetEvent(guiIEvent, (char *) cmd->id);
2372 else
2373 #endif
2374 mp_msg(MSGT_CPLAYER, MSGL_V,
2375 "Received unknown cmd %s\n", cmd->name);
1447 } 2376 }
1448 } 2377
1449 break; 2378 switch (cmd->pausing) {
1450 case MP_CMD_SWITCH_RATIO : { 2379 case 1: // "pausing"
1451 if (cmd->nargs == 0 || cmd->args[0].v.f == -1) 2380 mpctx->osd_function = OSD_PAUSE;
1452 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
1453 else
1454 movie_aspect = cmd->args[0].v.f;
1455 mpcodecs_config_vo (sh_video, sh_video->disp_w, sh_video->disp_h, 0);
1456 } break;
1457 case MP_CMD_SPEED_INCR : {
1458 float v = cmd->args[0].v.f;
1459 playback_speed += v;
1460 build_afilter_chain(sh_audio, &ao_data);
1461 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
1462 } break;
1463 case MP_CMD_SPEED_MULT : {
1464 float v = cmd->args[0].v.f;
1465 playback_speed *= v;
1466 build_afilter_chain(sh_audio, &ao_data);
1467 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
1468 } break;
1469 case MP_CMD_SPEED_SET : {
1470 float v = cmd->args[0].v.f;
1471 playback_speed = v;
1472 build_afilter_chain(sh_audio, &ao_data);
1473 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
1474 } break;
1475 case MP_CMD_FRAME_STEP :
1476 case MP_CMD_PAUSE : {
1477 cmd->pausing = 1;
1478 brk_cmd = 1;
1479 } break;
1480 case MP_CMD_FILE_FILTER : {
1481 file_filter = cmd->args[0].v.i;
1482 break;
1483 }
1484 case MP_CMD_QUIT : {
1485 exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
1486 }
1487 case MP_CMD_PLAY_TREE_STEP : {
1488 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i;
1489 int force = cmd->args[1].v.i;
1490
1491 #ifdef HAVE_NEW_GUI
1492 if (use_gui) {
1493 int i=0;
1494 if (n>0)
1495 for (i=0;i<n;i++)
1496 mplNext();
1497 else
1498 for (i=0;i<-1*n;i++)
1499 mplPrev();
1500 } else
1501 #endif
1502 {
1503 if (!force && mpctx->playtree_iter) {
1504 play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter);
1505
1506 if(play_tree_iter_step(i,n,0) == PLAY_TREE_ITER_ENTRY)
1507 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
1508 play_tree_iter_free(i);
1509 } else
1510 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
1511 if (mpctx->eof)
1512 mpctx->play_tree_step = n;
1513 brk_cmd = 1;
1514 }
1515 } break;
1516 case MP_CMD_PLAY_TREE_UP_STEP : {
1517 int n = cmd->args[0].v.i > 0 ? 1 : -1;
1518 int force = cmd->args[1].v.i;
1519
1520 if (!force && mpctx->playtree_iter) {
1521 play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter);
1522 if(play_tree_iter_up_step(i,n,0) == PLAY_TREE_ITER_ENTRY)
1523 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
1524 play_tree_iter_free(i);
1525 } else
1526 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
1527 brk_cmd = 1;
1528 } break;
1529 case MP_CMD_PLAY_ALT_SRC_STEP : {
1530 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) {
1531 int v = cmd->args[0].v.i;
1532 if (v > 0 && mpctx->playtree_iter->file < mpctx->playtree_iter->num_files)
1533 mpctx->eof = PT_NEXT_SRC;
1534 else if (v < 0 && mpctx->playtree_iter->file > 1)
1535 mpctx->eof = PT_PREV_SRC;
1536 }
1537 brk_cmd = 1;
1538 } break;
1539 case MP_CMD_SUB_STEP : {
1540 if (sh_video) {
1541 int movement = cmd->args[0].v.i;
1542 step_sub(subdata, sh_video->pts, movement);
1543 #ifdef USE_ASS
1544 if (ass_track)
1545 sub_delay += ass_step_sub(ass_track, (sh_video->pts + sub_delay) * 1000 + .5, movement) / 1000.;
1546 #endif
1547 set_osd_msg(OSD_MSG_SUB_DELAY,1,osd_duration,
1548 MSGTR_OSDSubDelay, ROUND(sub_delay*1000));
1549 }
1550 } break;
1551 case MP_CMD_SUB_LOG : {
1552 log_sub();
1553 } break;
1554 case MP_CMD_OSD : {
1555 int v = cmd->args[0].v.i;
1556 int max = (term_osd && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
1557 if(osd_level > max) osd_level = max;
1558 if(v < 0)
1559 osd_level=(osd_level+1)%(max+1);
1560 else
1561 osd_level= v > max ? max : v;
1562 /* Show OSD state when disabled, but not when an explicit
1563 argument is given to the OSD command, i.e. in slave mode. */
1564 if (v == -1 && osd_level <= 1)
1565 set_osd_msg(OSD_MSG_OSD_STATUS,0,osd_duration,
1566 MSGTR_OSDosd, osd_level ? MSGTR_OSDenabled : MSGTR_OSDdisabled);
1567 else
1568 rm_osd_msg(OSD_MSG_OSD_STATUS);
1569 } break;
1570 case MP_CMD_OSD_SHOW_TEXT : {
1571 set_osd_msg(OSD_MSG_TEXT,cmd->args[2].v.i,
1572 (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
1573 "%-.63s",cmd->args[0].v.s);
1574 } break;
1575 case MP_CMD_OSD_SHOW_PROPERTY_TEXT : {
1576 char *txt = m_properties_expand_string(mp_properties,cmd->args[0].v.s,mpctx);
1577 /* if no argument supplied take default osd_duration, else <arg> ms. */
1578 if(txt) {
1579 set_osd_msg(OSD_MSG_TEXT,cmd->args[2].v.i,
1580 (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
1581 "%-.63s",txt);
1582 free(txt);
1583 }
1584 } break;
1585 case MP_CMD_LOADFILE : {
1586 play_tree_t* e = play_tree_new();
1587 play_tree_add_file(e,cmd->args[0].v.s);
1588
1589 if (cmd->args[1].v.i) // append
1590 play_tree_append_entry(mpctx->playtree, e);
1591 else {
1592 // Go back to the starting point.
1593 while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
1594 /* NOP */;
1595 play_tree_free_list(mpctx->playtree->child, 1);
1596 play_tree_set_child(mpctx->playtree, e);
1597 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
1598 mpctx->eof = PT_NEXT_SRC;
1599 }
1600 brk_cmd = 1;
1601 } break;
1602 case MP_CMD_LOADLIST : {
1603 play_tree_t* e = parse_playlist_file(cmd->args[0].v.s);
1604 if(!e)
1605 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_PlaylistLoadUnable,cmd->args[0].v.s);
1606 else {
1607 if (cmd->args[1].v.i) // append
1608 play_tree_append_entry(mpctx->playtree, e);
1609 else {
1610 // Go back to the starting point.
1611 while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
1612 /* NOP */;
1613 play_tree_free_list(mpctx->playtree->child, 1);
1614 play_tree_set_child(mpctx->playtree, e);
1615 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
1616 mpctx->eof = PT_NEXT_SRC;
1617 }
1618 }
1619 brk_cmd = 1;
1620 } break;
1621 #ifdef USE_RADIO
1622 case MP_CMD_RADIO_STEP_CHANNEL : {
1623 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
1624 int v = cmd->args[0].v.i;
1625 if(v > 0)
1626 radio_step_channel(mpctx->demuxer->stream, RADIO_CHANNEL_HIGHER);
1627 else
1628 radio_step_channel(mpctx->demuxer->stream, RADIO_CHANNEL_LOWER);
1629 if (radio_get_channel_name(mpctx->demuxer->stream)) {
1630 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
1631 MSGTR_OSDChannel, radio_get_channel_name(mpctx->demuxer->stream));
1632 }
1633 }
1634 } break;
1635 case MP_CMD_RADIO_SET_CHANNEL : {
1636 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
1637 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s);
1638 if (radio_get_channel_name(mpctx->demuxer->stream)) {
1639 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
1640 MSGTR_OSDChannel, radio_get_channel_name(mpctx->demuxer->stream));
1641 }
1642 }
1643 } break;
1644 case MP_CMD_RADIO_SET_FREQ : {
1645 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
1646 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
1647 } break;
1648 case MP_CMD_RADIO_STEP_FREQ :
1649 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
1650 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
1651 }
1652 break;
1653 #endif
1654 #ifdef USE_TV
1655 case MP_CMD_TV_SET_FREQ : {
1656 if (mpctx->file_format == DEMUXER_TYPE_TV)
1657 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.f * 16.0);
1658 } break;
1659 case MP_CMD_TV_SET_NORM : {
1660 if (mpctx->file_format == DEMUXER_TYPE_TV)
1661 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.s);
1662 } break;
1663 case MP_CMD_TV_STEP_CHANNEL : {
1664 if (mpctx->file_format == DEMUXER_TYPE_TV) {
1665 int v = cmd->args[0].v.i;
1666 if(v > 0){
1667 tv_step_channel((tvi_handle_t *) (mpctx->demuxer->priv), TV_CHANNEL_HIGHER);
1668 } else {
1669 tv_step_channel((tvi_handle_t *) (mpctx->demuxer->priv), TV_CHANNEL_LOWER);
1670 }
1671 if (tv_channel_list) {
1672 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
1673 MSGTR_OSDChannel, tv_channel_current->name);
1674 //vo_osd_changed(OSDTYPE_SUBTITLE);
1675 }
1676 }
1677 }
1678 #ifdef HAS_DVBIN_SUPPORT
1679 if ((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv)
1680 {
1681 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
1682 if(priv->is_on)
1683 {
1684 int dir;
1685 int v = cmd->args[0].v.i;
1686
1687 mpctx->last_dvb_step = v;
1688 if(v > 0)
1689 dir = DVB_CHANNEL_HIGHER;
1690 else
1691 dir = DVB_CHANNEL_LOWER;
1692
1693
1694 if(dvb_step_channel(priv, dir))
1695 mpctx->eof = mpctx->dvbin_reopen = 1;
1696 }
1697 }
1698 #endif /* HAS_DVBIN_SUPPORT */
1699 break;
1700 case MP_CMD_TV_SET_CHANNEL : {
1701 if (mpctx->file_format == DEMUXER_TYPE_TV) {
1702 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.s);
1703 if (tv_channel_list) {
1704 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
1705 MSGTR_OSDChannel, tv_channel_current->name);
1706 //vo_osd_changed(OSDTYPE_SUBTITLE);
1707 }
1708 }
1709 } break;
1710 #ifdef HAS_DVBIN_SUPPORT
1711 case MP_CMD_DVB_SET_CHANNEL:
1712 {
1713 if ((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv)
1714 {
1715 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
1716 if(priv->is_on)
1717 {
1718 if(priv->list->current <= cmd->args[0].v.i)
1719 mpctx->last_dvb_step = 1;
1720 else
1721 mpctx->last_dvb_step = -1;
1722
1723 if(dvb_set_channel(priv, cmd->args[1].v.i, cmd->args[0].v.i))
1724 mpctx->eof = mpctx->dvbin_reopen = 1;
1725 }
1726 }
1727 }
1728 break;
1729 #endif /* HAS_DVBIN_SUPPORT */
1730 case MP_CMD_TV_LAST_CHANNEL : {
1731 if (mpctx->file_format == DEMUXER_TYPE_TV) {
1732 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
1733 if (tv_channel_list) {
1734 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
1735 MSGTR_OSDChannel, tv_channel_current->name);
1736 //vo_osd_changed(OSDTYPE_SUBTITLE);
1737 }
1738 }
1739 } break;
1740 case MP_CMD_TV_STEP_NORM : {
1741 if (mpctx->file_format == DEMUXER_TYPE_TV)
1742 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv));
1743 } break;
1744 case MP_CMD_TV_STEP_CHANNEL_LIST : {
1745 if (mpctx->file_format == DEMUXER_TYPE_TV)
1746 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
1747 } break;
1748 #endif /* USE_TV */
1749 case MP_CMD_SUB_LOAD:
1750 {
1751 if (sh_video) {
1752 int n = mpctx->set_of_sub_size;
1753 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0);
1754 if (n != mpctx->set_of_sub_size) {
1755 if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0)
1756 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = mpctx->global_sub_size;
1757 ++mpctx->global_sub_size;
1758 }
1759 }
1760 } break;
1761 case MP_CMD_SUB_REMOVE:
1762 {
1763 if (sh_video) {
1764 int v = cmd->args[0].v.i;
1765 sub_data *subd;
1766 if (v < 0) {
1767 for (v = 0; v < mpctx->set_of_sub_size; ++v) {
1768 subd = mpctx->set_of_subtitles[v];
1769 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
1770 filename_recode(subd->filename));
1771 sub_free(subd);
1772 mpctx->set_of_subtitles[v] = NULL;
1773 }
1774 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
1775 mpctx->global_sub_size -= mpctx->set_of_sub_size;
1776 mpctx->set_of_sub_size = 0;
1777 if (mpctx->set_of_sub_pos >= 0) {
1778 mpctx->global_sub_pos = -2;
1779 vo_sub_last = vo_sub = NULL;
1780 vo_osd_changed(OSDTYPE_SUBTITLE);
1781 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
1782 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
1783 }
1784 }
1785 else if (v < mpctx->set_of_sub_size) {
1786 subd = mpctx->set_of_subtitles[v];
1787 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
1788 filename_recode(subd->filename));
1789 sub_free(subd);
1790 if (mpctx->set_of_sub_pos == v) {
1791 mpctx->global_sub_pos = -2;
1792 vo_sub_last = vo_sub = NULL;
1793 vo_osd_changed(OSDTYPE_SUBTITLE);
1794 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
1795 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
1796 }
1797 else if (mpctx->set_of_sub_pos > v) {
1798 --mpctx->set_of_sub_pos;
1799 --mpctx->global_sub_pos;
1800 }
1801 while (++v < mpctx->set_of_sub_size)
1802 mpctx->set_of_subtitles[v - 1] = mpctx->set_of_subtitles[v];
1803 --mpctx->set_of_sub_size;
1804 --mpctx->global_sub_size;
1805 if (mpctx->set_of_sub_size <= 0)
1806 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
1807 mpctx->set_of_subtitles[mpctx->set_of_sub_size] = NULL;
1808 }
1809 }
1810 } break;
1811 case MP_CMD_GET_SUB_VISIBILITY:
1812 {
1813 if (sh_video) {
1814 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_SUB_VISIBILITY=%d\n", sub_visibility);
1815 }
1816 } break;
1817 case MP_CMD_SCREENSHOT :
1818 if(vo_config_count){
1819 mp_msg(MSGT_CPLAYER,MSGL_INFO,"sending VFCTRL_SCREENSHOT!\n");
1820 if(CONTROL_OK!=((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SCREENSHOT, &cmd->args[0].v.i))
1821 mpctx->video_out->control(VOCTRL_SCREENSHOT, NULL);
1822 }
1823 break;
1824 case MP_CMD_VF_CHANGE_RECTANGLE:
1825 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i);
1826 break; 2381 break;
1827 2382 case 3: // "pausing_toggle"
1828 case MP_CMD_GET_TIME_LENGTH : { 2383 mpctx->was_paused = !mpctx->was_paused;
1829 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2lf\n", demuxer_get_time_length(mpctx->demuxer)); 2384 // fall through
1830 } break; 2385 case 2: // "pausing_keep"
1831 2386 if (mpctx->was_paused)
1832 case MP_CMD_GET_FILENAME : { 2387 mpctx->osd_function = OSD_PAUSE;
1833 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_FILENAME='%s'\n", get_metadata (META_NAME)); 2388 }
1834 } break;
1835
1836 case MP_CMD_GET_VIDEO_CODEC : {
1837 char *inf = get_metadata (META_VIDEO_CODEC);
1838 if (!inf) inf = strdup ("");
1839 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf);
1840 free (inf);
1841 } break;
1842
1843 case MP_CMD_GET_VIDEO_BITRATE : {
1844 char *inf = get_metadata (META_VIDEO_BITRATE);
1845 if (!inf) inf = strdup ("");
1846 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf);
1847 free (inf);
1848 } break;
1849
1850 case MP_CMD_GET_VIDEO_RESOLUTION : {
1851 char *inf = get_metadata (META_VIDEO_RESOLUTION);
1852 if (!inf) inf = strdup ("");
1853 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_RESOLUTION='%s'\n", inf);
1854 free (inf);
1855 } break;
1856
1857 case MP_CMD_GET_AUDIO_CODEC : {
1858 char *inf = get_metadata (META_AUDIO_CODEC);
1859 if (!inf) inf = strdup ("");
1860 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf);
1861 free (inf);
1862 } break;
1863
1864 case MP_CMD_GET_AUDIO_BITRATE : {
1865 char *inf = get_metadata (META_AUDIO_BITRATE);
1866 if (!inf) inf = strdup ("");
1867 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf);
1868 free (inf);
1869 } break;
1870
1871 case MP_CMD_GET_AUDIO_SAMPLES : {
1872 char *inf = get_metadata (META_AUDIO_SAMPLES);
1873 if (!inf) inf = strdup ("");
1874 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf);
1875 free (inf);
1876 } break;
1877
1878 case MP_CMD_GET_META_TITLE : {
1879 char *inf = get_metadata (META_INFO_TITLE);
1880 if (!inf) inf = strdup ("");
1881 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_TITLE='%s'\n", inf);
1882 free (inf);
1883 } break;
1884
1885 case MP_CMD_GET_META_ARTIST : {
1886 char *inf = get_metadata (META_INFO_ARTIST);
1887 if (!inf) inf = strdup ("");
1888 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf);
1889 free (inf);
1890 } break;
1891
1892 case MP_CMD_GET_META_ALBUM : {
1893 char *inf = get_metadata (META_INFO_ALBUM);
1894 if (!inf) inf = strdup ("");
1895 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf);
1896 free (inf);
1897 } break;
1898
1899 case MP_CMD_GET_META_YEAR : {
1900 char *inf = get_metadata (META_INFO_YEAR);
1901 if (!inf) inf = strdup ("");
1902 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_YEAR='%s'\n", inf);
1903 free (inf);
1904 } break;
1905
1906 case MP_CMD_GET_META_COMMENT : {
1907 char *inf = get_metadata (META_INFO_COMMENT);
1908 if (!inf) inf = strdup ("");
1909 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf);
1910 free (inf);
1911 } break;
1912
1913 case MP_CMD_GET_META_TRACK : {
1914 char *inf = get_metadata (META_INFO_TRACK);
1915 if (!inf) inf = strdup ("");
1916 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_TRACK='%s'\n", inf);
1917 free (inf);
1918 } break;
1919
1920 case MP_CMD_GET_META_GENRE : {
1921 char *inf = get_metadata (META_INFO_GENRE);
1922 if (!inf) inf = strdup ("");
1923 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_GENRE='%s'\n", inf);
1924 free (inf);
1925 } break;
1926
1927 case MP_CMD_GET_VO_FULLSCREEN : {
1928 if (mpctx->video_out && vo_config_count)
1929 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs);
1930 } break;
1931
1932 case MP_CMD_GET_PERCENT_POS : {
1933 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n", demuxer_get_percent_pos(mpctx->demuxer));
1934 } break;
1935 case MP_CMD_GET_TIME_POS : {
1936 float pos = 0;
1937 if (sh_video)
1938 pos = sh_video->pts;
1939 else
1940 if (sh_audio && mpctx->audio_out)
1941 pos = playing_audio_pts(sh_audio, mpctx->d_audio, mpctx->audio_out);
1942 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
1943 } break;
1944 case MP_CMD_RUN : {
1945 #ifndef __MINGW32__
1946 if(!fork()) {
1947 execl("/bin/sh","sh","-c",cmd->args[0].v.s,NULL);
1948 exit(0);
1949 }
1950 #endif
1951 } break;
1952 case MP_CMD_KEYDOWN_EVENTS : {
1953 mplayer_put_key(cmd->args[0].v.i);
1954 } break;
1955 case MP_CMD_SEEK_CHAPTER : {
1956 int seek = cmd->args[0].v.i;
1957 int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
1958 int chap;
1959 float next_pts = 0;
1960 int num_chapters;
1961 char *chapter_name;
1962
1963 rel_seek_secs = 0;
1964 abs_seek_pos = 0;
1965 chap = demuxer_seek_chapter(mpctx->demuxer, seek, abs, &next_pts, &num_chapters, &chapter_name);
1966 if(chap != -1) {
1967 if(next_pts > -1.0) {
1968 abs_seek_pos = 1;
1969 rel_seek_secs = next_pts;
1970 }
1971 if(chapter_name) {
1972 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter,
1973 chap+1, chapter_name);
1974 free(chapter_name);
1975 }
1976 } else {
1977 if (seek > 0)
1978 rel_seek_secs = 1000000000.;
1979 else
1980 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter, 0, MSGTR_Unknown);
1981 }
1982 break;
1983 } break;
1984 case MP_CMD_SET_MOUSE_POS: {
1985 int button = -1, pointer_x, pointer_y;
1986 double dx, dy;
1987 pointer_x = cmd->args[0].v.i;
1988 pointer_y = cmd->args[1].v.i;
1989 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
1990 #ifdef USE_DVDNAV
1991 if (mpctx->stream->type == STREAMTYPE_DVDNAV && dx > 0.0 && dy > 0.0) {
1992 pointer_x = (int) (dx * (double) sh_video->disp_w);
1993 pointer_y = (int) (dy * (double) sh_video->disp_h);
1994 mp_dvdnav_update_mouse_pos(mpctx->stream, pointer_x, pointer_y, &button);
1995 if(button>0) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Selected button number %d", button);
1996 }
1997 #endif
1998 break;
1999 }
2000 #ifdef USE_DVDNAV
2001 case MP_CMD_DVDNAV: {
2002 int button = -1;
2003 if (mpctx->stream->type != STREAMTYPE_DVDNAV) break;
2004
2005 if (mp_dvdnav_handle_input (mpctx->stream, cmd->args[0].v.i, &button)) {
2006 uninit_player(INITED_ALL-(INITED_STREAM|INITED_INPUT|(fixed_vo ? INITED_VO : 0)));
2007 brk_cmd = 2;
2008 } else if(button>0) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Selected button number %d", button);
2009 break;
2010 }
2011 #endif
2012 default : {
2013 #ifdef HAVE_NEW_GUI
2014 if ( ( use_gui )&&( cmd->id > MP_CMD_GUI_EVENTS ) ) guiGetEvent( guiIEvent,(char *)cmd->id );
2015 else
2016 #endif
2017 mp_msg(MSGT_CPLAYER, MSGL_V, "Received unknown cmd %s\n",cmd->name);
2018 }
2019 }
2020 switch (cmd->pausing) {
2021 case 1: // "pausing"
2022 mpctx->osd_function = OSD_PAUSE;
2023 break;
2024 case 3: // "pausing_toggle"
2025 mpctx->was_paused = !mpctx->was_paused;
2026 // fall through
2027 case 2: // "pausing_keep"
2028 if (mpctx->was_paused) mpctx->osd_function = OSD_PAUSE;
2029 }
2030 return brk_cmd; 2389 return brk_cmd;
2031 } 2390 }