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"
64 #include "libavutil/avstring.h"
66 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
70 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
72 //remove the borders, if any, and rescale to the range [0,1],[0,1]
73 if (vo_fs
) { //we are in full-screen mode
74 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
75 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
76 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
77 iy
-= (vo_screenheight
- vo_dheight
) / 2;
79 if (ix
< 0 || ix
> vo_dwidth
) {
82 } //we are on one of the borders
83 if (iy
< 0 || iy
> vo_dheight
) {
86 } //we are on one of the borders
89 *dx
= (double) ix
/ (double) vo_dwidth
;
90 *dy
= (double) iy
/ (double) vo_dheight
;
92 mp_msg(MSGT_CPLAYER
, MSGL_V
,
93 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
94 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
98 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
103 for (i
= 0; i
< SUB_SOURCES
; i
++) {
104 int j
= mpctx
->global_sub_indices
[i
];
105 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
113 static int sub_source(MPContext
* mpctx
)
115 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
119 * \brief Log the currently displayed subtitle to a file
121 * Logs the current or last displayed subtitle together with filename
122 * and time information to ~/.mplayer/subtitle_log
124 * Intended purpose is to allow convenient marking of bogus subtitles
125 * which need to be fixed while watching the movie.
128 static void log_sub(void)
134 if (subdata
== NULL
|| vo_sub_last
== NULL
)
136 fname
= get_path("subtitle_log");
137 f
= fopen(fname
, "a");
140 fprintf(f
, "----------------------------------------------------------\n");
141 if (subdata
->sub_uses_time
) {
143 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
144 filename
, vo_sub_last
->start
/ 360000,
145 (vo_sub_last
->start
/ 6000) % 60,
146 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
147 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
148 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
150 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
153 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
154 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
160 /// \defgroup Properties
163 /// \defgroup GeneralProperties General properties
164 /// \ingroup Properties
168 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
171 return m_property_choice(prop
, action
, arg
, &osd_level
);
175 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
179 case M_PROPERTY_PRINT
:
180 if (!arg
) return M_PROPERTY_ERROR
;
181 if (mpctx
->loop_times
< 0)
182 *(char**)arg
= strdup("off");
183 else if (mpctx
->loop_times
== 0)
184 *(char**)arg
= strdup("inf");
187 return M_PROPERTY_OK
;
189 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
192 /// Playback speed (RW)
193 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
194 void *arg
, MPContext
* mpctx
)
199 return M_PROPERTY_ERROR
;
200 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
201 playback_speed
= *(float *) arg
;
202 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
203 return M_PROPERTY_OK
;
204 case M_PROPERTY_STEP_UP
:
205 case M_PROPERTY_STEP_DOWN
:
206 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
207 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
208 M_PROPERTY_CLAMP(prop
, playback_speed
);
209 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
210 return M_PROPERTY_OK
;
212 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
215 /// filename with path (RO)
216 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
219 return m_property_string_ro(prop
, action
, arg
, filename
);
222 /// filename without path (RO)
223 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
228 return M_PROPERTY_UNAVAILABLE
;
229 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
233 return m_property_string_ro(prop
, action
, arg
, f
);
236 /// Demuxer name (RO)
237 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
241 return M_PROPERTY_UNAVAILABLE
;
242 return m_property_string_ro(prop
, action
, arg
,
243 (char *) mpctx
->demuxer
->desc
->name
);
246 /// Position in the stream (RW)
247 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
250 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
251 return M_PROPERTY_UNAVAILABLE
;
253 return M_PROPERTY_ERROR
;
256 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
257 return M_PROPERTY_OK
;
259 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
260 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
261 return M_PROPERTY_OK
;
263 return M_PROPERTY_NOT_IMPLEMENTED
;
266 /// Stream start offset (RO)
267 static int mp_property_stream_start(m_option_t
* prop
, int action
,
268 void *arg
, MPContext
* mpctx
)
270 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
271 return M_PROPERTY_UNAVAILABLE
;
274 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
275 return M_PROPERTY_OK
;
277 return M_PROPERTY_NOT_IMPLEMENTED
;
280 /// Stream end offset (RO)
281 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
284 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
285 return M_PROPERTY_UNAVAILABLE
;
288 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
289 return M_PROPERTY_OK
;
291 return M_PROPERTY_NOT_IMPLEMENTED
;
294 /// Stream length (RO)
295 static int mp_property_stream_length(m_option_t
* prop
, int action
,
296 void *arg
, MPContext
* mpctx
)
298 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
299 return M_PROPERTY_UNAVAILABLE
;
303 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
304 return M_PROPERTY_OK
;
306 return M_PROPERTY_NOT_IMPLEMENTED
;
309 /// Media length in seconds (RO)
310 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
315 if (!mpctx
->demuxer
||
316 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
317 return M_PROPERTY_UNAVAILABLE
;
319 return m_property_time_ro(prop
, action
, arg
, len
);
322 /// Current position in percent (RW)
323 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
324 void *arg
, MPContext
* mpctx
) {
328 return M_PROPERTY_UNAVAILABLE
;
332 if(!arg
) return M_PROPERTY_ERROR
;
333 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
336 case M_PROPERTY_STEP_UP
:
337 case M_PROPERTY_STEP_DOWN
:
338 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
339 pos
+= (arg
? *(int*)arg
: 10) *
340 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
341 M_PROPERTY_CLAMP(prop
, pos
);
344 return m_property_int_ro(prop
, action
, arg
,
345 demuxer_get_percent_pos(mpctx
->demuxer
));
348 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
349 rel_seek_secs
= pos
/ 100.0;
350 return M_PROPERTY_OK
;
353 /// Current position in seconds (RW)
354 static int mp_property_time_pos(m_option_t
* prop
, int action
,
355 void *arg
, MPContext
* mpctx
) {
356 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
357 return M_PROPERTY_UNAVAILABLE
;
361 if(!arg
) return M_PROPERTY_ERROR
;
362 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
363 abs_seek_pos
= SEEK_ABSOLUTE
;
364 rel_seek_secs
= *(double*)arg
;
365 return M_PROPERTY_OK
;
366 case M_PROPERTY_STEP_UP
:
367 case M_PROPERTY_STEP_DOWN
:
368 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
369 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
370 return M_PROPERTY_OK
;
372 return m_property_time_ro(prop
, action
, arg
,
373 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
374 playing_audio_pts(mpctx
->sh_audio
,
379 /// Current chapter (RW)
380 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
387 char *chapter_name
= NULL
;
389 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
391 return M_PROPERTY_UNAVAILABLE
;
396 return M_PROPERTY_ERROR
;
397 *(int *) arg
= chapter
;
398 return M_PROPERTY_OK
;
399 case M_PROPERTY_PRINT
: {
401 return M_PROPERTY_ERROR
;
402 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
404 return M_PROPERTY_UNAVAILABLE
;
405 *(char **) arg
= chapter_name
;
406 return M_PROPERTY_OK
;
410 return M_PROPERTY_ERROR
;
411 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
412 step_all
= *(int *)arg
- (chapter
+ 1);
415 case M_PROPERTY_STEP_UP
:
416 case M_PROPERTY_STEP_DOWN
: {
417 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
418 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
425 return M_PROPERTY_NOT_IMPLEMENTED
;
429 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
430 &next_pts
, &chapter_num
, &chapter_name
);
432 if (next_pts
> -1.0) {
433 abs_seek_pos
= SEEK_ABSOLUTE
;
434 rel_seek_secs
= next_pts
;
437 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
438 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
440 else if (step_all
> 0)
441 rel_seek_secs
= 1000000000.;
443 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
444 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
447 return M_PROPERTY_OK
;
450 /// Current dvd angle (RW)
451 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
456 char *angle_name
= NULL
;
458 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
460 return M_PROPERTY_UNAVAILABLE
;
461 angles
= demuxer_angles_count(mpctx
->demuxer
);
463 return M_PROPERTY_UNAVAILABLE
;
468 return M_PROPERTY_ERROR
;
469 *(int *) arg
= angle
;
470 return M_PROPERTY_OK
;
471 case M_PROPERTY_PRINT
: {
473 return M_PROPERTY_ERROR
;
474 angle_name
= calloc(1, 64);
476 return M_PROPERTY_UNAVAILABLE
;
477 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
478 *(char **) arg
= angle_name
;
479 return M_PROPERTY_OK
;
483 return M_PROPERTY_ERROR
;
485 M_PROPERTY_CLAMP(prop
, angle
);
487 case M_PROPERTY_STEP_UP
:
488 case M_PROPERTY_STEP_DOWN
: {
494 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
496 if (angle
< 1) //cycle
501 return M_PROPERTY_NOT_IMPLEMENTED
;
503 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
504 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
505 MSGTR_OSDAngle
, angle
, angles
);
508 return M_PROPERTY_OK
;
511 /// Demuxer meta data
512 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
514 m_property_action_t
* ka
;
516 static m_option_t key_type
=
517 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
519 return M_PROPERTY_UNAVAILABLE
;
523 if(!arg
) return M_PROPERTY_ERROR
;
524 *(char***)arg
= mpctx
->demuxer
->info
;
525 return M_PROPERTY_OK
;
526 case M_PROPERTY_KEY_ACTION
:
527 if(!arg
) return M_PROPERTY_ERROR
;
529 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
530 return M_PROPERTY_UNKNOWN
;
533 if(!ka
->arg
) return M_PROPERTY_ERROR
;
534 *(char**)ka
->arg
= meta
;
535 return M_PROPERTY_OK
;
536 case M_PROPERTY_GET_TYPE
:
537 if(!ka
->arg
) return M_PROPERTY_ERROR
;
538 *(m_option_t
**)ka
->arg
= &key_type
;
539 return M_PROPERTY_OK
;
542 return M_PROPERTY_NOT_IMPLEMENTED
;
548 /// \defgroup AudioProperties Audio properties
549 /// \ingroup Properties
553 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
557 if (!mpctx
->sh_audio
)
558 return M_PROPERTY_UNAVAILABLE
;
563 return M_PROPERTY_ERROR
;
564 mixer_getbothvolume(&mpctx
->mixer
, arg
);
565 return M_PROPERTY_OK
;
566 case M_PROPERTY_PRINT
:{
569 return M_PROPERTY_ERROR
;
570 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
571 return m_property_float_range(prop
, action
, arg
, &vol
);
573 case M_PROPERTY_STEP_UP
:
574 case M_PROPERTY_STEP_DOWN
:
578 return M_PROPERTY_NOT_IMPLEMENTED
;
581 if (mpctx
->edl_muted
)
582 return M_PROPERTY_DISABLED
;
583 mpctx
->user_muted
= 0;
588 return M_PROPERTY_ERROR
;
589 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
590 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
591 return M_PROPERTY_OK
;
592 case M_PROPERTY_STEP_UP
:
593 if (arg
&& *(float *) arg
<= 0)
594 mixer_decvolume(&mpctx
->mixer
);
596 mixer_incvolume(&mpctx
->mixer
);
597 return M_PROPERTY_OK
;
598 case M_PROPERTY_STEP_DOWN
:
599 if (arg
&& *(float *) arg
<= 0)
600 mixer_incvolume(&mpctx
->mixer
);
602 mixer_decvolume(&mpctx
->mixer
);
603 return M_PROPERTY_OK
;
605 return M_PROPERTY_NOT_IMPLEMENTED
;
609 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
613 if (!mpctx
->sh_audio
)
614 return M_PROPERTY_UNAVAILABLE
;
618 if (mpctx
->edl_muted
)
619 return M_PROPERTY_DISABLED
;
621 return M_PROPERTY_ERROR
;
622 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
623 mixer_mute(&mpctx
->mixer
);
624 mpctx
->user_muted
= mpctx
->mixer
.muted
;
625 return M_PROPERTY_OK
;
626 case M_PROPERTY_STEP_UP
:
627 case M_PROPERTY_STEP_DOWN
:
628 if (mpctx
->edl_muted
)
629 return M_PROPERTY_DISABLED
;
630 mixer_mute(&mpctx
->mixer
);
631 mpctx
->user_muted
= mpctx
->mixer
.muted
;
632 return M_PROPERTY_OK
;
633 case M_PROPERTY_PRINT
:
635 return M_PROPERTY_ERROR
;
636 if (mpctx
->edl_muted
) {
637 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
638 return M_PROPERTY_OK
;
641 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
647 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
648 void *arg
, MPContext
* mpctx
)
650 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
651 return M_PROPERTY_UNAVAILABLE
;
654 case M_PROPERTY_STEP_UP
:
655 case M_PROPERTY_STEP_DOWN
: {
657 float delay
= audio_delay
;
658 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
659 if (ret
!= M_PROPERTY_OK
)
662 mpctx
->delay
-= audio_delay
- delay
;
664 return M_PROPERTY_OK
;
666 return m_property_delay(prop
, action
, arg
, &audio_delay
);
670 /// Audio codec tag (RO)
671 static int mp_property_audio_format(m_option_t
* prop
, int action
,
672 void *arg
, MPContext
* mpctx
)
674 if (!mpctx
->sh_audio
)
675 return M_PROPERTY_UNAVAILABLE
;
676 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
679 /// Audio codec name (RO)
680 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
681 void *arg
, MPContext
* mpctx
)
683 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
684 return M_PROPERTY_UNAVAILABLE
;
685 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
688 /// Audio bitrate (RO)
689 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
690 void *arg
, MPContext
* mpctx
)
692 if (!mpctx
->sh_audio
)
693 return M_PROPERTY_UNAVAILABLE
;
694 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
698 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
701 if (!mpctx
->sh_audio
)
702 return M_PROPERTY_UNAVAILABLE
;
704 case M_PROPERTY_PRINT
:
705 if(!arg
) return M_PROPERTY_ERROR
;
706 *(char**)arg
= malloc(16);
707 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
708 return M_PROPERTY_OK
;
710 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
713 /// Number of channels (RO)
714 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
717 if (!mpctx
->sh_audio
)
718 return M_PROPERTY_UNAVAILABLE
;
720 case M_PROPERTY_PRINT
:
722 return M_PROPERTY_ERROR
;
723 switch (mpctx
->sh_audio
->channels
) {
725 *(char **) arg
= strdup("mono");
728 *(char **) arg
= strdup("stereo");
731 *(char **) arg
= malloc(32);
732 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
734 return M_PROPERTY_OK
;
736 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
740 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
745 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
746 return M_PROPERTY_UNAVAILABLE
;
751 return M_PROPERTY_ERROR
;
752 mixer_getbalance(&mpctx
->mixer
, arg
);
753 return M_PROPERTY_OK
;
754 case M_PROPERTY_PRINT
: {
757 return M_PROPERTY_ERROR
;
758 mixer_getbalance(&mpctx
->mixer
, &bal
);
760 *str
= strdup("center");
761 else if (bal
== -1.f
)
762 *str
= strdup("left only");
764 *str
= strdup("right only");
766 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
767 *str
= malloc(sizeof("left xxx%, right xxx%"));
768 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
770 return M_PROPERTY_OK
;
772 case M_PROPERTY_STEP_UP
:
773 case M_PROPERTY_STEP_DOWN
:
774 mixer_getbalance(&mpctx
->mixer
, &bal
);
775 bal
+= (arg
? *(float*)arg
: .1f
) *
776 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
777 M_PROPERTY_CLAMP(prop
, bal
);
778 mixer_setbalance(&mpctx
->mixer
, bal
);
779 return M_PROPERTY_OK
;
782 return M_PROPERTY_ERROR
;
783 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
784 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
785 return M_PROPERTY_OK
;
787 return M_PROPERTY_NOT_IMPLEMENTED
;
790 /// Selected audio id (RW)
791 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
794 int current_id
= -1, tmp
;
798 if (!mpctx
->sh_audio
)
799 return M_PROPERTY_UNAVAILABLE
;
801 return M_PROPERTY_ERROR
;
802 *(int *) arg
= audio_id
;
803 return M_PROPERTY_OK
;
804 case M_PROPERTY_PRINT
:
805 if (!mpctx
->sh_audio
)
806 return M_PROPERTY_UNAVAILABLE
;
808 return M_PROPERTY_ERROR
;
811 *(char **) arg
= strdup(MSGTR_Disabled
);
813 char lang
[40] = MSGTR_Unknown
;
814 sh_audio_t
* sh
= mpctx
->sh_audio
;
816 av_strlcpy(lang
, sh
->lang
, 40);
818 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
819 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
829 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
830 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
832 *(char **) arg
= malloc(64);
833 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
835 return M_PROPERTY_OK
;
837 case M_PROPERTY_STEP_UP
:
839 if (action
== M_PROPERTY_SET
&& arg
)
840 tmp
= *((int *) arg
);
843 current_id
= mpctx
->demuxer
->audio
->id
;
844 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
847 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
848 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
849 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
851 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
853 sh2
->ds
= mpctx
->demuxer
->audio
;
854 mpctx
->sh_audio
= sh2
;
855 reinit_audio_chain();
858 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
859 return M_PROPERTY_OK
;
861 return M_PROPERTY_NOT_IMPLEMENTED
;
866 /// Selected video id (RW)
867 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
870 int current_id
= -1, tmp
;
874 if (!mpctx
->sh_video
)
875 return M_PROPERTY_UNAVAILABLE
;
877 return M_PROPERTY_ERROR
;
878 *(int *) arg
= video_id
;
879 return M_PROPERTY_OK
;
880 case M_PROPERTY_PRINT
:
881 if (!mpctx
->sh_video
)
882 return M_PROPERTY_UNAVAILABLE
;
884 return M_PROPERTY_ERROR
;
887 *(char **) arg
= strdup(MSGTR_Disabled
);
889 char lang
[40] = MSGTR_Unknown
;
890 *(char **) arg
= malloc(64);
891 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
893 return M_PROPERTY_OK
;
895 case M_PROPERTY_STEP_UP
:
897 current_id
= mpctx
->demuxer
->video
->id
;
898 if (action
== M_PROPERTY_SET
&& arg
)
899 tmp
= *((int *) arg
);
902 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
904 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
905 && current_id
!= -2))
906 uninit_player(INITIALIZED_VCODEC
|
907 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
908 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
910 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
912 sh2
->ds
= mpctx
->demuxer
->video
;
913 mpctx
->sh_video
= sh2
;
914 reinit_video_chain();
917 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
918 return M_PROPERTY_OK
;
921 return M_PROPERTY_NOT_IMPLEMENTED
;
925 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
928 demux_program_t prog
;
931 case M_PROPERTY_STEP_UP
:
933 if (action
== M_PROPERTY_SET
&& arg
)
934 prog
.progid
= *((int *) arg
);
938 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
939 &prog
) == DEMUXER_CTRL_NOTIMPL
)
940 return M_PROPERTY_ERROR
;
942 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
943 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
944 return M_PROPERTY_OK
;
947 return M_PROPERTY_NOT_IMPLEMENTED
;
953 /// \defgroup VideoProperties Video properties
954 /// \ingroup Properties
957 /// Fullscreen state (RW)
958 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
962 if (!mpctx
->video_out
)
963 return M_PROPERTY_UNAVAILABLE
;
968 return M_PROPERTY_ERROR
;
969 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
970 if (vo_fs
== !!*(int *) arg
)
971 return M_PROPERTY_OK
;
972 case M_PROPERTY_STEP_UP
:
973 case M_PROPERTY_STEP_DOWN
:
976 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
980 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
981 return M_PROPERTY_OK
;
983 return m_property_flag(prop
, action
, arg
, &vo_fs
);
987 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
988 void *arg
, MPContext
* mpctx
)
992 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
993 return M_PROPERTY_UNAVAILABLE
;
994 vf
= mpctx
->sh_video
->vfilter
;
998 return M_PROPERTY_ERROR
;
999 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1000 return M_PROPERTY_OK
;
1001 case M_PROPERTY_SET
:
1003 return M_PROPERTY_ERROR
;
1004 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1005 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1006 return M_PROPERTY_OK
;
1007 case M_PROPERTY_STEP_UP
:
1008 case M_PROPERTY_STEP_DOWN
:
1009 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1010 deinterlace
= !deinterlace
;
1011 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1012 return M_PROPERTY_OK
;
1014 return M_PROPERTY_NOT_IMPLEMENTED
;
1018 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1022 if (!mpctx
->video_out
1023 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1024 return M_PROPERTY_UNAVAILABLE
;
1027 case M_PROPERTY_SET
:
1029 return M_PROPERTY_ERROR
;
1030 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1031 vo_panscan
= *(float *) arg
;
1032 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1033 return M_PROPERTY_OK
;
1034 case M_PROPERTY_STEP_UP
:
1035 case M_PROPERTY_STEP_DOWN
:
1036 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1037 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1040 else if (vo_panscan
< 0)
1042 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1043 return M_PROPERTY_OK
;
1045 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1049 /// Helper to set vo flags.
1050 /** \ingroup PropertyImplHelper
1052 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1053 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1056 if (!mpctx
->video_out
)
1057 return M_PROPERTY_UNAVAILABLE
;
1060 case M_PROPERTY_SET
:
1062 return M_PROPERTY_ERROR
;
1063 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1064 if (*vo_var
== !!*(int *) arg
)
1065 return M_PROPERTY_OK
;
1066 case M_PROPERTY_STEP_UP
:
1067 case M_PROPERTY_STEP_DOWN
:
1068 if (vo_config_count
)
1069 mpctx
->video_out
->control(vo_ctrl
, 0);
1070 return M_PROPERTY_OK
;
1072 return m_property_flag(prop
, action
, arg
, vo_var
);
1076 /// Window always on top (RW)
1077 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1080 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1084 /// Display in the root window (RW)
1085 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1088 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1089 &vo_rootwin
, mpctx
);
1092 /// Show window borders (RW)
1093 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1096 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1100 /// Framedropping state (RW)
1101 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1102 void *arg
, MPContext
* mpctx
)
1105 if (!mpctx
->sh_video
)
1106 return M_PROPERTY_UNAVAILABLE
;
1109 case M_PROPERTY_PRINT
:
1111 return M_PROPERTY_ERROR
;
1112 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1113 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1115 return M_PROPERTY_OK
;
1117 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1121 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1122 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1125 int *gamma
= prop
->priv
, r
, val
;
1127 if (!mpctx
->sh_video
)
1128 return M_PROPERTY_UNAVAILABLE
;
1130 if (gamma
[0] == 1000) {
1132 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1136 case M_PROPERTY_SET
:
1138 return M_PROPERTY_ERROR
;
1139 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1140 *gamma
= *(int *) arg
;
1141 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1145 case M_PROPERTY_GET
:
1146 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1148 return M_PROPERTY_ERROR
;
1150 return M_PROPERTY_OK
;
1153 case M_PROPERTY_STEP_UP
:
1154 case M_PROPERTY_STEP_DOWN
:
1155 *gamma
+= (arg
? *(int *) arg
: 1) *
1156 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1157 M_PROPERTY_CLAMP(prop
, *gamma
);
1158 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1163 return M_PROPERTY_NOT_IMPLEMENTED
;
1167 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1168 int l
= strlen(prop
->name
);
1169 char tv_prop
[3 + l
+ 1];
1170 sprintf(tv_prop
, "tv_%s", prop
->name
);
1171 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1175 return M_PROPERTY_UNAVAILABLE
;
1179 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1182 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1185 /// Video codec tag (RO)
1186 static int mp_property_video_format(m_option_t
* prop
, int action
,
1187 void *arg
, MPContext
* mpctx
)
1190 if (!mpctx
->sh_video
)
1191 return M_PROPERTY_UNAVAILABLE
;
1193 case M_PROPERTY_PRINT
:
1195 return M_PROPERTY_ERROR
;
1196 switch(mpctx
->sh_video
->format
) {
1198 meta
= strdup ("mpeg1"); break;
1200 meta
= strdup ("mpeg2"); break;
1202 meta
= strdup ("mpeg4"); break;
1204 meta
= strdup ("h264"); break;
1206 if(mpctx
->sh_video
->format
>= 0x20202020) {
1208 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1211 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1214 *(char**)arg
= meta
;
1215 return M_PROPERTY_OK
;
1217 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1220 /// Video codec name (RO)
1221 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1222 void *arg
, MPContext
* mpctx
)
1224 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1225 return M_PROPERTY_UNAVAILABLE
;
1226 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1230 /// Video bitrate (RO)
1231 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1232 void *arg
, MPContext
* mpctx
)
1234 if (!mpctx
->sh_video
)
1235 return M_PROPERTY_UNAVAILABLE
;
1236 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1239 /// Video display width (RO)
1240 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1243 if (!mpctx
->sh_video
)
1244 return M_PROPERTY_UNAVAILABLE
;
1245 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1248 /// Video display height (RO)
1249 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1252 if (!mpctx
->sh_video
)
1253 return M_PROPERTY_UNAVAILABLE
;
1254 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1258 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1261 if (!mpctx
->sh_video
)
1262 return M_PROPERTY_UNAVAILABLE
;
1263 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1266 /// Video aspect (RO)
1267 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1270 if (!mpctx
->sh_video
)
1271 return M_PROPERTY_UNAVAILABLE
;
1272 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1277 /// \defgroup SubProprties Subtitles properties
1278 /// \ingroup Properties
1281 /// Text subtitle position (RW)
1282 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1285 if (!mpctx
->sh_video
)
1286 return M_PROPERTY_UNAVAILABLE
;
1289 case M_PROPERTY_SET
:
1291 return M_PROPERTY_ERROR
;
1292 case M_PROPERTY_STEP_UP
:
1293 case M_PROPERTY_STEP_DOWN
:
1294 vo_osd_changed(OSDTYPE_SUBTITLE
);
1296 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1300 /// Selected subtitles (RW)
1301 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1304 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1305 const int global_sub_size
= mpctx
->global_sub_size
;
1306 int source
= -1, reset_spu
= 0;
1309 if (global_sub_size
<= 0)
1310 return M_PROPERTY_UNAVAILABLE
;
1313 case M_PROPERTY_GET
:
1315 return M_PROPERTY_ERROR
;
1316 *(int *) arg
= mpctx
->global_sub_pos
;
1317 return M_PROPERTY_OK
;
1318 case M_PROPERTY_PRINT
:
1320 return M_PROPERTY_ERROR
;
1321 *(char **) arg
= malloc(64);
1322 (*(char **) arg
)[63] = 0;
1325 sub_name
= subdata
->filename
;
1327 if (ass_track
&& ass_track
->name
)
1328 sub_name
= ass_track
->name
;
1333 if ((tmp2
= strrchr(tmp
, '/')))
1336 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1337 mpctx
->set_of_sub_pos
+ 1,
1338 strlen(tmp
) < 20 ? "" : "...",
1339 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1340 return M_PROPERTY_OK
;
1343 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1344 if (vo_spudec
&& dvdsub_id
>= 0) {
1345 unsigned char lang
[3];
1346 if (dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1347 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1348 return M_PROPERTY_OK
;
1354 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1355 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1356 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1357 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1358 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1359 if (!lang
) lang
= MSGTR_Unknown
;
1360 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1361 return M_PROPERTY_OK
;
1364 if (vo_vobsub
&& vobsub_id
>= 0) {
1365 const char *language
= MSGTR_Unknown
;
1366 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1367 snprintf(*(char **) arg
, 63, "(%d) %s",
1368 vobsub_id
, language
? language
: MSGTR_Unknown
);
1369 return M_PROPERTY_OK
;
1372 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1373 && dvdsub_id
>= 0) {
1375 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1376 lang
[0] = code
>> 8;
1379 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1380 return M_PROPERTY_OK
;
1383 if (dvdsub_id
>= 0) {
1384 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1385 return M_PROPERTY_OK
;
1387 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1388 return M_PROPERTY_OK
;
1390 case M_PROPERTY_SET
:
1392 return M_PROPERTY_ERROR
;
1393 if (*(int *) arg
< -1)
1395 else if (*(int *) arg
>= global_sub_size
)
1396 *(int *) arg
= global_sub_size
- 1;
1397 mpctx
->global_sub_pos
= *(int *) arg
;
1399 case M_PROPERTY_STEP_UP
:
1400 mpctx
->global_sub_pos
+= 2;
1401 mpctx
->global_sub_pos
=
1402 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1404 case M_PROPERTY_STEP_DOWN
:
1405 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1406 mpctx
->global_sub_pos
=
1407 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1410 return M_PROPERTY_NOT_IMPLEMENTED
;
1413 if (mpctx
->global_sub_pos
>= 0)
1414 source
= sub_source(mpctx
);
1416 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1417 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1419 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1420 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1421 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1422 mpctx
->global_sub_pos
, source
);
1424 mpctx
->set_of_sub_pos
= -1;
1438 if (source
== SUB_SOURCE_VOBSUB
) {
1439 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1440 } else if (source
== SUB_SOURCE_SUBS
) {
1441 mpctx
->set_of_sub_pos
=
1442 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1444 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1445 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1449 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1450 vo_osd_changed(OSDTYPE_SUBTITLE
);
1452 } else if (source
== SUB_SOURCE_DEMUX
) {
1454 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1455 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1457 // default: assume 1:1 mapping of sid and stream id
1458 d_sub
->id
= dvdsub_id
;
1459 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1460 ds_free_packs(d_sub
);
1461 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1462 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1463 if (sh
&& sh
->sid
== dvdsub_id
) {
1469 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1470 sh_sub_t
*sh
= d_sub
->sh
;
1471 if (sh
->type
== 'v')
1474 else if (ass_enabled
)
1475 ass_track
= sh
->ass_track
;
1485 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1486 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1487 && dvdsub_id
< 0 && reset_spu
) {
1489 d_sub
->id
= dvdsub_id
;
1492 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1494 return M_PROPERTY_OK
;
1497 /// Selected sub source (RW)
1498 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1502 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1503 return M_PROPERTY_UNAVAILABLE
;
1506 case M_PROPERTY_GET
:
1508 return M_PROPERTY_ERROR
;
1509 *(int *) arg
= sub_source(mpctx
);
1510 return M_PROPERTY_OK
;
1511 case M_PROPERTY_PRINT
:
1513 return M_PROPERTY_ERROR
;
1514 *(char **) arg
= malloc(64);
1515 (*(char **) arg
)[63] = 0;
1516 switch (sub_source(mpctx
))
1518 case SUB_SOURCE_SUBS
:
1519 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1521 case SUB_SOURCE_VOBSUB
:
1522 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1524 case SUB_SOURCE_DEMUX
:
1525 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1528 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1530 return M_PROPERTY_OK
;
1531 case M_PROPERTY_SET
:
1533 return M_PROPERTY_ERROR
;
1534 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1535 if (*(int *) arg
< 0)
1536 mpctx
->global_sub_pos
= -1;
1537 else if (*(int *) arg
!= sub_source(mpctx
)) {
1538 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1539 return M_PROPERTY_UNAVAILABLE
;
1540 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1543 case M_PROPERTY_STEP_UP
:
1544 case M_PROPERTY_STEP_DOWN
: {
1545 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1546 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1547 int step
= (step_all
> 0) ? 1 : -1;
1548 int cur_source
= sub_source(mpctx
);
1549 source
= cur_source
;
1552 if (source
>= SUB_SOURCES
)
1554 else if (source
< -1)
1555 source
= SUB_SOURCES
- 1;
1556 if (source
== cur_source
|| source
== -1 ||
1557 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1560 if (source
== cur_source
)
1561 return M_PROPERTY_OK
;
1563 mpctx
->global_sub_pos
= -1;
1565 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1569 return M_PROPERTY_NOT_IMPLEMENTED
;
1571 --mpctx
->global_sub_pos
;
1572 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1575 /// Selected subtitles from specific source (RW)
1576 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1579 int source
, is_cur_source
, offset
;
1580 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1581 return M_PROPERTY_UNAVAILABLE
;
1583 if (!strcmp(prop
->name
, "sub_file"))
1584 source
= SUB_SOURCE_SUBS
;
1585 else if (!strcmp(prop
->name
, "sub_vob"))
1586 source
= SUB_SOURCE_VOBSUB
;
1587 else if (!strcmp(prop
->name
, "sub_demux"))
1588 source
= SUB_SOURCE_DEMUX
;
1590 return M_PROPERTY_ERROR
;
1592 offset
= mpctx
->global_sub_indices
[source
];
1593 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1594 return M_PROPERTY_UNAVAILABLE
;
1596 is_cur_source
= sub_source(mpctx
) == source
;
1598 case M_PROPERTY_GET
:
1600 return M_PROPERTY_ERROR
;
1601 if (is_cur_source
) {
1602 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1603 if (source
== SUB_SOURCE_VOBSUB
)
1604 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1608 return M_PROPERTY_OK
;
1609 case M_PROPERTY_PRINT
:
1611 return M_PROPERTY_ERROR
;
1613 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1614 *(char **) arg
= malloc(64);
1615 (*(char **) arg
)[63] = 0;
1616 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1617 return M_PROPERTY_OK
;
1618 case M_PROPERTY_SET
:
1620 return M_PROPERTY_ERROR
;
1621 if (*(int *) arg
>= 0) {
1622 int index
= *(int *)arg
;
1623 if (source
== SUB_SOURCE_VOBSUB
)
1624 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1625 mpctx
->global_sub_pos
= offset
+ index
;
1626 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1627 || sub_source(mpctx
) != source
) {
1628 mpctx
->global_sub_pos
= -1;
1633 mpctx
->global_sub_pos
= -1;
1635 case M_PROPERTY_STEP_UP
:
1636 case M_PROPERTY_STEP_DOWN
: {
1637 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1638 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1639 int step
= (step_all
> 0) ? 1 : -1;
1640 int max_sub_pos_for_source
= -1;
1642 mpctx
->global_sub_pos
= -1;
1644 if (mpctx
->global_sub_pos
== -1) {
1646 mpctx
->global_sub_pos
= offset
;
1647 else if (max_sub_pos_for_source
== -1) {
1648 // Find max pos for specific source
1649 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1650 while (mpctx
->global_sub_pos
>= 0
1651 && sub_source(mpctx
) != source
)
1652 --mpctx
->global_sub_pos
;
1655 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1658 mpctx
->global_sub_pos
+= step
;
1659 if (mpctx
->global_sub_pos
< offset
||
1660 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1661 sub_source(mpctx
) != source
)
1662 mpctx
->global_sub_pos
= -1;
1669 return M_PROPERTY_NOT_IMPLEMENTED
;
1671 --mpctx
->global_sub_pos
;
1672 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1675 /// Subtitle delay (RW)
1676 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1679 if (!mpctx
->sh_video
)
1680 return M_PROPERTY_UNAVAILABLE
;
1681 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1684 /// Alignment of text subtitles (RW)
1685 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1686 void *arg
, MPContext
* mpctx
)
1688 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1690 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1691 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1692 return M_PROPERTY_UNAVAILABLE
;
1695 case M_PROPERTY_PRINT
:
1697 return M_PROPERTY_ERROR
;
1698 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1699 *(char **) arg
= strdup(name
[sub_alignment
]);
1700 return M_PROPERTY_OK
;
1701 case M_PROPERTY_SET
:
1703 return M_PROPERTY_ERROR
;
1704 case M_PROPERTY_STEP_UP
:
1705 case M_PROPERTY_STEP_DOWN
:
1706 vo_osd_changed(OSDTYPE_SUBTITLE
);
1708 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1712 /// Subtitle visibility (RW)
1713 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1714 void *arg
, MPContext
* mpctx
)
1716 if (!mpctx
->sh_video
)
1717 return M_PROPERTY_UNAVAILABLE
;
1720 case M_PROPERTY_SET
:
1722 return M_PROPERTY_ERROR
;
1723 case M_PROPERTY_STEP_UP
:
1724 case M_PROPERTY_STEP_DOWN
:
1725 vo_osd_changed(OSDTYPE_SUBTITLE
);
1727 vo_osd_changed(OSDTYPE_SPU
);
1729 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1734 /// Use margins for libass subtitles (RW)
1735 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1736 void *arg
, MPContext
* mpctx
)
1738 if (!mpctx
->sh_video
)
1739 return M_PROPERTY_UNAVAILABLE
;
1742 case M_PROPERTY_SET
:
1744 return M_PROPERTY_ERROR
;
1745 case M_PROPERTY_STEP_UP
:
1746 case M_PROPERTY_STEP_DOWN
:
1747 ass_force_reload
= 1;
1749 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1754 /// Show only forced subtitles (RW)
1755 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1756 void *arg
, MPContext
* mpctx
)
1759 return M_PROPERTY_UNAVAILABLE
;
1762 case M_PROPERTY_SET
:
1764 return M_PROPERTY_ERROR
;
1765 case M_PROPERTY_STEP_UP
:
1766 case M_PROPERTY_STEP_DOWN
:
1767 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1768 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1769 return M_PROPERTY_OK
;
1771 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1776 #ifdef HAVE_FREETYPE
1777 /// Subtitle scale (RW)
1778 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1783 case M_PROPERTY_SET
:
1785 return M_PROPERTY_ERROR
;
1786 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1789 ass_font_scale
= *(float *) arg
;
1790 ass_force_reload
= 1;
1793 text_font_scale_factor
= *(float *) arg
;
1794 force_load_font
= 1;
1795 return M_PROPERTY_OK
;
1796 case M_PROPERTY_STEP_UP
:
1797 case M_PROPERTY_STEP_DOWN
:
1800 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1801 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1802 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1803 ass_force_reload
= 1;
1806 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1807 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1808 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1809 force_load_font
= 1;
1810 return M_PROPERTY_OK
;
1814 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1817 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1824 /// \defgroup TVProperties TV properties
1825 /// \ingroup Properties
1830 /// TV color settings (RW)
1831 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1835 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1836 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1837 return M_PROPERTY_UNAVAILABLE
;
1840 case M_PROPERTY_SET
:
1842 return M_PROPERTY_ERROR
;
1843 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1844 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1845 case M_PROPERTY_GET
:
1846 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1847 case M_PROPERTY_STEP_UP
:
1848 case M_PROPERTY_STEP_DOWN
:
1849 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1851 return M_PROPERTY_ERROR
;
1852 val
+= (arg
? *(int *) arg
: 1) *
1853 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1854 M_PROPERTY_CLAMP(prop
, val
);
1855 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1857 return M_PROPERTY_ERROR
;
1859 return M_PROPERTY_NOT_IMPLEMENTED
;
1864 #ifdef HAVE_TV_TELETEXT
1865 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1869 int base_ioctl
=(int)prop
->priv
;
1871 for teletext's GET,SET,STEP ioctls this is not 0
1875 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1876 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1877 return M_PROPERTY_UNAVAILABLE
;
1879 return M_PROPERTY_ERROR
;
1882 case M_PROPERTY_GET
:
1884 return M_PROPERTY_ERROR
;
1885 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1887 case M_PROPERTY_SET
:
1889 return M_PROPERTY_ERROR
;
1890 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1891 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1893 case M_PROPERTY_STEP_UP
:
1894 case M_PROPERTY_STEP_DOWN
:
1895 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1896 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1897 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1900 return M_PROPERTY_NOT_IMPLEMENTED
;
1903 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1906 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1909 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1913 //with tvh==NULL will fail too
1914 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1915 if(result
!=M_PROPERTY_OK
)
1918 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1919 mp_input_set_section("teletext");
1921 mp_input_set_section("tv");
1922 return M_PROPERTY_OK
;
1925 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1928 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1932 case M_PROPERTY_STEP_UP
:
1933 case M_PROPERTY_STEP_DOWN
:
1934 //This should be handled separately
1935 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1936 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1939 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1945 #endif /* HAVE_TV_TELETEXT */
1949 /// All properties available in MPlayer.
1950 /** \ingroup Properties
1952 static const m_option_t mp_properties
[] = {
1954 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1955 M_OPT_RANGE
, 0, 3, NULL
},
1956 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1957 M_OPT_MIN
, -1, 0, NULL
},
1958 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1959 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1960 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1962 { "path", mp_property_path
, CONF_TYPE_STRING
,
1964 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1966 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1967 M_OPT_MIN
, 0, 0, NULL
},
1968 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1969 M_OPT_MIN
, 0, 0, NULL
},
1970 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1971 M_OPT_MIN
, 0, 0, NULL
},
1972 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1973 M_OPT_MIN
, 0, 0, NULL
},
1974 { "length", mp_property_length
, CONF_TYPE_TIME
,
1975 M_OPT_MIN
, 0, 0, NULL
},
1976 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1977 M_OPT_RANGE
, 0, 100, NULL
},
1978 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1979 M_OPT_MIN
, 0, 0, NULL
},
1980 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1981 M_OPT_MIN
, 1, 0, NULL
},
1982 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1983 CONF_RANGE
, -2, 10, NULL
},
1984 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1988 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1989 M_OPT_RANGE
, 0, 100, NULL
},
1990 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1991 M_OPT_RANGE
, 0, 1, NULL
},
1992 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1993 M_OPT_RANGE
, -100, 100, NULL
},
1994 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1996 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1998 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2000 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2002 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2004 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2005 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2006 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2007 M_OPT_RANGE
, -1, 1, NULL
},
2010 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2011 M_OPT_RANGE
, 0, 1, NULL
},
2012 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2013 M_OPT_RANGE
, 0, 1, NULL
},
2014 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2015 M_OPT_RANGE
, 0, 1, NULL
},
2016 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2017 M_OPT_RANGE
, 0, 1, NULL
},
2018 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2019 M_OPT_RANGE
, 0, 1, NULL
},
2020 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2021 M_OPT_RANGE
, 0, 2, NULL
},
2022 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2023 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2024 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2025 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2026 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2027 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2028 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2029 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2030 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2031 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2032 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2033 M_OPT_RANGE
, 0, 1, NULL
},
2034 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2035 M_OPT_RANGE
, 0, 1, NULL
},
2036 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2038 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2040 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2042 { "width", mp_property_width
, CONF_TYPE_INT
,
2044 { "height", mp_property_height
, CONF_TYPE_INT
,
2046 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2048 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2050 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2051 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2052 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2053 CONF_RANGE
, -1, 65535, NULL
},
2056 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2057 M_OPT_MIN
, -1, 0, NULL
},
2058 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2059 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2060 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2061 M_OPT_MIN
, -1, 0, NULL
},
2062 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2063 M_OPT_MIN
, -1, 0, NULL
},
2064 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2065 M_OPT_MIN
, -1, 0, NULL
},
2066 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2068 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2069 M_OPT_RANGE
, 0, 100, NULL
},
2070 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2071 M_OPT_RANGE
, 0, 2, NULL
},
2072 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2073 M_OPT_RANGE
, 0, 1, NULL
},
2074 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2075 M_OPT_RANGE
, 0, 1, NULL
},
2076 #ifdef HAVE_FREETYPE
2077 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2078 M_OPT_RANGE
, 0, 100, NULL
},
2081 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2082 M_OPT_RANGE
, 0, 1, NULL
},
2086 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2087 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2088 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2089 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2090 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2091 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2092 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2093 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2096 #ifdef HAVE_TV_TELETEXT
2097 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2098 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2099 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2100 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2101 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2102 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2103 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2104 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2105 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2106 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2109 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2113 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2115 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2118 char* mp_property_print(const char *name
, void* ctx
)
2121 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2126 char *property_expand_string(MPContext
* mpctx
, char *str
)
2128 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2131 void property_print_help(void)
2133 m_properties_print_help_list(mp_properties
);
2142 * \defgroup Command2Property Command to property bridge
2144 * It is used to handle most commands that just set a property
2145 * and optionally display something on the OSD.
2146 * Two kinds of commands are handled: adjust or toggle.
2148 * Adjust commands take 1 or 2 parameters: <value> <abs>
2149 * If <abs> is non-zero the property is set to the given value
2150 * otherwise it is adjusted.
2152 * Toggle commands take 0 or 1 parameters. With no parameter
2153 * or a value less than the property minimum it just steps the
2154 * property to its next value. Otherwise it sets it to the given
2160 /// List of the commands that can be handled by setting a property.
2166 /// set/adjust or toggle command
2168 /// progressbar type
2170 /// osd msg id if it must be shared
2172 /// osd msg template
2173 const char *osd_msg
;
2174 } set_prop_cmd
[] = {
2176 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2177 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2178 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2180 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2181 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2182 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2183 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2184 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2186 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2187 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2188 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2189 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2190 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2191 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2192 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2193 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2194 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2195 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2196 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2197 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2199 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2200 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2201 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2202 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2203 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2204 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2205 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2206 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2207 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2208 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2209 #ifdef HAVE_FREETYPE
2210 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2213 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2216 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2217 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2218 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2219 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2221 { NULL
, 0, 0, 0, -1, NULL
}
2225 /// Handle commands that set a property.
2226 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2232 // look for the command
2233 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2234 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2236 if (!(pname
= set_prop_cmd
[i
].name
))
2239 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2243 if (set_prop_cmd
[i
].toggle
) {
2245 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2246 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2248 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2249 } else if (cmd
->args
[1].v
.i
) //set
2250 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2252 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2257 if (set_prop_cmd
[i
].osd_progbar
) {
2258 if (prop
->type
== CONF_TYPE_INT
) {
2259 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2260 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2261 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2262 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2264 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2265 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2266 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2268 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2269 "Property use an unsupported type.\n");
2273 if (set_prop_cmd
[i
].osd_msg
) {
2274 char *val
= mp_property_print(pname
, mpctx
);
2276 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2277 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2278 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2286 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2288 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2289 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2291 if (!set_property_command(mpctx
, cmd
))
2297 mpctx
->osd_show_percentage
= sh_video
->fps
;
2298 v
= cmd
->args
[0].v
.f
;
2299 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2300 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2301 abs_seek_pos
= SEEK_ABSOLUTE
;
2303 mpctx
->osd_function
=
2304 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2306 } else if (abs
) { /* Absolute seek by percentage */
2307 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2309 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2310 rel_seek_secs
= v
/ 100.0;
2313 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2319 case MP_CMD_SET_PROPERTY
:{
2320 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2321 cmd
->args
[1].v
.s
, mpctx
);
2322 if (r
== M_PROPERTY_UNKNOWN
)
2323 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2324 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2326 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2327 "Failed to set property '%s' to '%s'.\n",
2328 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2332 case MP_CMD_STEP_PROPERTY
:{
2337 if (cmd
->args
[1].v
.f
) {
2339 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2340 M_PROPERTY_GET_TYPE
,
2341 &prop
, mpctx
)) <= 0)
2343 if(prop
->type
== CONF_TYPE_INT
||
2344 prop
->type
== CONF_TYPE_FLAG
)
2345 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2346 else if(prop
->type
== CONF_TYPE_FLOAT
)
2347 arg
= &cmd
->args
[1].v
.f
;
2348 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2349 prop
->type
== CONF_TYPE_TIME
)
2350 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2351 else if(prop
->type
== CONF_TYPE_POSITION
)
2352 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2354 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2355 "Ignoring step size stepping property '%s'.\n",
2358 r
= mp_property_do(cmd
->args
[0].v
.s
,
2359 cmd
->args
[2].v
.i
< 0 ?
2360 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2363 if (r
== M_PROPERTY_UNKNOWN
)
2364 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2365 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2367 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2368 "Failed to increment property '%s' by %f.\n",
2369 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2373 case MP_CMD_GET_PROPERTY
:{
2375 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2376 &tmp
, mpctx
) <= 0) {
2377 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2378 "Failed to get value of property '%s'.\n",
2382 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2383 cmd
->args
[0].v
.s
, tmp
);
2388 case MP_CMD_EDL_MARK
:
2390 float v
= sh_video
? sh_video
->pts
:
2391 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2394 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2395 mpctx
->begin_skip
= v
;
2396 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2398 if (mpctx
->begin_skip
> v
)
2399 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2401 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2402 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2404 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2409 case MP_CMD_SWITCH_RATIO
:
2410 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2411 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2413 movie_aspect
= cmd
->args
[0].v
.f
;
2414 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2417 case MP_CMD_SPEED_INCR
:{
2418 float v
= cmd
->args
[0].v
.f
;
2419 playback_speed
+= v
;
2420 build_afilter_chain(sh_audio
, &ao_data
);
2421 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2425 case MP_CMD_SPEED_MULT
:{
2426 float v
= cmd
->args
[0].v
.f
;
2427 playback_speed
*= v
;
2428 build_afilter_chain(sh_audio
, &ao_data
);
2429 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2433 case MP_CMD_SPEED_SET
:{
2434 float v
= cmd
->args
[0].v
.f
;
2436 build_afilter_chain(sh_audio
, &ao_data
);
2437 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2441 case MP_CMD_FRAME_STEP
:
2447 case MP_CMD_FILE_FILTER
:
2448 file_filter
= cmd
->args
[0].v
.i
;
2452 exit_player_with_rc(MSGTR_Exit_quit
,
2453 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2455 case MP_CMD_PLAY_TREE_STEP
:{
2456 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2457 int force
= cmd
->args
[1].v
.i
;
2463 for (i
= 0; i
< n
; i
++)
2466 for (i
= 0; i
< -1 * n
; i
++)
2471 if (!force
&& mpctx
->playtree_iter
) {
2472 play_tree_iter_t
*i
=
2473 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2474 if (play_tree_iter_step(i
, n
, 0) ==
2475 PLAY_TREE_ITER_ENTRY
)
2477 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2478 play_tree_iter_free(i
);
2480 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2482 mpctx
->play_tree_step
= n
;
2488 case MP_CMD_PLAY_TREE_UP_STEP
:{
2489 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2490 int force
= cmd
->args
[1].v
.i
;
2492 if (!force
&& mpctx
->playtree_iter
) {
2493 play_tree_iter_t
*i
=
2494 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2495 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2496 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2497 play_tree_iter_free(i
);
2499 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2504 case MP_CMD_PLAY_ALT_SRC_STEP
:
2505 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2506 int v
= cmd
->args
[0].v
.i
;
2508 && mpctx
->playtree_iter
->file
<
2509 mpctx
->playtree_iter
->num_files
)
2510 mpctx
->eof
= PT_NEXT_SRC
;
2511 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2512 mpctx
->eof
= PT_PREV_SRC
;
2517 case MP_CMD_SUB_STEP
:
2519 int movement
= cmd
->args
[0].v
.i
;
2520 step_sub(subdata
, sh_video
->pts
, movement
);
2524 ass_step_sub(ass_track
,
2526 sub_delay
) * 1000 + .5, movement
) / 1000.;
2528 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2529 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2533 case MP_CMD_SUB_LOG
:
2538 int v
= cmd
->args
[0].v
.i
;
2540 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2541 if (osd_level
> max
)
2544 osd_level
= (osd_level
+ 1) % (max
+ 1);
2546 osd_level
= v
> max
? max
: v
;
2547 /* Show OSD state when disabled, but not when an explicit
2548 argument is given to the OSD command, i.e. in slave mode. */
2549 if (v
== -1 && osd_level
<= 1)
2550 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2552 osd_level
? MSGTR_OSDenabled
:
2555 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2559 case MP_CMD_OSD_SHOW_TEXT
:
2560 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2562 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2563 "%-.63s", cmd
->args
[0].v
.s
);
2566 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2567 char *txt
= m_properties_expand_string(mp_properties
,
2570 /* if no argument supplied take default osd_duration, else <arg> ms. */
2572 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2574 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2581 case MP_CMD_LOADFILE
:{
2582 play_tree_t
*e
= play_tree_new();
2583 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2585 if (cmd
->args
[1].v
.i
) // append
2586 play_tree_append_entry(mpctx
->playtree
, e
);
2588 // Go back to the starting point.
2589 while (play_tree_iter_up_step
2590 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2592 play_tree_free_list(mpctx
->playtree
->child
, 1);
2593 play_tree_set_child(mpctx
->playtree
, e
);
2594 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2595 mpctx
->eof
= PT_NEXT_SRC
;
2601 case MP_CMD_LOADLIST
:{
2602 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2604 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2605 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2607 if (cmd
->args
[1].v
.i
) // append
2608 play_tree_append_entry(mpctx
->playtree
, e
);
2610 // Go back to the starting point.
2611 while (play_tree_iter_up_step
2612 (mpctx
->playtree_iter
, 0, 1)
2613 != PLAY_TREE_ITER_END
)
2615 play_tree_free_list(mpctx
->playtree
->child
, 1);
2616 play_tree_set_child(mpctx
->playtree
, e
);
2617 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2618 mpctx
->eof
= PT_NEXT_SRC
;
2626 case MP_CMD_RADIO_STEP_CHANNEL
:
2627 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2628 int v
= cmd
->args
[0].v
.i
;
2630 radio_step_channel(mpctx
->demuxer
->stream
,
2631 RADIO_CHANNEL_HIGHER
);
2633 radio_step_channel(mpctx
->demuxer
->stream
,
2634 RADIO_CHANNEL_LOWER
);
2635 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2636 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2638 radio_get_channel_name(mpctx
->demuxer
->stream
));
2643 case MP_CMD_RADIO_SET_CHANNEL
:
2644 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2645 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2646 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2647 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2649 radio_get_channel_name(mpctx
->demuxer
->stream
));
2654 case MP_CMD_RADIO_SET_FREQ
:
2655 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2656 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2659 case MP_CMD_RADIO_STEP_FREQ
:
2660 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2661 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2666 case MP_CMD_TV_START_SCAN
:
2667 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2668 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2670 case MP_CMD_TV_SET_FREQ
:
2671 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2672 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2673 cmd
->args
[0].v
.f
* 16.0);
2675 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2676 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2677 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2678 pvr_get_current_channelname (mpctx
->stream
),
2679 pvr_get_current_stationname (mpctx
->stream
));
2681 #endif /* HAVE_PVR */
2684 case MP_CMD_TV_STEP_FREQ
:
2685 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2686 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2687 cmd
->args
[0].v
.f
* 16.0);
2689 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2690 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2691 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2692 pvr_get_current_channelname (mpctx
->stream
),
2693 pvr_get_current_frequency (mpctx
->stream
));
2695 #endif /* HAVE_PVR */
2698 case MP_CMD_TV_SET_NORM
:
2699 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2700 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2704 case MP_CMD_TV_STEP_CHANNEL
:{
2705 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2706 int v
= cmd
->args
[0].v
.i
;
2708 tv_step_channel((tvi_handle_t
*) (mpctx
->
2712 tv_step_channel((tvi_handle_t
*) (mpctx
->
2716 if (tv_channel_list
) {
2717 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2718 MSGTR_OSDChannel
, tv_channel_current
->name
);
2719 //vo_osd_changed(OSDTYPE_SUBTITLE);
2723 else if (mpctx
->stream
&&
2724 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2725 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2726 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2727 pvr_get_current_channelname (mpctx
->stream
),
2728 pvr_get_current_stationname (mpctx
->stream
));
2730 #endif /* HAVE_PVR */
2732 #ifdef HAS_DVBIN_SUPPORT
2733 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2735 int v
= cmd
->args
[0].v
.i
;
2737 mpctx
->last_dvb_step
= v
;
2739 dir
= DVB_CHANNEL_HIGHER
;
2741 dir
= DVB_CHANNEL_LOWER
;
2744 if (dvb_step_channel(mpctx
->stream
, dir
))
2745 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2747 #endif /* HAS_DVBIN_SUPPORT */
2750 case MP_CMD_TV_SET_CHANNEL
:
2751 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2752 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2754 if (tv_channel_list
) {
2755 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2756 MSGTR_OSDChannel
, tv_channel_current
->name
);
2757 //vo_osd_changed(OSDTYPE_SUBTITLE);
2761 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2762 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2763 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2764 pvr_get_current_channelname (mpctx
->stream
),
2765 pvr_get_current_stationname (mpctx
->stream
));
2767 #endif /* HAVE_PVR */
2770 #ifdef HAS_DVBIN_SUPPORT
2771 case MP_CMD_DVB_SET_CHANNEL
:
2772 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2773 mpctx
->last_dvb_step
= 1;
2776 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2777 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2780 #endif /* HAS_DVBIN_SUPPORT */
2782 case MP_CMD_TV_LAST_CHANNEL
:
2783 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2784 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2785 if (tv_channel_list
) {
2786 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2787 MSGTR_OSDChannel
, tv_channel_current
->name
);
2788 //vo_osd_changed(OSDTYPE_SUBTITLE);
2792 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2793 pvr_set_lastchannel (mpctx
->stream
);
2794 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2795 pvr_get_current_channelname (mpctx
->stream
),
2796 pvr_get_current_stationname (mpctx
->stream
));
2798 #endif /* HAVE_PVR */
2801 case MP_CMD_TV_STEP_NORM
:
2802 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2803 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2806 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2807 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2808 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2810 #ifdef HAVE_TV_TELETEXT
2811 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2813 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2814 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2815 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2818 case MP_CMD_TV_TELETEXT_GO_LINK
:
2820 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2821 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2822 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2825 #endif /* HAVE_TV_TELETEXT */
2828 case MP_CMD_SUB_LOAD
:
2830 int n
= mpctx
->set_of_sub_size
;
2831 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2832 if (n
!= mpctx
->set_of_sub_size
) {
2833 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2834 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2835 mpctx
->global_sub_size
;
2836 ++mpctx
->global_sub_size
;
2841 case MP_CMD_SUB_REMOVE
:
2843 int v
= cmd
->args
[0].v
.i
;
2846 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2847 subd
= mpctx
->set_of_subtitles
[v
];
2848 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2849 MSGTR_RemovedSubtitleFile
, v
+ 1,
2850 filename_recode(subd
->filename
));
2852 mpctx
->set_of_subtitles
[v
] = NULL
;
2854 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2855 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2856 mpctx
->set_of_sub_size
= 0;
2857 if (mpctx
->set_of_sub_pos
>= 0) {
2858 mpctx
->global_sub_pos
= -2;
2860 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2862 } else if (v
< mpctx
->set_of_sub_size
) {
2863 subd
= mpctx
->set_of_subtitles
[v
];
2864 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2865 MSGTR_RemovedSubtitleFile
, v
+ 1,
2866 filename_recode(subd
->filename
));
2868 if (mpctx
->set_of_sub_pos
== v
) {
2869 mpctx
->global_sub_pos
= -2;
2871 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2872 } else if (mpctx
->set_of_sub_pos
> v
) {
2873 --mpctx
->set_of_sub_pos
;
2874 --mpctx
->global_sub_pos
;
2876 while (++v
< mpctx
->set_of_sub_size
)
2877 mpctx
->set_of_subtitles
[v
- 1] =
2878 mpctx
->set_of_subtitles
[v
];
2879 --mpctx
->set_of_sub_size
;
2880 --mpctx
->global_sub_size
;
2881 if (mpctx
->set_of_sub_size
<= 0)
2882 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2883 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2888 case MP_CMD_GET_SUB_VISIBILITY
:
2890 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2891 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2895 case MP_CMD_SCREENSHOT
:
2896 if (vo_config_count
) {
2897 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2899 ((vf_instance_t
*) sh_video
->vfilter
)->
2900 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2902 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2906 case MP_CMD_VF_CHANGE_RECTANGLE
:
2907 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2910 case MP_CMD_GET_TIME_LENGTH
:{
2911 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2912 demuxer_get_time_length(mpctx
->demuxer
));
2916 case MP_CMD_GET_FILENAME
:{
2917 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2918 get_metadata(META_NAME
));
2922 case MP_CMD_GET_VIDEO_CODEC
:{
2923 char *inf
= get_metadata(META_VIDEO_CODEC
);
2926 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2931 case MP_CMD_GET_VIDEO_BITRATE
:{
2932 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2935 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2940 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2941 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2944 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2945 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2950 case MP_CMD_GET_AUDIO_CODEC
:{
2951 char *inf
= get_metadata(META_AUDIO_CODEC
);
2954 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2959 case MP_CMD_GET_AUDIO_BITRATE
:{
2960 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2963 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2968 case MP_CMD_GET_AUDIO_SAMPLES
:{
2969 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2972 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2977 case MP_CMD_GET_META_TITLE
:{
2978 char *inf
= get_metadata(META_INFO_TITLE
);
2981 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
2986 case MP_CMD_GET_META_ARTIST
:{
2987 char *inf
= get_metadata(META_INFO_ARTIST
);
2990 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
2995 case MP_CMD_GET_META_ALBUM
:{
2996 char *inf
= get_metadata(META_INFO_ALBUM
);
2999 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3004 case MP_CMD_GET_META_YEAR
:{
3005 char *inf
= get_metadata(META_INFO_YEAR
);
3008 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3013 case MP_CMD_GET_META_COMMENT
:{
3014 char *inf
= get_metadata(META_INFO_COMMENT
);
3017 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3022 case MP_CMD_GET_META_TRACK
:{
3023 char *inf
= get_metadata(META_INFO_TRACK
);
3026 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3031 case MP_CMD_GET_META_GENRE
:{
3032 char *inf
= get_metadata(META_INFO_GENRE
);
3035 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3040 case MP_CMD_GET_VO_FULLSCREEN
:
3041 if (mpctx
->video_out
&& vo_config_count
)
3042 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3045 case MP_CMD_GET_PERCENT_POS
:
3046 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3047 demuxer_get_percent_pos(mpctx
->demuxer
));
3050 case MP_CMD_GET_TIME_POS
:{
3053 pos
= sh_video
->pts
;
3054 else if (sh_audio
&& mpctx
->audio_out
)
3056 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3058 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3065 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3071 case MP_CMD_KEYDOWN_EVENTS
:
3072 mplayer_put_key(cmd
->args
[0].v
.i
);
3075 case MP_CMD_SET_MOUSE_POS
:{
3076 int pointer_x
, pointer_y
;
3078 pointer_x
= cmd
->args
[0].v
.i
;
3079 pointer_y
= cmd
->args
[1].v
.i
;
3080 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3082 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3083 && dx
> 0.0 && dy
> 0.0) {
3085 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3086 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3087 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3088 pointer_x
, pointer_y
, &button
);
3089 if (osd_level
> 1 && button
> 0)
3090 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3091 "Selected button number %d", button
);
3095 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3096 menu_update_mouse_pos(dx
, dy
);
3102 case MP_CMD_DVDNAV
:{
3104 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3107 mp_dvdnav_handle_input(mpctx
->stream
,cmd
->args
[0].v
.i
,&button
);
3108 if (osd_level
> 1 && button
> 0)
3109 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3110 "Selected button number %d", button
);
3114 case MP_CMD_SWITCH_TITLE
:
3115 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3116 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3123 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3124 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3127 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3128 "Received unknown cmd %s\n", cmd
->name
);
3131 switch (cmd
->pausing
) {
3132 case 1: // "pausing"
3133 mpctx
->osd_function
= OSD_PAUSE
;
3135 case 3: // "pausing_toggle"
3136 mpctx
->was_paused
= !mpctx
->was_paused
;
3137 if (mpctx
->was_paused
)
3138 mpctx
->osd_function
= OSD_PAUSE
;
3139 else if (mpctx
->osd_function
== OSD_PAUSE
)
3140 mpctx
->osd_function
= OSD_PLAY
;
3142 case 2: // "pausing_keep"
3143 if (mpctx
->was_paused
)
3144 mpctx
->osd_function
= OSD_PAUSE
;