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"
56 #include "libmenu/menu.h"
59 #include "gui/interface.h"
65 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
69 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
71 //remove the borders, if any, and rescale to the range [0,1],[0,1]
72 if (vo_fs
) { //we are in full-screen mode
73 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
74 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
75 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
76 iy
-= (vo_screenheight
- vo_dheight
) / 2;
78 if (ix
< 0 || ix
> vo_dwidth
) {
81 } //we are on one of the borders
82 if (iy
< 0 || iy
> vo_dheight
) {
85 } //we are on one of the borders
88 *dx
= (double) ix
/ (double) vo_dwidth
;
89 *dy
= (double) iy
/ (double) vo_dheight
;
91 mp_msg(MSGT_CPLAYER
, MSGL_V
,
92 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
93 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
97 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
102 for (i
= 0; i
< SUB_SOURCES
; i
++) {
103 int j
= mpctx
->global_sub_indices
[i
];
104 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
112 static int sub_source(MPContext
* mpctx
)
114 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
118 * \brief Log the currently displayed subtitle to a file
120 * Logs the current or last displayed subtitle together with filename
121 * and time information to ~/.mplayer/subtitle_log
123 * Intended purpose is to allow convenient marking of bogus subtitles
124 * which need to be fixed while watching the movie.
127 static void log_sub(void)
133 if (subdata
== NULL
|| vo_sub_last
== NULL
)
135 fname
= get_path("subtitle_log");
136 f
= fopen(fname
, "a");
139 fprintf(f
, "----------------------------------------------------------\n");
140 if (subdata
->sub_uses_time
) {
142 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
143 filename
, vo_sub_last
->start
/ 360000,
144 (vo_sub_last
->start
/ 6000) % 60,
145 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
146 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
147 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
149 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
152 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
153 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
159 /// \defgroup Properties
162 /// \defgroup GeneralProperties General properties
163 /// \ingroup Properties
167 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
170 return m_property_choice(prop
, action
, arg
, &osd_level
);
174 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
178 case M_PROPERTY_PRINT
:
179 if (!arg
) return M_PROPERTY_ERROR
;
180 if (mpctx
->loop_times
< 0)
181 *(char**)arg
= strdup("off");
182 else if (mpctx
->loop_times
== 0)
183 *(char**)arg
= strdup("inf");
186 return M_PROPERTY_OK
;
188 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
191 /// Playback speed (RW)
192 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
193 void *arg
, MPContext
* mpctx
)
198 return M_PROPERTY_ERROR
;
199 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
200 playback_speed
= *(float *) arg
;
201 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
202 return M_PROPERTY_OK
;
203 case M_PROPERTY_STEP_UP
:
204 case M_PROPERTY_STEP_DOWN
:
205 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
206 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
207 M_PROPERTY_CLAMP(prop
, playback_speed
);
208 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
209 return M_PROPERTY_OK
;
211 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
214 /// filename with path (RO)
215 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
218 return m_property_string_ro(prop
, action
, arg
, filename
);
221 /// filename without path (RO)
222 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
227 return M_PROPERTY_UNAVAILABLE
;
228 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
232 return m_property_string_ro(prop
, action
, arg
, f
);
235 /// Demuxer name (RO)
236 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
240 return M_PROPERTY_UNAVAILABLE
;
241 return m_property_string_ro(prop
, action
, arg
,
242 (char *) mpctx
->demuxer
->desc
->name
);
245 /// Position in the stream (RW)
246 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
249 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
250 return M_PROPERTY_UNAVAILABLE
;
252 return M_PROPERTY_ERROR
;
255 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
256 return M_PROPERTY_OK
;
258 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
259 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
260 return M_PROPERTY_OK
;
262 return M_PROPERTY_NOT_IMPLEMENTED
;
265 /// Stream start offset (RO)
266 static int mp_property_stream_start(m_option_t
* prop
, int action
,
267 void *arg
, MPContext
* mpctx
)
269 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
270 return M_PROPERTY_UNAVAILABLE
;
273 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
274 return M_PROPERTY_OK
;
276 return M_PROPERTY_NOT_IMPLEMENTED
;
279 /// Stream end offset (RO)
280 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
283 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
284 return M_PROPERTY_UNAVAILABLE
;
287 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
288 return M_PROPERTY_OK
;
290 return M_PROPERTY_NOT_IMPLEMENTED
;
293 /// Stream length (RO)
294 static int mp_property_stream_length(m_option_t
* prop
, int action
,
295 void *arg
, MPContext
* mpctx
)
297 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
298 return M_PROPERTY_UNAVAILABLE
;
302 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
303 return M_PROPERTY_OK
;
305 return M_PROPERTY_NOT_IMPLEMENTED
;
308 /// Media length in seconds (RO)
309 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
314 if (!mpctx
->demuxer
||
315 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
316 return M_PROPERTY_UNAVAILABLE
;
318 return m_property_time_ro(prop
, action
, arg
, len
);
321 /// Current position in percent (RW)
322 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
323 void *arg
, MPContext
* mpctx
) {
327 return M_PROPERTY_UNAVAILABLE
;
331 if(!arg
) return M_PROPERTY_ERROR
;
332 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
335 case M_PROPERTY_STEP_UP
:
336 case M_PROPERTY_STEP_DOWN
:
337 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
338 pos
+= (arg
? *(int*)arg
: 10) *
339 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
340 M_PROPERTY_CLAMP(prop
, pos
);
343 return m_property_int_ro(prop
, action
, arg
,
344 demuxer_get_percent_pos(mpctx
->demuxer
));
348 rel_seek_secs
= pos
/ 100.0;
349 return M_PROPERTY_OK
;
352 /// Current position in seconds (RW)
353 static int mp_property_time_pos(m_option_t
* prop
, int action
,
354 void *arg
, MPContext
* mpctx
) {
355 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
356 return M_PROPERTY_UNAVAILABLE
;
360 if(!arg
) return M_PROPERTY_ERROR
;
361 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
363 rel_seek_secs
= *(double*)arg
;
364 return M_PROPERTY_OK
;
365 case M_PROPERTY_STEP_UP
:
366 case M_PROPERTY_STEP_DOWN
:
367 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
368 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
369 return M_PROPERTY_OK
;
371 return m_property_time_ro(prop
, action
, arg
,
372 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
373 playing_audio_pts(mpctx
->sh_audio
,
378 /// Current chapter (RW)
379 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
386 char *chapter_name
= NULL
;
390 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
392 return M_PROPERTY_UNAVAILABLE
;
394 return M_PROPERTY_ERROR
;
395 *(int *) arg
= chapter
;
396 return M_PROPERTY_OK
;
397 case M_PROPERTY_PRINT
: {
399 return M_PROPERTY_ERROR
;
400 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
402 return M_PROPERTY_UNAVAILABLE
;
403 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
405 return M_PROPERTY_UNAVAILABLE
;
406 *(char **) arg
= chapter_name
;
407 return M_PROPERTY_OK
;
411 return M_PROPERTY_ERROR
;
412 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
413 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
415 return M_PROPERTY_UNAVAILABLE
;
416 step_all
= *(int *)arg
- (chapter
+ 1);
419 case M_PROPERTY_STEP_UP
:
420 case M_PROPERTY_STEP_DOWN
: {
421 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
422 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
423 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
425 return M_PROPERTY_UNAVAILABLE
;
432 return M_PROPERTY_NOT_IMPLEMENTED
;
436 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
437 &next_pts
, &chapter_num
, &chapter_name
);
439 if (next_pts
> -1.0) {
441 rel_seek_secs
= next_pts
;
444 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
445 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
447 else if (step_all
> 0)
448 rel_seek_secs
= 1000000000.;
450 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
451 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
454 return M_PROPERTY_OK
;
457 /// Demuxer meta data
458 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
460 m_property_action_t
* ka
;
462 static m_option_t key_type
=
463 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
465 return M_PROPERTY_UNAVAILABLE
;
469 if(!arg
) return M_PROPERTY_ERROR
;
470 *(char***)arg
= mpctx
->demuxer
->info
;
471 return M_PROPERTY_OK
;
472 case M_PROPERTY_KEY_ACTION
:
473 if(!arg
) return M_PROPERTY_ERROR
;
475 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
476 return M_PROPERTY_UNKNOWN
;
479 if(!ka
->arg
) return M_PROPERTY_ERROR
;
480 *(char**)ka
->arg
= meta
;
481 return M_PROPERTY_OK
;
482 case M_PROPERTY_GET_TYPE
:
483 if(!ka
->arg
) return M_PROPERTY_ERROR
;
484 *(m_option_t
**)ka
->arg
= &key_type
;
485 return M_PROPERTY_OK
;
488 return M_PROPERTY_NOT_IMPLEMENTED
;
494 /// \defgroup AudioProperties Audio properties
495 /// \ingroup Properties
499 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
503 if (!mpctx
->sh_audio
)
504 return M_PROPERTY_UNAVAILABLE
;
509 return M_PROPERTY_ERROR
;
510 mixer_getbothvolume(&mpctx
->mixer
, arg
);
511 return M_PROPERTY_OK
;
512 case M_PROPERTY_PRINT
:{
515 return M_PROPERTY_ERROR
;
516 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
517 return m_property_float_range(prop
, action
, arg
, &vol
);
519 case M_PROPERTY_STEP_UP
:
520 case M_PROPERTY_STEP_DOWN
:
524 return M_PROPERTY_NOT_IMPLEMENTED
;
527 if (mpctx
->edl_muted
)
528 return M_PROPERTY_DISABLED
;
529 mpctx
->user_muted
= 0;
534 return M_PROPERTY_ERROR
;
535 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
536 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
537 return M_PROPERTY_OK
;
538 case M_PROPERTY_STEP_UP
:
539 if (arg
&& *(float *) arg
<= 0)
540 mixer_decvolume(&mpctx
->mixer
);
542 mixer_incvolume(&mpctx
->mixer
);
543 return M_PROPERTY_OK
;
544 case M_PROPERTY_STEP_DOWN
:
545 if (arg
&& *(float *) arg
<= 0)
546 mixer_incvolume(&mpctx
->mixer
);
548 mixer_decvolume(&mpctx
->mixer
);
549 return M_PROPERTY_OK
;
551 return M_PROPERTY_NOT_IMPLEMENTED
;
555 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
559 if (!mpctx
->sh_audio
)
560 return M_PROPERTY_UNAVAILABLE
;
564 if (mpctx
->edl_muted
)
565 return M_PROPERTY_DISABLED
;
567 return M_PROPERTY_ERROR
;
568 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
569 mixer_mute(&mpctx
->mixer
);
570 mpctx
->user_muted
= mpctx
->mixer
.muted
;
571 return M_PROPERTY_OK
;
572 case M_PROPERTY_STEP_UP
:
573 case M_PROPERTY_STEP_DOWN
:
574 if (mpctx
->edl_muted
)
575 return M_PROPERTY_DISABLED
;
576 mixer_mute(&mpctx
->mixer
);
577 mpctx
->user_muted
= mpctx
->mixer
.muted
;
578 return M_PROPERTY_OK
;
579 case M_PROPERTY_PRINT
:
581 return M_PROPERTY_ERROR
;
582 if (mpctx
->edl_muted
) {
583 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
584 return M_PROPERTY_OK
;
587 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
593 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
594 void *arg
, MPContext
* mpctx
)
596 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
597 return M_PROPERTY_UNAVAILABLE
;
600 case M_PROPERTY_STEP_UP
:
601 case M_PROPERTY_STEP_DOWN
:
603 return M_PROPERTY_ERROR
;
605 float delay
= audio_delay
;
606 m_property_delay(prop
, action
, arg
, &audio_delay
);
608 mpctx
->delay
-= audio_delay
- delay
;
610 return M_PROPERTY_OK
;
612 return m_property_delay(prop
, action
, arg
, &audio_delay
);
616 /// Audio codec tag (RO)
617 static int mp_property_audio_format(m_option_t
* prop
, int action
,
618 void *arg
, MPContext
* mpctx
)
620 if (!mpctx
->sh_audio
)
621 return M_PROPERTY_UNAVAILABLE
;
622 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
625 /// Audio codec name (RO)
626 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
627 void *arg
, MPContext
* mpctx
)
629 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
630 return M_PROPERTY_UNAVAILABLE
;
631 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
634 /// Audio bitrate (RO)
635 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
636 void *arg
, MPContext
* mpctx
)
638 if (!mpctx
->sh_audio
)
639 return M_PROPERTY_UNAVAILABLE
;
640 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
644 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
647 if (!mpctx
->sh_audio
)
648 return M_PROPERTY_UNAVAILABLE
;
650 case M_PROPERTY_PRINT
:
651 if(!arg
) return M_PROPERTY_ERROR
;
652 *(char**)arg
= malloc(16);
653 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
654 return M_PROPERTY_OK
;
656 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
659 /// Number of channels (RO)
660 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
663 if (!mpctx
->sh_audio
)
664 return M_PROPERTY_UNAVAILABLE
;
666 case M_PROPERTY_PRINT
:
668 return M_PROPERTY_ERROR
;
669 switch (mpctx
->sh_audio
->channels
) {
671 *(char **) arg
= strdup("mono");
674 *(char **) arg
= strdup("stereo");
677 *(char **) arg
= malloc(32);
678 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
680 return M_PROPERTY_OK
;
682 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
686 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
691 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
692 return M_PROPERTY_UNAVAILABLE
;
697 return M_PROPERTY_ERROR
;
698 mixer_getbalance(&mpctx
->mixer
, arg
);
699 return M_PROPERTY_OK
;
700 case M_PROPERTY_PRINT
: {
703 return M_PROPERTY_ERROR
;
704 mixer_getbalance(&mpctx
->mixer
, &bal
);
706 *str
= strdup("center");
707 else if (bal
== -1.f
)
708 *str
= strdup("left only");
710 *str
= strdup("right only");
712 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
713 *str
= malloc(sizeof("left xxx%, right xxx%"));
714 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
716 return M_PROPERTY_OK
;
718 case M_PROPERTY_STEP_UP
:
719 case M_PROPERTY_STEP_DOWN
:
720 mixer_getbalance(&mpctx
->mixer
, &bal
);
721 bal
+= (arg
? *(float*)arg
: .1f
) *
722 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
723 M_PROPERTY_CLAMP(prop
, bal
);
724 mixer_setbalance(&mpctx
->mixer
, bal
);
725 return M_PROPERTY_OK
;
728 return M_PROPERTY_ERROR
;
729 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
730 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
731 return M_PROPERTY_OK
;
733 return M_PROPERTY_NOT_IMPLEMENTED
;
736 /// Selected audio id (RW)
737 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
740 int current_id
= -1, tmp
;
744 if (!mpctx
->sh_audio
)
745 return M_PROPERTY_UNAVAILABLE
;
747 return M_PROPERTY_ERROR
;
748 *(int *) arg
= audio_id
;
749 return M_PROPERTY_OK
;
750 case M_PROPERTY_PRINT
:
751 if (!mpctx
->sh_audio
)
752 return M_PROPERTY_UNAVAILABLE
;
754 return M_PROPERTY_ERROR
;
757 *(char **) arg
= strdup(MSGTR_Disabled
);
759 char lang
[40] = MSGTR_Unknown
;
760 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
761 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
763 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
764 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
774 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
775 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
777 *(char **) arg
= malloc(64);
778 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
780 return M_PROPERTY_OK
;
782 case M_PROPERTY_STEP_UP
:
784 if (action
== M_PROPERTY_SET
&& arg
)
785 tmp
= *((int *) arg
);
788 current_id
= mpctx
->demuxer
->audio
->id
;
789 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
792 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
793 uninit_player(INITED_AO
| INITED_ACODEC
);
794 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
796 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
798 sh2
->ds
= mpctx
->demuxer
->audio
;
799 mpctx
->sh_audio
= sh2
;
800 reinit_audio_chain();
803 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
804 return M_PROPERTY_OK
;
806 return M_PROPERTY_NOT_IMPLEMENTED
;
811 /// Selected video id (RW)
812 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
815 int current_id
= -1, tmp
;
819 if (!mpctx
->sh_video
)
820 return M_PROPERTY_UNAVAILABLE
;
822 return M_PROPERTY_ERROR
;
823 *(int *) arg
= video_id
;
824 return M_PROPERTY_OK
;
825 case M_PROPERTY_PRINT
:
826 if (!mpctx
->sh_video
)
827 return M_PROPERTY_UNAVAILABLE
;
829 return M_PROPERTY_ERROR
;
832 *(char **) arg
= strdup(MSGTR_Disabled
);
834 char lang
[40] = MSGTR_Unknown
;
835 *(char **) arg
= malloc(64);
836 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
838 return M_PROPERTY_OK
;
840 case M_PROPERTY_STEP_UP
:
842 current_id
= mpctx
->demuxer
->video
->id
;
843 if (action
== M_PROPERTY_SET
&& arg
)
844 tmp
= *((int *) arg
);
847 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
849 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
850 && current_id
!= -2))
851 uninit_player(INITED_VCODEC
|
852 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
853 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
855 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
857 sh2
->ds
= mpctx
->demuxer
->video
;
858 mpctx
->sh_video
= sh2
;
859 reinit_video_chain();
862 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
863 return M_PROPERTY_OK
;
866 return M_PROPERTY_NOT_IMPLEMENTED
;
870 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
873 demux_program_t prog
;
876 case M_PROPERTY_STEP_UP
:
878 if (action
== M_PROPERTY_SET
&& arg
)
879 prog
.progid
= *((int *) arg
);
883 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
884 &prog
) == DEMUXER_CTRL_NOTIMPL
)
885 return M_PROPERTY_ERROR
;
887 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
888 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
889 return M_PROPERTY_OK
;
892 return M_PROPERTY_NOT_IMPLEMENTED
;
898 /// \defgroup VideoProperties Video properties
899 /// \ingroup Properties
902 /// Fullscreen state (RW)
903 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
907 if (!mpctx
->video_out
)
908 return M_PROPERTY_UNAVAILABLE
;
913 return M_PROPERTY_ERROR
;
914 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
915 if (vo_fs
== !!*(int *) arg
)
916 return M_PROPERTY_OK
;
917 case M_PROPERTY_STEP_UP
:
918 case M_PROPERTY_STEP_DOWN
:
921 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
925 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
926 return M_PROPERTY_OK
;
928 return m_property_flag(prop
, action
, arg
, &vo_fs
);
932 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
933 void *arg
, MPContext
* mpctx
)
937 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
938 return M_PROPERTY_UNAVAILABLE
;
939 vf
= mpctx
->sh_video
->vfilter
;
943 return M_PROPERTY_ERROR
;
944 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
945 return M_PROPERTY_OK
;
948 return M_PROPERTY_ERROR
;
949 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
950 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
951 return M_PROPERTY_OK
;
952 case M_PROPERTY_STEP_UP
:
953 case M_PROPERTY_STEP_DOWN
:
954 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
955 deinterlace
= !deinterlace
;
956 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
957 return M_PROPERTY_OK
;
959 return M_PROPERTY_NOT_IMPLEMENTED
;
963 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
967 if (!mpctx
->video_out
968 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
969 return M_PROPERTY_UNAVAILABLE
;
974 return M_PROPERTY_ERROR
;
975 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
976 vo_panscan
= *(float *) arg
;
977 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
978 return M_PROPERTY_OK
;
979 case M_PROPERTY_STEP_UP
:
980 case M_PROPERTY_STEP_DOWN
:
981 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
982 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
985 else if (vo_panscan
< 0)
987 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
988 return M_PROPERTY_OK
;
990 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
994 /// Helper to set vo flags.
995 /** \ingroup PropertyImplHelper
997 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
998 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1001 if (!mpctx
->video_out
)
1002 return M_PROPERTY_UNAVAILABLE
;
1005 case M_PROPERTY_SET
:
1007 return M_PROPERTY_ERROR
;
1008 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1009 if (*vo_var
== !!*(int *) arg
)
1010 return M_PROPERTY_OK
;
1011 case M_PROPERTY_STEP_UP
:
1012 case M_PROPERTY_STEP_DOWN
:
1013 if (vo_config_count
)
1014 mpctx
->video_out
->control(vo_ctrl
, 0);
1015 return M_PROPERTY_OK
;
1017 return m_property_flag(prop
, action
, arg
, vo_var
);
1021 /// Window always on top (RW)
1022 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1025 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1029 /// Display in the root window (RW)
1030 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1033 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1034 &vo_rootwin
, mpctx
);
1037 /// Show window borders (RW)
1038 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1041 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1045 /// Framedropping state (RW)
1046 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1047 void *arg
, MPContext
* mpctx
)
1050 if (!mpctx
->sh_video
)
1051 return M_PROPERTY_UNAVAILABLE
;
1054 case M_PROPERTY_PRINT
:
1056 return M_PROPERTY_ERROR
;
1057 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1058 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1060 return M_PROPERTY_OK
;
1062 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1066 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1067 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1070 int *gamma
= prop
->priv
, r
;
1072 if (!mpctx
->sh_video
)
1073 return M_PROPERTY_UNAVAILABLE
;
1075 if (gamma
[0] == 1000) {
1077 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1081 case M_PROPERTY_SET
:
1083 return M_PROPERTY_ERROR
;
1084 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1085 *gamma
= *(int *) arg
;
1086 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1090 case M_PROPERTY_GET
:
1092 return M_PROPERTY_ERROR
;
1093 r
= get_video_colors(mpctx
->sh_video
, prop
->name
, arg
);
1097 case M_PROPERTY_STEP_UP
:
1098 case M_PROPERTY_STEP_DOWN
:
1099 *gamma
+= (arg
? *(int *) arg
: 1) *
1100 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1101 M_PROPERTY_CLAMP(prop
, *gamma
);
1102 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1107 return M_PROPERTY_NOT_IMPLEMENTED
;
1111 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1112 int l
= strlen(prop
->name
);
1113 char tv_prop
[3 + l
+ 1];
1114 sprintf(tv_prop
, "tv_%s", prop
->name
);
1115 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1119 return M_PROPERTY_UNAVAILABLE
;
1123 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1126 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1129 /// Video codec tag (RO)
1130 static int mp_property_video_format(m_option_t
* prop
, int action
,
1131 void *arg
, MPContext
* mpctx
)
1134 if (!mpctx
->sh_video
)
1135 return M_PROPERTY_UNAVAILABLE
;
1137 case M_PROPERTY_PRINT
:
1139 return M_PROPERTY_ERROR
;
1140 switch(mpctx
->sh_video
->format
) {
1142 meta
= strdup ("mpeg1"); break;
1144 meta
= strdup ("mpeg2"); break;
1146 meta
= strdup ("mpeg4"); break;
1148 meta
= strdup ("h264"); break;
1150 if(mpctx
->sh_video
->format
>= 0x20202020) {
1152 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1155 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1158 *(char**)arg
= meta
;
1159 return M_PROPERTY_OK
;
1161 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1164 /// Video codec name (RO)
1165 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1166 void *arg
, MPContext
* mpctx
)
1168 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1169 return M_PROPERTY_UNAVAILABLE
;
1170 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1174 /// Video bitrate (RO)
1175 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1176 void *arg
, MPContext
* mpctx
)
1178 if (!mpctx
->sh_video
)
1179 return M_PROPERTY_UNAVAILABLE
;
1180 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1183 /// Video display width (RO)
1184 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1187 if (!mpctx
->sh_video
)
1188 return M_PROPERTY_UNAVAILABLE
;
1189 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1192 /// Video display height (RO)
1193 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1196 if (!mpctx
->sh_video
)
1197 return M_PROPERTY_UNAVAILABLE
;
1198 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1202 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1205 if (!mpctx
->sh_video
)
1206 return M_PROPERTY_UNAVAILABLE
;
1207 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1210 /// Video aspect (RO)
1211 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1214 if (!mpctx
->sh_video
)
1215 return M_PROPERTY_UNAVAILABLE
;
1216 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1221 /// \defgroup SubProprties Subtitles properties
1222 /// \ingroup Properties
1225 /// Text subtitle position (RW)
1226 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1229 if (!mpctx
->sh_video
)
1230 return M_PROPERTY_UNAVAILABLE
;
1233 case M_PROPERTY_SET
:
1235 return M_PROPERTY_ERROR
;
1236 case M_PROPERTY_STEP_UP
:
1237 case M_PROPERTY_STEP_DOWN
:
1238 vo_osd_changed(OSDTYPE_SUBTITLE
);
1240 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1244 char *demux_lavf_sub_lang(demuxer_t
*demuxer
, int track_num
);
1246 /// Selected subtitles (RW)
1247 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1250 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1251 const int global_sub_size
= mpctx
->global_sub_size
;
1252 int source
= -1, reset_spu
= 0;
1255 if (global_sub_size
<= 0)
1256 return M_PROPERTY_UNAVAILABLE
;
1259 case M_PROPERTY_GET
:
1261 return M_PROPERTY_ERROR
;
1262 *(int *) arg
= mpctx
->global_sub_pos
;
1263 return M_PROPERTY_OK
;
1264 case M_PROPERTY_PRINT
:
1266 return M_PROPERTY_ERROR
;
1267 *(char **) arg
= malloc(64);
1268 (*(char **) arg
)[63] = 0;
1271 sub_name
= subdata
->filename
;
1273 if (ass_track
&& ass_track
->name
)
1274 sub_name
= ass_track
->name
;
1279 if ((tmp2
= strrchr(tmp
, '/')))
1282 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1283 mpctx
->set_of_sub_pos
+ 1,
1284 strlen(tmp
) < 20 ? "" : "...",
1285 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1286 return M_PROPERTY_OK
;
1289 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1290 if (vo_spudec
&& dvdsub_id
>= 0) {
1291 unsigned char lang
[3];
1292 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1293 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1294 return M_PROPERTY_OK
;
1300 #ifdef USE_LIBAVFORMAT
1301 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
&& dvdsub_id
>= 0) {
1302 char *lang
= demux_lavf_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1303 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1304 return M_PROPERTY_OK
;
1307 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1308 char lang
[40] = MSGTR_Unknown
;
1309 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1310 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1311 return M_PROPERTY_OK
;
1313 #ifdef HAVE_OGGVORBIS
1314 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1315 char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1317 lang
= MSGTR_Unknown
;
1318 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1319 return M_PROPERTY_OK
;
1322 if (vo_vobsub
&& vobsub_id
>= 0) {
1323 const char *language
= MSGTR_Unknown
;
1324 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1325 snprintf(*(char **) arg
, 63, "(%d) %s",
1326 vobsub_id
, language
? language
: MSGTR_Unknown
);
1327 return M_PROPERTY_OK
;
1330 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1331 && dvdsub_id
>= 0) {
1333 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1334 lang
[0] = code
>> 8;
1337 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1338 return M_PROPERTY_OK
;
1341 if (dvdsub_id
>= 0) {
1342 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1343 return M_PROPERTY_OK
;
1345 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1346 return M_PROPERTY_OK
;
1348 case M_PROPERTY_SET
:
1350 return M_PROPERTY_ERROR
;
1351 if (*(int *) arg
< -1)
1353 else if (*(int *) arg
>= global_sub_size
)
1354 *(int *) arg
= global_sub_size
- 1;
1355 mpctx
->global_sub_pos
= *(int *) arg
;
1357 case M_PROPERTY_STEP_UP
:
1358 mpctx
->global_sub_pos
+= 2;
1359 mpctx
->global_sub_pos
=
1360 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1362 case M_PROPERTY_STEP_DOWN
:
1363 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1364 mpctx
->global_sub_pos
=
1365 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1368 return M_PROPERTY_NOT_IMPLEMENTED
;
1371 if (mpctx
->global_sub_pos
>= 0)
1372 source
= sub_source(mpctx
);
1374 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1375 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1377 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1378 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1379 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1380 mpctx
->global_sub_pos
, source
);
1382 mpctx
->set_of_sub_pos
= -1;
1396 if (source
== SUB_SOURCE_VOBSUB
) {
1397 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1398 } else if (source
== SUB_SOURCE_SUBS
) {
1399 mpctx
->set_of_sub_pos
=
1400 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1402 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1403 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1407 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1408 vo_osd_changed(OSDTYPE_SUBTITLE
);
1410 } else if (source
== SUB_SOURCE_DEMUX
) {
1412 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1413 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1415 // default: assume 1:1 mapping of sid and stream id
1416 d_sub
->id
= dvdsub_id
;
1417 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1418 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1419 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1420 if (sh
&& sh
->sid
== dvdsub_id
) {
1426 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1427 sh_sub_t
*sh
= d_sub
->sh
;
1428 if (sh
->type
== 'v')
1431 else if (ass_enabled
&& sh
->type
== 'a')
1432 ass_track
= sh
->ass_track
;
1442 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1443 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1444 && dvdsub_id
< 0 && reset_spu
) {
1446 d_sub
->id
= dvdsub_id
;
1449 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1451 return M_PROPERTY_OK
;
1454 /// Selected sub source (RW)
1455 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1459 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1460 return M_PROPERTY_UNAVAILABLE
;
1463 case M_PROPERTY_GET
:
1465 return M_PROPERTY_ERROR
;
1466 *(int *) arg
= sub_source(mpctx
);
1467 return M_PROPERTY_OK
;
1468 case M_PROPERTY_PRINT
:
1470 return M_PROPERTY_ERROR
;
1471 *(char **) arg
= malloc(64);
1472 (*(char **) arg
)[63] = 0;
1473 switch (sub_source(mpctx
))
1475 case SUB_SOURCE_SUBS
:
1476 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1478 case SUB_SOURCE_VOBSUB
:
1479 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1481 case SUB_SOURCE_DEMUX
:
1482 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1485 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1487 return M_PROPERTY_OK
;
1488 case M_PROPERTY_SET
:
1490 return M_PROPERTY_ERROR
;
1491 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1492 if (*(int *) arg
< 0)
1493 mpctx
->global_sub_pos
= -1;
1494 else if (*(int *) arg
!= sub_source(mpctx
)) {
1495 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1496 return M_PROPERTY_UNAVAILABLE
;
1497 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1500 case M_PROPERTY_STEP_UP
:
1501 case M_PROPERTY_STEP_DOWN
: {
1502 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1503 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1504 int step
= (step_all
> 0) ? 1 : -1;
1505 int cur_source
= sub_source(mpctx
);
1506 source
= cur_source
;
1509 if (source
>= SUB_SOURCES
)
1511 else if (source
< -1)
1512 source
= SUB_SOURCES
- 1;
1513 if (source
== cur_source
|| source
== -1 ||
1514 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1517 if (source
== cur_source
)
1518 return M_PROPERTY_OK
;
1520 mpctx
->global_sub_pos
= -1;
1522 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1526 return M_PROPERTY_NOT_IMPLEMENTED
;
1528 --mpctx
->global_sub_pos
;
1529 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1532 /// Selected subtitles from specific source (RW)
1533 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1536 int source
, is_cur_source
, offset
;
1537 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1538 return M_PROPERTY_UNAVAILABLE
;
1540 if (!strcmp(prop
->name
, "sub_file"))
1541 source
= SUB_SOURCE_SUBS
;
1542 else if (!strcmp(prop
->name
, "sub_vob"))
1543 source
= SUB_SOURCE_VOBSUB
;
1544 else if (!strcmp(prop
->name
, "sub_demux"))
1545 source
= SUB_SOURCE_DEMUX
;
1547 return M_PROPERTY_ERROR
;
1549 offset
= mpctx
->global_sub_indices
[source
];
1550 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1551 return M_PROPERTY_UNAVAILABLE
;
1553 is_cur_source
= sub_source(mpctx
) == source
;
1555 case M_PROPERTY_GET
:
1557 return M_PROPERTY_ERROR
;
1558 if (is_cur_source
) {
1559 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1560 if (source
== SUB_SOURCE_VOBSUB
)
1561 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1565 return M_PROPERTY_OK
;
1566 case M_PROPERTY_PRINT
:
1568 return M_PROPERTY_ERROR
;
1570 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1571 *(char **) arg
= malloc(64);
1572 (*(char **) arg
)[63] = 0;
1573 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1574 return M_PROPERTY_OK
;
1575 case M_PROPERTY_SET
:
1577 return M_PROPERTY_ERROR
;
1578 if (*(int *) arg
>= 0) {
1579 int index
= *(int *)arg
;
1580 if (source
== SUB_SOURCE_VOBSUB
)
1581 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1582 mpctx
->global_sub_pos
= offset
+ index
;
1583 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1584 || sub_source(mpctx
) != source
) {
1585 mpctx
->global_sub_pos
= -1;
1590 mpctx
->global_sub_pos
= -1;
1592 case M_PROPERTY_STEP_UP
:
1593 case M_PROPERTY_STEP_DOWN
: {
1594 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1595 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1596 int step
= (step_all
> 0) ? 1 : -1;
1597 int max_sub_pos_for_source
= -1;
1599 mpctx
->global_sub_pos
= -1;
1601 if (mpctx
->global_sub_pos
== -1) {
1603 mpctx
->global_sub_pos
= offset
;
1604 else if (max_sub_pos_for_source
== -1) {
1605 // Find max pos for specific source
1606 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1607 while (mpctx
->global_sub_pos
>= 0
1608 && sub_source(mpctx
) != source
)
1609 --mpctx
->global_sub_pos
;
1612 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1615 mpctx
->global_sub_pos
+= step
;
1616 if (mpctx
->global_sub_pos
< offset
||
1617 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1618 sub_source(mpctx
) != source
)
1619 mpctx
->global_sub_pos
= -1;
1626 return M_PROPERTY_NOT_IMPLEMENTED
;
1628 --mpctx
->global_sub_pos
;
1629 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1632 /// Subtitle delay (RW)
1633 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1636 if (!mpctx
->sh_video
)
1637 return M_PROPERTY_UNAVAILABLE
;
1638 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1641 /// Alignment of text subtitles (RW)
1642 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1643 void *arg
, MPContext
* mpctx
)
1645 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1647 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1648 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1649 return M_PROPERTY_UNAVAILABLE
;
1652 case M_PROPERTY_PRINT
:
1654 return M_PROPERTY_ERROR
;
1655 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1656 *(char **) arg
= strdup(name
[sub_alignment
]);
1657 return M_PROPERTY_OK
;
1658 case M_PROPERTY_SET
:
1660 return M_PROPERTY_ERROR
;
1661 case M_PROPERTY_STEP_UP
:
1662 case M_PROPERTY_STEP_DOWN
:
1663 vo_osd_changed(OSDTYPE_SUBTITLE
);
1665 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1669 /// Subtitle visibility (RW)
1670 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1671 void *arg
, MPContext
* mpctx
)
1673 if (!mpctx
->sh_video
)
1674 return M_PROPERTY_UNAVAILABLE
;
1677 case M_PROPERTY_SET
:
1679 return M_PROPERTY_ERROR
;
1680 case M_PROPERTY_STEP_UP
:
1681 case M_PROPERTY_STEP_DOWN
:
1682 vo_osd_changed(OSDTYPE_SUBTITLE
);
1684 vo_osd_changed(OSDTYPE_SPU
);
1686 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1690 /// Show only forced subtitles (RW)
1691 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1692 void *arg
, MPContext
* mpctx
)
1695 return M_PROPERTY_UNAVAILABLE
;
1698 case M_PROPERTY_SET
:
1700 return M_PROPERTY_ERROR
;
1701 case M_PROPERTY_STEP_UP
:
1702 case M_PROPERTY_STEP_DOWN
:
1703 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1704 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1705 return M_PROPERTY_OK
;
1707 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1712 #ifdef HAVE_FREETYPE
1713 /// Subtitle scale (RW)
1714 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1719 case M_PROPERTY_SET
:
1721 return M_PROPERTY_ERROR
;
1722 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1723 text_font_scale_factor
= *(float *) arg
;
1724 force_load_font
= 1;
1725 return M_PROPERTY_OK
;
1726 case M_PROPERTY_STEP_UP
:
1727 case M_PROPERTY_STEP_DOWN
:
1728 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1729 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1730 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1731 force_load_font
= 1;
1732 return M_PROPERTY_OK
;
1734 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1741 /// \defgroup TVProperties TV properties
1742 /// \ingroup Properties
1747 /// TV color settings (RW)
1748 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1752 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1753 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1754 return M_PROPERTY_UNAVAILABLE
;
1757 case M_PROPERTY_SET
:
1759 return M_PROPERTY_ERROR
;
1760 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1761 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1762 case M_PROPERTY_GET
:
1763 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1764 case M_PROPERTY_STEP_UP
:
1765 case M_PROPERTY_STEP_DOWN
:
1766 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1768 return M_PROPERTY_ERROR
;
1769 val
+= (arg
? *(int *) arg
: 1) *
1770 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1771 M_PROPERTY_CLAMP(prop
, val
);
1772 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1774 return M_PROPERTY_ERROR
;
1776 return M_PROPERTY_NOT_IMPLEMENTED
;
1781 #ifdef HAVE_TV_TELETEXT
1782 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1786 int base_ioctl
=(int)prop
->priv
;
1788 for teletext's GET,SET,STEP ioctls this is not 0
1792 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1793 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1794 return M_PROPERTY_UNAVAILABLE
;
1796 return M_PROPERTY_ERROR
;
1799 case M_PROPERTY_GET
:
1801 return M_PROPERTY_ERROR
;
1802 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1804 case M_PROPERTY_SET
:
1806 return M_PROPERTY_ERROR
;
1807 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1808 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1810 case M_PROPERTY_STEP_UP
:
1811 case M_PROPERTY_STEP_DOWN
:
1812 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1813 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1814 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1817 return M_PROPERTY_NOT_IMPLEMENTED
;
1820 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1823 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1826 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1830 //with tvh==NULL will fail too
1831 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1832 if(result
!=M_PROPERTY_OK
)
1835 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1836 mp_input_set_section("teletext");
1838 mp_input_set_section("tv");
1839 return M_PROPERTY_OK
;
1842 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1845 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1849 case M_PROPERTY_STEP_UP
:
1850 case M_PROPERTY_STEP_DOWN
:
1851 //This should be handled separately
1852 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1853 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1856 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1862 #endif /* HAVE_TV_TELETEXT */
1866 /// All properties available in MPlayer.
1867 /** \ingroup Properties
1869 static m_option_t mp_properties
[] = {
1871 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1872 M_OPT_RANGE
, 0, 3, NULL
},
1873 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1874 M_OPT_MIN
, -1, 0, NULL
},
1875 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1876 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1877 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1879 { "path", mp_property_path
, CONF_TYPE_STRING
,
1881 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1883 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1884 M_OPT_MIN
, 0, 0, NULL
},
1885 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1886 M_OPT_MIN
, 0, 0, NULL
},
1887 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1888 M_OPT_MIN
, 0, 0, NULL
},
1889 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1890 M_OPT_MIN
, 0, 0, NULL
},
1891 { "length", mp_property_length
, CONF_TYPE_TIME
,
1892 M_OPT_MIN
, 0, 0, NULL
},
1893 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1894 M_OPT_RANGE
, 0, 100, NULL
},
1895 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1896 M_OPT_MIN
, 0, 0, NULL
},
1897 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1898 M_OPT_MIN
, 1, 0, NULL
},
1899 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1903 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1904 M_OPT_RANGE
, 0, 100, NULL
},
1905 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1906 M_OPT_RANGE
, 0, 1, NULL
},
1907 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1908 M_OPT_RANGE
, -100, 100, NULL
},
1909 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1911 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1913 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1915 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
1917 { "channels", mp_property_channels
, CONF_TYPE_INT
,
1919 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
1920 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
1921 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
1922 M_OPT_RANGE
, -1, 1, NULL
},
1925 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
1926 M_OPT_RANGE
, 0, 1, NULL
},
1927 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
1928 M_OPT_RANGE
, 0, 1, NULL
},
1929 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
1930 M_OPT_RANGE
, 0, 1, NULL
},
1931 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
1932 M_OPT_RANGE
, 0, 1, NULL
},
1933 { "border", mp_property_border
, CONF_TYPE_FLAG
,
1934 M_OPT_RANGE
, 0, 1, NULL
},
1935 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
1936 M_OPT_RANGE
, 0, 2, NULL
},
1937 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
1938 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
1939 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
1940 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
1941 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
1942 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
1943 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
1944 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
1945 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
1946 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
1947 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
1948 M_OPT_RANGE
, 0, 1, NULL
},
1949 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
1950 M_OPT_RANGE
, 0, 1, NULL
},
1951 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
1953 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
1955 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
1957 { "width", mp_property_width
, CONF_TYPE_INT
,
1959 { "height", mp_property_height
, CONF_TYPE_INT
,
1961 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
1963 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
1965 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
1966 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
1967 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
1968 CONF_RANGE
, -1, 65535, NULL
},
1971 { "sub", mp_property_sub
, CONF_TYPE_INT
,
1972 M_OPT_MIN
, -1, 0, NULL
},
1973 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
1974 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
1975 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
1976 M_OPT_MIN
, -1, 0, NULL
},
1977 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
1978 M_OPT_MIN
, -1, 0, NULL
},
1979 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
1980 M_OPT_MIN
, -1, 0, NULL
},
1981 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
1983 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
1984 M_OPT_RANGE
, 0, 100, NULL
},
1985 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
1986 M_OPT_RANGE
, 0, 2, NULL
},
1987 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
1988 M_OPT_RANGE
, 0, 1, NULL
},
1989 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
1990 M_OPT_RANGE
, 0, 1, NULL
},
1991 #ifdef HAVE_FREETYPE
1992 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
1993 M_OPT_RANGE
, 0, 100, NULL
},
1997 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
1998 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
1999 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2000 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2001 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2002 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2003 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2004 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2007 #ifdef HAVE_TV_TELETEXT
2008 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2009 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2010 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2011 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2012 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2013 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2014 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2015 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2016 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2017 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2020 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2024 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2026 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2029 char* mp_property_print(const char *name
, void* ctx
)
2032 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2037 char *property_expand_string(MPContext
* mpctx
, char *str
)
2039 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2042 void property_print_help(void)
2044 m_properties_print_help_list(mp_properties
);
2053 * \defgroup Command2Property Command to property bridge
2055 * It is used to handle most commands that just set a property
2056 * and optionally display something on the OSD.
2057 * Two kinds of commands are handled: adjust or toggle.
2059 * Adjust commands take 1 or 2 parameters: <value> <abs>
2060 * If <abs> is non-zero the property is set to the given value
2061 * otherwise it is adjusted.
2063 * Toggle commands take 0 or 1 parameters. With no parameter
2064 * or a value less than the property minimum it just steps the
2065 * property to its next value. Otherwise it sets it to the given
2071 /// List of the commands that can be handled by setting a property.
2077 /// set/adjust or toggle command
2079 /// progressbar type
2081 /// osd msg id if it must be shared
2083 /// osd msg template
2084 const char *osd_msg
;
2085 } set_prop_cmd
[] = {
2087 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2088 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2090 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2091 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2092 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2093 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2094 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2096 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2097 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2098 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2099 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2100 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2101 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2102 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2103 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2104 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2105 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2106 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2107 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2109 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2110 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2111 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2112 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2113 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2114 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2115 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2116 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2117 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2118 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2119 #ifdef HAVE_FREETYPE
2120 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2123 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2124 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2125 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2126 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2128 { NULL
, 0, 0, 0, -1, NULL
}
2132 /// Handle commands that set a property.
2133 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2139 // look for the command
2140 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2141 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2143 if (!(pname
= set_prop_cmd
[i
].name
))
2146 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2150 if (set_prop_cmd
[i
].toggle
) {
2152 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2153 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2155 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2156 } else if (cmd
->args
[1].v
.i
) //set
2157 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2159 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2164 if (set_prop_cmd
[i
].osd_progbar
) {
2165 if (prop
->type
== CONF_TYPE_INT
) {
2166 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2167 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2168 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2169 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2171 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2172 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2173 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2175 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2176 "Property use an unsupported type.\n");
2180 if (set_prop_cmd
[i
].osd_msg
) {
2181 char *val
= mp_property_print(pname
, mpctx
);
2183 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2184 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2185 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2193 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2195 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2196 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2198 if (!set_property_command(mpctx
, cmd
))
2204 mpctx
->osd_show_percentage
= sh_video
->fps
;
2205 v
= cmd
->args
[0].v
.f
;
2206 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2207 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2210 mpctx
->osd_function
=
2211 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2213 } else if (abs
) { /* Absolute seek by percentage */
2216 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2217 rel_seek_secs
= v
/ 100.0;
2220 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2226 case MP_CMD_SET_PROPERTY
:{
2227 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2228 cmd
->args
[1].v
.s
, mpctx
);
2229 if (r
== M_PROPERTY_UNKNOWN
)
2230 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2231 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2233 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2234 "Failed to set property '%s' to '%s'.\n",
2235 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2239 case MP_CMD_STEP_PROPERTY
:{
2244 if (cmd
->args
[1].v
.f
) {
2246 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2247 M_PROPERTY_GET_TYPE
,
2248 &prop
, mpctx
)) <= 0)
2250 if(prop
->type
== CONF_TYPE_INT
||
2251 prop
->type
== CONF_TYPE_FLAG
)
2252 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2253 else if(prop
->type
== CONF_TYPE_FLOAT
)
2254 arg
= &cmd
->args
[1].v
.f
;
2255 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2256 prop
->type
== CONF_TYPE_TIME
)
2257 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2258 else if(prop
->type
== CONF_TYPE_POSITION
)
2259 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2261 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2262 "Ignoring step size stepping property '%s'.\n",
2265 r
= mp_property_do(cmd
->args
[0].v
.s
,
2266 cmd
->args
[2].v
.i
< 0 ?
2267 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2270 if (r
== M_PROPERTY_UNKNOWN
)
2271 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2272 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2274 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2275 "Failed to increment property '%s' by %f.\n",
2276 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2280 case MP_CMD_GET_PROPERTY
:{
2282 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2283 &tmp
, mpctx
) <= 0) {
2284 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2285 "Failed to get value of property '%s'.\n",
2289 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2290 cmd
->args
[0].v
.s
, tmp
);
2295 case MP_CMD_EDL_MARK
:
2297 float v
= sh_video
? sh_video
->pts
:
2298 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2301 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2302 mpctx
->begin_skip
= v
;
2303 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2305 if (mpctx
->begin_skip
> v
)
2306 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2308 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2309 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2311 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2316 case MP_CMD_SWITCH_RATIO
:
2317 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2318 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2320 movie_aspect
= cmd
->args
[0].v
.f
;
2321 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2324 case MP_CMD_SPEED_INCR
:{
2325 float v
= cmd
->args
[0].v
.f
;
2326 playback_speed
+= v
;
2327 build_afilter_chain(sh_audio
, &ao_data
);
2328 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2332 case MP_CMD_SPEED_MULT
:{
2333 float v
= cmd
->args
[0].v
.f
;
2334 playback_speed
*= v
;
2335 build_afilter_chain(sh_audio
, &ao_data
);
2336 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2340 case MP_CMD_SPEED_SET
:{
2341 float v
= cmd
->args
[0].v
.f
;
2343 build_afilter_chain(sh_audio
, &ao_data
);
2344 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2348 case MP_CMD_FRAME_STEP
:
2354 case MP_CMD_FILE_FILTER
:
2355 file_filter
= cmd
->args
[0].v
.i
;
2359 exit_player_with_rc(MSGTR_Exit_quit
,
2360 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2362 case MP_CMD_PLAY_TREE_STEP
:{
2363 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2364 int force
= cmd
->args
[1].v
.i
;
2370 for (i
= 0; i
< n
; i
++)
2373 for (i
= 0; i
< -1 * n
; i
++)
2378 if (!force
&& mpctx
->playtree_iter
) {
2379 play_tree_iter_t
*i
=
2380 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2381 if (play_tree_iter_step(i
, n
, 0) ==
2382 PLAY_TREE_ITER_ENTRY
)
2384 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2385 play_tree_iter_free(i
);
2387 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2389 mpctx
->play_tree_step
= n
;
2395 case MP_CMD_PLAY_TREE_UP_STEP
:{
2396 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2397 int force
= cmd
->args
[1].v
.i
;
2399 if (!force
&& mpctx
->playtree_iter
) {
2400 play_tree_iter_t
*i
=
2401 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2402 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2403 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2404 play_tree_iter_free(i
);
2406 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2411 case MP_CMD_PLAY_ALT_SRC_STEP
:
2412 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2413 int v
= cmd
->args
[0].v
.i
;
2415 && mpctx
->playtree_iter
->file
<
2416 mpctx
->playtree_iter
->num_files
)
2417 mpctx
->eof
= PT_NEXT_SRC
;
2418 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2419 mpctx
->eof
= PT_PREV_SRC
;
2424 case MP_CMD_SUB_STEP
:
2426 int movement
= cmd
->args
[0].v
.i
;
2427 step_sub(subdata
, sh_video
->pts
, movement
);
2431 ass_step_sub(ass_track
,
2433 sub_delay
) * 1000 + .5, movement
) / 1000.;
2435 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2436 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2440 case MP_CMD_SUB_LOG
:
2445 int v
= cmd
->args
[0].v
.i
;
2447 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2448 if (osd_level
> max
)
2451 osd_level
= (osd_level
+ 1) % (max
+ 1);
2453 osd_level
= v
> max
? max
: v
;
2454 /* Show OSD state when disabled, but not when an explicit
2455 argument is given to the OSD command, i.e. in slave mode. */
2456 if (v
== -1 && osd_level
<= 1)
2457 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2459 osd_level
? MSGTR_OSDenabled
:
2462 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2466 case MP_CMD_OSD_SHOW_TEXT
:
2467 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2469 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2470 "%-.63s", cmd
->args
[0].v
.s
);
2473 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2474 char *txt
= m_properties_expand_string(mp_properties
,
2477 /* if no argument supplied take default osd_duration, else <arg> ms. */
2479 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2481 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2488 case MP_CMD_LOADFILE
:{
2489 play_tree_t
*e
= play_tree_new();
2490 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2492 if (cmd
->args
[1].v
.i
) // append
2493 play_tree_append_entry(mpctx
->playtree
, e
);
2495 // Go back to the starting point.
2496 while (play_tree_iter_up_step
2497 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2499 play_tree_free_list(mpctx
->playtree
->child
, 1);
2500 play_tree_set_child(mpctx
->playtree
, e
);
2501 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2502 mpctx
->eof
= PT_NEXT_SRC
;
2508 case MP_CMD_LOADLIST
:{
2509 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2511 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2512 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2514 if (cmd
->args
[1].v
.i
) // append
2515 play_tree_append_entry(mpctx
->playtree
, e
);
2517 // Go back to the starting point.
2518 while (play_tree_iter_up_step
2519 (mpctx
->playtree_iter
, 0, 1)
2520 != PLAY_TREE_ITER_END
)
2522 play_tree_free_list(mpctx
->playtree
->child
, 1);
2523 play_tree_set_child(mpctx
->playtree
, e
);
2524 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2525 mpctx
->eof
= PT_NEXT_SRC
;
2533 case MP_CMD_RADIO_STEP_CHANNEL
:
2534 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2535 int v
= cmd
->args
[0].v
.i
;
2537 radio_step_channel(mpctx
->demuxer
->stream
,
2538 RADIO_CHANNEL_HIGHER
);
2540 radio_step_channel(mpctx
->demuxer
->stream
,
2541 RADIO_CHANNEL_LOWER
);
2542 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2543 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2545 radio_get_channel_name(mpctx
->demuxer
->stream
));
2550 case MP_CMD_RADIO_SET_CHANNEL
:
2551 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2552 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2553 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2554 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2556 radio_get_channel_name(mpctx
->demuxer
->stream
));
2561 case MP_CMD_RADIO_SET_FREQ
:
2562 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2563 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2566 case MP_CMD_RADIO_STEP_FREQ
:
2567 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2568 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2573 case MP_CMD_TV_START_SCAN
:
2574 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2575 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2577 case MP_CMD_TV_SET_FREQ
:
2578 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2579 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2580 cmd
->args
[0].v
.f
* 16.0);
2582 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2583 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2584 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2585 pvr_get_current_channelname (mpctx
->stream
),
2586 pvr_get_current_stationname (mpctx
->stream
));
2588 #endif /* HAVE_PVR */
2591 case MP_CMD_TV_STEP_FREQ
:
2592 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2593 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2594 cmd
->args
[0].v
.f
* 16.0);
2596 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2597 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2598 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2599 pvr_get_current_channelname (mpctx
->stream
),
2600 pvr_get_current_frequency (mpctx
->stream
));
2602 #endif /* HAVE_PVR */
2605 case MP_CMD_TV_SET_NORM
:
2606 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2607 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2611 case MP_CMD_TV_STEP_CHANNEL
:{
2612 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2613 int v
= cmd
->args
[0].v
.i
;
2615 tv_step_channel((tvi_handle_t
*) (mpctx
->
2619 tv_step_channel((tvi_handle_t
*) (mpctx
->
2623 if (tv_channel_list
) {
2624 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2625 MSGTR_OSDChannel
, tv_channel_current
->name
);
2626 //vo_osd_changed(OSDTYPE_SUBTITLE);
2630 else if (mpctx
->stream
&&
2631 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2632 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2633 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2634 pvr_get_current_channelname (mpctx
->stream
),
2635 pvr_get_current_stationname (mpctx
->stream
));
2637 #endif /* HAVE_PVR */
2639 #ifdef HAS_DVBIN_SUPPORT
2640 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2642 int v
= cmd
->args
[0].v
.i
;
2644 mpctx
->last_dvb_step
= v
;
2646 dir
= DVB_CHANNEL_HIGHER
;
2648 dir
= DVB_CHANNEL_LOWER
;
2651 if (dvb_step_channel(mpctx
->stream
, dir
))
2652 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2654 #endif /* HAS_DVBIN_SUPPORT */
2657 case MP_CMD_TV_SET_CHANNEL
:
2658 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2659 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2661 if (tv_channel_list
) {
2662 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2663 MSGTR_OSDChannel
, tv_channel_current
->name
);
2664 //vo_osd_changed(OSDTYPE_SUBTITLE);
2668 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2669 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2670 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2671 pvr_get_current_channelname (mpctx
->stream
),
2672 pvr_get_current_stationname (mpctx
->stream
));
2674 #endif /* HAVE_PVR */
2677 #ifdef HAS_DVBIN_SUPPORT
2678 case MP_CMD_DVB_SET_CHANNEL
:
2679 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2680 mpctx
->last_dvb_step
= 1;
2683 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2684 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2687 #endif /* HAS_DVBIN_SUPPORT */
2689 case MP_CMD_TV_LAST_CHANNEL
:
2690 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2691 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2692 if (tv_channel_list
) {
2693 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2694 MSGTR_OSDChannel
, tv_channel_current
->name
);
2695 //vo_osd_changed(OSDTYPE_SUBTITLE);
2699 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2700 pvr_set_lastchannel (mpctx
->stream
);
2701 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2702 pvr_get_current_channelname (mpctx
->stream
),
2703 pvr_get_current_stationname (mpctx
->stream
));
2705 #endif /* HAVE_PVR */
2708 case MP_CMD_TV_STEP_NORM
:
2709 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2710 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2713 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2714 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2715 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2717 #ifdef HAVE_TV_TELETEXT
2718 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2720 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2721 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2722 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2725 case MP_CMD_TV_TELETEXT_GO_LINK
:
2727 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2728 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2729 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2732 #endif /* HAVE_TV_TELETEXT */
2735 case MP_CMD_SUB_LOAD
:
2737 int n
= mpctx
->set_of_sub_size
;
2738 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2739 if (n
!= mpctx
->set_of_sub_size
) {
2740 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2741 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2742 mpctx
->global_sub_size
;
2743 ++mpctx
->global_sub_size
;
2748 case MP_CMD_SUB_REMOVE
:
2750 int v
= cmd
->args
[0].v
.i
;
2753 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2754 subd
= mpctx
->set_of_subtitles
[v
];
2755 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2756 MSGTR_RemovedSubtitleFile
, v
+ 1,
2757 filename_recode(subd
->filename
));
2759 mpctx
->set_of_subtitles
[v
] = NULL
;
2761 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2762 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2763 mpctx
->set_of_sub_size
= 0;
2764 if (mpctx
->set_of_sub_pos
>= 0) {
2765 mpctx
->global_sub_pos
= -2;
2767 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2769 } else if (v
< mpctx
->set_of_sub_size
) {
2770 subd
= mpctx
->set_of_subtitles
[v
];
2771 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2772 MSGTR_RemovedSubtitleFile
, v
+ 1,
2773 filename_recode(subd
->filename
));
2775 if (mpctx
->set_of_sub_pos
== v
) {
2776 mpctx
->global_sub_pos
= -2;
2778 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2779 } else if (mpctx
->set_of_sub_pos
> v
) {
2780 --mpctx
->set_of_sub_pos
;
2781 --mpctx
->global_sub_pos
;
2783 while (++v
< mpctx
->set_of_sub_size
)
2784 mpctx
->set_of_subtitles
[v
- 1] =
2785 mpctx
->set_of_subtitles
[v
];
2786 --mpctx
->set_of_sub_size
;
2787 --mpctx
->global_sub_size
;
2788 if (mpctx
->set_of_sub_size
<= 0)
2789 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2790 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2795 case MP_CMD_GET_SUB_VISIBILITY
:
2797 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2798 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2802 case MP_CMD_SCREENSHOT
:
2803 if (vo_config_count
) {
2804 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2806 ((vf_instance_t
*) sh_video
->vfilter
)->
2807 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2809 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2813 case MP_CMD_VF_CHANGE_RECTANGLE
:
2814 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2817 case MP_CMD_GET_TIME_LENGTH
:{
2818 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2819 demuxer_get_time_length(mpctx
->demuxer
));
2823 case MP_CMD_GET_FILENAME
:{
2824 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2825 get_metadata(META_NAME
));
2829 case MP_CMD_GET_VIDEO_CODEC
:{
2830 char *inf
= get_metadata(META_VIDEO_CODEC
);
2833 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2838 case MP_CMD_GET_VIDEO_BITRATE
:{
2839 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2842 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2847 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2848 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2851 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2852 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2857 case MP_CMD_GET_AUDIO_CODEC
:{
2858 char *inf
= get_metadata(META_AUDIO_CODEC
);
2861 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2866 case MP_CMD_GET_AUDIO_BITRATE
:{
2867 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2870 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2875 case MP_CMD_GET_AUDIO_SAMPLES
:{
2876 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2879 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2884 case MP_CMD_GET_META_TITLE
:{
2885 char *inf
= get_metadata(META_INFO_TITLE
);
2888 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2893 case MP_CMD_GET_META_ARTIST
:{
2894 char *inf
= get_metadata(META_INFO_ARTIST
);
2897 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2902 case MP_CMD_GET_META_ALBUM
:{
2903 char *inf
= get_metadata(META_INFO_ALBUM
);
2906 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
2911 case MP_CMD_GET_META_YEAR
:{
2912 char *inf
= get_metadata(META_INFO_YEAR
);
2915 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
2920 case MP_CMD_GET_META_COMMENT
:{
2921 char *inf
= get_metadata(META_INFO_COMMENT
);
2924 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
2929 case MP_CMD_GET_META_TRACK
:{
2930 char *inf
= get_metadata(META_INFO_TRACK
);
2933 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
2938 case MP_CMD_GET_META_GENRE
:{
2939 char *inf
= get_metadata(META_INFO_GENRE
);
2942 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
2947 case MP_CMD_GET_VO_FULLSCREEN
:
2948 if (mpctx
->video_out
&& vo_config_count
)
2949 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
2952 case MP_CMD_GET_PERCENT_POS
:
2953 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
2954 demuxer_get_percent_pos(mpctx
->demuxer
));
2957 case MP_CMD_GET_TIME_POS
:{
2960 pos
= sh_video
->pts
;
2961 else if (sh_audio
&& mpctx
->audio_out
)
2963 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2965 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
2972 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
2978 case MP_CMD_KEYDOWN_EVENTS
:
2979 mplayer_put_key(cmd
->args
[0].v
.i
);
2982 case MP_CMD_SET_MOUSE_POS
:{
2983 int pointer_x
, pointer_y
;
2985 pointer_x
= cmd
->args
[0].v
.i
;
2986 pointer_y
= cmd
->args
[1].v
.i
;
2987 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
2989 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
2990 && dx
> 0.0 && dy
> 0.0) {
2992 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
2993 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
2994 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
2995 pointer_x
, pointer_y
, &button
);
2997 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
2998 "Selected button number %d", button
);
3002 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3003 menu_update_mouse_pos(dx
, dy
);
3009 case MP_CMD_DVDNAV
:{
3011 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3014 if (mp_dvdnav_handle_input
3015 (mpctx
->stream
, cmd
->args
[0].v
.i
, &button
)) {
3016 uninit_player(INITED_ALL
- (INITED_STREAM
| INITED_INPUT
|
3017 (fixed_vo
? INITED_VO
: 0)));
3019 } else if (button
> 0)
3020 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3021 "Selected button number %d", button
);
3028 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3029 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3032 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3033 "Received unknown cmd %s\n", cmd
->name
);
3036 switch (cmd
->pausing
) {
3037 case 1: // "pausing"
3038 mpctx
->osd_function
= OSD_PAUSE
;
3040 case 3: // "pausing_toggle"
3041 mpctx
->was_paused
= !mpctx
->was_paused
;
3042 if (mpctx
->was_paused
)
3043 mpctx
->osd_function
= OSD_PAUSE
;
3044 else if (mpctx
->osd_function
== OSD_PAUSE
)
3045 mpctx
->osd_function
= OSD_PLAY
;
3047 case 2: // "pausing_keep"
3048 if (mpctx
->was_paused
)
3049 mpctx
->osd_function
= OSD_PAUSE
;