7 #include "input/input.h"
8 #include "stream/stream.h"
9 #include "libmpdemux/demuxer.h"
10 #include "libmpdemux/stheader.h"
11 #include "codec-cfg.h"
13 #include "libvo/sub.h"
15 #include "m_property.h"
18 #include "libmpcodecs/mp_image.h"
19 #include "libmpcodecs/vf.h"
20 #include "libmpcodecs/vd.h"
21 #include "libvo/video_out.h"
22 #include "libvo/font_load.h"
24 #include "libao2/audio_out.h"
27 #include "libmpdemux/matroska.h"
28 #include "libmpcodecs/dec_video.h"
33 #include "stream/tv.h"
36 #include "stream/stream_radio.h"
39 #include "stream/pvr.h"
41 #ifdef HAS_DVBIN_SUPPORT
42 #include "stream/dvbin.h"
45 #include "stream/stream_dvd.h"
48 #include "stream/stream_dvdnav.h"
51 #include "libass/ass.h"
52 #include "libass/ass_mp.h"
55 #include "gui/interface.h"
61 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
63 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
65 //remove the borders, if any, and rescale to the range [0,1],[0,1]
66 if (vo_fs
) { //we are in full-screen mode
67 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
68 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
69 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
70 iy
-= (vo_screenheight
- vo_dheight
) / 2;
72 if (ix
< 0 || ix
> vo_dwidth
) {
75 } //we are on one of the borders
76 if (iy
< 0 || iy
> vo_dheight
) {
79 } //we are on one of the borders
82 *dx
= (double) ix
/ (double) vo_dwidth
;
83 *dy
= (double) iy
/ (double) vo_dheight
;
85 mp_msg(MSGT_CPLAYER
, MSGL_V
,
86 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
87 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
91 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
96 for (i
= 0; i
< SUB_SOURCES
; i
++) {
97 int j
= mpctx
->global_sub_indices
[i
];
98 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
106 static int sub_source(MPContext
* mpctx
)
108 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
112 * \brief Log the currently displayed subtitle to a file
114 * Logs the current or last displayed subtitle together with filename
115 * and time information to ~/.mplayer/subtitle_log
117 * Intended purpose is to allow convenient marking of bogus subtitles
118 * which need to be fixed while watching the movie.
121 static void log_sub(void)
127 if (subdata
== NULL
|| vo_sub_last
== NULL
)
129 fname
= get_path("subtitle_log");
130 f
= fopen(fname
, "a");
133 fprintf(f
, "----------------------------------------------------------\n");
134 if (subdata
->sub_uses_time
) {
136 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
137 filename
, vo_sub_last
->start
/ 360000,
138 (vo_sub_last
->start
/ 6000) % 60,
139 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
140 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
141 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
143 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
146 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
147 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
153 /// \defgroup Properties
156 /// \defgroup GeneralProperties General properties
157 /// \ingroup Properties
161 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
164 return m_property_choice(prop
, action
, arg
, &osd_level
);
168 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
172 case M_PROPERTY_PRINT
:
173 if (!arg
) return M_PROPERTY_ERROR
;
174 if (mpctx
->loop_times
< 0)
175 *(char**)arg
= strdup("off");
176 else if (mpctx
->loop_times
== 0)
177 *(char**)arg
= strdup("inf");
180 return M_PROPERTY_OK
;
182 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
185 /// Playback speed (RW)
186 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
187 void *arg
, MPContext
* mpctx
)
192 return M_PROPERTY_ERROR
;
193 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
194 playback_speed
= *(float *) arg
;
195 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
196 return M_PROPERTY_OK
;
197 case M_PROPERTY_STEP_UP
:
198 case M_PROPERTY_STEP_DOWN
:
199 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
200 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
201 M_PROPERTY_CLAMP(prop
, playback_speed
);
202 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
203 return M_PROPERTY_OK
;
205 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
208 /// filename with path (RO)
209 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
212 return m_property_string_ro(prop
, action
, arg
, filename
);
215 /// filename without path (RO)
216 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
221 return M_PROPERTY_UNAVAILABLE
;
222 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
226 return m_property_string_ro(prop
, action
, arg
, f
);
229 /// Demuxer name (RO)
230 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
234 return M_PROPERTY_UNAVAILABLE
;
235 return m_property_string_ro(prop
, action
, arg
,
236 (char *) mpctx
->demuxer
->desc
->name
);
239 /// Position in the stream (RW)
240 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
243 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
244 return M_PROPERTY_UNAVAILABLE
;
246 return M_PROPERTY_ERROR
;
249 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
250 return M_PROPERTY_OK
;
252 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
253 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
254 return M_PROPERTY_OK
;
256 return M_PROPERTY_NOT_IMPLEMENTED
;
259 /// Stream start offset (RO)
260 static int mp_property_stream_start(m_option_t
* prop
, int action
,
261 void *arg
, MPContext
* mpctx
)
263 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
264 return M_PROPERTY_UNAVAILABLE
;
267 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
268 return M_PROPERTY_OK
;
270 return M_PROPERTY_NOT_IMPLEMENTED
;
273 /// Stream end offset (RO)
274 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
277 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
278 return M_PROPERTY_UNAVAILABLE
;
281 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
282 return M_PROPERTY_OK
;
284 return M_PROPERTY_NOT_IMPLEMENTED
;
287 /// Stream length (RO)
288 static int mp_property_stream_length(m_option_t
* prop
, int action
,
289 void *arg
, MPContext
* mpctx
)
291 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
292 return M_PROPERTY_UNAVAILABLE
;
296 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
297 return M_PROPERTY_OK
;
299 return M_PROPERTY_NOT_IMPLEMENTED
;
302 /// Media length in seconds (RO)
303 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
308 if (!mpctx
->demuxer
||
309 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
310 return M_PROPERTY_UNAVAILABLE
;
312 return m_property_time_ro(prop
, action
, arg
, len
);
315 /// Current position in percent (RW)
316 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
317 void *arg
, MPContext
* mpctx
) {
321 return M_PROPERTY_UNAVAILABLE
;
325 if(!arg
) return M_PROPERTY_ERROR
;
326 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
329 case M_PROPERTY_STEP_UP
:
330 case M_PROPERTY_STEP_DOWN
:
331 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
332 pos
+= (arg
? *(int*)arg
: 10) *
333 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
334 M_PROPERTY_CLAMP(prop
, pos
);
337 return m_property_int_ro(prop
, action
, arg
,
338 demuxer_get_percent_pos(mpctx
->demuxer
));
342 rel_seek_secs
= pos
/ 100.0;
343 return M_PROPERTY_OK
;
346 /// Current position in seconds (RW)
347 static int mp_property_time_pos(m_option_t
* prop
, int action
,
348 void *arg
, MPContext
* mpctx
) {
349 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
350 return M_PROPERTY_UNAVAILABLE
;
354 if(!arg
) return M_PROPERTY_ERROR
;
355 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
357 rel_seek_secs
= *(double*)arg
;
358 return M_PROPERTY_OK
;
359 case M_PROPERTY_STEP_UP
:
360 case M_PROPERTY_STEP_DOWN
:
361 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
362 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
363 return M_PROPERTY_OK
;
365 return m_property_time_ro(prop
, action
, arg
,
366 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
367 playing_audio_pts(mpctx
->sh_audio
,
372 /// Demuxer meta data
373 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
375 m_property_action_t
* ka
;
377 static m_option_t key_type
=
378 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
380 return M_PROPERTY_UNAVAILABLE
;
384 if(!arg
) return M_PROPERTY_ERROR
;
385 *(char***)arg
= mpctx
->demuxer
->info
;
386 return M_PROPERTY_OK
;
387 case M_PROPERTY_KEY_ACTION
:
388 if(!arg
) return M_PROPERTY_ERROR
;
390 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
391 return M_PROPERTY_UNKNOWN
;
394 if(!ka
->arg
) return M_PROPERTY_ERROR
;
395 *(char**)ka
->arg
= meta
;
396 return M_PROPERTY_OK
;
397 case M_PROPERTY_GET_TYPE
:
398 if(!ka
->arg
) return M_PROPERTY_ERROR
;
399 *(m_option_t
**)ka
->arg
= &key_type
;
400 return M_PROPERTY_OK
;
403 return M_PROPERTY_NOT_IMPLEMENTED
;
409 /// \defgroup AudioProperties Audio properties
410 /// \ingroup Properties
414 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
418 if (!mpctx
->sh_audio
)
419 return M_PROPERTY_UNAVAILABLE
;
424 return M_PROPERTY_ERROR
;
425 mixer_getbothvolume(&mpctx
->mixer
, arg
);
426 return M_PROPERTY_OK
;
427 case M_PROPERTY_PRINT
:{
430 return M_PROPERTY_ERROR
;
431 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
432 return m_property_float_range(prop
, action
, arg
, &vol
);
434 case M_PROPERTY_STEP_UP
:
435 case M_PROPERTY_STEP_DOWN
:
439 return M_PROPERTY_NOT_IMPLEMENTED
;
442 if (mpctx
->edl_muted
)
443 return M_PROPERTY_DISABLED
;
444 mpctx
->user_muted
= 0;
449 return M_PROPERTY_ERROR
;
450 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
451 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
452 return M_PROPERTY_OK
;
453 case M_PROPERTY_STEP_UP
:
454 if (arg
&& *(float *) arg
<= 0)
455 mixer_decvolume(&mpctx
->mixer
);
457 mixer_incvolume(&mpctx
->mixer
);
458 return M_PROPERTY_OK
;
459 case M_PROPERTY_STEP_DOWN
:
460 if (arg
&& *(float *) arg
<= 0)
461 mixer_incvolume(&mpctx
->mixer
);
463 mixer_decvolume(&mpctx
->mixer
);
464 return M_PROPERTY_OK
;
466 return M_PROPERTY_NOT_IMPLEMENTED
;
470 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
474 if (!mpctx
->sh_audio
)
475 return M_PROPERTY_UNAVAILABLE
;
479 if (mpctx
->edl_muted
)
480 return M_PROPERTY_DISABLED
;
482 return M_PROPERTY_ERROR
;
483 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
484 mixer_mute(&mpctx
->mixer
);
485 mpctx
->user_muted
= mpctx
->mixer
.muted
;
486 return M_PROPERTY_OK
;
487 case M_PROPERTY_STEP_UP
:
488 case M_PROPERTY_STEP_DOWN
:
489 if (mpctx
->edl_muted
)
490 return M_PROPERTY_DISABLED
;
491 mixer_mute(&mpctx
->mixer
);
492 mpctx
->user_muted
= mpctx
->mixer
.muted
;
493 return M_PROPERTY_OK
;
494 case M_PROPERTY_PRINT
:
496 return M_PROPERTY_ERROR
;
497 if (mpctx
->edl_muted
) {
498 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
499 return M_PROPERTY_OK
;
502 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
508 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
509 void *arg
, MPContext
* mpctx
)
511 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
512 return M_PROPERTY_UNAVAILABLE
;
515 case M_PROPERTY_STEP_UP
:
516 case M_PROPERTY_STEP_DOWN
:
518 return M_PROPERTY_ERROR
;
520 float delay
= audio_delay
;
521 m_property_delay(prop
, action
, arg
, &audio_delay
);
523 mpctx
->delay
-= audio_delay
- delay
;
525 return M_PROPERTY_OK
;
527 return m_property_delay(prop
, action
, arg
, &audio_delay
);
531 /// Audio codec tag (RO)
532 static int mp_property_audio_format(m_option_t
* prop
, int action
,
533 void *arg
, MPContext
* mpctx
)
535 if (!mpctx
->sh_audio
)
536 return M_PROPERTY_UNAVAILABLE
;
537 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
540 /// Audio codec name (RO)
541 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
542 void *arg
, MPContext
* mpctx
)
544 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
545 return M_PROPERTY_UNAVAILABLE
;
546 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
549 /// Audio bitrate (RO)
550 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
551 void *arg
, MPContext
* mpctx
)
553 if (!mpctx
->sh_audio
)
554 return M_PROPERTY_UNAVAILABLE
;
555 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
559 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
562 if (!mpctx
->sh_audio
)
563 return M_PROPERTY_UNAVAILABLE
;
565 case M_PROPERTY_PRINT
:
566 if(!arg
) return M_PROPERTY_ERROR
;
567 *(char**)arg
= malloc(16);
568 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
569 return M_PROPERTY_OK
;
571 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
574 /// Number of channels (RO)
575 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
578 if (!mpctx
->sh_audio
)
579 return M_PROPERTY_UNAVAILABLE
;
581 case M_PROPERTY_PRINT
:
583 return M_PROPERTY_ERROR
;
584 switch (mpctx
->sh_audio
->channels
) {
586 *(char **) arg
= strdup("mono");
589 *(char **) arg
= strdup("stereo");
592 *(char **) arg
= malloc(32);
593 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
595 return M_PROPERTY_OK
;
597 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
601 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
606 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
607 return M_PROPERTY_UNAVAILABLE
;
612 return M_PROPERTY_ERROR
;
613 mixer_getbalance(&mpctx
->mixer
, arg
);
614 return M_PROPERTY_OK
;
615 case M_PROPERTY_PRINT
: {
618 return M_PROPERTY_ERROR
;
619 mixer_getbalance(&mpctx
->mixer
, &bal
);
621 *str
= strdup("center");
622 else if (bal
== -1.f
)
623 *str
= strdup("left only");
625 *str
= strdup("right only");
627 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
628 *str
= malloc(sizeof("left xxx%, right xxx%"));
629 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
631 return M_PROPERTY_OK
;
633 case M_PROPERTY_STEP_UP
:
634 case M_PROPERTY_STEP_DOWN
:
635 mixer_getbalance(&mpctx
->mixer
, &bal
);
636 bal
+= (arg
? *(float*)arg
: .1f
) *
637 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
638 M_PROPERTY_CLAMP(prop
, bal
);
639 mixer_setbalance(&mpctx
->mixer
, bal
);
640 return M_PROPERTY_OK
;
643 return M_PROPERTY_ERROR
;
644 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
645 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
646 return M_PROPERTY_OK
;
648 return M_PROPERTY_NOT_IMPLEMENTED
;
651 /// Selected audio id (RW)
652 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
655 int current_id
= -1, tmp
;
659 if (!mpctx
->sh_audio
)
660 return M_PROPERTY_UNAVAILABLE
;
662 return M_PROPERTY_ERROR
;
663 *(int *) arg
= audio_id
;
664 return M_PROPERTY_OK
;
665 case M_PROPERTY_PRINT
:
666 if (!mpctx
->sh_audio
)
667 return M_PROPERTY_UNAVAILABLE
;
669 return M_PROPERTY_ERROR
;
672 *(char **) arg
= strdup(MSGTR_Disabled
);
674 char lang
[40] = MSGTR_Unknown
;
675 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
676 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
678 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
679 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
689 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
690 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
692 *(char **) arg
= malloc(64);
693 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
695 return M_PROPERTY_OK
;
697 case M_PROPERTY_STEP_UP
:
699 if (action
== M_PROPERTY_SET
&& arg
)
700 tmp
= *((int *) arg
);
703 current_id
= mpctx
->demuxer
->audio
->id
;
704 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
707 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
708 uninit_player(INITED_AO
| INITED_ACODEC
);
709 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
711 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
713 sh2
->ds
= mpctx
->demuxer
->audio
;
714 mpctx
->sh_audio
= sh2
;
715 reinit_audio_chain();
718 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
719 return M_PROPERTY_OK
;
721 return M_PROPERTY_NOT_IMPLEMENTED
;
726 /// Selected video id (RW)
727 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
730 int current_id
= -1, tmp
;
734 if (!mpctx
->sh_video
)
735 return M_PROPERTY_UNAVAILABLE
;
737 return M_PROPERTY_ERROR
;
738 *(int *) arg
= video_id
;
739 return M_PROPERTY_OK
;
740 case M_PROPERTY_PRINT
:
741 if (!mpctx
->sh_video
)
742 return M_PROPERTY_UNAVAILABLE
;
744 return M_PROPERTY_ERROR
;
747 *(char **) arg
= strdup(MSGTR_Disabled
);
749 char lang
[40] = MSGTR_Unknown
;
750 *(char **) arg
= malloc(64);
751 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
753 return M_PROPERTY_OK
;
755 case M_PROPERTY_STEP_UP
:
757 current_id
= mpctx
->demuxer
->video
->id
;
758 if (action
== M_PROPERTY_SET
&& arg
)
759 tmp
= *((int *) arg
);
762 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
764 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
765 && current_id
!= -2))
766 uninit_player(INITED_VCODEC
|
767 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
768 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
770 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
772 sh2
->ds
= mpctx
->demuxer
->video
;
773 mpctx
->sh_video
= sh2
;
774 reinit_video_chain();
777 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
778 return M_PROPERTY_OK
;
781 return M_PROPERTY_NOT_IMPLEMENTED
;
785 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
788 demux_program_t prog
;
791 case M_PROPERTY_STEP_UP
:
793 if (action
== M_PROPERTY_SET
&& arg
)
794 prog
.progid
= *((int *) arg
);
798 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
799 &prog
) == DEMUXER_CTRL_NOTIMPL
)
800 return M_PROPERTY_ERROR
;
802 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
803 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
804 return M_PROPERTY_OK
;
807 return M_PROPERTY_NOT_IMPLEMENTED
;
813 /// \defgroup VideoProperties Video properties
814 /// \ingroup Properties
817 /// Fullscreen state (RW)
818 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
822 if (!mpctx
->video_out
)
823 return M_PROPERTY_UNAVAILABLE
;
828 return M_PROPERTY_ERROR
;
829 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
830 if (vo_fs
== !!*(int *) arg
)
831 return M_PROPERTY_OK
;
832 case M_PROPERTY_STEP_UP
:
833 case M_PROPERTY_STEP_DOWN
:
836 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
840 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
841 return M_PROPERTY_OK
;
843 return m_property_flag(prop
, action
, arg
, &vo_fs
);
847 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
848 void *arg
, MPContext
* mpctx
)
852 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
853 return M_PROPERTY_UNAVAILABLE
;
854 vf
= mpctx
->sh_video
->vfilter
;
858 return M_PROPERTY_ERROR
;
859 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
860 return M_PROPERTY_OK
;
863 return M_PROPERTY_ERROR
;
864 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
865 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
866 return M_PROPERTY_OK
;
867 case M_PROPERTY_STEP_UP
:
868 case M_PROPERTY_STEP_DOWN
:
869 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
870 deinterlace
= !deinterlace
;
871 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
872 return M_PROPERTY_OK
;
874 return M_PROPERTY_NOT_IMPLEMENTED
;
878 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
882 if (!mpctx
->video_out
883 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
884 return M_PROPERTY_UNAVAILABLE
;
889 return M_PROPERTY_ERROR
;
890 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
891 vo_panscan
= *(float *) arg
;
892 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
893 return M_PROPERTY_OK
;
894 case M_PROPERTY_STEP_UP
:
895 case M_PROPERTY_STEP_DOWN
:
896 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
897 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
900 else if (vo_panscan
< 0)
902 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
903 return M_PROPERTY_OK
;
905 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
909 /// Helper to set vo flags.
910 /** \ingroup PropertyImplHelper
912 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
913 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
916 if (!mpctx
->video_out
)
917 return M_PROPERTY_UNAVAILABLE
;
922 return M_PROPERTY_ERROR
;
923 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
924 if (*vo_var
== !!*(int *) arg
)
925 return M_PROPERTY_OK
;
926 case M_PROPERTY_STEP_UP
:
927 case M_PROPERTY_STEP_DOWN
:
929 mpctx
->video_out
->control(vo_ctrl
, 0);
930 return M_PROPERTY_OK
;
932 return m_property_flag(prop
, action
, arg
, vo_var
);
936 /// Window always on top (RW)
937 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
940 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
944 /// Display in the root window (RW)
945 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
948 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
952 /// Show window borders (RW)
953 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
956 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
960 /// Framedropping state (RW)
961 static int mp_property_framedropping(m_option_t
* prop
, int action
,
962 void *arg
, MPContext
* mpctx
)
965 if (!mpctx
->sh_video
)
966 return M_PROPERTY_UNAVAILABLE
;
969 case M_PROPERTY_PRINT
:
971 return M_PROPERTY_ERROR
;
972 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
973 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
975 return M_PROPERTY_OK
;
977 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
981 /// Color settings, try to use vf/vo then fall back on TV. (RW)
982 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
985 int *gamma
= prop
->priv
, r
;
987 if (!mpctx
->sh_video
)
988 return M_PROPERTY_UNAVAILABLE
;
990 if (gamma
[0] == 1000) {
992 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
998 return M_PROPERTY_ERROR
;
999 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1000 *gamma
= *(int *) arg
;
1001 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1005 case M_PROPERTY_GET
:
1007 return M_PROPERTY_ERROR
;
1008 r
= get_video_colors(mpctx
->sh_video
, prop
->name
, arg
);
1012 case M_PROPERTY_STEP_UP
:
1013 case M_PROPERTY_STEP_DOWN
:
1014 *gamma
+= (arg
? *(int *) arg
: 1) *
1015 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1016 M_PROPERTY_CLAMP(prop
, *gamma
);
1017 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1022 return M_PROPERTY_NOT_IMPLEMENTED
;
1026 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1027 int l
= strlen(prop
->name
);
1028 char tv_prop
[3 + l
+ 1];
1029 sprintf(tv_prop
, "tv_%s", prop
->name
);
1030 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1034 return M_PROPERTY_UNAVAILABLE
;
1038 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1041 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1044 /// Video codec tag (RO)
1045 static int mp_property_video_format(m_option_t
* prop
, int action
,
1046 void *arg
, MPContext
* mpctx
)
1049 if (!mpctx
->sh_video
)
1050 return M_PROPERTY_UNAVAILABLE
;
1052 case M_PROPERTY_PRINT
:
1054 return M_PROPERTY_ERROR
;
1055 switch(mpctx
->sh_video
->format
) {
1057 meta
= strdup ("mpeg1"); break;
1059 meta
= strdup ("mpeg2"); break;
1061 meta
= strdup ("mpeg4"); break;
1063 meta
= strdup ("h264"); break;
1065 if(mpctx
->sh_video
->format
>= 0x20202020) {
1067 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1070 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1073 *(char**)arg
= meta
;
1074 return M_PROPERTY_OK
;
1076 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1079 /// Video codec name (RO)
1080 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1081 void *arg
, MPContext
* mpctx
)
1083 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1084 return M_PROPERTY_UNAVAILABLE
;
1085 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1089 /// Video bitrate (RO)
1090 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1091 void *arg
, MPContext
* mpctx
)
1093 if (!mpctx
->sh_video
)
1094 return M_PROPERTY_UNAVAILABLE
;
1095 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1098 /// Video display width (RO)
1099 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1102 if (!mpctx
->sh_video
)
1103 return M_PROPERTY_UNAVAILABLE
;
1104 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1107 /// Video display height (RO)
1108 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1111 if (!mpctx
->sh_video
)
1112 return M_PROPERTY_UNAVAILABLE
;
1113 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1117 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1120 if (!mpctx
->sh_video
)
1121 return M_PROPERTY_UNAVAILABLE
;
1122 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1125 /// Video aspect (RO)
1126 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1129 if (!mpctx
->sh_video
)
1130 return M_PROPERTY_UNAVAILABLE
;
1131 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1136 /// \defgroup SubProprties Subtitles properties
1137 /// \ingroup Properties
1140 /// Text subtitle position (RW)
1141 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1144 if (!mpctx
->sh_video
)
1145 return M_PROPERTY_UNAVAILABLE
;
1148 case M_PROPERTY_SET
:
1150 return M_PROPERTY_ERROR
;
1151 case M_PROPERTY_STEP_UP
:
1152 case M_PROPERTY_STEP_DOWN
:
1153 vo_osd_changed(OSDTYPE_SUBTITLE
);
1155 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1159 char *demux_lavf_sub_lang(demuxer_t
*demuxer
, int track_num
);
1161 /// Selected subtitles (RW)
1162 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1165 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1166 const int global_sub_size
= mpctx
->global_sub_size
;
1167 int source
= -1, reset_spu
= 0;
1170 if (global_sub_size
<= 0)
1171 return M_PROPERTY_UNAVAILABLE
;
1174 case M_PROPERTY_GET
:
1176 return M_PROPERTY_ERROR
;
1177 *(int *) arg
= mpctx
->global_sub_pos
;
1178 return M_PROPERTY_OK
;
1179 case M_PROPERTY_PRINT
:
1181 return M_PROPERTY_ERROR
;
1182 *(char **) arg
= malloc(64);
1183 (*(char **) arg
)[63] = 0;
1186 sub_name
= subdata
->filename
;
1188 if (ass_track
&& ass_track
->name
)
1189 sub_name
= ass_track
->name
;
1194 if ((tmp2
= strrchr(tmp
, '/')))
1197 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1198 mpctx
->set_of_sub_pos
+ 1,
1199 strlen(tmp
) < 20 ? "" : "...",
1200 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1201 return M_PROPERTY_OK
;
1204 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1205 if (vo_spudec
&& dvdsub_id
>= 0) {
1206 unsigned char lang
[3];
1207 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1208 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1209 return M_PROPERTY_OK
;
1215 #ifdef USE_LIBAVFORMAT
1216 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
&& dvdsub_id
>= 0) {
1217 char *lang
= demux_lavf_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1218 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1219 return M_PROPERTY_OK
;
1222 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1223 char lang
[40] = MSGTR_Unknown
;
1224 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1225 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1226 return M_PROPERTY_OK
;
1228 #ifdef HAVE_OGGVORBIS
1229 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1230 char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1232 lang
= MSGTR_Unknown
;
1233 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1234 return M_PROPERTY_OK
;
1237 if (vo_vobsub
&& vobsub_id
>= 0) {
1238 const char *language
= MSGTR_Unknown
;
1239 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1240 snprintf(*(char **) arg
, 63, "(%d) %s",
1241 vobsub_id
, language
? language
: MSGTR_Unknown
);
1242 return M_PROPERTY_OK
;
1245 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1246 && dvdsub_id
>= 0) {
1248 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1249 lang
[0] = code
>> 8;
1252 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1253 return M_PROPERTY_OK
;
1256 if (dvdsub_id
>= 0) {
1257 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1258 return M_PROPERTY_OK
;
1260 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1261 return M_PROPERTY_OK
;
1263 case M_PROPERTY_SET
:
1265 return M_PROPERTY_ERROR
;
1266 if (*(int *) arg
< -1)
1268 else if (*(int *) arg
>= global_sub_size
)
1269 *(int *) arg
= global_sub_size
- 1;
1270 mpctx
->global_sub_pos
= *(int *) arg
;
1272 case M_PROPERTY_STEP_UP
:
1273 mpctx
->global_sub_pos
+= 2;
1274 mpctx
->global_sub_pos
=
1275 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1277 case M_PROPERTY_STEP_DOWN
:
1278 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1279 mpctx
->global_sub_pos
=
1280 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1283 return M_PROPERTY_NOT_IMPLEMENTED
;
1286 if (mpctx
->global_sub_pos
>= 0)
1287 source
= sub_source(mpctx
);
1289 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1290 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1292 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1293 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1294 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1295 mpctx
->global_sub_pos
, source
);
1297 mpctx
->set_of_sub_pos
= -1;
1311 if (source
== SUB_SOURCE_VOBSUB
) {
1312 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1313 } else if (source
== SUB_SOURCE_SUBS
) {
1314 mpctx
->set_of_sub_pos
=
1315 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1317 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1318 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1322 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1323 vo_osd_changed(OSDTYPE_SUBTITLE
);
1325 } else if (source
== SUB_SOURCE_DEMUX
) {
1327 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1328 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1330 // default: assume 1:1 mapping of sid and stream id
1331 d_sub
->id
= dvdsub_id
;
1332 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1333 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1334 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1335 if (sh
&& sh
->sid
== dvdsub_id
) {
1341 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1342 sh_sub_t
*sh
= d_sub
->sh
;
1343 if (sh
->type
== 'v')
1346 else if (ass_enabled
&& sh
->type
== 'a')
1347 ass_track
= sh
->ass_track
;
1357 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1358 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1359 && dvdsub_id
< 0 && reset_spu
) {
1361 d_sub
->id
= dvdsub_id
;
1364 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1366 return M_PROPERTY_OK
;
1369 /// Selected sub source (RW)
1370 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1374 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1375 return M_PROPERTY_UNAVAILABLE
;
1378 case M_PROPERTY_GET
:
1380 return M_PROPERTY_ERROR
;
1381 *(int *) arg
= sub_source(mpctx
);
1382 return M_PROPERTY_OK
;
1383 case M_PROPERTY_PRINT
:
1385 return M_PROPERTY_ERROR
;
1386 *(char **) arg
= malloc(64);
1387 (*(char **) arg
)[63] = 0;
1388 switch (sub_source(mpctx
))
1390 case SUB_SOURCE_SUBS
:
1391 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1393 case SUB_SOURCE_VOBSUB
:
1394 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1396 case SUB_SOURCE_DEMUX
:
1397 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1400 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1402 return M_PROPERTY_OK
;
1403 case M_PROPERTY_SET
:
1405 return M_PROPERTY_ERROR
;
1406 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1407 if (*(int *) arg
< 0)
1408 mpctx
->global_sub_pos
= -1;
1409 else if (*(int *) arg
!= sub_source(mpctx
)) {
1410 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1411 return M_PROPERTY_UNAVAILABLE
;
1412 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1415 case M_PROPERTY_STEP_UP
:
1416 case M_PROPERTY_STEP_DOWN
: {
1417 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1418 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1419 int step
= (step_all
> 0) ? 1 : -1;
1420 int cur_source
= sub_source(mpctx
);
1421 source
= cur_source
;
1424 if (source
>= SUB_SOURCES
)
1426 else if (source
< -1)
1427 source
= SUB_SOURCES
- 1;
1428 if (source
== cur_source
|| source
== -1 ||
1429 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1432 if (source
== cur_source
)
1433 return M_PROPERTY_OK
;
1435 mpctx
->global_sub_pos
= -1;
1437 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1441 return M_PROPERTY_NOT_IMPLEMENTED
;
1443 --mpctx
->global_sub_pos
;
1444 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1447 /// Selected subtitles from specific source (RW)
1448 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1451 int source
, is_cur_source
, offset
;
1452 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1453 return M_PROPERTY_UNAVAILABLE
;
1455 if (!strcmp(prop
->name
, "sub_file"))
1456 source
= SUB_SOURCE_SUBS
;
1457 else if (!strcmp(prop
->name
, "sub_vob"))
1458 source
= SUB_SOURCE_VOBSUB
;
1459 else if (!strcmp(prop
->name
, "sub_demux"))
1460 source
= SUB_SOURCE_DEMUX
;
1462 return M_PROPERTY_ERROR
;
1464 offset
= mpctx
->global_sub_indices
[source
];
1465 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1466 return M_PROPERTY_UNAVAILABLE
;
1468 is_cur_source
= sub_source(mpctx
) == source
;
1470 case M_PROPERTY_GET
:
1472 return M_PROPERTY_ERROR
;
1473 if (is_cur_source
) {
1474 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1475 if (source
== SUB_SOURCE_VOBSUB
)
1476 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1480 return M_PROPERTY_OK
;
1481 case M_PROPERTY_PRINT
:
1483 return M_PROPERTY_ERROR
;
1485 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1486 *(char **) arg
= malloc(64);
1487 (*(char **) arg
)[63] = 0;
1488 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1489 return M_PROPERTY_OK
;
1490 case M_PROPERTY_SET
:
1492 return M_PROPERTY_ERROR
;
1493 if (*(int *) arg
>= 0) {
1494 int index
= *(int *)arg
;
1495 if (source
== SUB_SOURCE_VOBSUB
)
1496 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1497 mpctx
->global_sub_pos
= offset
+ index
;
1498 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1499 || sub_source(mpctx
) != source
) {
1500 mpctx
->global_sub_pos
= -1;
1505 mpctx
->global_sub_pos
= -1;
1507 case M_PROPERTY_STEP_UP
:
1508 case M_PROPERTY_STEP_DOWN
: {
1509 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1510 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1511 int step
= (step_all
> 0) ? 1 : -1;
1512 int max_sub_pos_for_source
= -1;
1514 mpctx
->global_sub_pos
= -1;
1516 if (mpctx
->global_sub_pos
== -1) {
1518 mpctx
->global_sub_pos
= offset
;
1519 else if (max_sub_pos_for_source
== -1) {
1520 // Find max pos for specific source
1521 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1522 while (mpctx
->global_sub_pos
>= 0
1523 && sub_source(mpctx
) != source
)
1524 --mpctx
->global_sub_pos
;
1527 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1530 mpctx
->global_sub_pos
+= step
;
1531 if (mpctx
->global_sub_pos
< offset
||
1532 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1533 sub_source(mpctx
) != source
)
1534 mpctx
->global_sub_pos
= -1;
1541 return M_PROPERTY_NOT_IMPLEMENTED
;
1543 --mpctx
->global_sub_pos
;
1544 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1547 /// Subtitle delay (RW)
1548 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1551 if (!mpctx
->sh_video
)
1552 return M_PROPERTY_UNAVAILABLE
;
1553 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1556 /// Alignment of text subtitles (RW)
1557 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1558 void *arg
, MPContext
* mpctx
)
1560 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1562 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1563 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1564 return M_PROPERTY_UNAVAILABLE
;
1567 case M_PROPERTY_PRINT
:
1569 return M_PROPERTY_ERROR
;
1570 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1571 *(char **) arg
= strdup(name
[sub_alignment
]);
1572 return M_PROPERTY_OK
;
1573 case M_PROPERTY_SET
:
1575 return M_PROPERTY_ERROR
;
1576 case M_PROPERTY_STEP_UP
:
1577 case M_PROPERTY_STEP_DOWN
:
1578 vo_osd_changed(OSDTYPE_SUBTITLE
);
1580 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1584 /// Subtitle visibility (RW)
1585 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1586 void *arg
, MPContext
* mpctx
)
1588 if (!mpctx
->sh_video
)
1589 return M_PROPERTY_UNAVAILABLE
;
1592 case M_PROPERTY_SET
:
1594 return M_PROPERTY_ERROR
;
1595 case M_PROPERTY_STEP_UP
:
1596 case M_PROPERTY_STEP_DOWN
:
1597 vo_osd_changed(OSDTYPE_SUBTITLE
);
1599 vo_osd_changed(OSDTYPE_SPU
);
1601 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1605 /// Show only forced subtitles (RW)
1606 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1607 void *arg
, MPContext
* mpctx
)
1610 return M_PROPERTY_UNAVAILABLE
;
1613 case M_PROPERTY_SET
:
1615 return M_PROPERTY_ERROR
;
1616 case M_PROPERTY_STEP_UP
:
1617 case M_PROPERTY_STEP_DOWN
:
1618 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1619 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1620 return M_PROPERTY_OK
;
1622 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1627 #ifdef HAVE_FREETYPE
1628 /// Subtitle scale (RW)
1629 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1634 case M_PROPERTY_SET
:
1636 return M_PROPERTY_ERROR
;
1637 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1638 text_font_scale_factor
= *(float *) arg
;
1639 force_load_font
= 1;
1640 return M_PROPERTY_OK
;
1641 case M_PROPERTY_STEP_UP
:
1642 case M_PROPERTY_STEP_DOWN
:
1643 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1644 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1645 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1646 force_load_font
= 1;
1647 return M_PROPERTY_OK
;
1649 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1656 /// \defgroup TVProperties TV properties
1657 /// \ingroup Properties
1662 /// TV color settings (RW)
1663 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1667 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1668 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1669 return M_PROPERTY_UNAVAILABLE
;
1672 case M_PROPERTY_SET
:
1674 return M_PROPERTY_ERROR
;
1675 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1676 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1677 case M_PROPERTY_GET
:
1678 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1679 case M_PROPERTY_STEP_UP
:
1680 case M_PROPERTY_STEP_DOWN
:
1681 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1683 return M_PROPERTY_ERROR
;
1684 val
+= (arg
? *(int *) arg
: 1) *
1685 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1686 M_PROPERTY_CLAMP(prop
, val
);
1687 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1689 return M_PROPERTY_ERROR
;
1691 return M_PROPERTY_NOT_IMPLEMENTED
;
1696 #ifdef HAVE_TV_TELETEXT
1697 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1701 int base_ioctl
=(int)prop
->priv
;
1703 for teletext's GET,SET,STEP ioctls this is not 0
1707 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1708 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1709 return M_PROPERTY_UNAVAILABLE
;
1711 return M_PROPERTY_ERROR
;
1714 case M_PROPERTY_GET
:
1716 return M_PROPERTY_ERROR
;
1717 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1719 case M_PROPERTY_SET
:
1721 return M_PROPERTY_ERROR
;
1722 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1723 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1725 case M_PROPERTY_STEP_UP
:
1726 case M_PROPERTY_STEP_DOWN
:
1727 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1728 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1729 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1732 return M_PROPERTY_NOT_IMPLEMENTED
;
1735 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1738 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1741 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1745 //with tvh==NULL will fail too
1746 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1747 if(result
!=M_PROPERTY_OK
)
1750 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1751 mp_input_set_section("teletext");
1753 mp_input_set_section("tv");
1754 return M_PROPERTY_OK
;
1757 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1760 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1764 case M_PROPERTY_STEP_UP
:
1765 case M_PROPERTY_STEP_DOWN
:
1766 //This should be handled separately
1767 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1768 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1771 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1777 #endif /* HAVE_TV_TELETEXT */
1781 /// All properties available in MPlayer.
1782 /** \ingroup Properties
1784 static m_option_t mp_properties
[] = {
1786 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1787 M_OPT_RANGE
, 0, 3, NULL
},
1788 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1789 M_OPT_MIN
, -1, 0, NULL
},
1790 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1791 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1792 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1794 { "path", mp_property_path
, CONF_TYPE_STRING
,
1796 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1798 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1799 M_OPT_MIN
, 0, 0, NULL
},
1800 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1801 M_OPT_MIN
, 0, 0, NULL
},
1802 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1803 M_OPT_MIN
, 0, 0, NULL
},
1804 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1805 M_OPT_MIN
, 0, 0, NULL
},
1806 { "length", mp_property_length
, CONF_TYPE_TIME
,
1807 M_OPT_MIN
, 0, 0, NULL
},
1808 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1809 M_OPT_RANGE
, 0, 100, NULL
},
1810 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1811 M_OPT_MIN
, 0, 0, NULL
},
1812 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1816 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1817 M_OPT_RANGE
, 0, 100, NULL
},
1818 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1819 M_OPT_RANGE
, 0, 1, NULL
},
1820 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1821 M_OPT_RANGE
, -100, 100, NULL
},
1822 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1824 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1826 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1828 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1830 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1832 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1833 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1834 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
1835 M_OPT_RANGE
, -1, 1, NULL
},
1838 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1839 M_OPT_RANGE
, 0, 1, NULL
},
1840 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1841 M_OPT_RANGE
, 0, 1, NULL
},
1842 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1843 M_OPT_RANGE
, 0, 1, NULL
},
1844 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1845 M_OPT_RANGE
, 0, 1, NULL
},
1846 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1847 M_OPT_RANGE
, 0, 1, NULL
},
1848 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1849 M_OPT_RANGE
, 0, 2, NULL
},
1850 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1851 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1852 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1853 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1854 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1855 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1856 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
1857 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
1858 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
1859 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
1860 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
1861 M_OPT_RANGE
, 0, 1, NULL
},
1862 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
1863 M_OPT_RANGE
, 0, 1, NULL
},
1864 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
1866 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
1868 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
1870 { "width", mp_property_width
, CONF_TYPE_INT
,
1872 { "height", mp_property_height
, CONF_TYPE_INT
,
1874 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
1876 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
1878 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
1879 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
1880 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
1881 CONF_RANGE
, -1, 65535, NULL
},
1884 { "sub", mp_property_sub
, CONF_TYPE_INT
,
1885 M_OPT_MIN
, -1, 0, NULL
},
1886 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
1887 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
1888 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
1889 M_OPT_MIN
, -1, 0, NULL
},
1890 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
1891 M_OPT_MIN
, -1, 0, NULL
},
1892 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
1893 M_OPT_MIN
, -1, 0, NULL
},
1894 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
1896 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
1897 M_OPT_RANGE
, 0, 100, NULL
},
1898 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
1899 M_OPT_RANGE
, 0, 2, NULL
},
1900 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
1901 M_OPT_RANGE
, 0, 1, NULL
},
1902 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
1903 M_OPT_RANGE
, 0, 1, NULL
},
1904 #ifdef HAVE_FREETYPE
1905 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
1906 M_OPT_RANGE
, 0, 100, NULL
},
1910 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
1911 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
1912 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
1913 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
1914 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
1915 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
1916 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
1917 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
1920 #ifdef HAVE_TV_TELETEXT
1921 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
1922 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
1923 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
1924 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
1925 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
1926 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
1927 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
1928 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
1929 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
1930 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
1933 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
1937 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
1939 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
1942 char* mp_property_print(const char *name
, void* ctx
)
1945 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
1950 char *property_expand_string(MPContext
* mpctx
, char *str
)
1952 return m_properties_expand_string(mp_properties
, str
, mpctx
);
1955 void property_print_help(void)
1957 m_properties_print_help_list(mp_properties
);
1966 * \defgroup Command2Property Command to property bridge
1968 * It is used to handle most commands that just set a property
1969 * and optionally display something on the OSD.
1970 * Two kinds of commands are handled: adjust or toggle.
1972 * Adjust commands take 1 or 2 parameters: <value> <abs>
1973 * If <abs> is non-zero the property is set to the given value
1974 * otherwise it is adjusted.
1976 * Toggle commands take 0 or 1 parameters. With no parameter
1977 * or a value less than the property minimum it just steps the
1978 * property to its next value. Otherwise it sets it to the given
1984 /// List of the commands that can be handled by setting a property.
1990 /// set/adjust or toggle command
1992 /// progressbar type
1994 /// osd msg id if it must be shared
1996 /// osd msg template
1997 const char *osd_msg
;
1998 } set_prop_cmd
[] = {
2000 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2002 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2003 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2004 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2005 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2006 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2008 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2009 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2010 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2011 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2012 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2013 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2014 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2015 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2016 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2017 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2018 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2019 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2021 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2022 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2023 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2024 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2025 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2026 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2027 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2028 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2029 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2030 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2031 #ifdef HAVE_FREETYPE
2032 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2035 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2036 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2037 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2038 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2040 { NULL
, 0, 0, 0, -1, NULL
}
2044 /// Handle commands that set a property.
2045 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2051 // look for the command
2052 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2053 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2055 if (!(pname
= set_prop_cmd
[i
].name
))
2058 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2062 if (set_prop_cmd
[i
].toggle
) {
2064 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2065 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2067 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2068 } else if (cmd
->args
[1].v
.i
) //set
2069 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2071 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2076 if (set_prop_cmd
[i
].osd_progbar
) {
2077 if (prop
->type
== CONF_TYPE_INT
) {
2078 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2079 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2080 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2081 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2083 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2084 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2085 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2087 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2088 "Property use an unsupported type.\n");
2092 if (set_prop_cmd
[i
].osd_msg
) {
2093 char *val
= mp_property_print(pname
, mpctx
);
2095 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2096 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2097 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2105 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2107 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2108 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2110 if (!set_property_command(mpctx
, cmd
))
2116 mpctx
->osd_show_percentage
= sh_video
->fps
;
2117 v
= cmd
->args
[0].v
.f
;
2118 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2119 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2122 mpctx
->osd_function
=
2123 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2125 } else if (abs
) { /* Absolute seek by percentage */
2128 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2129 rel_seek_secs
= v
/ 100.0;
2132 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2138 case MP_CMD_SET_PROPERTY
:{
2139 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2140 cmd
->args
[1].v
.s
, mpctx
);
2141 if (r
== M_PROPERTY_UNKNOWN
)
2142 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2143 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2145 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2146 "Failed to set property '%s' to '%s'.\n",
2147 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2151 case MP_CMD_STEP_PROPERTY
:{
2156 if (cmd
->args
[1].v
.f
) {
2158 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2159 M_PROPERTY_GET_TYPE
,
2160 &prop
, mpctx
)) <= 0)
2162 if(prop
->type
== CONF_TYPE_INT
||
2163 prop
->type
== CONF_TYPE_FLAG
)
2164 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2165 else if(prop
->type
== CONF_TYPE_FLOAT
)
2166 arg
= &cmd
->args
[1].v
.f
;
2167 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2168 prop
->type
== CONF_TYPE_TIME
)
2169 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2170 else if(prop
->type
== CONF_TYPE_POSITION
)
2171 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2173 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2174 "Ignoring step size stepping property '%s'.\n",
2177 r
= mp_property_do(cmd
->args
[0].v
.s
,
2178 cmd
->args
[2].v
.i
< 0 ?
2179 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2182 if (r
== M_PROPERTY_UNKNOWN
)
2183 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2184 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2186 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2187 "Failed to increment property '%s' by %f.\n",
2188 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2192 case MP_CMD_GET_PROPERTY
:{
2194 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2195 &tmp
, mpctx
) <= 0) {
2196 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2197 "Failed to get value of property '%s'.\n",
2201 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2202 cmd
->args
[0].v
.s
, tmp
);
2207 case MP_CMD_EDL_MARK
:
2209 float v
= sh_video
? sh_video
->pts
:
2210 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2213 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2214 mpctx
->begin_skip
= v
;
2215 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2217 if (mpctx
->begin_skip
> v
)
2218 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2220 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2221 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2223 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2228 case MP_CMD_SWITCH_RATIO
:
2229 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2230 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2232 movie_aspect
= cmd
->args
[0].v
.f
;
2233 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2236 case MP_CMD_SPEED_INCR
:{
2237 float v
= cmd
->args
[0].v
.f
;
2238 playback_speed
+= v
;
2239 build_afilter_chain(sh_audio
, &ao_data
);
2240 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2244 case MP_CMD_SPEED_MULT
:{
2245 float v
= cmd
->args
[0].v
.f
;
2246 playback_speed
*= v
;
2247 build_afilter_chain(sh_audio
, &ao_data
);
2248 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2252 case MP_CMD_SPEED_SET
:{
2253 float v
= cmd
->args
[0].v
.f
;
2255 build_afilter_chain(sh_audio
, &ao_data
);
2256 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2260 case MP_CMD_FRAME_STEP
:
2266 case MP_CMD_FILE_FILTER
:
2267 file_filter
= cmd
->args
[0].v
.i
;
2271 exit_player_with_rc(MSGTR_Exit_quit
,
2272 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2274 case MP_CMD_PLAY_TREE_STEP
:{
2275 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2276 int force
= cmd
->args
[1].v
.i
;
2282 for (i
= 0; i
< n
; i
++)
2285 for (i
= 0; i
< -1 * n
; i
++)
2290 if (!force
&& mpctx
->playtree_iter
) {
2291 play_tree_iter_t
*i
=
2292 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2293 if (play_tree_iter_step(i
, n
, 0) ==
2294 PLAY_TREE_ITER_ENTRY
)
2296 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2297 play_tree_iter_free(i
);
2299 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2301 mpctx
->play_tree_step
= n
;
2307 case MP_CMD_PLAY_TREE_UP_STEP
:{
2308 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2309 int force
= cmd
->args
[1].v
.i
;
2311 if (!force
&& mpctx
->playtree_iter
) {
2312 play_tree_iter_t
*i
=
2313 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2314 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2315 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2316 play_tree_iter_free(i
);
2318 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2323 case MP_CMD_PLAY_ALT_SRC_STEP
:
2324 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2325 int v
= cmd
->args
[0].v
.i
;
2327 && mpctx
->playtree_iter
->file
<
2328 mpctx
->playtree_iter
->num_files
)
2329 mpctx
->eof
= PT_NEXT_SRC
;
2330 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2331 mpctx
->eof
= PT_PREV_SRC
;
2336 case MP_CMD_SUB_STEP
:
2338 int movement
= cmd
->args
[0].v
.i
;
2339 step_sub(subdata
, sh_video
->pts
, movement
);
2343 ass_step_sub(ass_track
,
2345 sub_delay
) * 1000 + .5, movement
) / 1000.;
2347 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2348 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2352 case MP_CMD_SUB_LOG
:
2357 int v
= cmd
->args
[0].v
.i
;
2359 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2360 if (osd_level
> max
)
2363 osd_level
= (osd_level
+ 1) % (max
+ 1);
2365 osd_level
= v
> max
? max
: v
;
2366 /* Show OSD state when disabled, but not when an explicit
2367 argument is given to the OSD command, i.e. in slave mode. */
2368 if (v
== -1 && osd_level
<= 1)
2369 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2371 osd_level
? MSGTR_OSDenabled
:
2374 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2378 case MP_CMD_OSD_SHOW_TEXT
:
2379 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2381 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2382 "%-.63s", cmd
->args
[0].v
.s
);
2385 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2386 char *txt
= m_properties_expand_string(mp_properties
,
2389 /* if no argument supplied take default osd_duration, else <arg> ms. */
2391 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2393 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2400 case MP_CMD_LOADFILE
:{
2401 play_tree_t
*e
= play_tree_new();
2402 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2404 if (cmd
->args
[1].v
.i
) // append
2405 play_tree_append_entry(mpctx
->playtree
, e
);
2407 // Go back to the starting point.
2408 while (play_tree_iter_up_step
2409 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2411 play_tree_free_list(mpctx
->playtree
->child
, 1);
2412 play_tree_set_child(mpctx
->playtree
, e
);
2413 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2414 mpctx
->eof
= PT_NEXT_SRC
;
2420 case MP_CMD_LOADLIST
:{
2421 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2423 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2424 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2426 if (cmd
->args
[1].v
.i
) // append
2427 play_tree_append_entry(mpctx
->playtree
, e
);
2429 // Go back to the starting point.
2430 while (play_tree_iter_up_step
2431 (mpctx
->playtree_iter
, 0, 1)
2432 != PLAY_TREE_ITER_END
)
2434 play_tree_free_list(mpctx
->playtree
->child
, 1);
2435 play_tree_set_child(mpctx
->playtree
, e
);
2436 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2437 mpctx
->eof
= PT_NEXT_SRC
;
2445 case MP_CMD_RADIO_STEP_CHANNEL
:
2446 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2447 int v
= cmd
->args
[0].v
.i
;
2449 radio_step_channel(mpctx
->demuxer
->stream
,
2450 RADIO_CHANNEL_HIGHER
);
2452 radio_step_channel(mpctx
->demuxer
->stream
,
2453 RADIO_CHANNEL_LOWER
);
2454 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2455 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2457 radio_get_channel_name(mpctx
->demuxer
->stream
));
2462 case MP_CMD_RADIO_SET_CHANNEL
:
2463 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2464 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2465 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2466 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2468 radio_get_channel_name(mpctx
->demuxer
->stream
));
2473 case MP_CMD_RADIO_SET_FREQ
:
2474 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2475 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2478 case MP_CMD_RADIO_STEP_FREQ
:
2479 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2480 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2485 case MP_CMD_TV_START_SCAN
:
2486 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2487 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2489 case MP_CMD_TV_SET_FREQ
:
2490 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2491 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2492 cmd
->args
[0].v
.f
* 16.0);
2494 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2495 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2496 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2497 pvr_get_current_channelname (mpctx
->stream
),
2498 pvr_get_current_stationname (mpctx
->stream
));
2500 #endif /* HAVE_PVR */
2503 case MP_CMD_TV_STEP_FREQ
:
2504 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2505 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2506 cmd
->args
[0].v
.f
* 16.0);
2508 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2509 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2510 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2511 pvr_get_current_channelname (mpctx
->stream
),
2512 pvr_get_current_frequency (mpctx
->stream
));
2514 #endif /* HAVE_PVR */
2517 case MP_CMD_TV_SET_NORM
:
2518 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2519 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2523 case MP_CMD_TV_STEP_CHANNEL
:{
2524 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2525 int v
= cmd
->args
[0].v
.i
;
2527 tv_step_channel((tvi_handle_t
*) (mpctx
->
2531 tv_step_channel((tvi_handle_t
*) (mpctx
->
2535 if (tv_channel_list
) {
2536 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2537 MSGTR_OSDChannel
, tv_channel_current
->name
);
2538 //vo_osd_changed(OSDTYPE_SUBTITLE);
2542 else if (mpctx
->stream
&&
2543 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2544 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2545 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2546 pvr_get_current_channelname (mpctx
->stream
),
2547 pvr_get_current_stationname (mpctx
->stream
));
2549 #endif /* HAVE_PVR */
2551 #ifdef HAS_DVBIN_SUPPORT
2552 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2553 && mpctx
->stream
->priv
) {
2554 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2557 int v
= cmd
->args
[0].v
.i
;
2559 mpctx
->last_dvb_step
= v
;
2561 dir
= DVB_CHANNEL_HIGHER
;
2563 dir
= DVB_CHANNEL_LOWER
;
2566 if (dvb_step_channel(priv
, dir
))
2567 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2570 #endif /* HAS_DVBIN_SUPPORT */
2573 case MP_CMD_TV_SET_CHANNEL
:
2574 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2575 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2577 if (tv_channel_list
) {
2578 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2579 MSGTR_OSDChannel
, tv_channel_current
->name
);
2580 //vo_osd_changed(OSDTYPE_SUBTITLE);
2584 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2585 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2586 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2587 pvr_get_current_channelname (mpctx
->stream
),
2588 pvr_get_current_stationname (mpctx
->stream
));
2590 #endif /* HAVE_PVR */
2593 #ifdef HAS_DVBIN_SUPPORT
2594 case MP_CMD_DVB_SET_CHANNEL
:
2595 if ((mpctx
->stream
->type
== STREAMTYPE_DVB
)
2596 && mpctx
->stream
->priv
) {
2597 dvb_priv_t
*priv
= (dvb_priv_t
*) mpctx
->stream
->priv
;
2599 if (priv
->list
->current
<= cmd
->args
[0].v
.i
)
2600 mpctx
->last_dvb_step
= 1;
2602 mpctx
->last_dvb_step
= -1;
2605 (priv
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2606 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2610 #endif /* HAS_DVBIN_SUPPORT */
2612 case MP_CMD_TV_LAST_CHANNEL
:
2613 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2614 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2615 if (tv_channel_list
) {
2616 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2617 MSGTR_OSDChannel
, tv_channel_current
->name
);
2618 //vo_osd_changed(OSDTYPE_SUBTITLE);
2622 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2623 pvr_set_lastchannel (mpctx
->stream
);
2624 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2625 pvr_get_current_channelname (mpctx
->stream
),
2626 pvr_get_current_stationname (mpctx
->stream
));
2628 #endif /* HAVE_PVR */
2631 case MP_CMD_TV_STEP_NORM
:
2632 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2633 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2636 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2637 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2638 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2640 #ifdef HAVE_TV_TELETEXT
2641 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2643 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2644 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2645 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2648 case MP_CMD_TV_TELETEXT_GO_LINK
:
2650 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2651 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2652 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2655 #endif /* HAVE_TV_TELETEXT */
2658 case MP_CMD_SUB_LOAD
:
2660 int n
= mpctx
->set_of_sub_size
;
2661 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2662 if (n
!= mpctx
->set_of_sub_size
) {
2663 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2664 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2665 mpctx
->global_sub_size
;
2666 ++mpctx
->global_sub_size
;
2671 case MP_CMD_SUB_REMOVE
:
2673 int v
= cmd
->args
[0].v
.i
;
2676 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2677 subd
= mpctx
->set_of_subtitles
[v
];
2678 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2679 MSGTR_RemovedSubtitleFile
, v
+ 1,
2680 filename_recode(subd
->filename
));
2682 mpctx
->set_of_subtitles
[v
] = NULL
;
2684 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2685 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2686 mpctx
->set_of_sub_size
= 0;
2687 if (mpctx
->set_of_sub_pos
>= 0) {
2688 mpctx
->global_sub_pos
= -2;
2690 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2692 } else if (v
< mpctx
->set_of_sub_size
) {
2693 subd
= mpctx
->set_of_subtitles
[v
];
2694 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2695 MSGTR_RemovedSubtitleFile
, v
+ 1,
2696 filename_recode(subd
->filename
));
2698 if (mpctx
->set_of_sub_pos
== v
) {
2699 mpctx
->global_sub_pos
= -2;
2701 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2702 } else if (mpctx
->set_of_sub_pos
> v
) {
2703 --mpctx
->set_of_sub_pos
;
2704 --mpctx
->global_sub_pos
;
2706 while (++v
< mpctx
->set_of_sub_size
)
2707 mpctx
->set_of_subtitles
[v
- 1] =
2708 mpctx
->set_of_subtitles
[v
];
2709 --mpctx
->set_of_sub_size
;
2710 --mpctx
->global_sub_size
;
2711 if (mpctx
->set_of_sub_size
<= 0)
2712 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2713 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2718 case MP_CMD_GET_SUB_VISIBILITY
:
2720 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2721 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2725 case MP_CMD_SCREENSHOT
:
2726 if (vo_config_count
) {
2727 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2729 ((vf_instance_t
*) sh_video
->vfilter
)->
2730 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2732 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2736 case MP_CMD_VF_CHANGE_RECTANGLE
:
2737 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2740 case MP_CMD_GET_TIME_LENGTH
:{
2741 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2742 demuxer_get_time_length(mpctx
->demuxer
));
2746 case MP_CMD_GET_FILENAME
:{
2747 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2748 get_metadata(META_NAME
));
2752 case MP_CMD_GET_VIDEO_CODEC
:{
2753 char *inf
= get_metadata(META_VIDEO_CODEC
);
2756 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2761 case MP_CMD_GET_VIDEO_BITRATE
:{
2762 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2765 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2770 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2771 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2774 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2775 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2780 case MP_CMD_GET_AUDIO_CODEC
:{
2781 char *inf
= get_metadata(META_AUDIO_CODEC
);
2784 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2789 case MP_CMD_GET_AUDIO_BITRATE
:{
2790 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2793 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2798 case MP_CMD_GET_AUDIO_SAMPLES
:{
2799 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2802 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2807 case MP_CMD_GET_META_TITLE
:{
2808 char *inf
= get_metadata(META_INFO_TITLE
);
2811 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2816 case MP_CMD_GET_META_ARTIST
:{
2817 char *inf
= get_metadata(META_INFO_ARTIST
);
2820 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2825 case MP_CMD_GET_META_ALBUM
:{
2826 char *inf
= get_metadata(META_INFO_ALBUM
);
2829 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2834 case MP_CMD_GET_META_YEAR
:{
2835 char *inf
= get_metadata(META_INFO_YEAR
);
2838 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2843 case MP_CMD_GET_META_COMMENT
:{
2844 char *inf
= get_metadata(META_INFO_COMMENT
);
2847 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2852 case MP_CMD_GET_META_TRACK
:{
2853 char *inf
= get_metadata(META_INFO_TRACK
);
2856 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2861 case MP_CMD_GET_META_GENRE
:{
2862 char *inf
= get_metadata(META_INFO_GENRE
);
2865 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
2870 case MP_CMD_GET_VO_FULLSCREEN
:
2871 if (mpctx
->video_out
&& vo_config_count
)
2872 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
2875 case MP_CMD_GET_PERCENT_POS
:
2876 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
2877 demuxer_get_percent_pos(mpctx
->demuxer
));
2880 case MP_CMD_GET_TIME_POS
:{
2883 pos
= sh_video
->pts
;
2884 else if (sh_audio
&& mpctx
->audio_out
)
2886 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2888 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
2895 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
2901 case MP_CMD_KEYDOWN_EVENTS
:
2902 mplayer_put_key(cmd
->args
[0].v
.i
);
2905 case MP_CMD_SEEK_CHAPTER
:{
2906 int seek
= cmd
->args
[0].v
.i
;
2907 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2916 demuxer_seek_chapter(mpctx
->demuxer
, seek
, abs
,
2917 &next_pts
, &num_chapters
,
2920 if (next_pts
> -1.0) {
2922 rel_seek_secs
= next_pts
;
2925 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2926 MSGTR_OSDChapter
, chap
+ 1, chapter_name
);
2931 rel_seek_secs
= 1000000000.;
2933 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2934 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
2940 case MP_CMD_SET_MOUSE_POS
:{
2941 int pointer_x
, pointer_y
;
2943 pointer_x
= cmd
->args
[0].v
.i
;
2944 pointer_y
= cmd
->args
[1].v
.i
;
2945 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
2947 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
2948 && dx
> 0.0 && dy
> 0.0) {
2950 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
2951 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
2952 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
2953 pointer_x
, pointer_y
, &button
);
2955 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2956 "Selected button number %d", button
);
2963 case MP_CMD_DVDNAV
:{
2965 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
2968 if (mp_dvdnav_handle_input
2969 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
2970 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
2971 (fixed_vo
? INITED_VO
: 0)));
2973 } else if (button
> 0)
2974 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2975 "Selected button number %d", button
);
2982 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
2983 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
2986 mp_msg(MSGT_CPLAYER
, MSGL_V
,
2987 "Received unknown cmd %s\n", cmd
->name
);
2990 switch (cmd
->pausing
) {
2991 case 1: // "pausing"
2992 mpctx
->osd_function
= OSD_PAUSE
;
2994 case 3: // "pausing_toggle"
2995 mpctx
->was_paused
= !mpctx
->was_paused
;
2996 if (mpctx
->was_paused
)
2997 mpctx
->osd_function
= OSD_PAUSE
;
2998 else if (mpctx
->osd_function
== OSD_PAUSE
)
2999 mpctx
->osd_function
= OSD_PLAY
;
3001 case 2: // "pausing_keep"
3002 if (mpctx
->was_paused
)
3003 mpctx
->osd_function
= OSD_PAUSE
;