comparison command.c @ 31077:dd7f15a3fb1b

the great MPlayer tab removal: part II some extra indentation fixes are put in as a bonus
author diego
date Mon, 03 May 2010 23:34:38 +0000
parents 8d840754a921
children 69d662752608
comparison
equal deleted inserted replaced
31076:783f8faee539 31077:dd7f15a3fb1b
71 extern int use_menu; 71 extern int use_menu;
72 72
73 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) 73 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy)
74 { 74 {
75 //remove the borders, if any, and rescale to the range [0,1],[0,1] 75 //remove the borders, if any, and rescale to the range [0,1],[0,1]
76 if (vo_fs) { //we are in full-screen mode 76 if (vo_fs) { //we are in full-screen mode
77 if (vo_screenwidth > vo_dwidth) //there are borders along the x axis 77 if (vo_screenwidth > vo_dwidth) //there are borders along the x axis
78 ix -= (vo_screenwidth - vo_dwidth) / 2; 78 ix -= (vo_screenwidth - vo_dwidth) / 2;
79 if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way) 79 if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
80 iy -= (vo_screenheight - vo_dheight) / 2; 80 iy -= (vo_screenheight - vo_dheight) / 2;
81 81
82 if (ix < 0 || ix > vo_dwidth) { 82 if (ix < 0 || ix > vo_dwidth) {
83 *dx = *dy = -1.0; 83 *dx = *dy = -1.0;
84 return; 84 return;
85 } //we are on one of the borders 85 } //we are on one of the borders
86 if (iy < 0 || iy > vo_dheight) { 86 if (iy < 0 || iy > vo_dheight) {
87 *dx = *dy = -1.0; 87 *dx = *dy = -1.0;
88 return; 88 return;
89 } //we are on one of the borders 89 } //we are on one of the borders
90 } 90 }
91 91
92 *dx = (double) ix / (double) vo_dwidth; 92 *dx = (double) ix / (double) vo_dwidth;
93 *dy = (double) iy / (double) vo_dheight; 93 *dy = (double) iy / (double) vo_dheight;
94 94
95 mp_msg(MSGT_CPLAYER, MSGL_V, 95 mp_msg(MSGT_CPLAYER, MSGL_V,
96 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n", 96 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
97 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, 97 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth,
98 vo_dheight, vo_fs); 98 vo_dheight, vo_fs);
99 } 99 }
100 100
101 static int sub_source_by_pos(MPContext * mpctx, int pos) 101 static int sub_source_by_pos(MPContext * mpctx, int pos)
102 { 102 {
103 int source = -1; 103 int source = -1;
104 int top = -1; 104 int top = -1;
105 int i; 105 int i;
106 for (i = 0; i < SUB_SOURCES; i++) { 106 for (i = 0; i < SUB_SOURCES; i++) {
107 int j = mpctx->global_sub_indices[i]; 107 int j = mpctx->global_sub_indices[i];
108 if ((j >= 0) && (j > top) && (pos >= j)) { 108 if ((j >= 0) && (j > top) && (pos >= j)) {
109 source = i; 109 source = i;
110 top = j; 110 top = j;
111 } 111 }
112 } 112 }
113 return source; 113 return source;
114 } 114 }
115 115
116 static int sub_source(MPContext * mpctx) 116 static int sub_source(MPContext * mpctx)
133 char *fname; 133 char *fname;
134 FILE *f; 134 FILE *f;
135 int i; 135 int i;
136 136
137 if (subdata == NULL || vo_sub_last == NULL) 137 if (subdata == NULL || vo_sub_last == NULL)
138 return; 138 return;
139 fname = get_path("subtitle_log"); 139 fname = get_path("subtitle_log");
140 f = fopen(fname, "a"); 140 f = fopen(fname, "a");
141 if (!f) 141 if (!f)
142 return; 142 return;
143 fprintf(f, "----------------------------------------------------------\n"); 143 fprintf(f, "----------------------------------------------------------\n");
144 if (subdata->sub_uses_time) { 144 if (subdata->sub_uses_time) {
145 fprintf(f, 145 fprintf(f,
146 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", 146 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
147 filename, vo_sub_last->start / 360000, 147 filename, vo_sub_last->start / 360000,
148 (vo_sub_last->start / 6000) % 60, 148 (vo_sub_last->start / 6000) % 60,
149 (vo_sub_last->start / 100) % 60, vo_sub_last->start % 100, 149 (vo_sub_last->start / 100) % 60, vo_sub_last->start % 100,
150 vo_sub_last->end / 360000, (vo_sub_last->end / 6000) % 60, 150 vo_sub_last->end / 360000, (vo_sub_last->end / 6000) % 60,
151 (vo_sub_last->end / 100) % 60, vo_sub_last->end % 100); 151 (vo_sub_last->end / 100) % 60, vo_sub_last->end % 100);
152 } else { 152 } else {
153 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start, 153 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start,
154 vo_sub_last->end); 154 vo_sub_last->end);
155 } 155 }
156 for (i = 0; i < vo_sub_last->lines; i++) { 156 for (i = 0; i < vo_sub_last->lines; i++) {
157 fprintf(f, "%s\n", vo_sub_last->text[i]); 157 fprintf(f, "%s\n", vo_sub_last->text[i]);
158 } 158 }
159 fclose(f); 159 fclose(f);
160 } 160 }
161 161
162 162
167 /// \ingroup Properties 167 /// \ingroup Properties
168 ///@{ 168 ///@{
169 169
170 /// OSD level (RW) 170 /// OSD level (RW)
171 static int mp_property_osdlevel(m_option_t * prop, int action, void *arg, 171 static int mp_property_osdlevel(m_option_t * prop, int action, void *arg,
172 MPContext * mpctx) 172 MPContext * mpctx)
173 { 173 {
174 return m_property_choice(prop, action, arg, &osd_level); 174 return m_property_choice(prop, action, arg, &osd_level);
175 } 175 }
176 176
177 /// Loop (RW) 177 /// Loop (RW)
192 return m_property_int_range(prop, action, arg, &mpctx->loop_times); 192 return m_property_int_range(prop, action, arg, &mpctx->loop_times);
193 } 193 }
194 194
195 /// Playback speed (RW) 195 /// Playback speed (RW)
196 static int mp_property_playback_speed(m_option_t * prop, int action, 196 static int mp_property_playback_speed(m_option_t * prop, int action,
197 void *arg, MPContext * mpctx) 197 void *arg, MPContext * mpctx)
198 { 198 {
199 switch (action) { 199 switch (action) {
200 case M_PROPERTY_SET: 200 case M_PROPERTY_SET:
201 if (!arg) 201 if (!arg)
202 return M_PROPERTY_ERROR; 202 return M_PROPERTY_ERROR;
203 M_PROPERTY_CLAMP(prop, *(float *) arg); 203 M_PROPERTY_CLAMP(prop, *(float *) arg);
204 playback_speed = *(float *) arg; 204 playback_speed = *(float *) arg;
205 build_afilter_chain(mpctx->sh_audio, &ao_data); 205 build_afilter_chain(mpctx->sh_audio, &ao_data);
206 return M_PROPERTY_OK; 206 return M_PROPERTY_OK;
207 case M_PROPERTY_STEP_UP: 207 case M_PROPERTY_STEP_UP:
208 case M_PROPERTY_STEP_DOWN: 208 case M_PROPERTY_STEP_DOWN:
209 playback_speed += (arg ? *(float *) arg : 0.1) * 209 playback_speed += (arg ? *(float *) arg : 0.1) *
210 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 210 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
211 M_PROPERTY_CLAMP(prop, playback_speed); 211 M_PROPERTY_CLAMP(prop, playback_speed);
212 build_afilter_chain(mpctx->sh_audio, &ao_data); 212 build_afilter_chain(mpctx->sh_audio, &ao_data);
213 return M_PROPERTY_OK; 213 return M_PROPERTY_OK;
214 } 214 }
215 return m_property_float_range(prop, action, arg, &playback_speed); 215 return m_property_float_range(prop, action, arg, &playback_speed);
216 } 216 }
217 217
218 /// filename with path (RO) 218 /// filename with path (RO)
219 static int mp_property_path(m_option_t * prop, int action, void *arg, 219 static int mp_property_path(m_option_t * prop, int action, void *arg,
220 MPContext * mpctx) 220 MPContext * mpctx)
221 { 221 {
222 return m_property_string_ro(prop, action, arg, filename); 222 return m_property_string_ro(prop, action, arg, filename);
223 } 223 }
224 224
225 /// filename without path (RO) 225 /// filename without path (RO)
226 static int mp_property_filename(m_option_t * prop, int action, void *arg, 226 static int mp_property_filename(m_option_t * prop, int action, void *arg,
227 MPContext * mpctx) 227 MPContext * mpctx)
228 { 228 {
229 char *f; 229 char *f;
230 if (!filename) 230 if (!filename)
231 return M_PROPERTY_UNAVAILABLE; 231 return M_PROPERTY_UNAVAILABLE;
232 if (((f = strrchr(filename, '/')) || (f = strrchr(filename, '\\'))) && f[1]) 232 if (((f = strrchr(filename, '/')) || (f = strrchr(filename, '\\'))) && f[1])
233 f++; 233 f++;
234 else 234 else
235 f = filename; 235 f = filename;
236 return m_property_string_ro(prop, action, arg, f); 236 return m_property_string_ro(prop, action, arg, f);
237 } 237 }
238 238
239 /// Demuxer name (RO) 239 /// Demuxer name (RO)
240 static int mp_property_demuxer(m_option_t * prop, int action, void *arg, 240 static int mp_property_demuxer(m_option_t * prop, int action, void *arg,
241 MPContext * mpctx) 241 MPContext * mpctx)
242 { 242 {
243 if (!mpctx->demuxer) 243 if (!mpctx->demuxer)
244 return M_PROPERTY_UNAVAILABLE; 244 return M_PROPERTY_UNAVAILABLE;
245 return m_property_string_ro(prop, action, arg, 245 return m_property_string_ro(prop, action, arg,
246 (char *) mpctx->demuxer->desc->name); 246 (char *) mpctx->demuxer->desc->name);
247 } 247 }
248 248
249 /// Position in the stream (RW) 249 /// Position in the stream (RW)
250 static int mp_property_stream_pos(m_option_t * prop, int action, void *arg, 250 static int mp_property_stream_pos(m_option_t * prop, int action, void *arg,
251 MPContext * mpctx) 251 MPContext * mpctx)
252 { 252 {
253 if (!mpctx->demuxer || !mpctx->demuxer->stream) 253 if (!mpctx->demuxer || !mpctx->demuxer->stream)
254 return M_PROPERTY_UNAVAILABLE; 254 return M_PROPERTY_UNAVAILABLE;
255 if (!arg) 255 if (!arg)
256 return M_PROPERTY_ERROR; 256 return M_PROPERTY_ERROR;
257 switch (action) { 257 switch (action) {
258 case M_PROPERTY_GET: 258 case M_PROPERTY_GET:
259 *(off_t *) arg = stream_tell(mpctx->demuxer->stream); 259 *(off_t *) arg = stream_tell(mpctx->demuxer->stream);
260 return M_PROPERTY_OK; 260 return M_PROPERTY_OK;
261 case M_PROPERTY_SET: 261 case M_PROPERTY_SET:
262 M_PROPERTY_CLAMP(prop, *(off_t *) arg); 262 M_PROPERTY_CLAMP(prop, *(off_t *) arg);
263 stream_seek(mpctx->demuxer->stream, *(off_t *) arg); 263 stream_seek(mpctx->demuxer->stream, *(off_t *) arg);
264 return M_PROPERTY_OK; 264 return M_PROPERTY_OK;
265 } 265 }
266 return M_PROPERTY_NOT_IMPLEMENTED; 266 return M_PROPERTY_NOT_IMPLEMENTED;
267 } 267 }
268 268
269 /// Stream start offset (RO) 269 /// Stream start offset (RO)
270 static int mp_property_stream_start(m_option_t * prop, int action, 270 static int mp_property_stream_start(m_option_t * prop, int action,
271 void *arg, MPContext * mpctx) 271 void *arg, MPContext * mpctx)
272 { 272 {
273 if (!mpctx->demuxer || !mpctx->demuxer->stream) 273 if (!mpctx->demuxer || !mpctx->demuxer->stream)
274 return M_PROPERTY_UNAVAILABLE; 274 return M_PROPERTY_UNAVAILABLE;
275 switch (action) { 275 switch (action) {
276 case M_PROPERTY_GET: 276 case M_PROPERTY_GET:
277 *(off_t *) arg = mpctx->demuxer->stream->start_pos; 277 *(off_t *) arg = mpctx->demuxer->stream->start_pos;
278 return M_PROPERTY_OK; 278 return M_PROPERTY_OK;
279 } 279 }
280 return M_PROPERTY_NOT_IMPLEMENTED; 280 return M_PROPERTY_NOT_IMPLEMENTED;
281 } 281 }
282 282
283 /// Stream end offset (RO) 283 /// Stream end offset (RO)
284 static int mp_property_stream_end(m_option_t * prop, int action, void *arg, 284 static int mp_property_stream_end(m_option_t * prop, int action, void *arg,
285 MPContext * mpctx) 285 MPContext * mpctx)
286 { 286 {
287 if (!mpctx->demuxer || !mpctx->demuxer->stream) 287 if (!mpctx->demuxer || !mpctx->demuxer->stream)
288 return M_PROPERTY_UNAVAILABLE; 288 return M_PROPERTY_UNAVAILABLE;
289 switch (action) { 289 switch (action) {
290 case M_PROPERTY_GET: 290 case M_PROPERTY_GET:
291 *(off_t *) arg = mpctx->demuxer->stream->end_pos; 291 *(off_t *) arg = mpctx->demuxer->stream->end_pos;
292 return M_PROPERTY_OK; 292 return M_PROPERTY_OK;
293 } 293 }
294 return M_PROPERTY_NOT_IMPLEMENTED; 294 return M_PROPERTY_NOT_IMPLEMENTED;
295 } 295 }
296 296
297 /// Stream length (RO) 297 /// Stream length (RO)
298 static int mp_property_stream_length(m_option_t * prop, int action, 298 static int mp_property_stream_length(m_option_t * prop, int action,
299 void *arg, MPContext * mpctx) 299 void *arg, MPContext * mpctx)
300 { 300 {
301 if (!mpctx->demuxer || !mpctx->demuxer->stream) 301 if (!mpctx->demuxer || !mpctx->demuxer->stream)
302 return M_PROPERTY_UNAVAILABLE; 302 return M_PROPERTY_UNAVAILABLE;
303 switch (action) { 303 switch (action) {
304 case M_PROPERTY_GET: 304 case M_PROPERTY_GET:
305 *(off_t *) arg = 305 *(off_t *) arg =
306 mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos; 306 mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos;
307 return M_PROPERTY_OK; 307 return M_PROPERTY_OK;
308 } 308 }
309 return M_PROPERTY_NOT_IMPLEMENTED; 309 return M_PROPERTY_NOT_IMPLEMENTED;
310 } 310 }
311 311
312 /// Media length in seconds (RO) 312 /// Media length in seconds (RO)
313 static int mp_property_length(m_option_t * prop, int action, void *arg, 313 static int mp_property_length(m_option_t * prop, int action, void *arg,
314 MPContext * mpctx) 314 MPContext * mpctx)
315 { 315 {
316 double len; 316 double len;
317 317
318 if (!mpctx->demuxer || 318 if (!mpctx->demuxer ||
319 !(int) (len = demuxer_get_time_length(mpctx->demuxer))) 319 !(int) (len = demuxer_get_time_length(mpctx->demuxer)))
320 return M_PROPERTY_UNAVAILABLE; 320 return M_PROPERTY_UNAVAILABLE;
321 321
322 return m_property_time_ro(prop, action, arg, len); 322 return m_property_time_ro(prop, action, arg, len);
323 } 323 }
324 324
325 /// Current position in percent (RW) 325 /// Current position in percent (RW)
326 static int mp_property_percent_pos(m_option_t * prop, int action, 326 static int mp_property_percent_pos(m_option_t * prop, int action,
327 void *arg, MPContext * mpctx) { 327 void *arg, MPContext * mpctx) {
328 int pos; 328 int pos;
329 329
330 if (!mpctx->demuxer) 330 if (!mpctx->demuxer)
331 return M_PROPERTY_UNAVAILABLE; 331 return M_PROPERTY_UNAVAILABLE;
332 332
333 switch(action) { 333 switch(action) {
334 case M_PROPERTY_SET: 334 case M_PROPERTY_SET:
335 if(!arg) return M_PROPERTY_ERROR; 335 if(!arg) return M_PROPERTY_ERROR;
336 M_PROPERTY_CLAMP(prop, *(int*)arg); 336 M_PROPERTY_CLAMP(prop, *(int*)arg);
530 m_property_action_t* ka; 530 m_property_action_t* ka;
531 char* meta; 531 char* meta;
532 static m_option_t key_type = 532 static m_option_t key_type =
533 { "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL }; 533 { "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL };
534 if (!mpctx->demuxer) 534 if (!mpctx->demuxer)
535 return M_PROPERTY_UNAVAILABLE; 535 return M_PROPERTY_UNAVAILABLE;
536 536
537 switch(action) { 537 switch(action) {
538 case M_PROPERTY_GET: 538 case M_PROPERTY_GET:
539 if(!arg) return M_PROPERTY_ERROR; 539 if(!arg) return M_PROPERTY_ERROR;
540 *(char***)arg = mpctx->demuxer->info; 540 *(char***)arg = mpctx->demuxer->info;
571 /// \ingroup Properties 571 /// \ingroup Properties
572 ///@{ 572 ///@{
573 573
574 /// Volume (RW) 574 /// Volume (RW)
575 static int mp_property_volume(m_option_t * prop, int action, void *arg, 575 static int mp_property_volume(m_option_t * prop, int action, void *arg,
576 MPContext * mpctx) 576 MPContext * mpctx)
577 { 577 {
578 578
579 if (!mpctx->sh_audio) 579 if (!mpctx->sh_audio)
580 return M_PROPERTY_UNAVAILABLE; 580 return M_PROPERTY_UNAVAILABLE;
581 581
582 switch (action) { 582 switch (action) {
583 case M_PROPERTY_GET: 583 case M_PROPERTY_GET:
584 if (!arg) 584 if (!arg)
585 return M_PROPERTY_ERROR; 585 return M_PROPERTY_ERROR;
586 mixer_getbothvolume(&mpctx->mixer, arg); 586 mixer_getbothvolume(&mpctx->mixer, arg);
587 return M_PROPERTY_OK; 587 return M_PROPERTY_OK;
588 case M_PROPERTY_PRINT:{ 588 case M_PROPERTY_PRINT:{
589 float vol; 589 float vol;
590 if (!arg) 590 if (!arg)
591 return M_PROPERTY_ERROR; 591 return M_PROPERTY_ERROR;
592 mixer_getbothvolume(&mpctx->mixer, &vol); 592 mixer_getbothvolume(&mpctx->mixer, &vol);
593 return m_property_float_range(prop, action, arg, &vol); 593 return m_property_float_range(prop, action, arg, &vol);
594 } 594 }
595 case M_PROPERTY_STEP_UP: 595 case M_PROPERTY_STEP_UP:
596 case M_PROPERTY_STEP_DOWN: 596 case M_PROPERTY_STEP_DOWN:
597 case M_PROPERTY_SET: 597 case M_PROPERTY_SET:
598 break; 598 break;
599 default: 599 default:
600 return M_PROPERTY_NOT_IMPLEMENTED; 600 return M_PROPERTY_NOT_IMPLEMENTED;
601 } 601 }
602 602
603 if (mpctx->edl_muted) 603 if (mpctx->edl_muted)
604 return M_PROPERTY_DISABLED; 604 return M_PROPERTY_DISABLED;
605 mpctx->user_muted = 0; 605 mpctx->user_muted = 0;
606 606
607 switch (action) { 607 switch (action) {
608 case M_PROPERTY_SET: 608 case M_PROPERTY_SET:
609 if (!arg) 609 if (!arg)
610 return M_PROPERTY_ERROR; 610 return M_PROPERTY_ERROR;
611 M_PROPERTY_CLAMP(prop, *(float *) arg); 611 M_PROPERTY_CLAMP(prop, *(float *) arg);
612 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg); 612 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg);
613 return M_PROPERTY_OK; 613 return M_PROPERTY_OK;
614 case M_PROPERTY_STEP_UP: 614 case M_PROPERTY_STEP_UP:
615 if (arg && *(float *) arg <= 0) 615 if (arg && *(float *) arg <= 0)
616 mixer_decvolume(&mpctx->mixer); 616 mixer_decvolume(&mpctx->mixer);
617 else 617 else
618 mixer_incvolume(&mpctx->mixer); 618 mixer_incvolume(&mpctx->mixer);
619 return M_PROPERTY_OK; 619 return M_PROPERTY_OK;
620 case M_PROPERTY_STEP_DOWN: 620 case M_PROPERTY_STEP_DOWN:
621 if (arg && *(float *) arg <= 0) 621 if (arg && *(float *) arg <= 0)
622 mixer_incvolume(&mpctx->mixer); 622 mixer_incvolume(&mpctx->mixer);
623 else 623 else
624 mixer_decvolume(&mpctx->mixer); 624 mixer_decvolume(&mpctx->mixer);
625 return M_PROPERTY_OK; 625 return M_PROPERTY_OK;
626 } 626 }
627 return M_PROPERTY_NOT_IMPLEMENTED; 627 return M_PROPERTY_NOT_IMPLEMENTED;
628 } 628 }
629 629
630 /// Mute (RW) 630 /// Mute (RW)
631 static int mp_property_mute(m_option_t * prop, int action, void *arg, 631 static int mp_property_mute(m_option_t * prop, int action, void *arg,
632 MPContext * mpctx) 632 MPContext * mpctx)
633 { 633 {
634 634
635 if (!mpctx->sh_audio) 635 if (!mpctx->sh_audio)
636 return M_PROPERTY_UNAVAILABLE; 636 return M_PROPERTY_UNAVAILABLE;
637 637
638 switch (action) { 638 switch (action) {
639 case M_PROPERTY_SET: 639 case M_PROPERTY_SET:
640 if (mpctx->edl_muted) 640 if (mpctx->edl_muted)
641 return M_PROPERTY_DISABLED; 641 return M_PROPERTY_DISABLED;
642 if (!arg) 642 if (!arg)
643 return M_PROPERTY_ERROR; 643 return M_PROPERTY_ERROR;
644 if ((!!*(int *) arg) != mpctx->mixer.muted) 644 if ((!!*(int *) arg) != mpctx->mixer.muted)
645 mixer_mute(&mpctx->mixer); 645 mixer_mute(&mpctx->mixer);
646 mpctx->user_muted = mpctx->mixer.muted; 646 mpctx->user_muted = mpctx->mixer.muted;
647 return M_PROPERTY_OK; 647 return M_PROPERTY_OK;
648 case M_PROPERTY_STEP_UP: 648 case M_PROPERTY_STEP_UP:
649 case M_PROPERTY_STEP_DOWN: 649 case M_PROPERTY_STEP_DOWN:
650 if (mpctx->edl_muted) 650 if (mpctx->edl_muted)
651 return M_PROPERTY_DISABLED; 651 return M_PROPERTY_DISABLED;
652 mixer_mute(&mpctx->mixer); 652 mixer_mute(&mpctx->mixer);
653 mpctx->user_muted = mpctx->mixer.muted; 653 mpctx->user_muted = mpctx->mixer.muted;
654 return M_PROPERTY_OK; 654 return M_PROPERTY_OK;
655 case M_PROPERTY_PRINT: 655 case M_PROPERTY_PRINT:
656 if (!arg) 656 if (!arg)
657 return M_PROPERTY_ERROR; 657 return M_PROPERTY_ERROR;
658 if (mpctx->edl_muted) { 658 if (mpctx->edl_muted) {
659 *(char **) arg = strdup(MSGTR_EnabledEdl); 659 *(char **) arg = strdup(MSGTR_EnabledEdl);
660 return M_PROPERTY_OK; 660 return M_PROPERTY_OK;
661 } 661 }
662 default: 662 default:
663 return m_property_flag(prop, action, arg, &mpctx->mixer.muted); 663 return m_property_flag(prop, action, arg, &mpctx->mixer.muted);
664 664
665 } 665 }
666 } 666 }
667 667
668 /// Audio delay (RW) 668 /// Audio delay (RW)
669 static int mp_property_audio_delay(m_option_t * prop, int action, 669 static int mp_property_audio_delay(m_option_t * prop, int action,
670 void *arg, MPContext * mpctx) 670 void *arg, MPContext * mpctx)
671 { 671 {
672 if (!(mpctx->sh_audio && mpctx->sh_video)) 672 if (!(mpctx->sh_audio && mpctx->sh_video))
673 return M_PROPERTY_UNAVAILABLE; 673 return M_PROPERTY_UNAVAILABLE;
674 switch (action) { 674 switch (action) {
675 case M_PROPERTY_SET: 675 case M_PROPERTY_SET:
676 case M_PROPERTY_STEP_UP: 676 case M_PROPERTY_STEP_UP:
677 case M_PROPERTY_STEP_DOWN: { 677 case M_PROPERTY_STEP_DOWN: {
678 int ret; 678 int ret;
679 float delay = audio_delay; 679 float delay = audio_delay;
680 ret = m_property_delay(prop, action, arg, &audio_delay); 680 ret = m_property_delay(prop, action, arg, &audio_delay);
681 if (ret != M_PROPERTY_OK) 681 if (ret != M_PROPERTY_OK)
682 return ret; 682 return ret;
683 if (mpctx->sh_audio) 683 if (mpctx->sh_audio)
684 mpctx->delay -= audio_delay - delay; 684 mpctx->delay -= audio_delay - delay;
685 } 685 }
686 return M_PROPERTY_OK; 686 return M_PROPERTY_OK;
687 default: 687 default:
688 return m_property_delay(prop, action, arg, &audio_delay); 688 return m_property_delay(prop, action, arg, &audio_delay);
689 } 689 }
690 } 690 }
691 691
692 /// Audio codec tag (RO) 692 /// Audio codec tag (RO)
693 static int mp_property_audio_format(m_option_t * prop, int action, 693 static int mp_property_audio_format(m_option_t * prop, int action,
694 void *arg, MPContext * mpctx) 694 void *arg, MPContext * mpctx)
695 { 695 {
696 if (!mpctx->sh_audio) 696 if (!mpctx->sh_audio)
697 return M_PROPERTY_UNAVAILABLE; 697 return M_PROPERTY_UNAVAILABLE;
698 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format); 698 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format);
699 } 699 }
700 700
701 /// Audio codec name (RO) 701 /// Audio codec name (RO)
702 static int mp_property_audio_codec(m_option_t * prop, int action, 702 static int mp_property_audio_codec(m_option_t * prop, int action,
703 void *arg, MPContext * mpctx) 703 void *arg, MPContext * mpctx)
704 { 704 {
705 if (!mpctx->sh_audio || !mpctx->sh_audio->codec) 705 if (!mpctx->sh_audio || !mpctx->sh_audio->codec)
706 return M_PROPERTY_UNAVAILABLE; 706 return M_PROPERTY_UNAVAILABLE;
707 return m_property_string_ro(prop, action, arg, mpctx->sh_audio->codec->name); 707 return m_property_string_ro(prop, action, arg, mpctx->sh_audio->codec->name);
708 } 708 }
709 709
710 /// Audio bitrate (RO) 710 /// Audio bitrate (RO)
711 static int mp_property_audio_bitrate(m_option_t * prop, int action, 711 static int mp_property_audio_bitrate(m_option_t * prop, int action,
712 void *arg, MPContext * mpctx) 712 void *arg, MPContext * mpctx)
713 { 713 {
714 if (!mpctx->sh_audio) 714 if (!mpctx->sh_audio)
715 return M_PROPERTY_UNAVAILABLE; 715 return M_PROPERTY_UNAVAILABLE;
716 return m_property_bitrate(prop, action, arg, mpctx->sh_audio->i_bps); 716 return m_property_bitrate(prop, action, arg, mpctx->sh_audio->i_bps);
717 } 717 }
718 718
719 /// Samplerate (RO) 719 /// Samplerate (RO)
720 static int mp_property_samplerate(m_option_t * prop, int action, void *arg, 720 static int mp_property_samplerate(m_option_t * prop, int action, void *arg,
721 MPContext * mpctx) 721 MPContext * mpctx)
722 { 722 {
723 if (!mpctx->sh_audio) 723 if (!mpctx->sh_audio)
724 return M_PROPERTY_UNAVAILABLE; 724 return M_PROPERTY_UNAVAILABLE;
725 switch(action) { 725 switch(action) {
726 case M_PROPERTY_PRINT: 726 case M_PROPERTY_PRINT:
727 if(!arg) return M_PROPERTY_ERROR; 727 if(!arg) return M_PROPERTY_ERROR;
728 *(char**)arg = malloc(16); 728 *(char**)arg = malloc(16);
729 sprintf(*(char**)arg,"%d kHz",mpctx->sh_audio->samplerate/1000); 729 sprintf(*(char**)arg,"%d kHz",mpctx->sh_audio->samplerate/1000);
732 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate); 732 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate);
733 } 733 }
734 734
735 /// Number of channels (RO) 735 /// Number of channels (RO)
736 static int mp_property_channels(m_option_t * prop, int action, void *arg, 736 static int mp_property_channels(m_option_t * prop, int action, void *arg,
737 MPContext * mpctx) 737 MPContext * mpctx)
738 { 738 {
739 if (!mpctx->sh_audio) 739 if (!mpctx->sh_audio)
740 return M_PROPERTY_UNAVAILABLE; 740 return M_PROPERTY_UNAVAILABLE;
741 switch (action) { 741 switch (action) {
742 case M_PROPERTY_PRINT: 742 case M_PROPERTY_PRINT:
743 if (!arg) 743 if (!arg)
744 return M_PROPERTY_ERROR; 744 return M_PROPERTY_ERROR;
745 switch (mpctx->sh_audio->channels) { 745 switch (mpctx->sh_audio->channels) {
746 case 1: 746 case 1:
747 *(char **) arg = strdup("mono"); 747 *(char **) arg = strdup("mono");
748 break; 748 break;
749 case 2: 749 case 2:
750 *(char **) arg = strdup("stereo"); 750 *(char **) arg = strdup("stereo");
751 break; 751 break;
752 default: 752 default:
753 *(char **) arg = malloc(32); 753 *(char **) arg = malloc(32);
754 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels); 754 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels);
755 } 755 }
756 return M_PROPERTY_OK; 756 return M_PROPERTY_OK;
757 } 757 }
758 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels); 758 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels);
759 } 759 }
760 760
761 /// Balance (RW) 761 /// Balance (RW)
762 static int mp_property_balance(m_option_t * prop, int action, void *arg, 762 static int mp_property_balance(m_option_t * prop, int action, void *arg,
763 MPContext * mpctx) 763 MPContext * mpctx)
764 { 764 {
765 float bal; 765 float bal;
766 766
767 if (!mpctx->sh_audio || mpctx->sh_audio->channels < 2) 767 if (!mpctx->sh_audio || mpctx->sh_audio->channels < 2)
768 return M_PROPERTY_UNAVAILABLE; 768 return M_PROPERTY_UNAVAILABLE;
769 769
770 switch (action) { 770 switch (action) {
771 case M_PROPERTY_GET: 771 case M_PROPERTY_GET:
772 if (!arg) 772 if (!arg)
773 return M_PROPERTY_ERROR; 773 return M_PROPERTY_ERROR;
774 mixer_getbalance(&mpctx->mixer, arg); 774 mixer_getbalance(&mpctx->mixer, arg);
775 return M_PROPERTY_OK; 775 return M_PROPERTY_OK;
776 case M_PROPERTY_PRINT: { 776 case M_PROPERTY_PRINT: {
777 char** str = arg; 777 char** str = arg;
778 if (!arg) 778 if (!arg)
779 return M_PROPERTY_ERROR; 779 return M_PROPERTY_ERROR;
780 mixer_getbalance(&mpctx->mixer, &bal); 780 mixer_getbalance(&mpctx->mixer, &bal);
781 if (bal == 0.f) 781 if (bal == 0.f)
782 *str = strdup("center"); 782 *str = strdup("center");
783 else if (bal == -1.f) 783 else if (bal == -1.f)
784 *str = strdup("left only"); 784 *str = strdup("left only");
785 else if (bal == 1.f) 785 else if (bal == 1.f)
786 *str = strdup("right only"); 786 *str = strdup("right only");
787 else { 787 else {
788 unsigned right = (bal + 1.f) / 2.f * 100.f; 788 unsigned right = (bal + 1.f) / 2.f * 100.f;
789 *str = malloc(sizeof("left xxx%, right xxx%")); 789 *str = malloc(sizeof("left xxx%, right xxx%"));
790 sprintf(*str, "left %d%%, right %d%%", 100 - right, right); 790 sprintf(*str, "left %d%%, right %d%%", 100 - right, right);
791 } 791 }
792 return M_PROPERTY_OK; 792 return M_PROPERTY_OK;
793 } 793 }
794 case M_PROPERTY_STEP_UP: 794 case M_PROPERTY_STEP_UP:
795 case M_PROPERTY_STEP_DOWN: 795 case M_PROPERTY_STEP_DOWN:
796 mixer_getbalance(&mpctx->mixer, &bal); 796 mixer_getbalance(&mpctx->mixer, &bal);
797 bal += (arg ? *(float*)arg : .1f) * 797 bal += (arg ? *(float*)arg : .1f) *
798 (action == M_PROPERTY_STEP_UP ? 1.f : -1.f); 798 (action == M_PROPERTY_STEP_UP ? 1.f : -1.f);
799 M_PROPERTY_CLAMP(prop, bal); 799 M_PROPERTY_CLAMP(prop, bal);
800 mixer_setbalance(&mpctx->mixer, bal); 800 mixer_setbalance(&mpctx->mixer, bal);
801 return M_PROPERTY_OK; 801 return M_PROPERTY_OK;
802 case M_PROPERTY_SET: 802 case M_PROPERTY_SET:
803 if (!arg) 803 if (!arg)
804 return M_PROPERTY_ERROR; 804 return M_PROPERTY_ERROR;
805 M_PROPERTY_CLAMP(prop, *(float*)arg); 805 M_PROPERTY_CLAMP(prop, *(float*)arg);
806 mixer_setbalance(&mpctx->mixer, *(float*)arg); 806 mixer_setbalance(&mpctx->mixer, *(float*)arg);
807 return M_PROPERTY_OK; 807 return M_PROPERTY_OK;
808 } 808 }
809 return M_PROPERTY_NOT_IMPLEMENTED; 809 return M_PROPERTY_NOT_IMPLEMENTED;
810 } 810 }
811 811
812 /// Selected audio id (RW) 812 /// Selected audio id (RW)
813 static int mp_property_audio(m_option_t * prop, int action, void *arg, 813 static int mp_property_audio(m_option_t * prop, int action, void *arg,
814 MPContext * mpctx) 814 MPContext * mpctx)
815 { 815 {
816 int current_id, tmp; 816 int current_id, tmp;
817 if (!mpctx->demuxer || !mpctx->demuxer->audio) 817 if (!mpctx->demuxer || !mpctx->demuxer->audio)
818 return M_PROPERTY_UNAVAILABLE; 818 return M_PROPERTY_UNAVAILABLE;
819 current_id = mpctx->demuxer->audio->id; 819 current_id = mpctx->demuxer->audio->id;
820 820
821 switch (action) { 821 switch (action) {
822 case M_PROPERTY_GET: 822 case M_PROPERTY_GET:
823 if (!arg) 823 if (!arg)
824 return M_PROPERTY_ERROR; 824 return M_PROPERTY_ERROR;
825 *(int *) arg = current_id; 825 *(int *) arg = current_id;
826 return M_PROPERTY_OK; 826 return M_PROPERTY_OK;
827 case M_PROPERTY_PRINT: 827 case M_PROPERTY_PRINT:
828 if (!arg) 828 if (!arg)
829 return M_PROPERTY_ERROR; 829 return M_PROPERTY_ERROR;
830 830
831 if (current_id < 0) 831 if (current_id < 0)
832 *(char **) arg = strdup(MSGTR_Disabled); 832 *(char **) arg = strdup(MSGTR_Disabled);
833 else { 833 else {
834 char lang[40] = MSGTR_Unknown; 834 char lang[40] = MSGTR_Unknown;
835 sh_audio_t* sh = mpctx->sh_audio; 835 sh_audio_t* sh = mpctx->sh_audio;
836 if (sh && sh->lang) 836 if (sh && sh->lang)
837 av_strlcpy(lang, sh->lang, 40); 837 av_strlcpy(lang, sh->lang, 40);
838 #ifdef CONFIG_DVDREAD 838 #ifdef CONFIG_DVDREAD
839 else if (mpctx->stream->type == STREAMTYPE_DVD) { 839 else if (mpctx->stream->type == STREAMTYPE_DVD) {
840 int code = dvd_lang_from_aid(mpctx->stream, current_id); 840 int code = dvd_lang_from_aid(mpctx->stream, current_id);
841 if (code) { 841 if (code) {
842 lang[0] = code >> 8; 842 lang[0] = code >> 8;
843 lang[1] = code; 843 lang[1] = code;
844 lang[2] = 0; 844 lang[2] = 0;
845 } 845 }
846 } 846 }
847 #endif 847 #endif
848 848
849 #ifdef CONFIG_DVDNAV 849 #ifdef CONFIG_DVDNAV
850 else if (mpctx->stream->type == STREAMTYPE_DVDNAV) 850 else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
851 mp_dvdnav_lang_from_aid(mpctx->stream, current_id, lang); 851 mp_dvdnav_lang_from_aid(mpctx->stream, current_id, lang);
852 #endif 852 #endif
853 *(char **) arg = malloc(64); 853 *(char **) arg = malloc(64);
854 snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang); 854 snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang);
855 } 855 }
856 return M_PROPERTY_OK; 856 return M_PROPERTY_OK;
857 857
858 case M_PROPERTY_STEP_UP: 858 case M_PROPERTY_STEP_UP:
859 case M_PROPERTY_SET: 859 case M_PROPERTY_SET:
860 if (action == M_PROPERTY_SET && arg) 860 if (action == M_PROPERTY_SET && arg)
861 tmp = *((int *) arg); 861 tmp = *((int *) arg);
862 else 862 else
863 tmp = -1; 863 tmp = -1;
864 audio_id = demuxer_switch_audio(mpctx->demuxer, tmp); 864 audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
865 if (audio_id == -2 865 if (audio_id == -2
866 || (audio_id > -1 866 || (audio_id > -1
867 && mpctx->demuxer->audio->id != current_id && current_id != -2)) 867 && mpctx->demuxer->audio->id != current_id && current_id != -2))
868 uninit_player(INITIALIZED_AO | INITIALIZED_ACODEC); 868 uninit_player(INITIALIZED_AO | INITIALIZED_ACODEC);
869 if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) { 869 if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
870 sh_audio_t *sh2; 870 sh_audio_t *sh2;
871 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id]; 871 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
872 if (sh2) { 872 if (sh2) {
873 sh2->ds = mpctx->demuxer->audio; 873 sh2->ds = mpctx->demuxer->audio;
874 mpctx->sh_audio = sh2; 874 mpctx->sh_audio = sh2;
875 reinit_audio_chain(); 875 reinit_audio_chain();
876 } 876 }
877 } 877 }
878 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id); 878 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
879 return M_PROPERTY_OK; 879 return M_PROPERTY_OK;
880 default: 880 default:
881 return M_PROPERTY_NOT_IMPLEMENTED; 881 return M_PROPERTY_NOT_IMPLEMENTED;
882 } 882 }
883 883
884 } 884 }
885 885
886 /// Selected video id (RW) 886 /// Selected video id (RW)
887 static int mp_property_video(m_option_t * prop, int action, void *arg, 887 static int mp_property_video(m_option_t * prop, int action, void *arg,
888 MPContext * mpctx) 888 MPContext * mpctx)
889 { 889 {
890 int current_id, tmp; 890 int current_id, tmp;
891 if (!mpctx->demuxer || !mpctx->demuxer->video) 891 if (!mpctx->demuxer || !mpctx->demuxer->video)
892 return M_PROPERTY_UNAVAILABLE; 892 return M_PROPERTY_UNAVAILABLE;
893 current_id = mpctx->demuxer->video->id; 893 current_id = mpctx->demuxer->video->id;
894 894
895 switch (action) { 895 switch (action) {
896 case M_PROPERTY_GET: 896 case M_PROPERTY_GET:
897 if (!arg) 897 if (!arg)
898 return M_PROPERTY_ERROR; 898 return M_PROPERTY_ERROR;
899 *(int *) arg = current_id; 899 *(int *) arg = current_id;
900 return M_PROPERTY_OK; 900 return M_PROPERTY_OK;
901 case M_PROPERTY_PRINT: 901 case M_PROPERTY_PRINT:
902 if (!arg) 902 if (!arg)
903 return M_PROPERTY_ERROR; 903 return M_PROPERTY_ERROR;
904 904
905 if (current_id < 0) 905 if (current_id < 0)
906 *(char **) arg = strdup(MSGTR_Disabled); 906 *(char **) arg = strdup(MSGTR_Disabled);
907 else { 907 else {
908 char lang[40] = MSGTR_Unknown; 908 char lang[40] = MSGTR_Unknown;
909 *(char **) arg = malloc(64); 909 *(char **) arg = malloc(64);
910 snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang); 910 snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang);
911 } 911 }
912 return M_PROPERTY_OK; 912 return M_PROPERTY_OK;
913 913
914 case M_PROPERTY_STEP_UP: 914 case M_PROPERTY_STEP_UP:
915 case M_PROPERTY_SET: 915 case M_PROPERTY_SET:
916 if (action == M_PROPERTY_SET && arg) 916 if (action == M_PROPERTY_SET && arg)
917 tmp = *((int *) arg); 917 tmp = *((int *) arg);
918 else 918 else
919 tmp = -1; 919 tmp = -1;
920 video_id = demuxer_switch_video(mpctx->demuxer, tmp); 920 video_id = demuxer_switch_video(mpctx->demuxer, tmp);
921 if (video_id == -2 921 if (video_id == -2
922 || (video_id > -1 && mpctx->demuxer->video->id != current_id 922 || (video_id > -1 && mpctx->demuxer->video->id != current_id
923 && current_id != -2)) 923 && current_id != -2))
924 uninit_player(INITIALIZED_VCODEC | 924 uninit_player(INITIALIZED_VCODEC |
925 (fixed_vo && video_id != -2 ? 0 : INITIALIZED_VO)); 925 (fixed_vo && video_id != -2 ? 0 : INITIALIZED_VO));
926 if (video_id > -1 && mpctx->demuxer->video->id != current_id) { 926 if (video_id > -1 && mpctx->demuxer->video->id != current_id) {
927 sh_video_t *sh2; 927 sh_video_t *sh2;
928 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id]; 928 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
929 if (sh2) { 929 if (sh2) {
930 sh2->ds = mpctx->demuxer->video; 930 sh2->ds = mpctx->demuxer->video;
931 mpctx->sh_video = sh2; 931 mpctx->sh_video = sh2;
932 reinit_video_chain(); 932 reinit_video_chain();
933 } 933 }
934 } 934 }
935 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id); 935 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id);
936 return M_PROPERTY_OK; 936 return M_PROPERTY_OK;
937 937
938 default: 938 default:
939 return M_PROPERTY_NOT_IMPLEMENTED; 939 return M_PROPERTY_NOT_IMPLEMENTED;
940 } 940 }
941 } 941 }
942 942
943 static int mp_property_program(m_option_t * prop, int action, void *arg, 943 static int mp_property_program(m_option_t * prop, int action, void *arg,
944 MPContext * mpctx) 944 MPContext * mpctx)
945 { 945 {
946 demux_program_t prog; 946 demux_program_t prog;
947 947
948 switch (action) { 948 switch (action) {
949 case M_PROPERTY_STEP_UP: 949 case M_PROPERTY_STEP_UP:
950 case M_PROPERTY_SET: 950 case M_PROPERTY_SET:
951 if (action == M_PROPERTY_SET && arg) 951 if (action == M_PROPERTY_SET && arg)
952 prog.progid = *((int *) arg); 952 prog.progid = *((int *) arg);
953 else 953 else
954 prog.progid = -1; 954 prog.progid = -1;
955 if (demux_control 955 if (demux_control
956 (mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, 956 (mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM,
957 &prog) == DEMUXER_CTRL_NOTIMPL) 957 &prog) == DEMUXER_CTRL_NOTIMPL)
958 return M_PROPERTY_ERROR; 958 return M_PROPERTY_ERROR;
959 959
960 if (prog.aid < 0 && prog.vid < 0) { 960 if (prog.aid < 0 && prog.vid < 0) {
961 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Selected program contains no audio or video streams!\n"); 961 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Selected program contains no audio or video streams!\n");
962 return M_PROPERTY_ERROR; 962 return M_PROPERTY_ERROR;
963 } 963 }
964 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx); 964 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx);
965 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx); 965 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx);
966 return M_PROPERTY_OK; 966 return M_PROPERTY_OK;
967 967
968 default: 968 default:
969 return M_PROPERTY_NOT_IMPLEMENTED; 969 return M_PROPERTY_NOT_IMPLEMENTED;
970 } 970 }
971 } 971 }
972 972
973 ///@} 973 ///@}
974 974
976 /// \ingroup Properties 976 /// \ingroup Properties
977 ///@{ 977 ///@{
978 978
979 /// Fullscreen state (RW) 979 /// Fullscreen state (RW)
980 static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, 980 static int mp_property_fullscreen(m_option_t * prop, int action, void *arg,
981 MPContext * mpctx) 981 MPContext * mpctx)
982 { 982 {
983 983
984 if (!mpctx->video_out) 984 if (!mpctx->video_out)
985 return M_PROPERTY_UNAVAILABLE; 985 return M_PROPERTY_UNAVAILABLE;
986 986
987 switch (action) { 987 switch (action) {
988 case M_PROPERTY_SET: 988 case M_PROPERTY_SET:
989 if (!arg) 989 if (!arg)
990 return M_PROPERTY_ERROR; 990 return M_PROPERTY_ERROR;
991 M_PROPERTY_CLAMP(prop, *(int *) arg); 991 M_PROPERTY_CLAMP(prop, *(int *) arg);
992 if (vo_fs == !!*(int *) arg) 992 if (vo_fs == !!*(int *) arg)
993 return M_PROPERTY_OK; 993 return M_PROPERTY_OK;
994 case M_PROPERTY_STEP_UP: 994 case M_PROPERTY_STEP_UP:
995 case M_PROPERTY_STEP_DOWN: 995 case M_PROPERTY_STEP_DOWN:
996 #ifdef CONFIG_GUI 996 #ifdef CONFIG_GUI
997 if (use_gui) 997 if (use_gui)
998 guiGetEvent(guiIEvent, (char *) MP_CMD_GUI_FULLSCREEN); 998 guiGetEvent(guiIEvent, (char *) MP_CMD_GUI_FULLSCREEN);
999 else 999 else
1000 #endif 1000 #endif
1001 if (vo_config_count) 1001 if (vo_config_count)
1002 mpctx->video_out->control(VOCTRL_FULLSCREEN, 0); 1002 mpctx->video_out->control(VOCTRL_FULLSCREEN, 0);
1003 return M_PROPERTY_OK; 1003 return M_PROPERTY_OK;
1004 default: 1004 default:
1005 return m_property_flag(prop, action, arg, &vo_fs); 1005 return m_property_flag(prop, action, arg, &vo_fs);
1006 } 1006 }
1007 } 1007 }
1008 1008
1009 static int mp_property_deinterlace(m_option_t * prop, int action, 1009 static int mp_property_deinterlace(m_option_t * prop, int action,
1010 void *arg, MPContext * mpctx) 1010 void *arg, MPContext * mpctx)
1011 { 1011 {
1012 int deinterlace; 1012 int deinterlace;
1013 vf_instance_t *vf; 1013 vf_instance_t *vf;
1014 if (!mpctx->sh_video || !mpctx->sh_video->vfilter) 1014 if (!mpctx->sh_video || !mpctx->sh_video->vfilter)
1015 return M_PROPERTY_UNAVAILABLE; 1015 return M_PROPERTY_UNAVAILABLE;
1016 vf = mpctx->sh_video->vfilter; 1016 vf = mpctx->sh_video->vfilter;
1017 switch (action) { 1017 switch (action) {
1018 case M_PROPERTY_GET: 1018 case M_PROPERTY_GET:
1019 if (!arg) 1019 if (!arg)
1020 return M_PROPERTY_ERROR; 1020 return M_PROPERTY_ERROR;
1021 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg); 1021 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg);
1022 return M_PROPERTY_OK; 1022 return M_PROPERTY_OK;
1023 case M_PROPERTY_SET: 1023 case M_PROPERTY_SET:
1024 if (!arg) 1024 if (!arg)
1025 return M_PROPERTY_ERROR; 1025 return M_PROPERTY_ERROR;
1026 M_PROPERTY_CLAMP(prop, *(int *) arg); 1026 M_PROPERTY_CLAMP(prop, *(int *) arg);
1027 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg); 1027 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg);
1028 return M_PROPERTY_OK; 1028 return M_PROPERTY_OK;
1029 case M_PROPERTY_STEP_UP: 1029 case M_PROPERTY_STEP_UP:
1030 case M_PROPERTY_STEP_DOWN: 1030 case M_PROPERTY_STEP_DOWN:
1031 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace); 1031 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace);
1032 deinterlace = !deinterlace; 1032 deinterlace = !deinterlace;
1033 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace); 1033 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace);
1034 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDDeinterlace, 1034 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDDeinterlace,
1035 deinterlace ? MSGTR_Enabled : MSGTR_Disabled); 1035 deinterlace ? MSGTR_Enabled : MSGTR_Disabled);
1036 return M_PROPERTY_OK; 1036 return M_PROPERTY_OK;
1037 } 1037 }
1038 return M_PROPERTY_NOT_IMPLEMENTED; 1038 return M_PROPERTY_NOT_IMPLEMENTED;
1039 } 1039 }
1040 1040
1041 /// Panscan (RW) 1041 /// Panscan (RW)
1042 static int mp_property_panscan(m_option_t * prop, int action, void *arg, 1042 static int mp_property_panscan(m_option_t * prop, int action, void *arg,
1043 MPContext * mpctx) 1043 MPContext * mpctx)
1044 { 1044 {
1045 1045
1046 if (!mpctx->video_out 1046 if (!mpctx->video_out
1047 || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE) 1047 || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
1048 return M_PROPERTY_UNAVAILABLE; 1048 return M_PROPERTY_UNAVAILABLE;
1049 1049
1050 switch (action) { 1050 switch (action) {
1051 case M_PROPERTY_SET: 1051 case M_PROPERTY_SET:
1052 if (!arg) 1052 if (!arg)
1053 return M_PROPERTY_ERROR; 1053 return M_PROPERTY_ERROR;
1054 M_PROPERTY_CLAMP(prop, *(float *) arg); 1054 M_PROPERTY_CLAMP(prop, *(float *) arg);
1055 vo_panscan = *(float *) arg; 1055 vo_panscan = *(float *) arg;
1056 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); 1056 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
1057 return M_PROPERTY_OK; 1057 return M_PROPERTY_OK;
1058 case M_PROPERTY_STEP_UP: 1058 case M_PROPERTY_STEP_UP:
1059 case M_PROPERTY_STEP_DOWN: 1059 case M_PROPERTY_STEP_DOWN:
1060 vo_panscan += (arg ? *(float *) arg : 0.1) * 1060 vo_panscan += (arg ? *(float *) arg : 0.1) *
1061 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 1061 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
1062 if (vo_panscan > 1) 1062 if (vo_panscan > 1)
1063 vo_panscan = 1; 1063 vo_panscan = 1;
1064 else if (vo_panscan < 0) 1064 else if (vo_panscan < 0)
1065 vo_panscan = 0; 1065 vo_panscan = 0;
1066 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); 1066 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
1067 return M_PROPERTY_OK; 1067 return M_PROPERTY_OK;
1068 default: 1068 default:
1069 return m_property_float_range(prop, action, arg, &vo_panscan); 1069 return m_property_float_range(prop, action, arg, &vo_panscan);
1070 } 1070 }
1071 } 1071 }
1072 1072
1073 /// Helper to set vo flags. 1073 /// Helper to set vo flags.
1074 /** \ingroup PropertyImplHelper 1074 /** \ingroup PropertyImplHelper
1075 */ 1075 */
1076 static int mp_property_vo_flag(m_option_t * prop, int action, void *arg, 1076 static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
1077 int vo_ctrl, int *vo_var, MPContext * mpctx) 1077 int vo_ctrl, int *vo_var, MPContext * mpctx)
1078 { 1078 {
1079 1079
1080 if (!mpctx->video_out) 1080 if (!mpctx->video_out)
1081 return M_PROPERTY_UNAVAILABLE; 1081 return M_PROPERTY_UNAVAILABLE;
1082 1082
1083 switch (action) { 1083 switch (action) {
1084 case M_PROPERTY_SET: 1084 case M_PROPERTY_SET:
1085 if (!arg) 1085 if (!arg)
1086 return M_PROPERTY_ERROR; 1086 return M_PROPERTY_ERROR;
1087 M_PROPERTY_CLAMP(prop, *(int *) arg); 1087 M_PROPERTY_CLAMP(prop, *(int *) arg);
1088 if (*vo_var == !!*(int *) arg) 1088 if (*vo_var == !!*(int *) arg)
1089 return M_PROPERTY_OK; 1089 return M_PROPERTY_OK;
1090 case M_PROPERTY_STEP_UP: 1090 case M_PROPERTY_STEP_UP:
1091 case M_PROPERTY_STEP_DOWN: 1091 case M_PROPERTY_STEP_DOWN:
1092 if (vo_config_count) 1092 if (vo_config_count)
1093 mpctx->video_out->control(vo_ctrl, 0); 1093 mpctx->video_out->control(vo_ctrl, 0);
1094 return M_PROPERTY_OK; 1094 return M_PROPERTY_OK;
1095 default: 1095 default:
1096 return m_property_flag(prop, action, arg, vo_var); 1096 return m_property_flag(prop, action, arg, vo_var);
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 /// Window always on top (RW) 1100 /// Window always on top (RW)
1101 static int mp_property_ontop(m_option_t * prop, int action, void *arg, 1101 static int mp_property_ontop(m_option_t * prop, int action, void *arg,
1102 MPContext * mpctx) 1102 MPContext * mpctx)
1103 { 1103 {
1104 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop, 1104 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop,
1105 mpctx); 1105 mpctx);
1106 } 1106 }
1107 1107
1108 /// Display in the root window (RW) 1108 /// Display in the root window (RW)
1109 static int mp_property_rootwin(m_option_t * prop, int action, void *arg, 1109 static int mp_property_rootwin(m_option_t * prop, int action, void *arg,
1110 MPContext * mpctx) 1110 MPContext * mpctx)
1111 { 1111 {
1112 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN, 1112 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN,
1113 &vo_rootwin, mpctx); 1113 &vo_rootwin, mpctx);
1114 } 1114 }
1115 1115
1116 /// Show window borders (RW) 1116 /// Show window borders (RW)
1117 static int mp_property_border(m_option_t * prop, int action, void *arg, 1117 static int mp_property_border(m_option_t * prop, int action, void *arg,
1118 MPContext * mpctx) 1118 MPContext * mpctx)
1119 { 1119 {
1120 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, 1120 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER,
1121 &vo_border, mpctx); 1121 &vo_border, mpctx);
1122 } 1122 }
1123 1123
1124 /// Framedropping state (RW) 1124 /// Framedropping state (RW)
1125 static int mp_property_framedropping(m_option_t * prop, int action, 1125 static int mp_property_framedropping(m_option_t * prop, int action,
1126 void *arg, MPContext * mpctx) 1126 void *arg, MPContext * mpctx)
1127 { 1127 {
1128 1128
1129 if (!mpctx->sh_video) 1129 if (!mpctx->sh_video)
1130 return M_PROPERTY_UNAVAILABLE; 1130 return M_PROPERTY_UNAVAILABLE;
1131 1131
1132 switch (action) { 1132 switch (action) {
1133 case M_PROPERTY_PRINT: 1133 case M_PROPERTY_PRINT:
1134 if (!arg) 1134 if (!arg)
1135 return M_PROPERTY_ERROR; 1135 return M_PROPERTY_ERROR;
1136 *(char **) arg = strdup(frame_dropping == 1 ? MSGTR_Enabled : 1136 *(char **) arg = strdup(frame_dropping == 1 ? MSGTR_Enabled :
1137 (frame_dropping == 2 ? MSGTR_HardFrameDrop : 1137 (frame_dropping == 2 ? MSGTR_HardFrameDrop :
1138 MSGTR_Disabled)); 1138 MSGTR_Disabled));
1139 return M_PROPERTY_OK; 1139 return M_PROPERTY_OK;
1140 default: 1140 default:
1141 return m_property_choice(prop, action, arg, &frame_dropping); 1141 return m_property_choice(prop, action, arg, &frame_dropping);
1142 } 1142 }
1143 } 1143 }
1144 1144
1145 /// Color settings, try to use vf/vo then fall back on TV. (RW) 1145 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1146 static int mp_property_gamma(m_option_t * prop, int action, void *arg, 1146 static int mp_property_gamma(m_option_t * prop, int action, void *arg,
1147 MPContext * mpctx) 1147 MPContext * mpctx)
1148 { 1148 {
1149 int *gamma = prop->priv, r, val; 1149 int *gamma = prop->priv, r, val;
1150 1150
1151 if (!mpctx->sh_video) 1151 if (!mpctx->sh_video)
1152 return M_PROPERTY_UNAVAILABLE; 1152 return M_PROPERTY_UNAVAILABLE;
1153 1153
1154 if (gamma[0] == 1000) { 1154 if (gamma[0] == 1000) {
1155 gamma[0] = 0; 1155 gamma[0] = 0;
1156 get_video_colors(mpctx->sh_video, prop->name, gamma); 1156 get_video_colors(mpctx->sh_video, prop->name, gamma);
1157 } 1157 }
1158 1158
1159 switch (action) { 1159 switch (action) {
1160 case M_PROPERTY_SET: 1160 case M_PROPERTY_SET:
1161 if (!arg) 1161 if (!arg)
1162 return M_PROPERTY_ERROR; 1162 return M_PROPERTY_ERROR;
1163 M_PROPERTY_CLAMP(prop, *(int *) arg); 1163 M_PROPERTY_CLAMP(prop, *(int *) arg);
1164 *gamma = *(int *) arg; 1164 *gamma = *(int *) arg;
1165 r = set_video_colors(mpctx->sh_video, prop->name, *gamma); 1165 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
1166 if (r <= 0) 1166 if (r <= 0)
1167 break; 1167 break;
1168 return r; 1168 return r;
1169 case M_PROPERTY_GET: 1169 case M_PROPERTY_GET:
1170 if (get_video_colors(mpctx->sh_video, prop->name, &val) > 0) { 1170 if (get_video_colors(mpctx->sh_video, prop->name, &val) > 0) {
1171 if (!arg) 1171 if (!arg)
1172 return M_PROPERTY_ERROR; 1172 return M_PROPERTY_ERROR;
1173 *(int *)arg = val; 1173 *(int *)arg = val;
1174 return M_PROPERTY_OK; 1174 return M_PROPERTY_OK;
1175 } 1175 }
1176 break; 1176 break;
1177 case M_PROPERTY_STEP_UP: 1177 case M_PROPERTY_STEP_UP:
1178 case M_PROPERTY_STEP_DOWN: 1178 case M_PROPERTY_STEP_DOWN:
1179 *gamma += (arg ? *(int *) arg : 1) * 1179 *gamma += (arg ? *(int *) arg : 1) *
1180 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 1180 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
1181 M_PROPERTY_CLAMP(prop, *gamma); 1181 M_PROPERTY_CLAMP(prop, *gamma);
1182 r = set_video_colors(mpctx->sh_video, prop->name, *gamma); 1182 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
1183 if (r <= 0) 1183 if (r <= 0)
1184 break; 1184 break;
1185 return r; 1185 return r;
1186 default: 1186 default:
1187 return M_PROPERTY_NOT_IMPLEMENTED; 1187 return M_PROPERTY_NOT_IMPLEMENTED;
1188 } 1188 }
1189 1189
1190 #ifdef CONFIG_TV 1190 #ifdef CONFIG_TV
1191 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) { 1191 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) {
1192 int l = strlen(prop->name); 1192 int l = strlen(prop->name);
1193 char tv_prop[3 + l + 1]; 1193 char tv_prop[3 + l + 1];
1194 sprintf(tv_prop, "tv_%s", prop->name); 1194 sprintf(tv_prop, "tv_%s", prop->name);
1195 return mp_property_do(tv_prop, action, arg, mpctx); 1195 return mp_property_do(tv_prop, action, arg, mpctx);
1196 } 1196 }
1197 #endif 1197 #endif
1198 1198
1199 return M_PROPERTY_UNAVAILABLE; 1199 return M_PROPERTY_UNAVAILABLE;
1200 } 1200 }
1201 1201
1202 /// VSync (RW) 1202 /// VSync (RW)
1203 static int mp_property_vsync(m_option_t * prop, int action, void *arg, 1203 static int mp_property_vsync(m_option_t * prop, int action, void *arg,
1204 MPContext * mpctx) 1204 MPContext * mpctx)
1205 { 1205 {
1206 return m_property_flag(prop, action, arg, &vo_vsync); 1206 return m_property_flag(prop, action, arg, &vo_vsync);
1207 } 1207 }
1208 1208
1209 /// Video codec tag (RO) 1209 /// Video codec tag (RO)
1210 static int mp_property_video_format(m_option_t * prop, int action, 1210 static int mp_property_video_format(m_option_t * prop, int action,
1211 void *arg, MPContext * mpctx) 1211 void *arg, MPContext * mpctx)
1212 { 1212 {
1213 char* meta; 1213 char* meta;
1214 if (!mpctx->sh_video) 1214 if (!mpctx->sh_video)
1215 return M_PROPERTY_UNAVAILABLE; 1215 return M_PROPERTY_UNAVAILABLE;
1216 switch(action) { 1216 switch(action) {
1217 case M_PROPERTY_PRINT: 1217 case M_PROPERTY_PRINT:
1218 if (!arg) 1218 if (!arg)
1219 return M_PROPERTY_ERROR; 1219 return M_PROPERTY_ERROR;
1220 switch(mpctx->sh_video->format) { 1220 switch(mpctx->sh_video->format) {
1221 case 0x10000001: 1221 case 0x10000001:
1222 meta = strdup ("mpeg1"); break; 1222 meta = strdup ("mpeg1"); break;
1223 case 0x10000002: 1223 case 0x10000002:
1224 meta = strdup ("mpeg2"); break; 1224 meta = strdup ("mpeg2"); break;
1244 /// Video codec name (RO) 1244 /// Video codec name (RO)
1245 static int mp_property_video_codec(m_option_t * prop, int action, 1245 static int mp_property_video_codec(m_option_t * prop, int action,
1246 void *arg, MPContext * mpctx) 1246 void *arg, MPContext * mpctx)
1247 { 1247 {
1248 if (!mpctx->sh_video || !mpctx->sh_video->codec) 1248 if (!mpctx->sh_video || !mpctx->sh_video->codec)
1249 return M_PROPERTY_UNAVAILABLE; 1249 return M_PROPERTY_UNAVAILABLE;
1250 return m_property_string_ro(prop, action, arg, mpctx->sh_video->codec->name); 1250 return m_property_string_ro(prop, action, arg, mpctx->sh_video->codec->name);
1251 } 1251 }
1252 1252
1253 1253
1254 /// Video bitrate (RO) 1254 /// Video bitrate (RO)
1255 static int mp_property_video_bitrate(m_option_t * prop, int action, 1255 static int mp_property_video_bitrate(m_option_t * prop, int action,
1256 void *arg, MPContext * mpctx) 1256 void *arg, MPContext * mpctx)
1257 { 1257 {
1258 if (!mpctx->sh_video) 1258 if (!mpctx->sh_video)
1259 return M_PROPERTY_UNAVAILABLE; 1259 return M_PROPERTY_UNAVAILABLE;
1260 return m_property_bitrate(prop, action, arg, mpctx->sh_video->i_bps); 1260 return m_property_bitrate(prop, action, arg, mpctx->sh_video->i_bps);
1261 } 1261 }
1262 1262
1263 /// Video display width (RO) 1263 /// Video display width (RO)
1264 static int mp_property_width(m_option_t * prop, int action, void *arg, 1264 static int mp_property_width(m_option_t * prop, int action, void *arg,
1265 MPContext * mpctx) 1265 MPContext * mpctx)
1266 { 1266 {
1267 if (!mpctx->sh_video) 1267 if (!mpctx->sh_video)
1268 return M_PROPERTY_UNAVAILABLE; 1268 return M_PROPERTY_UNAVAILABLE;
1269 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w); 1269 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w);
1270 } 1270 }
1271 1271
1272 /// Video display height (RO) 1272 /// Video display height (RO)
1273 static int mp_property_height(m_option_t * prop, int action, void *arg, 1273 static int mp_property_height(m_option_t * prop, int action, void *arg,
1274 MPContext * mpctx) 1274 MPContext * mpctx)
1275 { 1275 {
1276 if (!mpctx->sh_video) 1276 if (!mpctx->sh_video)
1277 return M_PROPERTY_UNAVAILABLE; 1277 return M_PROPERTY_UNAVAILABLE;
1278 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h); 1278 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h);
1279 } 1279 }
1280 1280
1281 /// Video fps (RO) 1281 /// Video fps (RO)
1282 static int mp_property_fps(m_option_t * prop, int action, void *arg, 1282 static int mp_property_fps(m_option_t * prop, int action, void *arg,
1283 MPContext * mpctx) 1283 MPContext * mpctx)
1284 { 1284 {
1285 if (!mpctx->sh_video) 1285 if (!mpctx->sh_video)
1286 return M_PROPERTY_UNAVAILABLE; 1286 return M_PROPERTY_UNAVAILABLE;
1287 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps); 1287 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps);
1288 } 1288 }
1289 1289
1290 /// Video aspect (RO) 1290 /// Video aspect (RO)
1291 static int mp_property_aspect(m_option_t * prop, int action, void *arg, 1291 static int mp_property_aspect(m_option_t * prop, int action, void *arg,
1292 MPContext * mpctx) 1292 MPContext * mpctx)
1293 { 1293 {
1294 if (!mpctx->sh_video) 1294 if (!mpctx->sh_video)
1295 return M_PROPERTY_UNAVAILABLE; 1295 return M_PROPERTY_UNAVAILABLE;
1296 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect); 1296 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect);
1297 } 1297 }
1298 1298
1299 ///@} 1299 ///@}
1300 1300
1302 /// \ingroup Properties 1302 /// \ingroup Properties
1303 ///@{ 1303 ///@{
1304 1304
1305 /// Text subtitle position (RW) 1305 /// Text subtitle position (RW)
1306 static int mp_property_sub_pos(m_option_t * prop, int action, void *arg, 1306 static int mp_property_sub_pos(m_option_t * prop, int action, void *arg,
1307 MPContext * mpctx) 1307 MPContext * mpctx)
1308 { 1308 {
1309 switch (action) { 1309 switch (action) {
1310 case M_PROPERTY_SET: 1310 case M_PROPERTY_SET:
1311 if (!arg) 1311 if (!arg)
1312 return M_PROPERTY_ERROR; 1312 return M_PROPERTY_ERROR;
1313 case M_PROPERTY_STEP_UP: 1313 case M_PROPERTY_STEP_UP:
1314 case M_PROPERTY_STEP_DOWN: 1314 case M_PROPERTY_STEP_DOWN:
1315 vo_osd_changed(OSDTYPE_SUBTITLE); 1315 vo_osd_changed(OSDTYPE_SUBTITLE);
1316 default: 1316 default:
1317 return m_property_int_range(prop, action, arg, &sub_pos); 1317 return m_property_int_range(prop, action, arg, &sub_pos);
1318 } 1318 }
1319 } 1319 }
1320 1320
1321 /// Selected subtitles (RW) 1321 /// Selected subtitles (RW)
1322 static int mp_property_sub(m_option_t * prop, int action, void *arg, 1322 static int mp_property_sub(m_option_t * prop, int action, void *arg,
1323 MPContext * mpctx) 1323 MPContext * mpctx)
1324 { 1324 {
1325 demux_stream_t *const d_sub = mpctx->d_sub; 1325 demux_stream_t *const d_sub = mpctx->d_sub;
1326 const int global_sub_size = mpctx->global_sub_size; 1326 const int global_sub_size = mpctx->global_sub_size;
1327 int source = -1, reset_spu = 0; 1327 int source = -1, reset_spu = 0;
1328 double pts = 0; 1328 double pts = 0;
1329 char *sub_name; 1329 char *sub_name;
1330 1330
1331 if (global_sub_size <= 0) 1331 if (global_sub_size <= 0)
1332 return M_PROPERTY_UNAVAILABLE; 1332 return M_PROPERTY_UNAVAILABLE;
1333 1333
1334 switch (action) { 1334 switch (action) {
1335 case M_PROPERTY_GET: 1335 case M_PROPERTY_GET:
1336 if (!arg) 1336 if (!arg)
1337 return M_PROPERTY_ERROR; 1337 return M_PROPERTY_ERROR;
1338 *(int *) arg = mpctx->global_sub_pos; 1338 *(int *) arg = mpctx->global_sub_pos;
1339 return M_PROPERTY_OK; 1339 return M_PROPERTY_OK;
1340 case M_PROPERTY_PRINT: 1340 case M_PROPERTY_PRINT:
1341 if (!arg) 1341 if (!arg)
1342 return M_PROPERTY_ERROR; 1342 return M_PROPERTY_ERROR;
1343 *(char **) arg = malloc(64); 1343 *(char **) arg = malloc(64);
1344 (*(char **) arg)[63] = 0; 1344 (*(char **) arg)[63] = 0;
1345 sub_name = 0; 1345 sub_name = 0;
1346 if (subdata) 1346 if (subdata)
1347 sub_name = subdata->filename; 1347 sub_name = subdata->filename;
1348 #ifdef CONFIG_ASS 1348 #ifdef CONFIG_ASS
1349 if (ass_track && ass_track->name) 1349 if (ass_track && ass_track->name)
1350 sub_name = ass_track->name; 1350 sub_name = ass_track->name;
1351 #endif 1351 #endif
1352 if (sub_name) { 1352 if (sub_name) {
1353 char *tmp, *tmp2; 1353 char *tmp, *tmp2;
1354 tmp = sub_name; 1354 tmp = sub_name;
1355 if ((tmp2 = strrchr(tmp, '/'))) 1355 if ((tmp2 = strrchr(tmp, '/')))
1356 tmp = tmp2 + 1; 1356 tmp = tmp2 + 1;
1357 1357
1358 snprintf(*(char **) arg, 63, "(%d) %s%s", 1358 snprintf(*(char **) arg, 63, "(%d) %s%s",
1359 mpctx->set_of_sub_pos + 1, 1359 mpctx->set_of_sub_pos + 1,
1360 strlen(tmp) < 20 ? "" : "...", 1360 strlen(tmp) < 20 ? "" : "...",
1361 strlen(tmp) < 20 ? tmp : tmp + strlen(tmp) - 19); 1361 strlen(tmp) < 20 ? tmp : tmp + strlen(tmp) - 19);
1362 return M_PROPERTY_OK; 1362 return M_PROPERTY_OK;
1363 } 1363 }
1364 #ifdef CONFIG_DVDNAV 1364 #ifdef CONFIG_DVDNAV
1365 if (mpctx->stream->type == STREAMTYPE_DVDNAV) { 1365 if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
1366 if (vo_spudec && dvdsub_id >= 0) { 1366 if (vo_spudec && dvdsub_id >= 0) {
1367 unsigned char lang[3]; 1367 unsigned char lang[3];
1368 if (mp_dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) { 1368 if (mp_dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) {
1369 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); 1369 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
1370 return M_PROPERTY_OK; 1370 return M_PROPERTY_OK;
1371 } 1371 }
1372 } 1372 }
1373 } 1373 }
1374 #endif 1374 #endif
1375 1375
1376 if ((mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA 1376 if ((mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA
1377 || mpctx->demuxer->type == DEMUXER_TYPE_LAVF 1377 || mpctx->demuxer->type == DEMUXER_TYPE_LAVF
1378 || mpctx->demuxer->type == DEMUXER_TYPE_LAVF_PREFERRED 1378 || mpctx->demuxer->type == DEMUXER_TYPE_LAVF_PREFERRED
1379 || mpctx->demuxer->type == DEMUXER_TYPE_OGG) 1379 || mpctx->demuxer->type == DEMUXER_TYPE_OGG)
1380 && d_sub && d_sub->sh && dvdsub_id >= 0) { 1380 && d_sub && d_sub->sh && dvdsub_id >= 0) {
1381 const char* lang = ((sh_sub_t*)d_sub->sh)->lang; 1381 const char* lang = ((sh_sub_t*)d_sub->sh)->lang;
1382 if (!lang) lang = MSGTR_Unknown; 1382 if (!lang) lang = MSGTR_Unknown;
1383 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); 1383 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
1384 return M_PROPERTY_OK; 1384 return M_PROPERTY_OK;
1385 } 1385 }
1386 1386
1387 if (vo_vobsub && vobsub_id >= 0) { 1387 if (vo_vobsub && vobsub_id >= 0) {
1388 const char *language = MSGTR_Unknown; 1388 const char *language = MSGTR_Unknown;
1389 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id); 1389 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
1390 snprintf(*(char **) arg, 63, "(%d) %s", 1390 snprintf(*(char **) arg, 63, "(%d) %s",
1391 vobsub_id, language ? language : MSGTR_Unknown); 1391 vobsub_id, language ? language : MSGTR_Unknown);
1392 return M_PROPERTY_OK; 1392 return M_PROPERTY_OK;
1393 } 1393 }
1394 #ifdef CONFIG_DVDREAD 1394 #ifdef CONFIG_DVDREAD
1395 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD 1395 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD
1396 && dvdsub_id >= 0) { 1396 && dvdsub_id >= 0) {
1397 char lang[3]; 1397 char lang[3];
1398 int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id); 1398 int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id);
1399 lang[0] = code >> 8; 1399 lang[0] = code >> 8;
1400 lang[1] = code; 1400 lang[1] = code;
1401 lang[2] = 0; 1401 lang[2] = 0;
1402 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); 1402 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang);
1403 return M_PROPERTY_OK; 1403 return M_PROPERTY_OK;
1404 } 1404 }
1405 #endif 1405 #endif
1406 if (dvdsub_id >= 0) { 1406 if (dvdsub_id >= 0) {
1407 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown); 1407 snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
1408 return M_PROPERTY_OK; 1408 return M_PROPERTY_OK;
1409 } 1409 }
1410 snprintf(*(char **) arg, 63, MSGTR_Disabled); 1410 snprintf(*(char **) arg, 63, MSGTR_Disabled);
1411 return M_PROPERTY_OK; 1411 return M_PROPERTY_OK;
1412 1412
1413 case M_PROPERTY_SET: 1413 case M_PROPERTY_SET:
1414 if (!arg) 1414 if (!arg)
1415 return M_PROPERTY_ERROR; 1415 return M_PROPERTY_ERROR;
1416 if (*(int *) arg < -1) 1416 if (*(int *) arg < -1)
1417 *(int *) arg = -1; 1417 *(int *) arg = -1;
1418 else if (*(int *) arg >= global_sub_size) 1418 else if (*(int *) arg >= global_sub_size)
1419 *(int *) arg = global_sub_size - 1; 1419 *(int *) arg = global_sub_size - 1;
1420 mpctx->global_sub_pos = *(int *) arg; 1420 mpctx->global_sub_pos = *(int *) arg;
1421 break; 1421 break;
1422 case M_PROPERTY_STEP_UP: 1422 case M_PROPERTY_STEP_UP:
1423 mpctx->global_sub_pos += 2; 1423 mpctx->global_sub_pos += 2;
1424 mpctx->global_sub_pos = 1424 mpctx->global_sub_pos =
1425 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; 1425 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
1426 break; 1426 break;
1427 case M_PROPERTY_STEP_DOWN: 1427 case M_PROPERTY_STEP_DOWN:
1428 mpctx->global_sub_pos += global_sub_size + 1; 1428 mpctx->global_sub_pos += global_sub_size + 1;
1429 mpctx->global_sub_pos = 1429 mpctx->global_sub_pos =
1430 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1; 1430 (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
1431 break; 1431 break;
1432 default: 1432 default:
1433 return M_PROPERTY_NOT_IMPLEMENTED; 1433 return M_PROPERTY_NOT_IMPLEMENTED;
1434 } 1434 }
1435 1435
1436 if (mpctx->global_sub_pos >= 0) 1436 if (mpctx->global_sub_pos >= 0)
1437 source = sub_source(mpctx); 1437 source = sub_source(mpctx);
1438 1438
1439 mp_msg(MSGT_CPLAYER, MSGL_DBG3, 1439 mp_msg(MSGT_CPLAYER, MSGL_DBG3,
1440 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n", 1440 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1441 global_sub_size, 1441 global_sub_size,
1442 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB], 1442 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB],
1443 mpctx->global_sub_indices[SUB_SOURCE_SUBS], 1443 mpctx->global_sub_indices[SUB_SOURCE_SUBS],
1444 mpctx->global_sub_indices[SUB_SOURCE_DEMUX], 1444 mpctx->global_sub_indices[SUB_SOURCE_DEMUX],
1445 mpctx->global_sub_pos, source); 1445 mpctx->global_sub_pos, source);
1446 1446
1447 mpctx->set_of_sub_pos = -1; 1447 mpctx->set_of_sub_pos = -1;
1448 subdata = NULL; 1448 subdata = NULL;
1449 1449
1450 vobsub_id = -1; 1450 vobsub_id = -1;
1451 dvdsub_id = -1; 1451 dvdsub_id = -1;
1452 if (d_sub) { 1452 if (d_sub) {
1453 if (d_sub->id > -2) 1453 if (d_sub->id > -2)
1454 reset_spu = 1; 1454 reset_spu = 1;
1455 d_sub->id = -2; 1455 d_sub->id = -2;
1456 } 1456 }
1457 #ifdef CONFIG_ASS 1457 #ifdef CONFIG_ASS
1458 ass_track = 0; 1458 ass_track = 0;
1459 #endif 1459 #endif
1460 1460
1461 if (source == SUB_SOURCE_VOBSUB) { 1461 if (source == SUB_SOURCE_VOBSUB) {
1462 vobsub_id = vobsub_get_id_by_index(vo_vobsub, mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_VOBSUB]); 1462 vobsub_id = vobsub_get_id_by_index(vo_vobsub, mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_VOBSUB]);
1463 } else if (source == SUB_SOURCE_SUBS) { 1463 } else if (source == SUB_SOURCE_SUBS) {
1464 mpctx->set_of_sub_pos = 1464 mpctx->set_of_sub_pos =
1465 mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS]; 1465 mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS];
1466 #ifdef CONFIG_ASS 1466 #ifdef CONFIG_ASS
1467 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]) 1467 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos])
1468 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos]; 1468 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos];
1469 else 1469 else
1470 #endif 1470 #endif
1471 { 1471 {
1472 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos]; 1472 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos];
1473 vo_osd_changed(OSDTYPE_SUBTITLE); 1473 vo_osd_changed(OSDTYPE_SUBTITLE);
1474 } 1474 }
1475 } else if (source == SUB_SOURCE_DEMUX) { 1475 } else if (source == SUB_SOURCE_DEMUX) {
1476 dvdsub_id = 1476 dvdsub_id =
1477 mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX]; 1477 mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX];
1478 if (d_sub && dvdsub_id < MAX_S_STREAMS) { 1478 if (d_sub && dvdsub_id < MAX_S_STREAMS) {
1479 int i = 0; 1479 int i = 0;
1480 // default: assume 1:1 mapping of sid and stream id 1480 // default: assume 1:1 mapping of sid and stream id
1481 d_sub->id = dvdsub_id; 1481 d_sub->id = dvdsub_id;
1482 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id]; 1482 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
1483 ds_free_packs(d_sub); 1483 ds_free_packs(d_sub);
1484 for (i = 0; i < MAX_S_STREAMS; i++) { 1484 for (i = 0; i < MAX_S_STREAMS; i++) {
1485 sh_sub_t *sh = mpctx->demuxer->s_streams[i]; 1485 sh_sub_t *sh = mpctx->demuxer->s_streams[i];
1486 if (sh && sh->sid == dvdsub_id) { 1486 if (sh && sh->sid == dvdsub_id) {
1487 d_sub->id = i; 1487 d_sub->id = i;
1488 d_sub->sh = sh; 1488 d_sub->sh = sh;
1489 break; 1489 break;
1490 } 1490 }
1491 } 1491 }
1492 if (d_sub->sh && d_sub->id >= 0) { 1492 if (d_sub->sh && d_sub->id >= 0) {
1493 sh_sub_t *sh = d_sub->sh; 1493 sh_sub_t *sh = d_sub->sh;
1494 if (sh->type == 'v') 1494 if (sh->type == 'v')
1495 init_vo_spudec(); 1495 init_vo_spudec();
1496 #ifdef CONFIG_ASS 1496 #ifdef CONFIG_ASS
1497 else if (ass_enabled) 1497 else if (ass_enabled)
1498 ass_track = sh->ass_track; 1498 ass_track = sh->ass_track;
1499 #endif 1499 #endif
1500 } else { 1500 } else {
1501 d_sub->id = -2; 1501 d_sub->id = -2;
1502 d_sub->sh = NULL; 1502 d_sub->sh = NULL;
1503 } 1503 }
1504 } 1504 }
1505 } 1505 }
1506 #ifdef CONFIG_DVDREAD 1506 #ifdef CONFIG_DVDREAD
1507 if (vo_spudec 1507 if (vo_spudec
1508 && (mpctx->stream->type == STREAMTYPE_DVD 1508 && (mpctx->stream->type == STREAMTYPE_DVD
1509 || mpctx->stream->type == STREAMTYPE_DVDNAV) 1509 || mpctx->stream->type == STREAMTYPE_DVDNAV)
1510 && dvdsub_id < 0 && reset_spu) { 1510 && dvdsub_id < 0 && reset_spu) {
1511 d_sub->id = -2; 1511 d_sub->id = -2;
1512 d_sub->sh = NULL; 1512 d_sub->sh = NULL;
1513 } 1513 }
1514 #endif 1514 #endif
1515 if (mpctx->sh_audio) 1515 if (mpctx->sh_audio)
1516 pts = mpctx->sh_audio->pts; 1516 pts = mpctx->sh_audio->pts;
1517 if (mpctx->sh_video) 1517 if (mpctx->sh_video)
1699 return mp_property_sub(prop, M_PROPERTY_STEP_UP, NULL, mpctx); 1699 return mp_property_sub(prop, M_PROPERTY_STEP_UP, NULL, mpctx);
1700 } 1700 }
1701 1701
1702 /// Subtitle delay (RW) 1702 /// Subtitle delay (RW)
1703 static int mp_property_sub_delay(m_option_t * prop, int action, void *arg, 1703 static int mp_property_sub_delay(m_option_t * prop, int action, void *arg,
1704 MPContext * mpctx) 1704 MPContext * mpctx)
1705 { 1705 {
1706 if (!mpctx->sh_video) 1706 if (!mpctx->sh_video)
1707 return M_PROPERTY_UNAVAILABLE; 1707 return M_PROPERTY_UNAVAILABLE;
1708 return m_property_delay(prop, action, arg, &sub_delay); 1708 return m_property_delay(prop, action, arg, &sub_delay);
1709 } 1709 }
1710 1710
1711 /// Alignment of text subtitles (RW) 1711 /// Alignment of text subtitles (RW)
1712 static int mp_property_sub_alignment(m_option_t * prop, int action, 1712 static int mp_property_sub_alignment(m_option_t * prop, int action,
1713 void *arg, MPContext * mpctx) 1713 void *arg, MPContext * mpctx)
1714 { 1714 {
1715 char *name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom }; 1715 char *name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom };
1716 1716
1717 if (!mpctx->sh_video || mpctx->global_sub_pos < 0 1717 if (!mpctx->sh_video || mpctx->global_sub_pos < 0
1718 || sub_source(mpctx) != SUB_SOURCE_SUBS) 1718 || sub_source(mpctx) != SUB_SOURCE_SUBS)
1719 return M_PROPERTY_UNAVAILABLE; 1719 return M_PROPERTY_UNAVAILABLE;
1720 1720
1721 switch (action) { 1721 switch (action) {
1722 case M_PROPERTY_PRINT: 1722 case M_PROPERTY_PRINT:
1723 if (!arg) 1723 if (!arg)
1724 return M_PROPERTY_ERROR; 1724 return M_PROPERTY_ERROR;
1725 M_PROPERTY_CLAMP(prop, sub_alignment); 1725 M_PROPERTY_CLAMP(prop, sub_alignment);
1726 *(char **) arg = strdup(name[sub_alignment]); 1726 *(char **) arg = strdup(name[sub_alignment]);
1727 return M_PROPERTY_OK; 1727 return M_PROPERTY_OK;
1728 case M_PROPERTY_SET: 1728 case M_PROPERTY_SET:
1729 if (!arg) 1729 if (!arg)
1730 return M_PROPERTY_ERROR; 1730 return M_PROPERTY_ERROR;
1731 case M_PROPERTY_STEP_UP: 1731 case M_PROPERTY_STEP_UP:
1732 case M_PROPERTY_STEP_DOWN: 1732 case M_PROPERTY_STEP_DOWN:
1733 vo_osd_changed(OSDTYPE_SUBTITLE); 1733 vo_osd_changed(OSDTYPE_SUBTITLE);
1734 default: 1734 default:
1735 return m_property_choice(prop, action, arg, &sub_alignment); 1735 return m_property_choice(prop, action, arg, &sub_alignment);
1736 } 1736 }
1737 } 1737 }
1738 1738
1739 /// Subtitle visibility (RW) 1739 /// Subtitle visibility (RW)
1740 static int mp_property_sub_visibility(m_option_t * prop, int action, 1740 static int mp_property_sub_visibility(m_option_t * prop, int action,
1741 void *arg, MPContext * mpctx) 1741 void *arg, MPContext * mpctx)
1742 { 1742 {
1743 if (!mpctx->sh_video) 1743 if (!mpctx->sh_video)
1744 return M_PROPERTY_UNAVAILABLE; 1744 return M_PROPERTY_UNAVAILABLE;
1745 1745
1746 switch (action) { 1746 switch (action) {
1747 case M_PROPERTY_SET: 1747 case M_PROPERTY_SET:
1748 if (!arg) 1748 if (!arg)
1749 return M_PROPERTY_ERROR; 1749 return M_PROPERTY_ERROR;
1750 case M_PROPERTY_STEP_UP: 1750 case M_PROPERTY_STEP_UP:
1751 case M_PROPERTY_STEP_DOWN: 1751 case M_PROPERTY_STEP_DOWN:
1752 vo_osd_changed(OSDTYPE_SUBTITLE); 1752 vo_osd_changed(OSDTYPE_SUBTITLE);
1753 if (vo_spudec) 1753 if (vo_spudec)
1754 vo_osd_changed(OSDTYPE_SPU); 1754 vo_osd_changed(OSDTYPE_SPU);
1755 default: 1755 default:
1756 return m_property_flag(prop, action, arg, &sub_visibility); 1756 return m_property_flag(prop, action, arg, &sub_visibility);
1757 } 1757 }
1758 } 1758 }
1759 1759
1760 #ifdef CONFIG_ASS 1760 #ifdef CONFIG_ASS
1761 /// Use margins for libass subtitles (RW) 1761 /// Use margins for libass subtitles (RW)
1762 static int mp_property_ass_use_margins(m_option_t * prop, int action, 1762 static int mp_property_ass_use_margins(m_option_t * prop, int action,
1763 void *arg, MPContext * mpctx) 1763 void *arg, MPContext * mpctx)
1764 { 1764 {
1765 if (!mpctx->sh_video) 1765 if (!mpctx->sh_video)
1766 return M_PROPERTY_UNAVAILABLE; 1766 return M_PROPERTY_UNAVAILABLE;
1767 1767
1768 switch (action) { 1768 switch (action) {
1769 case M_PROPERTY_SET: 1769 case M_PROPERTY_SET:
1770 if (!arg) 1770 if (!arg)
1771 return M_PROPERTY_ERROR; 1771 return M_PROPERTY_ERROR;
1772 case M_PROPERTY_STEP_UP: 1772 case M_PROPERTY_STEP_UP:
1773 case M_PROPERTY_STEP_DOWN: 1773 case M_PROPERTY_STEP_DOWN:
1774 ass_force_reload = 1; 1774 ass_force_reload = 1;
1775 default: 1775 default:
1776 return m_property_flag(prop, action, arg, &ass_use_margins); 1776 return m_property_flag(prop, action, arg, &ass_use_margins);
1777 } 1777 }
1778 } 1778 }
1779 #endif 1779 #endif
1780 1780
1781 /// Show only forced subtitles (RW) 1781 /// Show only forced subtitles (RW)
1782 static int mp_property_sub_forced_only(m_option_t * prop, int action, 1782 static int mp_property_sub_forced_only(m_option_t * prop, int action,
1783 void *arg, MPContext * mpctx) 1783 void *arg, MPContext * mpctx)
1784 { 1784 {
1785 if (!vo_spudec) 1785 if (!vo_spudec)
1786 return M_PROPERTY_UNAVAILABLE; 1786 return M_PROPERTY_UNAVAILABLE;
1787 1787
1788 switch (action) { 1788 switch (action) {
1789 case M_PROPERTY_SET: 1789 case M_PROPERTY_SET:
1790 if (!arg) 1790 if (!arg)
1791 return M_PROPERTY_ERROR; 1791 return M_PROPERTY_ERROR;
1792 case M_PROPERTY_STEP_UP: 1792 case M_PROPERTY_STEP_UP:
1793 case M_PROPERTY_STEP_DOWN: 1793 case M_PROPERTY_STEP_DOWN:
1794 m_property_flag(prop, action, arg, &forced_subs_only); 1794 m_property_flag(prop, action, arg, &forced_subs_only);
1795 spudec_set_forced_subs_only(vo_spudec, forced_subs_only); 1795 spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
1796 return M_PROPERTY_OK; 1796 return M_PROPERTY_OK;
1797 default: 1797 default:
1798 return m_property_flag(prop, action, arg, &forced_subs_only); 1798 return m_property_flag(prop, action, arg, &forced_subs_only);
1799 } 1799 }
1800 1800
1801 } 1801 }
1802 1802
1803 #ifdef CONFIG_FREETYPE 1803 #ifdef CONFIG_FREETYPE
1804 /// Subtitle scale (RW) 1804 /// Subtitle scale (RW)
1805 static int mp_property_sub_scale(m_option_t * prop, int action, void *arg, 1805 static int mp_property_sub_scale(m_option_t * prop, int action, void *arg,
1806 MPContext * mpctx) 1806 MPContext * mpctx)
1807 { 1807 {
1808 1808
1809 switch (action) { 1809 switch (action) {
1810 case M_PROPERTY_SET: 1810 case M_PROPERTY_SET:
1811 if (!arg) 1811 if (!arg)
1854 1854
1855 #ifdef CONFIG_TV 1855 #ifdef CONFIG_TV
1856 1856
1857 /// TV color settings (RW) 1857 /// TV color settings (RW)
1858 static int mp_property_tv_color(m_option_t * prop, int action, void *arg, 1858 static int mp_property_tv_color(m_option_t * prop, int action, void *arg,
1859 MPContext * mpctx) 1859 MPContext * mpctx)
1860 { 1860 {
1861 int r, val; 1861 int r, val;
1862 tvi_handle_t *tvh = mpctx->demuxer->priv; 1862 tvi_handle_t *tvh = mpctx->demuxer->priv;
1863 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) 1863 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh)
1864 return M_PROPERTY_UNAVAILABLE; 1864 return M_PROPERTY_UNAVAILABLE;
1865 1865
1866 switch (action) { 1866 switch (action) {
1867 case M_PROPERTY_SET: 1867 case M_PROPERTY_SET:
1868 if (!arg) 1868 if (!arg)
1869 return M_PROPERTY_ERROR; 1869 return M_PROPERTY_ERROR;
1870 M_PROPERTY_CLAMP(prop, *(int *) arg); 1870 M_PROPERTY_CLAMP(prop, *(int *) arg);
1871 return tv_set_color_options(tvh, (int) prop->priv, *(int *) arg); 1871 return tv_set_color_options(tvh, (int) prop->priv, *(int *) arg);
1872 case M_PROPERTY_GET: 1872 case M_PROPERTY_GET:
1873 return tv_get_color_options(tvh, (int) prop->priv, arg); 1873 return tv_get_color_options(tvh, (int) prop->priv, arg);
1874 case M_PROPERTY_STEP_UP: 1874 case M_PROPERTY_STEP_UP:
1875 case M_PROPERTY_STEP_DOWN: 1875 case M_PROPERTY_STEP_DOWN:
1876 if ((r = tv_get_color_options(tvh, (int) prop->priv, &val)) >= 0) { 1876 if ((r = tv_get_color_options(tvh, (int) prop->priv, &val)) >= 0) {
1877 if (!r) 1877 if (!r)
1878 return M_PROPERTY_ERROR; 1878 return M_PROPERTY_ERROR;
1879 val += (arg ? *(int *) arg : 1) * 1879 val += (arg ? *(int *) arg : 1) *
1880 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); 1880 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
1881 M_PROPERTY_CLAMP(prop, val); 1881 M_PROPERTY_CLAMP(prop, val);
1882 return tv_set_color_options(tvh, (int) prop->priv, val); 1882 return tv_set_color_options(tvh, (int) prop->priv, val);
1883 } 1883 }
1884 return M_PROPERTY_ERROR; 1884 return M_PROPERTY_ERROR;
1885 } 1885 }
1886 return M_PROPERTY_NOT_IMPLEMENTED; 1886 return M_PROPERTY_NOT_IMPLEMENTED;
1887 } 1887 }
1888 1888
1889 #endif 1889 #endif
2217 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness }, 2217 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
2218 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast }, 2218 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
2219 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation }, 2219 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
2220 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue }, 2220 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
2221 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus }, 2221 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus },
2222 // subs 2222 // subs
2223 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus }, 2223 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus },
2224 { "sub_source", MP_CMD_SUB_SOURCE, 1, 0, -1, MSGTR_SubSourceStatus }, 2224 { "sub_source", MP_CMD_SUB_SOURCE, 1, 0, -1, MSGTR_SubSourceStatus },
2225 { "sub_vob", MP_CMD_SUB_VOB, 1, 0, -1, MSGTR_SubSelectStatus }, 2225 { "sub_vob", MP_CMD_SUB_VOB, 1, 0, -1, MSGTR_SubSelectStatus },
2226 { "sub_demux", MP_CMD_SUB_DEMUX, 1, 0, -1, MSGTR_SubSelectStatus }, 2226 { "sub_demux", MP_CMD_SUB_DEMUX, 1, 0, -1, MSGTR_SubSelectStatus },
2227 { "sub_file", MP_CMD_SUB_FILE, 1, 0, -1, MSGTR_SubSelectStatus }, 2227 { "sub_file", MP_CMD_SUB_FILE, 1, 0, -1, MSGTR_SubSelectStatus },
2253 m_option_t* prop; 2253 m_option_t* prop;
2254 const char *pname; 2254 const char *pname;
2255 2255
2256 // look for the command 2256 // look for the command
2257 for (i = 0; set_prop_cmd[i].name; i++) 2257 for (i = 0; set_prop_cmd[i].name; i++)
2258 if (set_prop_cmd[i].cmd == cmd->id) 2258 if (set_prop_cmd[i].cmd == cmd->id)
2259 break; 2259 break;
2260 if (!(pname = set_prop_cmd[i].name)) 2260 if (!(pname = set_prop_cmd[i].name))
2261 return 0; 2261 return 0;
2262 2262
2263 if (mp_property_do(pname,M_PROPERTY_GET_TYPE,&prop,mpctx) <= 0 || !prop) 2263 if (mp_property_do(pname,M_PROPERTY_GET_TYPE,&prop,mpctx) <= 0 || !prop)
2264 return 0; 2264 return 0;
2265 2265
2266 // toggle command 2266 // toggle command
2267 if (set_prop_cmd[i].toggle) { 2267 if (set_prop_cmd[i].toggle) {
2268 // set to value 2268 // set to value
2269 if (cmd->nargs > 0 && cmd->args[0].v.i >= prop->min) 2269 if (cmd->nargs > 0 && cmd->args[0].v.i >= prop->min)
2270 r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx); 2270 r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx);
2271 else 2271 else
2272 r = mp_property_do(pname, M_PROPERTY_STEP_UP, NULL, mpctx); 2272 r = mp_property_do(pname, M_PROPERTY_STEP_UP, NULL, mpctx);
2273 } else if (cmd->args[1].v.i) //set 2273 } else if (cmd->args[1].v.i) //set
2274 r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v, mpctx); 2274 r = mp_property_do(pname, M_PROPERTY_SET, &cmd->args[0].v, mpctx);
2275 else // adjust 2275 else // adjust
2276 r = mp_property_do(pname, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx); 2276 r = mp_property_do(pname, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx);
2277 2277
2278 if (r <= 0) 2278 if (r <= 0)
2279 return 1; 2279 return 1;
2280 2280
2281 if (set_prop_cmd[i].osd_progbar) { 2281 if (set_prop_cmd[i].osd_progbar) {
2282 if (prop->type == CONF_TYPE_INT) { 2282 if (prop->type == CONF_TYPE_INT) {
2283 if (mp_property_do(pname, M_PROPERTY_GET, &r, mpctx) > 0) 2283 if (mp_property_do(pname, M_PROPERTY_GET, &r, mpctx) > 0)
2284 set_osd_bar(set_prop_cmd[i].osd_progbar, 2284 set_osd_bar(set_prop_cmd[i].osd_progbar,
2285 set_prop_cmd[i].osd_msg, prop->min, prop->max, r); 2285 set_prop_cmd[i].osd_msg, prop->min, prop->max, r);
2286 } else if (prop->type == CONF_TYPE_FLOAT) { 2286 } else if (prop->type == CONF_TYPE_FLOAT) {
2287 float f; 2287 float f;
2288 if (mp_property_do(pname, M_PROPERTY_GET, &f, mpctx) > 0) 2288 if (mp_property_do(pname, M_PROPERTY_GET, &f, mpctx) > 0)
2289 set_osd_bar(set_prop_cmd[i].osd_progbar, 2289 set_osd_bar(set_prop_cmd[i].osd_progbar,
2290 set_prop_cmd[i].osd_msg, prop->min, prop->max, f); 2290 set_prop_cmd[i].osd_msg, prop->min, prop->max, f);
2291 } else 2291 } else
2292 mp_msg(MSGT_CPLAYER, MSGL_ERR, 2292 mp_msg(MSGT_CPLAYER, MSGL_ERR,
2293 "Property use an unsupported type.\n"); 2293 "Property use an unsupported type.\n");
2294 return 1; 2294 return 1;
2295 } 2295 }
2296 2296
2297 if (set_prop_cmd[i].osd_msg) { 2297 if (set_prop_cmd[i].osd_msg) {
2298 char *val = mp_property_print(pname, mpctx); 2298 char *val = mp_property_print(pname, mpctx);
2299 if (val) { 2299 if (val) {
2300 set_osd_msg(set_prop_cmd[i].osd_id >= 2300 set_osd_msg(set_prop_cmd[i].osd_id >=
2301 0 ? set_prop_cmd[i].osd_id : OSD_MSG_PROPERTY + i, 2301 0 ? set_prop_cmd[i].osd_id : OSD_MSG_PROPERTY + i,
2302 1, osd_duration, set_prop_cmd[i].osd_msg, val); 2302 1, osd_duration, set_prop_cmd[i].osd_msg, val);
2303 free(val); 2303 free(val);
2304 } 2304 }
2305 } 2305 }
2306 return 1; 2306 return 1;
2307 } 2307 }
2308 2308
2309 #ifdef CONFIG_DVDNAV 2309 #ifdef CONFIG_DVDNAV
2411 { 2411 {
2412 sh_audio_t * const sh_audio = mpctx->sh_audio; 2412 sh_audio_t * const sh_audio = mpctx->sh_audio;
2413 sh_video_t * const sh_video = mpctx->sh_video; 2413 sh_video_t * const sh_video = mpctx->sh_video;
2414 int brk_cmd = 0; 2414 int brk_cmd = 0;
2415 if (!set_property_command(mpctx, cmd)) 2415 if (!set_property_command(mpctx, cmd))
2416 switch (cmd->id) { 2416 switch (cmd->id) {
2417 case MP_CMD_SEEK:{ 2417 case MP_CMD_SEEK:{
2418 float v; 2418 float v;
2419 int abs; 2419 int abs;
2420 if (sh_video) 2420 if (sh_video)
2421 mpctx->osd_show_percentage = sh_video->fps; 2421 mpctx->osd_show_percentage = sh_video->fps;
2422 v = cmd->args[0].v.f; 2422 v = cmd->args[0].v.f;
2423 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0; 2423 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
2424 if (abs == 2) { /* Absolute seek to a specific timestamp in seconds */ 2424 if (abs == 2) { /* Absolute seek to a specific timestamp in seconds */
2425 abs_seek_pos = SEEK_ABSOLUTE; 2425 abs_seek_pos = SEEK_ABSOLUTE;
2426 if (sh_video) 2426 if (sh_video)
2427 mpctx->osd_function = 2427 mpctx->osd_function =
2428 (v > sh_video->pts) ? OSD_FFW : OSD_REW; 2428 (v > sh_video->pts) ? OSD_FFW : OSD_REW;
2429 rel_seek_secs = v; 2429 rel_seek_secs = v;
2430 } else if (abs) { /* Absolute seek by percentage */ 2430 } else if (abs) { /* Absolute seek by percentage */
2431 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; 2431 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR;
2432 if (sh_video) 2432 if (sh_video)
2433 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly 2433 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly
2434 rel_seek_secs = v / 100.0; 2434 rel_seek_secs = v / 100.0;
2435 } else { 2435 } else {
2436 rel_seek_secs += v; 2436 rel_seek_secs += v;
2437 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW; 2437 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW;
2438 } 2438 }
2439 brk_cmd = 1; 2439 brk_cmd = 1;
2440 } 2440 }
2441 break; 2441 break;
2442 2442
2443 case MP_CMD_SET_PROPERTY:{ 2443 case MP_CMD_SET_PROPERTY:{
2444 int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_PARSE, 2444 int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_PARSE,
2445 cmd->args[1].v.s, mpctx); 2445 cmd->args[1].v.s, mpctx);
2446 if (r == M_PROPERTY_UNKNOWN) 2446 if (r == M_PROPERTY_UNKNOWN)
2447 mp_msg(MSGT_CPLAYER, MSGL_WARN, 2447 mp_msg(MSGT_CPLAYER, MSGL_WARN,
2448 "Unknown property: '%s'\n", cmd->args[0].v.s); 2448 "Unknown property: '%s'\n", cmd->args[0].v.s);
2449 else if (r <= 0) 2449 else if (r <= 0)
2450 mp_msg(MSGT_CPLAYER, MSGL_WARN, 2450 mp_msg(MSGT_CPLAYER, MSGL_WARN,
2451 "Failed to set property '%s' to '%s'.\n", 2451 "Failed to set property '%s' to '%s'.\n",
2452 cmd->args[0].v.s, cmd->args[1].v.s); 2452 cmd->args[0].v.s, cmd->args[1].v.s);
2453 if (r <= 0) 2453 if (r <= 0)
2454 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r)); 2454 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r));
2455 } 2455 }
2456 break; 2456 break;
2457 2457
2458 case MP_CMD_STEP_PROPERTY:{ 2458 case MP_CMD_STEP_PROPERTY:{
2459 void* arg = NULL; 2459 void* arg = NULL;
2460 int r,i; 2460 int r,i;
2461 double d; 2461 double d;
2462 off_t o; 2462 off_t o;
2463 if (cmd->args[1].v.f) { 2463 if (cmd->args[1].v.f) {
2464 m_option_t* prop; 2464 m_option_t* prop;
2465 if((r = mp_property_do(cmd->args[0].v.s, 2465 if((r = mp_property_do(cmd->args[0].v.s,
2466 M_PROPERTY_GET_TYPE, 2466 M_PROPERTY_GET_TYPE,
2467 &prop, mpctx)) <= 0) 2467 &prop, mpctx)) <= 0)
2468 goto step_prop_err; 2468 goto step_prop_err;
2469 if(prop->type == CONF_TYPE_INT || 2469 if(prop->type == CONF_TYPE_INT ||
2470 prop->type == CONF_TYPE_FLAG) 2470 prop->type == CONF_TYPE_FLAG)
2471 i = cmd->args[1].v.f, arg = &i; 2471 i = cmd->args[1].v.f, arg = &i;
2472 else if(prop->type == CONF_TYPE_FLOAT) 2472 else if(prop->type == CONF_TYPE_FLOAT)
2473 arg = &cmd->args[1].v.f; 2473 arg = &cmd->args[1].v.f;
2474 else if(prop->type == CONF_TYPE_DOUBLE || 2474 else if(prop->type == CONF_TYPE_DOUBLE ||
2475 prop->type == CONF_TYPE_TIME) 2475 prop->type == CONF_TYPE_TIME)
2476 d = cmd->args[1].v.f, arg = &d; 2476 d = cmd->args[1].v.f, arg = &d;
2477 else if(prop->type == CONF_TYPE_POSITION) 2477 else if(prop->type == CONF_TYPE_POSITION)
2478 o = cmd->args[1].v.f, arg = &o; 2478 o = cmd->args[1].v.f, arg = &o;
2479 else 2479 else
2480 mp_msg(MSGT_CPLAYER, MSGL_WARN, 2480 mp_msg(MSGT_CPLAYER, MSGL_WARN,
2481 "Ignoring step size stepping property '%s'.\n", 2481 "Ignoring step size stepping property '%s'.\n",
2482 cmd->args[0].v.s); 2482 cmd->args[0].v.s);
2483 } 2483 }
2484 r = mp_property_do(cmd->args[0].v.s, 2484 r = mp_property_do(cmd->args[0].v.s,
2485 cmd->args[2].v.i < 0 ? 2485 cmd->args[2].v.i < 0 ?
2486 M_PROPERTY_STEP_DOWN : M_PROPERTY_STEP_UP, 2486 M_PROPERTY_STEP_DOWN : M_PROPERTY_STEP_UP,
2487 arg, mpctx); 2487 arg, mpctx);
2488 step_prop_err: 2488 step_prop_err:
2489 if (r == M_PROPERTY_UNKNOWN) 2489 if (r == M_PROPERTY_UNKNOWN)
2490 mp_msg(MSGT_CPLAYER, MSGL_WARN, 2490 mp_msg(MSGT_CPLAYER, MSGL_WARN,
2491 "Unknown property: '%s'\n", cmd->args[0].v.s); 2491 "Unknown property: '%s'\n", cmd->args[0].v.s);
2492 else if (r <= 0) 2492 else if (r <= 0)
2493 mp_msg(MSGT_CPLAYER, MSGL_WARN, 2493 mp_msg(MSGT_CPLAYER, MSGL_WARN,
2494 "Failed to increment property '%s' by %f.\n", 2494 "Failed to increment property '%s' by %f.\n",
2495 cmd->args[0].v.s, cmd->args[1].v.f); 2495 cmd->args[0].v.s, cmd->args[1].v.f);
2496 if (r <= 0) 2496 if (r <= 0)
2497 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r)); 2497 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r));
2498 } 2498 }
2499 break; 2499 break;
2500 2500
2501 case MP_CMD_GET_PROPERTY:{ 2501 case MP_CMD_GET_PROPERTY:{
2502 char *tmp; 2502 char *tmp;
2503 int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_TO_STRING, 2503 int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_TO_STRING,
2504 &tmp, mpctx); 2504 &tmp, mpctx);
2505 if (r <= 0) { 2505 if (r <= 0) {
2506 mp_msg(MSGT_CPLAYER, MSGL_WARN, 2506 mp_msg(MSGT_CPLAYER, MSGL_WARN,
2507 "Failed to get value of property '%s'.\n", 2507 "Failed to get value of property '%s'.\n",
2508 cmd->args[0].v.s); 2508 cmd->args[0].v.s);
2509 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r)); 2509 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n", property_error_string(r));
2510 break; 2510 break;
2511 } 2511 }
2512 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_%s=%s\n", 2512 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_%s=%s\n",
2513 cmd->args[0].v.s, tmp); 2513 cmd->args[0].v.s, tmp);
2514 free(tmp); 2514 free(tmp);
2515 } 2515 }
2516 break; 2516 break;
2517 2517
2518 case MP_CMD_EDL_MARK: 2518 case MP_CMD_EDL_MARK:
2519 if (edl_fd) { 2519 if (edl_fd) {
2520 float v = sh_video ? sh_video->pts : 2520 float v = sh_video ? sh_video->pts :
2521 playing_audio_pts(sh_audio, mpctx->d_audio, 2521 playing_audio_pts(sh_audio, mpctx->d_audio,
2522 mpctx->audio_out); 2522 mpctx->audio_out);
2523 2523
2524 if (mpctx->begin_skip == MP_NOPTS_VALUE) { 2524 if (mpctx->begin_skip == MP_NOPTS_VALUE) {
2525 mpctx->begin_skip = v; 2525 mpctx->begin_skip = v;
2526 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip); 2526 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip);
2527 } else { 2527 } else {
2528 if (mpctx->begin_skip > v) 2528 if (mpctx->begin_skip > v)
2529 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop); 2529 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop);
2530 else { 2530 else {
2531 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0); 2531 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0);
2532 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip); 2532 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip);
2533 } 2533 }
2534 mpctx->begin_skip = MP_NOPTS_VALUE; 2534 mpctx->begin_skip = MP_NOPTS_VALUE;
2535 } 2535 }
2536 } 2536 }
2537 break; 2537 break;
2538 2538
2539 case MP_CMD_SWITCH_RATIO: 2539 case MP_CMD_SWITCH_RATIO:
2540 if (!sh_video) 2540 if (!sh_video)
2541 break; 2541 break;
2542 if (cmd->nargs == 0 || cmd->args[0].v.f == -1) 2542 if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
2543 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h; 2543 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
2544 else 2544 else
2545 movie_aspect = cmd->args[0].v.f; 2545 movie_aspect = cmd->args[0].v.f;
2546 mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0); 2546 mpcodecs_config_vo(sh_video, sh_video->disp_w, sh_video->disp_h, 0);
2547 break; 2547 break;
2548 2548
2549 case MP_CMD_SPEED_INCR:{ 2549 case MP_CMD_SPEED_INCR:{
2550 float v = cmd->args[0].v.f; 2550 float v = cmd->args[0].v.f;
2551 playback_speed += v; 2551 playback_speed += v;
2552 build_afilter_chain(sh_audio, &ao_data); 2552 build_afilter_chain(sh_audio, &ao_data);
2553 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed, 2553 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
2554 playback_speed); 2554 playback_speed);
2555 } break; 2555 } break;
2556 2556
2557 case MP_CMD_SPEED_MULT:{ 2557 case MP_CMD_SPEED_MULT:{
2558 float v = cmd->args[0].v.f; 2558 float v = cmd->args[0].v.f;
2559 playback_speed *= v; 2559 playback_speed *= v;
2560 build_afilter_chain(sh_audio, &ao_data); 2560 build_afilter_chain(sh_audio, &ao_data);
2561 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed, 2561 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
2562 playback_speed); 2562 playback_speed);
2563 } break; 2563 } break;
2564 2564
2565 case MP_CMD_SPEED_SET:{ 2565 case MP_CMD_SPEED_SET:{
2566 float v = cmd->args[0].v.f; 2566 float v = cmd->args[0].v.f;
2567 playback_speed = v; 2567 playback_speed = v;
2568 build_afilter_chain(sh_audio, &ao_data); 2568 build_afilter_chain(sh_audio, &ao_data);
2569 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed, 2569 set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDSpeed,
2570 playback_speed); 2570 playback_speed);
2571 } break; 2571 } break;
2572 2572
2573 case MP_CMD_FRAME_STEP: 2573 case MP_CMD_FRAME_STEP:
2574 case MP_CMD_PAUSE: 2574 case MP_CMD_PAUSE:
2575 cmd->pausing = 1; 2575 cmd->pausing = 1;
2576 brk_cmd = 1; 2576 brk_cmd = 1;
2577 break; 2577 break;
2578 2578
2579 case MP_CMD_FILE_FILTER: 2579 case MP_CMD_FILE_FILTER:
2580 file_filter = cmd->args[0].v.i; 2580 file_filter = cmd->args[0].v.i;
2581 break; 2581 break;
2582 2582
2583 case MP_CMD_QUIT: 2583 case MP_CMD_QUIT:
2584 exit_player_with_rc(EXIT_QUIT, 2584 exit_player_with_rc(EXIT_QUIT,
2585 (cmd->nargs > 0) ? cmd->args[0].v.i : 0); 2585 (cmd->nargs > 0) ? cmd->args[0].v.i : 0);
2586 2586
2587 case MP_CMD_PLAY_TREE_STEP:{ 2587 case MP_CMD_PLAY_TREE_STEP:{
2588 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i; 2588 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i;
2589 int force = cmd->args[1].v.i; 2589 int force = cmd->args[1].v.i;
2590 2590
2591 #ifdef CONFIG_GUI 2591 #ifdef CONFIG_GUI
2592 if (use_gui) { 2592 if (use_gui) {
2593 int i = 0; 2593 int i = 0;
2594 if (n > 0) 2594 if (n > 0)
2595 for (i = 0; i < n; i++) 2595 for (i = 0; i < n; i++)
2596 mplNext(); 2596 mplNext();
2597 else 2597 else
2598 for (i = 0; i < -1 * n; i++) 2598 for (i = 0; i < -1 * n; i++)
2599 mplPrev(); 2599 mplPrev();
2600 } else 2600 } else
2601 #endif 2601 #endif
2602 { 2602 {
2603 if (!force && mpctx->playtree_iter) { 2603 if (!force && mpctx->playtree_iter) {
2604 play_tree_iter_t *i = 2604 play_tree_iter_t *i =
2605 play_tree_iter_new_copy(mpctx->playtree_iter); 2605 play_tree_iter_new_copy(mpctx->playtree_iter);
2606 if (play_tree_iter_step(i, n, 0) == 2606 if (play_tree_iter_step(i, n, 0) ==
2607 PLAY_TREE_ITER_ENTRY) 2607 PLAY_TREE_ITER_ENTRY)
2608 mpctx->eof = 2608 mpctx->eof =
2609 (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; 2609 (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
2610 play_tree_iter_free(i); 2610 play_tree_iter_free(i);
2611 } else 2611 } else
2612 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY; 2612 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
2613 if (mpctx->eof) 2613 if (mpctx->eof)
2614 mpctx->play_tree_step = n; 2614 mpctx->play_tree_step = n;
2615 brk_cmd = 1; 2615 brk_cmd = 1;
2616 } 2616 }
2617 } 2617 }
2618 break; 2618 break;
2619 2619
2620 case MP_CMD_PLAY_TREE_UP_STEP:{ 2620 case MP_CMD_PLAY_TREE_UP_STEP:{
2621 int n = cmd->args[0].v.i > 0 ? 1 : -1; 2621 int n = cmd->args[0].v.i > 0 ? 1 : -1;
2622 int force = cmd->args[1].v.i; 2622 int force = cmd->args[1].v.i;
2623 2623
2624 if (!force && mpctx->playtree_iter) { 2624 if (!force && mpctx->playtree_iter) {
2625 play_tree_iter_t *i = 2625 play_tree_iter_t *i =
2626 play_tree_iter_new_copy(mpctx->playtree_iter); 2626 play_tree_iter_new_copy(mpctx->playtree_iter);
2627 if (play_tree_iter_up_step(i, n, 0) == PLAY_TREE_ITER_ENTRY) 2627 if (play_tree_iter_up_step(i, n, 0) == PLAY_TREE_ITER_ENTRY)
2628 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV; 2628 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
2629 play_tree_iter_free(i); 2629 play_tree_iter_free(i);
2630 } else 2630 } else
2631 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV; 2631 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
2632 brk_cmd = 1; 2632 brk_cmd = 1;
2633 } 2633 }
2634 break; 2634 break;
2635 2635
2636 case MP_CMD_PLAY_ALT_SRC_STEP: 2636 case MP_CMD_PLAY_ALT_SRC_STEP:
2637 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) { 2637 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) {
2638 int v = cmd->args[0].v.i; 2638 int v = cmd->args[0].v.i;
2639 if (v > 0 2639 if (v > 0
2640 && mpctx->playtree_iter->file < 2640 && mpctx->playtree_iter->file <
2641 mpctx->playtree_iter->num_files) 2641 mpctx->playtree_iter->num_files)
2642 mpctx->eof = PT_NEXT_SRC; 2642 mpctx->eof = PT_NEXT_SRC;
2643 else if (v < 0 && mpctx->playtree_iter->file > 1) 2643 else if (v < 0 && mpctx->playtree_iter->file > 1)
2644 mpctx->eof = PT_PREV_SRC; 2644 mpctx->eof = PT_PREV_SRC;
2645 } 2645 }
2646 brk_cmd = 1; 2646 brk_cmd = 1;
2647 break; 2647 break;
2648 2648
2649 case MP_CMD_SUB_STEP: 2649 case MP_CMD_SUB_STEP:
2650 if (sh_video) { 2650 if (sh_video) {
2651 int movement = cmd->args[0].v.i; 2651 int movement = cmd->args[0].v.i;
2652 step_sub(subdata, sh_video->pts, movement); 2652 step_sub(subdata, sh_video->pts, movement);
2653 #ifdef CONFIG_ASS 2653 #ifdef CONFIG_ASS
2654 if (ass_track) 2654 if (ass_track)
2655 sub_delay += 2655 sub_delay +=
2656 ass_step_sub(ass_track, 2656 ass_step_sub(ass_track,
2657 (sh_video->pts + 2657 (sh_video->pts +
2658 sub_delay) * 1000 + .5, movement) / 1000.; 2658 sub_delay) * 1000 + .5, movement) / 1000.;
2659 #endif 2659 #endif
2660 set_osd_msg(OSD_MSG_SUB_DELAY, 1, osd_duration, 2660 set_osd_msg(OSD_MSG_SUB_DELAY, 1, osd_duration,
2661 MSGTR_OSDSubDelay, ROUND(sub_delay * 1000)); 2661 MSGTR_OSDSubDelay, ROUND(sub_delay * 1000));
2662 } 2662 }
2663 break; 2663 break;
2664 2664
2665 case MP_CMD_SUB_LOG: 2665 case MP_CMD_SUB_LOG:
2666 log_sub(); 2666 log_sub();
2667 break; 2667 break;
2668 2668
2669 case MP_CMD_OSD:{ 2669 case MP_CMD_OSD:{
2670 int v = cmd->args[0].v.i; 2670 int v = cmd->args[0].v.i;
2671 int max = (term_osd 2671 int max = (term_osd
2672 && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL; 2672 && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
2673 if (osd_level > max) 2673 if (osd_level > max)
2674 osd_level = max; 2674 osd_level = max;
2675 if (v < 0) 2675 if (v < 0)
2676 osd_level = (osd_level + 1) % (max + 1); 2676 osd_level = (osd_level + 1) % (max + 1);
2677 else 2677 else
2678 osd_level = v > max ? max : v; 2678 osd_level = v > max ? max : v;
2679 /* Show OSD state when disabled, but not when an explicit 2679 /* Show OSD state when disabled, but not when an explicit
2680 argument is given to the OSD command, i.e. in slave mode. */ 2680 argument is given to the OSD command, i.e. in slave mode. */
2681 if (v == -1 && osd_level <= 1) 2681 if (v == -1 && osd_level <= 1)
2682 set_osd_msg(OSD_MSG_OSD_STATUS, 0, osd_duration, 2682 set_osd_msg(OSD_MSG_OSD_STATUS, 0, osd_duration,
2683 MSGTR_OSDosd, 2683 MSGTR_OSDosd,
2684 osd_level ? MSGTR_OSDenabled : 2684 osd_level ? MSGTR_OSDenabled :
2685 MSGTR_OSDdisabled); 2685 MSGTR_OSDdisabled);
2686 else 2686 else
2687 rm_osd_msg(OSD_MSG_OSD_STATUS); 2687 rm_osd_msg(OSD_MSG_OSD_STATUS);
2688 } 2688 }
2689 break; 2689 break;
2690 2690
2691 case MP_CMD_OSD_SHOW_TEXT: 2691 case MP_CMD_OSD_SHOW_TEXT:
2692 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i, 2692 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i,
2693 (cmd->args[1].v.i < 2693 (cmd->args[1].v.i <
2694 0 ? osd_duration : cmd->args[1].v.i), 2694 0 ? osd_duration : cmd->args[1].v.i),
2695 "%-.63s", cmd->args[0].v.s); 2695 "%-.63s", cmd->args[0].v.s);
2696 break; 2696 break;
2697 2697
2698 case MP_CMD_OSD_SHOW_PROPERTY_TEXT:{ 2698 case MP_CMD_OSD_SHOW_PROPERTY_TEXT:{
2699 char *txt = m_properties_expand_string(mp_properties, 2699 char *txt = m_properties_expand_string(mp_properties,
2700 cmd->args[0].v.s, 2700 cmd->args[0].v.s,
2701 mpctx); 2701 mpctx);
2702 /* if no argument supplied take default osd_duration, else <arg> ms. */ 2702 /* if no argument supplied take default osd_duration, else <arg> ms. */
2703 if (txt) { 2703 if (txt) {
2704 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i, 2704 set_osd_msg(OSD_MSG_TEXT, cmd->args[2].v.i,
2705 (cmd->args[1].v.i < 2705 (cmd->args[1].v.i <
2706 0 ? osd_duration : cmd->args[1].v.i), 2706 0 ? osd_duration : cmd->args[1].v.i),
2707 "%-.63s", txt); 2707 "%-.63s", txt);
2708 free(txt); 2708 free(txt);
2709 } 2709 }
2710 } 2710 }
2711 break; 2711 break;
2712 2712
2713 case MP_CMD_LOADFILE:{ 2713 case MP_CMD_LOADFILE:{
2714 play_tree_t *e = play_tree_new(); 2714 play_tree_t *e = play_tree_new();
2715 play_tree_add_file(e, cmd->args[0].v.s); 2715 play_tree_add_file(e, cmd->args[0].v.s);
2716 2716
2717 if (cmd->args[1].v.i) // append 2717 if (cmd->args[1].v.i) // append
2718 play_tree_append_entry(mpctx->playtree->child, e); 2718 play_tree_append_entry(mpctx->playtree->child, e);
2719 else { 2719 else {
2720 // Go back to the starting point. 2720 // Go back to the starting point.
2721 while (play_tree_iter_up_step 2721 while (play_tree_iter_up_step
2722 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) 2722 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
2723 /* NOP */ ; 2723 /* NOP */ ;
2724 play_tree_free_list(mpctx->playtree->child, 1); 2724 play_tree_free_list(mpctx->playtree->child, 1);
2725 play_tree_set_child(mpctx->playtree, e); 2725 play_tree_set_child(mpctx->playtree, e);
2726 pt_iter_goto_head(mpctx->playtree_iter); 2726 pt_iter_goto_head(mpctx->playtree_iter);
2727 mpctx->eof = PT_NEXT_SRC; 2727 mpctx->eof = PT_NEXT_SRC;
2728 } 2728 }
2729 brk_cmd = 1; 2729 brk_cmd = 1;
2730 } 2730 }
2731 break; 2731 break;
2732 2732
2733 case MP_CMD_LOADLIST:{ 2733 case MP_CMD_LOADLIST:{
2734 play_tree_t *e = parse_playlist_file(cmd->args[0].v.s); 2734 play_tree_t *e = parse_playlist_file(cmd->args[0].v.s);
2735 if (!e) 2735 if (!e)
2736 mp_msg(MSGT_CPLAYER, MSGL_ERR, 2736 mp_msg(MSGT_CPLAYER, MSGL_ERR,
2737 MSGTR_PlaylistLoadUnable, cmd->args[0].v.s); 2737 MSGTR_PlaylistLoadUnable, cmd->args[0].v.s);
2738 else { 2738 else {
2739 if (cmd->args[1].v.i) // append 2739 if (cmd->args[1].v.i) // append
2740 play_tree_append_entry(mpctx->playtree->child, e); 2740 play_tree_append_entry(mpctx->playtree->child, e);
2741 else { 2741 else {
2742 // Go back to the starting point. 2742 // Go back to the starting point.
2743 while (play_tree_iter_up_step 2743 while (play_tree_iter_up_step
2744 (mpctx->playtree_iter, 0, 1) 2744 (mpctx->playtree_iter, 0, 1)
2745 != PLAY_TREE_ITER_END) 2745 != PLAY_TREE_ITER_END)
2746 /* NOP */ ; 2746 /* NOP */ ;
2747 play_tree_free_list(mpctx->playtree->child, 1); 2747 play_tree_free_list(mpctx->playtree->child, 1);
2748 play_tree_set_child(mpctx->playtree, e); 2748 play_tree_set_child(mpctx->playtree, e);
2749 pt_iter_goto_head(mpctx->playtree_iter); 2749 pt_iter_goto_head(mpctx->playtree_iter);
2750 mpctx->eof = PT_NEXT_SRC; 2750 mpctx->eof = PT_NEXT_SRC;
2751 } 2751 }
2752 } 2752 }
2753 brk_cmd = 1; 2753 brk_cmd = 1;
2754 } 2754 }
2755 break; 2755 break;
2756 2756
2757 case MP_CMD_STOP: 2757 case MP_CMD_STOP:
2758 // Go back to the starting point. 2758 // Go back to the starting point.
2759 while (play_tree_iter_up_step 2759 while (play_tree_iter_up_step
2760 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) 2760 (mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
2761 /* NOP */ ; 2761 /* NOP */ ;
2762 mpctx->eof = PT_STOP; 2762 mpctx->eof = PT_STOP;
2763 brk_cmd = 1; 2763 brk_cmd = 1;
2764 break; 2764 break;
2765 2765
2766 case MP_CMD_OSD_SHOW_PROGRESSION:{ 2766 case MP_CMD_OSD_SHOW_PROGRESSION:{
2767 int len = demuxer_get_time_length(mpctx->demuxer); 2767 int len = demuxer_get_time_length(mpctx->demuxer);
2768 int pts = demuxer_get_current_time(mpctx->demuxer); 2768 int pts = demuxer_get_current_time(mpctx->demuxer);
2769 set_osd_bar(0, "Position", 0, 100, demuxer_get_percent_pos(mpctx->demuxer)); 2769 set_osd_bar(0, "Position", 0, 100, demuxer_get_percent_pos(mpctx->demuxer));
2770 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, 2770 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
2771 "%c %02d:%02d:%02d / %02d:%02d:%02d", 2771 "%c %02d:%02d:%02d / %02d:%02d:%02d",
2772 mpctx->osd_function, pts/3600, (pts/60)%60, pts%60, 2772 mpctx->osd_function, pts/3600, (pts/60)%60, pts%60,
2773 len/3600, (len/60)%60, len%60); 2773 len/3600, (len/60)%60, len%60);
2774 } 2774 }
2775 break; 2775 break;
2776 2776
2777 #ifdef CONFIG_RADIO 2777 #ifdef CONFIG_RADIO
2778 case MP_CMD_RADIO_STEP_CHANNEL: 2778 case MP_CMD_RADIO_STEP_CHANNEL:
2779 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { 2779 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
2780 int v = cmd->args[0].v.i; 2780 int v = cmd->args[0].v.i;
2781 if (v > 0) 2781 if (v > 0)
2782 radio_step_channel(mpctx->demuxer->stream, 2782 radio_step_channel(mpctx->demuxer->stream,
2783 RADIO_CHANNEL_HIGHER); 2783 RADIO_CHANNEL_HIGHER);
2784 else 2784 else
2785 radio_step_channel(mpctx->demuxer->stream, 2785 radio_step_channel(mpctx->demuxer->stream,
2786 RADIO_CHANNEL_LOWER); 2786 RADIO_CHANNEL_LOWER);
2787 if (radio_get_channel_name(mpctx->demuxer->stream)) { 2787 if (radio_get_channel_name(mpctx->demuxer->stream)) {
2788 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration, 2788 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
2789 MSGTR_OSDChannel, 2789 MSGTR_OSDChannel,
2790 radio_get_channel_name(mpctx->demuxer->stream)); 2790 radio_get_channel_name(mpctx->demuxer->stream));
2791 } 2791 }
2792 } 2792 }
2793 break; 2793 break;
2794 2794
2795 case MP_CMD_RADIO_SET_CHANNEL: 2795 case MP_CMD_RADIO_SET_CHANNEL:
2796 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { 2796 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
2797 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s); 2797 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s);
2798 if (radio_get_channel_name(mpctx->demuxer->stream)) { 2798 if (radio_get_channel_name(mpctx->demuxer->stream)) {
2799 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration, 2799 set_osd_msg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
2800 MSGTR_OSDChannel, 2800 MSGTR_OSDChannel,
2801 radio_get_channel_name(mpctx->demuxer->stream)); 2801 radio_get_channel_name(mpctx->demuxer->stream));
2802 } 2802 }
2803 } 2803 }
2804 break; 2804 break;
2805 2805
2806 case MP_CMD_RADIO_SET_FREQ: 2806 case MP_CMD_RADIO_SET_FREQ:
2807 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) 2807 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
2808 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f); 2808 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
2809 break; 2809 break;
2810 2810
2811 case MP_CMD_RADIO_STEP_FREQ: 2811 case MP_CMD_RADIO_STEP_FREQ:
2812 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) 2812 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
2813 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f); 2813 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
2814 break; 2814 break;
2815 #endif 2815 #endif
2816 2816
2817 #ifdef CONFIG_TV 2817 #ifdef CONFIG_TV
2818 case MP_CMD_TV_START_SCAN: 2818 case MP_CMD_TV_START_SCAN:
2819 if (mpctx->file_format == DEMUXER_TYPE_TV) 2819 if (mpctx->file_format == DEMUXER_TYPE_TV)
2820 tv_start_scan((tvi_handle_t *) (mpctx->demuxer->priv),1); 2820 tv_start_scan((tvi_handle_t *) (mpctx->demuxer->priv),1);
2821 break; 2821 break;
2822 case MP_CMD_TV_SET_FREQ: 2822 case MP_CMD_TV_SET_FREQ:
2823 if (mpctx->file_format == DEMUXER_TYPE_TV) 2823 if (mpctx->file_format == DEMUXER_TYPE_TV)
2824 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv), 2824 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv),
2825 cmd->args[0].v.f * 16.0); 2825 cmd->args[0].v.f * 16.0);
2826 #ifdef CONFIG_PVR 2826 #ifdef CONFIG_PVR
2827 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { 2827 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
2828 pvr_set_freq (mpctx->stream, ROUND (cmd->args[0].v.f)); 2828 pvr_set_freq (mpctx->stream, ROUND (cmd->args[0].v.f));
2829 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", 2829 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
2830 pvr_get_current_channelname (mpctx->stream), 2830 pvr_get_current_channelname (mpctx->stream),
2831 pvr_get_current_stationname (mpctx->stream)); 2831 pvr_get_current_stationname (mpctx->stream));
2832 } 2832 }
2833 #endif /* CONFIG_PVR */ 2833 #endif /* CONFIG_PVR */
2834 break; 2834 break;
2835 2835
2836 case MP_CMD_TV_STEP_FREQ: 2836 case MP_CMD_TV_STEP_FREQ:
2837 if (mpctx->file_format == DEMUXER_TYPE_TV) 2837 if (mpctx->file_format == DEMUXER_TYPE_TV)
2838 tv_step_freq((tvi_handle_t *) (mpctx->demuxer->priv), 2838 tv_step_freq((tvi_handle_t *) (mpctx->demuxer->priv),
2839 cmd->args[0].v.f * 16.0); 2839 cmd->args[0].v.f * 16.0);
2840 #ifdef CONFIG_PVR 2840 #ifdef CONFIG_PVR
2841 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { 2841 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
2842 pvr_force_freq_step (mpctx->stream, ROUND (cmd->args[0].v.f)); 2842 pvr_force_freq_step (mpctx->stream, ROUND (cmd->args[0].v.f));
2843 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: f %d", 2843 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: f %d",
2844 pvr_get_current_channelname (mpctx->stream), 2844 pvr_get_current_channelname (mpctx->stream),
2845 pvr_get_current_frequency (mpctx->stream)); 2845 pvr_get_current_frequency (mpctx->stream));
2846 } 2846 }
2847 #endif /* CONFIG_PVR */ 2847 #endif /* CONFIG_PVR */
2848 break; 2848 break;
2849 2849
2850 case MP_CMD_TV_SET_NORM: 2850 case MP_CMD_TV_SET_NORM:
2851 if (mpctx->file_format == DEMUXER_TYPE_TV) 2851 if (mpctx->file_format == DEMUXER_TYPE_TV)
2852 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv), 2852 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv),
2853 cmd->args[0].v.s); 2853 cmd->args[0].v.s);
2854 break; 2854 break;
2855 2855
2856 case MP_CMD_TV_STEP_CHANNEL:{ 2856 case MP_CMD_TV_STEP_CHANNEL:{
2857 if (mpctx->file_format == DEMUXER_TYPE_TV) { 2857 if (mpctx->file_format == DEMUXER_TYPE_TV) {
2858 int v = cmd->args[0].v.i; 2858 int v = cmd->args[0].v.i;
2859 if (v > 0) { 2859 if (v > 0) {
2860 tv_step_channel((tvi_handle_t *) (mpctx-> 2860 tv_step_channel((tvi_handle_t *) (mpctx->
2861 demuxer->priv), 2861 demuxer->priv),
2862 TV_CHANNEL_HIGHER); 2862 TV_CHANNEL_HIGHER);
2863 } else { 2863 } else {
2864 tv_step_channel((tvi_handle_t *) (mpctx-> 2864 tv_step_channel((tvi_handle_t *) (mpctx->
2865 demuxer->priv), 2865 demuxer->priv),
2866 TV_CHANNEL_LOWER); 2866 TV_CHANNEL_LOWER);
2867 } 2867 }
2868 if (tv_channel_list) { 2868 if (tv_channel_list) {
2869 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration, 2869 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
2870 MSGTR_OSDChannel, tv_channel_current->name); 2870 MSGTR_OSDChannel, tv_channel_current->name);
2871 //vo_osd_changed(OSDTYPE_SUBTITLE); 2871 //vo_osd_changed(OSDTYPE_SUBTITLE);
2872 } 2872 }
2873 } 2873 }
2874 #ifdef CONFIG_PVR 2874 #ifdef CONFIG_PVR
2875 else if (mpctx->stream && 2875 else if (mpctx->stream &&
2876 mpctx->stream->type == STREAMTYPE_PVR) { 2876 mpctx->stream->type == STREAMTYPE_PVR) {
2877 pvr_set_channel_step (mpctx->stream, cmd->args[0].v.i); 2877 pvr_set_channel_step (mpctx->stream, cmd->args[0].v.i);
2878 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", 2878 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
2879 pvr_get_current_channelname (mpctx->stream), 2879 pvr_get_current_channelname (mpctx->stream),
2880 pvr_get_current_stationname (mpctx->stream)); 2880 pvr_get_current_stationname (mpctx->stream));
2881 } 2881 }
2882 #endif /* CONFIG_PVR */ 2882 #endif /* CONFIG_PVR */
2883 } 2883 }
2884 #ifdef CONFIG_DVBIN 2884 #ifdef CONFIG_DVBIN
2885 if (mpctx->stream->type == STREAMTYPE_DVB) { 2885 if (mpctx->stream->type == STREAMTYPE_DVB) {
2886 int dir; 2886 int dir;
2887 int v = cmd->args[0].v.i; 2887 int v = cmd->args[0].v.i;
2888 2888
2889 mpctx->last_dvb_step = v; 2889 mpctx->last_dvb_step = v;
2890 if (v > 0) 2890 if (v > 0)
2891 dir = DVB_CHANNEL_HIGHER; 2891 dir = DVB_CHANNEL_HIGHER;
2892 else 2892 else
2893 dir = DVB_CHANNEL_LOWER; 2893 dir = DVB_CHANNEL_LOWER;
2894 2894
2895 2895
2896 if (dvb_step_channel(mpctx->stream, dir)) 2896 if (dvb_step_channel(mpctx->stream, dir))
2897 mpctx->eof = mpctx->dvbin_reopen = 1; 2897 mpctx->eof = mpctx->dvbin_reopen = 1;
2898 } 2898 }
2899 #endif /* CONFIG_DVBIN */ 2899 #endif /* CONFIG_DVBIN */
2900 break; 2900 break;
2901 2901
2902 case MP_CMD_TV_SET_CHANNEL: 2902 case MP_CMD_TV_SET_CHANNEL:
2903 if (mpctx->file_format == DEMUXER_TYPE_TV) { 2903 if (mpctx->file_format == DEMUXER_TYPE_TV) {
2904 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv), 2904 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv),
2905 cmd->args[0].v.s); 2905 cmd->args[0].v.s);
2906 if (tv_channel_list) { 2906 if (tv_channel_list) {
2907 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration, 2907 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
2908 MSGTR_OSDChannel, tv_channel_current->name); 2908 MSGTR_OSDChannel, tv_channel_current->name);
2909 //vo_osd_changed(OSDTYPE_SUBTITLE); 2909 //vo_osd_changed(OSDTYPE_SUBTITLE);
2910 } 2910 }
2911 } 2911 }
2912 #ifdef CONFIG_PVR 2912 #ifdef CONFIG_PVR
2913 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { 2913 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
2914 pvr_set_channel (mpctx->stream, cmd->args[0].v.s); 2914 pvr_set_channel (mpctx->stream, cmd->args[0].v.s);
2915 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", 2915 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
2916 pvr_get_current_channelname (mpctx->stream), 2916 pvr_get_current_channelname (mpctx->stream),
2917 pvr_get_current_stationname (mpctx->stream)); 2917 pvr_get_current_stationname (mpctx->stream));
2918 } 2918 }
2919 #endif /* CONFIG_PVR */ 2919 #endif /* CONFIG_PVR */
2920 break; 2920 break;
2921 2921
2922 #ifdef CONFIG_DVBIN 2922 #ifdef CONFIG_DVBIN
2923 case MP_CMD_DVB_SET_CHANNEL: 2923 case MP_CMD_DVB_SET_CHANNEL:
2924 if (mpctx->stream->type == STREAMTYPE_DVB) { 2924 if (mpctx->stream->type == STREAMTYPE_DVB) {
2925 mpctx->last_dvb_step = 1; 2925 mpctx->last_dvb_step = 1;
2926 2926
2927 if (dvb_set_channel 2927 if (dvb_set_channel
2928 (mpctx->stream, cmd->args[1].v.i, cmd->args[0].v.i)) 2928 (mpctx->stream, cmd->args[1].v.i, cmd->args[0].v.i))
2929 mpctx->eof = mpctx->dvbin_reopen = 1; 2929 mpctx->eof = mpctx->dvbin_reopen = 1;
2930 } 2930 }
2931 break; 2931 break;
2932 #endif /* CONFIG_DVBIN */ 2932 #endif /* CONFIG_DVBIN */
2933 2933
2934 case MP_CMD_TV_LAST_CHANNEL: 2934 case MP_CMD_TV_LAST_CHANNEL:
2935 if (mpctx->file_format == DEMUXER_TYPE_TV) { 2935 if (mpctx->file_format == DEMUXER_TYPE_TV) {
2936 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv)); 2936 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
2937 if (tv_channel_list) { 2937 if (tv_channel_list) {
2938 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration, 2938 set_osd_msg(OSD_MSG_TV_CHANNEL, 1, osd_duration,
2939 MSGTR_OSDChannel, tv_channel_current->name); 2939 MSGTR_OSDChannel, tv_channel_current->name);
2940 //vo_osd_changed(OSDTYPE_SUBTITLE); 2940 //vo_osd_changed(OSDTYPE_SUBTITLE);
2941 } 2941 }
2942 } 2942 }
2943 #ifdef CONFIG_PVR 2943 #ifdef CONFIG_PVR
2944 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) { 2944 else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
2945 pvr_set_lastchannel (mpctx->stream); 2945 pvr_set_lastchannel (mpctx->stream);
2946 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s", 2946 set_osd_msg (OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
2947 pvr_get_current_channelname (mpctx->stream), 2947 pvr_get_current_channelname (mpctx->stream),
2948 pvr_get_current_stationname (mpctx->stream)); 2948 pvr_get_current_stationname (mpctx->stream));
2949 } 2949 }
2950 #endif /* CONFIG_PVR */ 2950 #endif /* CONFIG_PVR */
2951 break; 2951 break;
2952 2952
2953 case MP_CMD_TV_STEP_NORM: 2953 case MP_CMD_TV_STEP_NORM:
2954 if (mpctx->file_format == DEMUXER_TYPE_TV) 2954 if (mpctx->file_format == DEMUXER_TYPE_TV)
2955 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv)); 2955 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv));
2956 break; 2956 break;
2957 2957
2958 case MP_CMD_TV_STEP_CHANNEL_LIST: 2958 case MP_CMD_TV_STEP_CHANNEL_LIST:
2959 if (mpctx->file_format == DEMUXER_TYPE_TV) 2959 if (mpctx->file_format == DEMUXER_TYPE_TV)
2960 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv)); 2960 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
2961 break; 2961 break;
2962 #endif /* CONFIG_TV */ 2962 #endif /* CONFIG_TV */
2963 case MP_CMD_TV_TELETEXT_ADD_DEC: 2963 case MP_CMD_TV_TELETEXT_ADD_DEC:
2964 { 2964 {
2965 if (mpctx->demuxer->teletext) 2965 if (mpctx->demuxer->teletext)
2966 teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_ADD_DEC, 2966 teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_ADD_DEC,
2967 &(cmd->args[0].v.s)); 2967 &(cmd->args[0].v.s));
2968 break; 2968 break;
2969 } 2969 }
2970 case MP_CMD_TV_TELETEXT_GO_LINK: 2970 case MP_CMD_TV_TELETEXT_GO_LINK:
2971 { 2971 {
2972 if (mpctx->demuxer->teletext) 2972 if (mpctx->demuxer->teletext)
2973 teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_GO_LINK, 2973 teletext_control(mpctx->demuxer->teletext,TV_VBI_CONTROL_GO_LINK,
2974 &(cmd->args[0].v.i)); 2974 &(cmd->args[0].v.i));
2975 break; 2975 break;
2976 } 2976 }
2977 2977
2978 case MP_CMD_SUB_LOAD: 2978 case MP_CMD_SUB_LOAD:
2979 if (sh_video) { 2979 if (sh_video) {
2980 int n = mpctx->set_of_sub_size; 2980 int n = mpctx->set_of_sub_size;
2981 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0); 2981 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0);
2982 if (n != mpctx->set_of_sub_size) { 2982 if (n != mpctx->set_of_sub_size) {
2983 if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0) 2983 if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0)
2984 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = 2984 mpctx->global_sub_indices[SUB_SOURCE_SUBS] =
2985 mpctx->global_sub_size; 2985 mpctx->global_sub_size;
2986 ++mpctx->global_sub_size; 2986 ++mpctx->global_sub_size;
2987 } 2987 }
2988 } 2988 }
2989 break; 2989 break;
2990 2990
2991 case MP_CMD_SUB_REMOVE: 2991 case MP_CMD_SUB_REMOVE:
2992 if (sh_video) { 2992 if (sh_video) {
2993 int v = cmd->args[0].v.i; 2993 int v = cmd->args[0].v.i;
2994 if (v < 0) { 2994 if (v < 0) {
2995 remove_subtitle_range(mpctx, 0, mpctx->set_of_sub_size); 2995 remove_subtitle_range(mpctx, 0, mpctx->set_of_sub_size);
2996 } else if (v < mpctx->set_of_sub_size) { 2996 } else if (v < mpctx->set_of_sub_size) {
2997 remove_subtitle_range(mpctx, v, 1); 2997 remove_subtitle_range(mpctx, v, 1);
2998 } 2998 }
2999 } 2999 }
3000 break; 3000 break;
3001 3001
3002 case MP_CMD_GET_SUB_VISIBILITY: 3002 case MP_CMD_GET_SUB_VISIBILITY:
3003 if (sh_video) { 3003 if (sh_video) {
3004 mp_msg(MSGT_GLOBAL, MSGL_INFO, 3004 mp_msg(MSGT_GLOBAL, MSGL_INFO,
3005 "ANS_SUB_VISIBILITY=%d\n", sub_visibility); 3005 "ANS_SUB_VISIBILITY=%d\n", sub_visibility);
3006 } 3006 }
3007 break; 3007 break;
3008 3008
3009 case MP_CMD_SCREENSHOT: 3009 case MP_CMD_SCREENSHOT:
3010 if (vo_config_count) { 3010 if (vo_config_count) {
3011 mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n"); 3011 mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n");
3012 if (CONTROL_OK != 3012 if (CONTROL_OK !=
3013 ((vf_instance_t *) sh_video->vfilter)-> 3013 ((vf_instance_t *) sh_video->vfilter)->
3014 control(sh_video->vfilter, VFCTRL_SCREENSHOT, 3014 control(sh_video->vfilter, VFCTRL_SCREENSHOT,
3015 &cmd->args[0].v.i)) 3015 &cmd->args[0].v.i))
3016 mp_msg(MSGT_CPLAYER, MSGL_INFO, "failed (forgot -vf screenshot?)\n"); 3016 mp_msg(MSGT_CPLAYER, MSGL_INFO, "failed (forgot -vf screenshot?)\n");
3017 } 3017 }
3018 break; 3018 break;
3019 3019
3020 case MP_CMD_VF_CHANGE_RECTANGLE: 3020 case MP_CMD_VF_CHANGE_RECTANGLE:
3021 if (!sh_video) 3021 if (!sh_video)
3022 break; 3022 break;
3023 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i); 3023 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i);
3024 break; 3024 break;
3025 3025
3026 case MP_CMD_GET_TIME_LENGTH:{ 3026 case MP_CMD_GET_TIME_LENGTH:{
3027 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2lf\n", 3027 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2lf\n",
3028 demuxer_get_time_length(mpctx->demuxer)); 3028 demuxer_get_time_length(mpctx->demuxer));
3029 } 3029 }
3030 break; 3030 break;
3031 3031
3032 case MP_CMD_GET_FILENAME:{ 3032 case MP_CMD_GET_FILENAME:{
3033 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_FILENAME='%s'\n", 3033 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_FILENAME='%s'\n",
3034 get_metadata(META_NAME)); 3034 get_metadata(META_NAME));
3035 } 3035 }
3036 break; 3036 break;
3037 3037
3038 case MP_CMD_GET_VIDEO_CODEC:{ 3038 case MP_CMD_GET_VIDEO_CODEC:{
3039 char *inf = get_metadata(META_VIDEO_CODEC); 3039 char *inf = get_metadata(META_VIDEO_CODEC);
3040 if (!inf) 3040 if (!inf)
3041 inf = strdup(""); 3041 inf = strdup("");
3042 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf); 3042 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf);
3043 free(inf); 3043 free(inf);
3044 } 3044 }
3045 break; 3045 break;
3046 3046
3047 case MP_CMD_GET_VIDEO_BITRATE:{ 3047 case MP_CMD_GET_VIDEO_BITRATE:{
3048 char *inf = get_metadata(META_VIDEO_BITRATE); 3048 char *inf = get_metadata(META_VIDEO_BITRATE);
3049 if (!inf) 3049 if (!inf)
3050 inf = strdup(""); 3050 inf = strdup("");
3051 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf); 3051 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf);
3052 free(inf); 3052 free(inf);
3053 } 3053 }
3054 break; 3054 break;
3055 3055
3056 case MP_CMD_GET_VIDEO_RESOLUTION:{ 3056 case MP_CMD_GET_VIDEO_RESOLUTION:{
3057 char *inf = get_metadata(META_VIDEO_RESOLUTION); 3057 char *inf = get_metadata(META_VIDEO_RESOLUTION);
3058 if (!inf) 3058 if (!inf)
3059 inf = strdup(""); 3059 inf = strdup("");
3060 mp_msg(MSGT_GLOBAL, MSGL_INFO, 3060 mp_msg(MSGT_GLOBAL, MSGL_INFO,
3061 "ANS_VIDEO_RESOLUTION='%s'\n", inf); 3061 "ANS_VIDEO_RESOLUTION='%s'\n", inf);
3062 free(inf); 3062 free(inf);
3063 } 3063 }
3064 break; 3064 break;
3065 3065
3066 case MP_CMD_GET_AUDIO_CODEC:{ 3066 case MP_CMD_GET_AUDIO_CODEC:{
3067 char *inf = get_metadata(META_AUDIO_CODEC); 3067 char *inf = get_metadata(META_AUDIO_CODEC);
3068 if (!inf) 3068 if (!inf)
3069 inf = strdup(""); 3069 inf = strdup("");
3070 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf); 3070 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf);
3071 free(inf); 3071 free(inf);
3072 } 3072 }
3073 break; 3073 break;
3074 3074
3075 case MP_CMD_GET_AUDIO_BITRATE:{ 3075 case MP_CMD_GET_AUDIO_BITRATE:{
3076 char *inf = get_metadata(META_AUDIO_BITRATE); 3076 char *inf = get_metadata(META_AUDIO_BITRATE);
3077 if (!inf) 3077 if (!inf)
3078 inf = strdup(""); 3078 inf = strdup("");
3079 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf); 3079 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf);
3080 free(inf); 3080 free(inf);
3081 } 3081 }
3082 break; 3082 break;
3083 3083
3084 case MP_CMD_GET_AUDIO_SAMPLES:{ 3084 case MP_CMD_GET_AUDIO_SAMPLES:{
3085 char *inf = get_metadata(META_AUDIO_SAMPLES); 3085 char *inf = get_metadata(META_AUDIO_SAMPLES);
3086 if (!inf) 3086 if (!inf)
3087 inf = strdup(""); 3087 inf = strdup("");
3088 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf); 3088 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf);
3089 free(inf); 3089 free(inf);
3090 } 3090 }
3091 break; 3091 break;
3092 3092
3093 case MP_CMD_GET_META_TITLE:{ 3093 case MP_CMD_GET_META_TITLE:{
3094 char *inf = get_metadata(META_INFO_TITLE); 3094 char *inf = get_metadata(META_INFO_TITLE);
3095 if (!inf) 3095 if (!inf)
3096 inf = strdup(""); 3096 inf = strdup("");
3097 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TITLE='%s'\n", inf); 3097 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TITLE='%s'\n", inf);
3098 free(inf); 3098 free(inf);
3099 } 3099 }
3100 break; 3100 break;
3101 3101
3102 case MP_CMD_GET_META_ARTIST:{ 3102 case MP_CMD_GET_META_ARTIST:{
3103 char *inf = get_metadata(META_INFO_ARTIST); 3103 char *inf = get_metadata(META_INFO_ARTIST);
3104 if (!inf) 3104 if (!inf)
3105 inf = strdup(""); 3105 inf = strdup("");
3106 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf); 3106 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf);
3107 free(inf); 3107 free(inf);
3108 } 3108 }
3109 break; 3109 break;
3110 3110
3111 case MP_CMD_GET_META_ALBUM:{ 3111 case MP_CMD_GET_META_ALBUM:{
3112 char *inf = get_metadata(META_INFO_ALBUM); 3112 char *inf = get_metadata(META_INFO_ALBUM);
3113 if (!inf) 3113 if (!inf)
3114 inf = strdup(""); 3114 inf = strdup("");
3115 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf); 3115 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf);
3116 free(inf); 3116 free(inf);
3117 } 3117 }
3118 break; 3118 break;
3119 3119
3120 case MP_CMD_GET_META_YEAR:{ 3120 case MP_CMD_GET_META_YEAR:{
3121 char *inf = get_metadata(META_INFO_YEAR); 3121 char *inf = get_metadata(META_INFO_YEAR);
3122 if (!inf) 3122 if (!inf)
3123 inf = strdup(""); 3123 inf = strdup("");
3124 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_YEAR='%s'\n", inf); 3124 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_YEAR='%s'\n", inf);
3125 free(inf); 3125 free(inf);
3126 } 3126 }
3127 break; 3127 break;
3128 3128
3129 case MP_CMD_GET_META_COMMENT:{ 3129 case MP_CMD_GET_META_COMMENT:{
3130 char *inf = get_metadata(META_INFO_COMMENT); 3130 char *inf = get_metadata(META_INFO_COMMENT);
3131 if (!inf) 3131 if (!inf)
3132 inf = strdup(""); 3132 inf = strdup("");
3133 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf); 3133 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf);
3134 free(inf); 3134 free(inf);
3135 } 3135 }
3136 break; 3136 break;
3137 3137
3138 case MP_CMD_GET_META_TRACK:{ 3138 case MP_CMD_GET_META_TRACK:{
3139 char *inf = get_metadata(META_INFO_TRACK); 3139 char *inf = get_metadata(META_INFO_TRACK);
3140 if (!inf) 3140 if (!inf)
3141 inf = strdup(""); 3141 inf = strdup("");
3142 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TRACK='%s'\n", inf); 3142 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_TRACK='%s'\n", inf);
3143 free(inf); 3143 free(inf);
3144 } 3144 }
3145 break; 3145 break;
3146 3146
3147 case MP_CMD_GET_META_GENRE:{ 3147 case MP_CMD_GET_META_GENRE:{
3148 char *inf = get_metadata(META_INFO_GENRE); 3148 char *inf = get_metadata(META_INFO_GENRE);
3149 if (!inf) 3149 if (!inf)
3150 inf = strdup(""); 3150 inf = strdup("");
3151 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_GENRE='%s'\n", inf); 3151 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_META_GENRE='%s'\n", inf);
3152 free(inf); 3152 free(inf);
3153 } 3153 }
3154 break; 3154 break;
3155 3155
3156 case MP_CMD_GET_VO_FULLSCREEN: 3156 case MP_CMD_GET_VO_FULLSCREEN:
3157 if (mpctx->video_out && vo_config_count) 3157 if (mpctx->video_out && vo_config_count)
3158 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs); 3158 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs);
3159 break; 3159 break;
3160 3160
3161 case MP_CMD_GET_PERCENT_POS: 3161 case MP_CMD_GET_PERCENT_POS:
3162 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n", 3162 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n",
3163 demuxer_get_percent_pos(mpctx->demuxer)); 3163 demuxer_get_percent_pos(mpctx->demuxer));
3164 break; 3164 break;
3165 3165
3166 case MP_CMD_GET_TIME_POS:{ 3166 case MP_CMD_GET_TIME_POS:{
3167 float pos = 0; 3167 float pos = 0;
3168 if (sh_video) 3168 if (sh_video)
3169 pos = sh_video->pts; 3169 pos = sh_video->pts;
3170 else if (sh_audio && mpctx->audio_out) 3170 else if (sh_audio && mpctx->audio_out)
3171 pos = 3171 pos =
3172 playing_audio_pts(sh_audio, mpctx->d_audio, 3172 playing_audio_pts(sh_audio, mpctx->d_audio,
3173 mpctx->audio_out); 3173 mpctx->audio_out);
3174 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos); 3174 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
3175 } 3175 }
3176 break; 3176 break;
3177 3177
3178 case MP_CMD_RUN: 3178 case MP_CMD_RUN:
3179 #ifndef __MINGW32__ 3179 #ifndef __MINGW32__
3180 if (!fork()) { 3180 if (!fork()) {
3181 execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, NULL); 3181 execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, NULL);
3182 exit(0); 3182 exit(0);
3183 } 3183 }
3184 #endif 3184 #endif
3185 break; 3185 break;
3186 3186
3187 case MP_CMD_KEYDOWN_EVENTS: 3187 case MP_CMD_KEYDOWN_EVENTS:
3188 mplayer_put_key(cmd->args[0].v.i); 3188 mplayer_put_key(cmd->args[0].v.i);
3189 break; 3189 break;
3190 3190
3191 case MP_CMD_SET_MOUSE_POS:{ 3191 case MP_CMD_SET_MOUSE_POS:{
3192 int pointer_x, pointer_y; 3192 int pointer_x, pointer_y;
3193 double dx, dy; 3193 double dx, dy;
3194 pointer_x = cmd->args[0].v.i; 3194 pointer_x = cmd->args[0].v.i;
3195 pointer_y = cmd->args[1].v.i; 3195 pointer_y = cmd->args[1].v.i;
3196 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy); 3196 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
3197 #ifdef CONFIG_DVDNAV 3197 #ifdef CONFIG_DVDNAV
3198 if (mpctx->stream->type == STREAMTYPE_DVDNAV 3198 if (mpctx->stream->type == STREAMTYPE_DVDNAV
3199 && dx > 0.0 && dy > 0.0) { 3199 && dx > 0.0 && dy > 0.0) {
3200 int button = -1; 3200 int button = -1;
3201 pointer_x = (int) (dx * (double) sh_video->disp_w); 3201 pointer_x = (int) (dx * (double) sh_video->disp_w);
3202 pointer_y = (int) (dy * (double) sh_video->disp_h); 3202 pointer_y = (int) (dy * (double) sh_video->disp_h);
3203 mp_dvdnav_update_mouse_pos(mpctx->stream, 3203 mp_dvdnav_update_mouse_pos(mpctx->stream,
3204 pointer_x, pointer_y, &button); 3204 pointer_x, pointer_y, &button);
3205 if (osd_level > 1 && button > 0) 3205 if (osd_level > 1 && button > 0)
3206 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, 3206 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
3207 "Selected button number %d", button); 3207 "Selected button number %d", button);
3208 } 3208 }
3209 #endif 3209 #endif
3210 #ifdef CONFIG_MENU 3210 #ifdef CONFIG_MENU
3211 if (use_menu && dx >= 0.0 && dy >= 0.0) 3211 if (use_menu && dx >= 0.0 && dy >= 0.0)
3212 menu_update_mouse_pos(dx, dy); 3212 menu_update_mouse_pos(dx, dy);
3213 #endif 3213 #endif
3214 } 3214 }
3215 break; 3215 break;
3216 3216
3217 #ifdef CONFIG_DVDNAV 3217 #ifdef CONFIG_DVDNAV
3218 case MP_CMD_DVDNAV:{ 3218 case MP_CMD_DVDNAV:{
3219 int button = -1; 3219 int button = -1;
3220 int i; 3220 int i;
3221 mp_command_type command = 0; 3221 mp_command_type command = 0;
3222 if (mpctx->stream->type != STREAMTYPE_DVDNAV) 3222 if (mpctx->stream->type != STREAMTYPE_DVDNAV)
3223 break; 3223 break;
3224 3224
3225 for (i = 0; mp_dvdnav_bindings[i].name; i++) 3225 for (i = 0; mp_dvdnav_bindings[i].name; i++)
3226 if (cmd->args[0].v.s && 3226 if (cmd->args[0].v.s &&
3227 !strcasecmp (cmd->args[0].v.s, 3227 !strcasecmp (cmd->args[0].v.s,
3228 mp_dvdnav_bindings[i].name)) 3228 mp_dvdnav_bindings[i].name))
3229 command = mp_dvdnav_bindings[i].cmd; 3229 command = mp_dvdnav_bindings[i].cmd;
3230 3230
3231 mp_dvdnav_handle_input(mpctx->stream,command,&button); 3231 mp_dvdnav_handle_input(mpctx->stream,command,&button);
3232 if (osd_level > 1 && button > 0) 3232 if (osd_level > 1 && button > 0)
3233 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, 3233 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
3234 "Selected button number %d", button); 3234 "Selected button number %d", button);
3235 } 3235 }
3236 break; 3236 break;
3237 3237
3238 case MP_CMD_SWITCH_TITLE: 3238 case MP_CMD_SWITCH_TITLE:
3239 if (mpctx->stream->type == STREAMTYPE_DVDNAV) 3239 if (mpctx->stream->type == STREAMTYPE_DVDNAV)
3240 mp_dvdnav_switch_title(mpctx->stream, cmd->args[0].v.i); 3240 mp_dvdnav_switch_title(mpctx->stream, cmd->args[0].v.i);
3241 break; 3241 break;
3242 3242
3243 #endif 3243 #endif
3244 3244
3245 case MP_CMD_AF_SWITCH: 3245 case MP_CMD_AF_SWITCH:
3246 if (sh_audio) 3246 if (sh_audio)
3277 break; 3277 break;
3278 af_uninit(mpctx->mixer.afilter); 3278 af_uninit(mpctx->mixer.afilter);
3279 af_init(mpctx->mixer.afilter); 3279 af_init(mpctx->mixer.afilter);
3280 build_afilter_chain(sh_audio, &ao_data); 3280 build_afilter_chain(sh_audio, &ao_data);
3281 break; 3281 break;
3282 default: 3282 default:
3283 #ifdef CONFIG_GUI 3283 #ifdef CONFIG_GUI
3284 if ((use_gui) && (cmd->id > MP_CMD_GUI_EVENTS)) 3284 if ((use_gui) && (cmd->id > MP_CMD_GUI_EVENTS))
3285 guiGetEvent(guiIEvent, (char *) cmd->id); 3285 guiGetEvent(guiIEvent, (char *) cmd->id);
3286 else 3286 else
3287 #endif 3287 #endif
3288 mp_msg(MSGT_CPLAYER, MSGL_V, 3288 mp_msg(MSGT_CPLAYER, MSGL_V,
3289 "Received unknown cmd %s\n", cmd->name); 3289 "Received unknown cmd %s\n", cmd->name);
3290 } 3290 }
3291 3291
3292 switch (cmd->pausing) { 3292 switch (cmd->pausing) {
3293 case 1: // "pausing" 3293 case 1: // "pausing"
3294 mpctx->osd_function = OSD_PAUSE; 3294 mpctx->osd_function = OSD_PAUSE;
3295 break; 3295 break;
3296 case 3: // "pausing_toggle" 3296 case 3: // "pausing_toggle"
3297 mpctx->was_paused = !mpctx->was_paused; 3297 mpctx->was_paused = !mpctx->was_paused;
3298 if (mpctx->was_paused) 3298 if (mpctx->was_paused)
3299 mpctx->osd_function = OSD_PAUSE; 3299 mpctx->osd_function = OSD_PAUSE;
3300 else if (mpctx->osd_function == OSD_PAUSE) 3300 else if (mpctx->osd_function == OSD_PAUSE)
3301 mpctx->osd_function = OSD_PLAY; 3301 mpctx->osd_function = OSD_PLAY;
3302 break; 3302 break;
3303 case 2: // "pausing_keep" 3303 case 2: // "pausing_keep"
3304 if (mpctx->was_paused) 3304 if (mpctx->was_paused)
3305 mpctx->osd_function = OSD_PAUSE; 3305 mpctx->osd_function = OSD_PAUSE;
3306 } 3306 }
3307 return brk_cmd; 3307 return brk_cmd;
3308 } 3308 }