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
;
388 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
390 return M_PROPERTY_UNAVAILABLE
;
395 return M_PROPERTY_ERROR
;
396 *(int *) arg
= chapter
;
397 return M_PROPERTY_OK
;
398 case M_PROPERTY_PRINT
: {
400 return M_PROPERTY_ERROR
;
401 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
403 return M_PROPERTY_UNAVAILABLE
;
404 *(char **) arg
= chapter_name
;
405 return M_PROPERTY_OK
;
409 return M_PROPERTY_ERROR
;
410 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
411 step_all
= *(int *)arg
- (chapter
+ 1);
414 case M_PROPERTY_STEP_UP
:
415 case M_PROPERTY_STEP_DOWN
: {
416 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
417 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
424 return M_PROPERTY_NOT_IMPLEMENTED
;
428 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
429 &next_pts
, &chapter_num
, &chapter_name
);
431 if (next_pts
> -1.0) {
433 rel_seek_secs
= next_pts
;
436 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
437 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
439 else if (step_all
> 0)
440 rel_seek_secs
= 1000000000.;
442 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
443 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
446 return M_PROPERTY_OK
;
449 /// Current dvd angle (RW)
450 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
455 char *angle_name
= NULL
;
457 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
459 return M_PROPERTY_UNAVAILABLE
;
460 angles
= demuxer_angles_count(mpctx
->demuxer
);
462 return M_PROPERTY_UNAVAILABLE
;
467 return M_PROPERTY_ERROR
;
468 *(int *) arg
= angle
;
469 return M_PROPERTY_OK
;
470 case M_PROPERTY_PRINT
: {
472 return M_PROPERTY_ERROR
;
473 angle_name
= calloc(1, 64);
475 return M_PROPERTY_UNAVAILABLE
;
476 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
477 *(char **) arg
= angle_name
;
478 return M_PROPERTY_OK
;
482 return M_PROPERTY_ERROR
;
484 M_PROPERTY_CLAMP(prop
, angle
);
486 case M_PROPERTY_STEP_UP
:
487 case M_PROPERTY_STEP_DOWN
: {
493 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
495 if (angle
< 1) //cycle
500 return M_PROPERTY_NOT_IMPLEMENTED
;
502 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
503 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
504 MSGTR_OSDAngle
, angle
, angles
);
507 return M_PROPERTY_OK
;
510 /// Demuxer meta data
511 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
513 m_property_action_t
* ka
;
515 static m_option_t key_type
=
516 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
518 return M_PROPERTY_UNAVAILABLE
;
522 if(!arg
) return M_PROPERTY_ERROR
;
523 *(char***)arg
= mpctx
->demuxer
->info
;
524 return M_PROPERTY_OK
;
525 case M_PROPERTY_KEY_ACTION
:
526 if(!arg
) return M_PROPERTY_ERROR
;
528 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
529 return M_PROPERTY_UNKNOWN
;
532 if(!ka
->arg
) return M_PROPERTY_ERROR
;
533 *(char**)ka
->arg
= meta
;
534 return M_PROPERTY_OK
;
535 case M_PROPERTY_GET_TYPE
:
536 if(!ka
->arg
) return M_PROPERTY_ERROR
;
537 *(m_option_t
**)ka
->arg
= &key_type
;
538 return M_PROPERTY_OK
;
541 return M_PROPERTY_NOT_IMPLEMENTED
;
547 /// \defgroup AudioProperties Audio properties
548 /// \ingroup Properties
552 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
556 if (!mpctx
->sh_audio
)
557 return M_PROPERTY_UNAVAILABLE
;
562 return M_PROPERTY_ERROR
;
563 mixer_getbothvolume(&mpctx
->mixer
, arg
);
564 return M_PROPERTY_OK
;
565 case M_PROPERTY_PRINT
:{
568 return M_PROPERTY_ERROR
;
569 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
570 return m_property_float_range(prop
, action
, arg
, &vol
);
572 case M_PROPERTY_STEP_UP
:
573 case M_PROPERTY_STEP_DOWN
:
577 return M_PROPERTY_NOT_IMPLEMENTED
;
580 if (mpctx
->edl_muted
)
581 return M_PROPERTY_DISABLED
;
582 mpctx
->user_muted
= 0;
587 return M_PROPERTY_ERROR
;
588 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
589 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
590 return M_PROPERTY_OK
;
591 case M_PROPERTY_STEP_UP
:
592 if (arg
&& *(float *) arg
<= 0)
593 mixer_decvolume(&mpctx
->mixer
);
595 mixer_incvolume(&mpctx
->mixer
);
596 return M_PROPERTY_OK
;
597 case M_PROPERTY_STEP_DOWN
:
598 if (arg
&& *(float *) arg
<= 0)
599 mixer_incvolume(&mpctx
->mixer
);
601 mixer_decvolume(&mpctx
->mixer
);
602 return M_PROPERTY_OK
;
604 return M_PROPERTY_NOT_IMPLEMENTED
;
608 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
612 if (!mpctx
->sh_audio
)
613 return M_PROPERTY_UNAVAILABLE
;
617 if (mpctx
->edl_muted
)
618 return M_PROPERTY_DISABLED
;
620 return M_PROPERTY_ERROR
;
621 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
622 mixer_mute(&mpctx
->mixer
);
623 mpctx
->user_muted
= mpctx
->mixer
.muted
;
624 return M_PROPERTY_OK
;
625 case M_PROPERTY_STEP_UP
:
626 case M_PROPERTY_STEP_DOWN
:
627 if (mpctx
->edl_muted
)
628 return M_PROPERTY_DISABLED
;
629 mixer_mute(&mpctx
->mixer
);
630 mpctx
->user_muted
= mpctx
->mixer
.muted
;
631 return M_PROPERTY_OK
;
632 case M_PROPERTY_PRINT
:
634 return M_PROPERTY_ERROR
;
635 if (mpctx
->edl_muted
) {
636 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
637 return M_PROPERTY_OK
;
640 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
646 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
647 void *arg
, MPContext
* mpctx
)
649 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
650 return M_PROPERTY_UNAVAILABLE
;
653 case M_PROPERTY_STEP_UP
:
654 case M_PROPERTY_STEP_DOWN
: {
656 float delay
= audio_delay
;
657 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
658 if (ret
!= M_PROPERTY_OK
)
661 mpctx
->delay
-= audio_delay
- delay
;
663 return M_PROPERTY_OK
;
665 return m_property_delay(prop
, action
, arg
, &audio_delay
);
669 /// Audio codec tag (RO)
670 static int mp_property_audio_format(m_option_t
* prop
, int action
,
671 void *arg
, MPContext
* mpctx
)
673 if (!mpctx
->sh_audio
)
674 return M_PROPERTY_UNAVAILABLE
;
675 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
678 /// Audio codec name (RO)
679 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
680 void *arg
, MPContext
* mpctx
)
682 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
683 return M_PROPERTY_UNAVAILABLE
;
684 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
687 /// Audio bitrate (RO)
688 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
689 void *arg
, MPContext
* mpctx
)
691 if (!mpctx
->sh_audio
)
692 return M_PROPERTY_UNAVAILABLE
;
693 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
697 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
700 if (!mpctx
->sh_audio
)
701 return M_PROPERTY_UNAVAILABLE
;
703 case M_PROPERTY_PRINT
:
704 if(!arg
) return M_PROPERTY_ERROR
;
705 *(char**)arg
= malloc(16);
706 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
707 return M_PROPERTY_OK
;
709 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
712 /// Number of channels (RO)
713 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
716 if (!mpctx
->sh_audio
)
717 return M_PROPERTY_UNAVAILABLE
;
719 case M_PROPERTY_PRINT
:
721 return M_PROPERTY_ERROR
;
722 switch (mpctx
->sh_audio
->channels
) {
724 *(char **) arg
= strdup("mono");
727 *(char **) arg
= strdup("stereo");
730 *(char **) arg
= malloc(32);
731 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
733 return M_PROPERTY_OK
;
735 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
739 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
744 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
745 return M_PROPERTY_UNAVAILABLE
;
750 return M_PROPERTY_ERROR
;
751 mixer_getbalance(&mpctx
->mixer
, arg
);
752 return M_PROPERTY_OK
;
753 case M_PROPERTY_PRINT
: {
756 return M_PROPERTY_ERROR
;
757 mixer_getbalance(&mpctx
->mixer
, &bal
);
759 *str
= strdup("center");
760 else if (bal
== -1.f
)
761 *str
= strdup("left only");
763 *str
= strdup("right only");
765 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
766 *str
= malloc(sizeof("left xxx%, right xxx%"));
767 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
769 return M_PROPERTY_OK
;
771 case M_PROPERTY_STEP_UP
:
772 case M_PROPERTY_STEP_DOWN
:
773 mixer_getbalance(&mpctx
->mixer
, &bal
);
774 bal
+= (arg
? *(float*)arg
: .1f
) *
775 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
776 M_PROPERTY_CLAMP(prop
, bal
);
777 mixer_setbalance(&mpctx
->mixer
, bal
);
778 return M_PROPERTY_OK
;
781 return M_PROPERTY_ERROR
;
782 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
783 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
784 return M_PROPERTY_OK
;
786 return M_PROPERTY_NOT_IMPLEMENTED
;
789 /// Selected audio id (RW)
790 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
793 int current_id
= -1, tmp
;
797 if (!mpctx
->sh_audio
)
798 return M_PROPERTY_UNAVAILABLE
;
800 return M_PROPERTY_ERROR
;
801 *(int *) arg
= audio_id
;
802 return M_PROPERTY_OK
;
803 case M_PROPERTY_PRINT
:
804 if (!mpctx
->sh_audio
)
805 return M_PROPERTY_UNAVAILABLE
;
807 return M_PROPERTY_ERROR
;
810 *(char **) arg
= strdup(MSGTR_Disabled
);
812 char lang
[40] = MSGTR_Unknown
;
813 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
)
814 demux_mkv_get_audio_lang(mpctx
->demuxer
, audio_id
, lang
, 9);
816 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
817 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
827 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
828 dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
830 *(char **) arg
= malloc(64);
831 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
833 return M_PROPERTY_OK
;
835 case M_PROPERTY_STEP_UP
:
837 if (action
== M_PROPERTY_SET
&& arg
)
838 tmp
= *((int *) arg
);
841 current_id
= mpctx
->demuxer
->audio
->id
;
842 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
845 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
846 uninit_player(INITED_AO
| INITED_ACODEC
);
847 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
849 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
851 sh2
->ds
= mpctx
->demuxer
->audio
;
852 mpctx
->sh_audio
= sh2
;
853 reinit_audio_chain();
856 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
857 return M_PROPERTY_OK
;
859 return M_PROPERTY_NOT_IMPLEMENTED
;
864 /// Selected video id (RW)
865 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
868 int current_id
= -1, tmp
;
872 if (!mpctx
->sh_video
)
873 return M_PROPERTY_UNAVAILABLE
;
875 return M_PROPERTY_ERROR
;
876 *(int *) arg
= video_id
;
877 return M_PROPERTY_OK
;
878 case M_PROPERTY_PRINT
:
879 if (!mpctx
->sh_video
)
880 return M_PROPERTY_UNAVAILABLE
;
882 return M_PROPERTY_ERROR
;
885 *(char **) arg
= strdup(MSGTR_Disabled
);
887 char lang
[40] = MSGTR_Unknown
;
888 *(char **) arg
= malloc(64);
889 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
891 return M_PROPERTY_OK
;
893 case M_PROPERTY_STEP_UP
:
895 current_id
= mpctx
->demuxer
->video
->id
;
896 if (action
== M_PROPERTY_SET
&& arg
)
897 tmp
= *((int *) arg
);
900 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
902 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
903 && current_id
!= -2))
904 uninit_player(INITED_VCODEC
|
905 (fixed_vo
&& video_id
!= -2 ? 0 : INITED_VO
));
906 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
908 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
910 sh2
->ds
= mpctx
->demuxer
->video
;
911 mpctx
->sh_video
= sh2
;
912 reinit_video_chain();
915 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
916 return M_PROPERTY_OK
;
919 return M_PROPERTY_NOT_IMPLEMENTED
;
923 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
926 demux_program_t prog
;
929 case M_PROPERTY_STEP_UP
:
931 if (action
== M_PROPERTY_SET
&& arg
)
932 prog
.progid
= *((int *) arg
);
936 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
937 &prog
) == DEMUXER_CTRL_NOTIMPL
)
938 return M_PROPERTY_ERROR
;
940 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
941 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
942 return M_PROPERTY_OK
;
945 return M_PROPERTY_NOT_IMPLEMENTED
;
951 /// \defgroup VideoProperties Video properties
952 /// \ingroup Properties
955 /// Fullscreen state (RW)
956 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
960 if (!mpctx
->video_out
)
961 return M_PROPERTY_UNAVAILABLE
;
966 return M_PROPERTY_ERROR
;
967 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
968 if (vo_fs
== !!*(int *) arg
)
969 return M_PROPERTY_OK
;
970 case M_PROPERTY_STEP_UP
:
971 case M_PROPERTY_STEP_DOWN
:
974 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
978 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
979 return M_PROPERTY_OK
;
981 return m_property_flag(prop
, action
, arg
, &vo_fs
);
985 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
986 void *arg
, MPContext
* mpctx
)
990 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
991 return M_PROPERTY_UNAVAILABLE
;
992 vf
= mpctx
->sh_video
->vfilter
;
996 return M_PROPERTY_ERROR
;
997 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
998 return M_PROPERTY_OK
;
1001 return M_PROPERTY_ERROR
;
1002 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1003 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1004 return M_PROPERTY_OK
;
1005 case M_PROPERTY_STEP_UP
:
1006 case M_PROPERTY_STEP_DOWN
:
1007 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1008 deinterlace
= !deinterlace
;
1009 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1010 return M_PROPERTY_OK
;
1012 return M_PROPERTY_NOT_IMPLEMENTED
;
1016 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1020 if (!mpctx
->video_out
1021 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1022 return M_PROPERTY_UNAVAILABLE
;
1025 case M_PROPERTY_SET
:
1027 return M_PROPERTY_ERROR
;
1028 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1029 vo_panscan
= *(float *) arg
;
1030 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1031 return M_PROPERTY_OK
;
1032 case M_PROPERTY_STEP_UP
:
1033 case M_PROPERTY_STEP_DOWN
:
1034 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1035 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1038 else if (vo_panscan
< 0)
1040 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1041 return M_PROPERTY_OK
;
1043 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1047 /// Helper to set vo flags.
1048 /** \ingroup PropertyImplHelper
1050 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1051 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1054 if (!mpctx
->video_out
)
1055 return M_PROPERTY_UNAVAILABLE
;
1058 case M_PROPERTY_SET
:
1060 return M_PROPERTY_ERROR
;
1061 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1062 if (*vo_var
== !!*(int *) arg
)
1063 return M_PROPERTY_OK
;
1064 case M_PROPERTY_STEP_UP
:
1065 case M_PROPERTY_STEP_DOWN
:
1066 if (vo_config_count
)
1067 mpctx
->video_out
->control(vo_ctrl
, 0);
1068 return M_PROPERTY_OK
;
1070 return m_property_flag(prop
, action
, arg
, vo_var
);
1074 /// Window always on top (RW)
1075 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1078 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1082 /// Display in the root window (RW)
1083 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1086 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1087 &vo_rootwin
, mpctx
);
1090 /// Show window borders (RW)
1091 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1094 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1098 /// Framedropping state (RW)
1099 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1100 void *arg
, MPContext
* mpctx
)
1103 if (!mpctx
->sh_video
)
1104 return M_PROPERTY_UNAVAILABLE
;
1107 case M_PROPERTY_PRINT
:
1109 return M_PROPERTY_ERROR
;
1110 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1111 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1113 return M_PROPERTY_OK
;
1115 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1119 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1120 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1123 int *gamma
= prop
->priv
, r
, val
;
1125 if (!mpctx
->sh_video
)
1126 return M_PROPERTY_UNAVAILABLE
;
1128 if (gamma
[0] == 1000) {
1130 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1134 case M_PROPERTY_SET
:
1136 return M_PROPERTY_ERROR
;
1137 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1138 *gamma
= *(int *) arg
;
1139 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1143 case M_PROPERTY_GET
:
1144 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1146 return M_PROPERTY_ERROR
;
1148 return M_PROPERTY_OK
;
1151 case M_PROPERTY_STEP_UP
:
1152 case M_PROPERTY_STEP_DOWN
:
1153 *gamma
+= (arg
? *(int *) arg
: 1) *
1154 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1155 M_PROPERTY_CLAMP(prop
, *gamma
);
1156 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1161 return M_PROPERTY_NOT_IMPLEMENTED
;
1165 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1166 int l
= strlen(prop
->name
);
1167 char tv_prop
[3 + l
+ 1];
1168 sprintf(tv_prop
, "tv_%s", prop
->name
);
1169 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1173 return M_PROPERTY_UNAVAILABLE
;
1177 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1180 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1183 /// Video codec tag (RO)
1184 static int mp_property_video_format(m_option_t
* prop
, int action
,
1185 void *arg
, MPContext
* mpctx
)
1188 if (!mpctx
->sh_video
)
1189 return M_PROPERTY_UNAVAILABLE
;
1191 case M_PROPERTY_PRINT
:
1193 return M_PROPERTY_ERROR
;
1194 switch(mpctx
->sh_video
->format
) {
1196 meta
= strdup ("mpeg1"); break;
1198 meta
= strdup ("mpeg2"); break;
1200 meta
= strdup ("mpeg4"); break;
1202 meta
= strdup ("h264"); break;
1204 if(mpctx
->sh_video
->format
>= 0x20202020) {
1206 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1209 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1212 *(char**)arg
= meta
;
1213 return M_PROPERTY_OK
;
1215 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1218 /// Video codec name (RO)
1219 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1220 void *arg
, MPContext
* mpctx
)
1222 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1223 return M_PROPERTY_UNAVAILABLE
;
1224 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1228 /// Video bitrate (RO)
1229 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1230 void *arg
, MPContext
* mpctx
)
1232 if (!mpctx
->sh_video
)
1233 return M_PROPERTY_UNAVAILABLE
;
1234 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1237 /// Video display width (RO)
1238 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1241 if (!mpctx
->sh_video
)
1242 return M_PROPERTY_UNAVAILABLE
;
1243 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1246 /// Video display height (RO)
1247 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1250 if (!mpctx
->sh_video
)
1251 return M_PROPERTY_UNAVAILABLE
;
1252 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1256 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1259 if (!mpctx
->sh_video
)
1260 return M_PROPERTY_UNAVAILABLE
;
1261 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1264 /// Video aspect (RO)
1265 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1268 if (!mpctx
->sh_video
)
1269 return M_PROPERTY_UNAVAILABLE
;
1270 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1275 /// \defgroup SubProprties Subtitles properties
1276 /// \ingroup Properties
1279 /// Text subtitle position (RW)
1280 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1283 if (!mpctx
->sh_video
)
1284 return M_PROPERTY_UNAVAILABLE
;
1287 case M_PROPERTY_SET
:
1289 return M_PROPERTY_ERROR
;
1290 case M_PROPERTY_STEP_UP
:
1291 case M_PROPERTY_STEP_DOWN
:
1292 vo_osd_changed(OSDTYPE_SUBTITLE
);
1294 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1298 char *demux_lavf_sub_lang(demuxer_t
*demuxer
, int track_num
);
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 #ifdef USE_LIBAVFORMAT
1355 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
&& dvdsub_id
>= 0) {
1356 char *lang
= demux_lavf_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1357 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1358 return M_PROPERTY_OK
;
1361 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
&& dvdsub_id
>= 0) {
1362 char lang
[40] = MSGTR_Unknown
;
1363 demux_mkv_get_sub_lang(mpctx
->demuxer
, dvdsub_id
, lang
, 9);
1364 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1365 return M_PROPERTY_OK
;
1367 #ifdef HAVE_OGGVORBIS
1368 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
&& d_sub
&& dvdsub_id
>= 0) {
1369 const char *lang
= demux_ogg_sub_lang(mpctx
->demuxer
, dvdsub_id
);
1371 lang
= MSGTR_Unknown
;
1372 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1373 return M_PROPERTY_OK
;
1376 if (vo_vobsub
&& vobsub_id
>= 0) {
1377 const char *language
= MSGTR_Unknown
;
1378 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1379 snprintf(*(char **) arg
, 63, "(%d) %s",
1380 vobsub_id
, language
? language
: MSGTR_Unknown
);
1381 return M_PROPERTY_OK
;
1384 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1385 && dvdsub_id
>= 0) {
1387 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1388 lang
[0] = code
>> 8;
1391 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1392 return M_PROPERTY_OK
;
1395 if (dvdsub_id
>= 0) {
1396 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1397 return M_PROPERTY_OK
;
1399 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1400 return M_PROPERTY_OK
;
1402 case M_PROPERTY_SET
:
1404 return M_PROPERTY_ERROR
;
1405 if (*(int *) arg
< -1)
1407 else if (*(int *) arg
>= global_sub_size
)
1408 *(int *) arg
= global_sub_size
- 1;
1409 mpctx
->global_sub_pos
= *(int *) arg
;
1411 case M_PROPERTY_STEP_UP
:
1412 mpctx
->global_sub_pos
+= 2;
1413 mpctx
->global_sub_pos
=
1414 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1416 case M_PROPERTY_STEP_DOWN
:
1417 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1418 mpctx
->global_sub_pos
=
1419 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1422 return M_PROPERTY_NOT_IMPLEMENTED
;
1425 if (mpctx
->global_sub_pos
>= 0)
1426 source
= sub_source(mpctx
);
1428 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1429 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1431 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1432 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1433 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1434 mpctx
->global_sub_pos
, source
);
1436 mpctx
->set_of_sub_pos
= -1;
1450 if (source
== SUB_SOURCE_VOBSUB
) {
1451 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1452 } else if (source
== SUB_SOURCE_SUBS
) {
1453 mpctx
->set_of_sub_pos
=
1454 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1456 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1457 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1461 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1462 vo_osd_changed(OSDTYPE_SUBTITLE
);
1464 } else if (source
== SUB_SOURCE_DEMUX
) {
1466 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1467 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1469 // default: assume 1:1 mapping of sid and stream id
1470 d_sub
->id
= dvdsub_id
;
1471 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1472 ds_free_packs(d_sub
);
1473 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1474 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1475 if (sh
&& sh
->sid
== dvdsub_id
) {
1481 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1482 sh_sub_t
*sh
= d_sub
->sh
;
1483 if (sh
->type
== 'v')
1486 else if (ass_enabled
&& (sh
->type
== 'a' || sh
->type
== 't'))
1487 ass_track
= sh
->ass_track
;
1497 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1498 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1499 && dvdsub_id
< 0 && reset_spu
) {
1501 d_sub
->id
= dvdsub_id
;
1504 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1506 return M_PROPERTY_OK
;
1509 /// Selected sub source (RW)
1510 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1514 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1515 return M_PROPERTY_UNAVAILABLE
;
1518 case M_PROPERTY_GET
:
1520 return M_PROPERTY_ERROR
;
1521 *(int *) arg
= sub_source(mpctx
);
1522 return M_PROPERTY_OK
;
1523 case M_PROPERTY_PRINT
:
1525 return M_PROPERTY_ERROR
;
1526 *(char **) arg
= malloc(64);
1527 (*(char **) arg
)[63] = 0;
1528 switch (sub_source(mpctx
))
1530 case SUB_SOURCE_SUBS
:
1531 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1533 case SUB_SOURCE_VOBSUB
:
1534 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1536 case SUB_SOURCE_DEMUX
:
1537 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1540 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1542 return M_PROPERTY_OK
;
1543 case M_PROPERTY_SET
:
1545 return M_PROPERTY_ERROR
;
1546 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1547 if (*(int *) arg
< 0)
1548 mpctx
->global_sub_pos
= -1;
1549 else if (*(int *) arg
!= sub_source(mpctx
)) {
1550 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1551 return M_PROPERTY_UNAVAILABLE
;
1552 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1555 case M_PROPERTY_STEP_UP
:
1556 case M_PROPERTY_STEP_DOWN
: {
1557 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1558 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1559 int step
= (step_all
> 0) ? 1 : -1;
1560 int cur_source
= sub_source(mpctx
);
1561 source
= cur_source
;
1564 if (source
>= SUB_SOURCES
)
1566 else if (source
< -1)
1567 source
= SUB_SOURCES
- 1;
1568 if (source
== cur_source
|| source
== -1 ||
1569 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1572 if (source
== cur_source
)
1573 return M_PROPERTY_OK
;
1575 mpctx
->global_sub_pos
= -1;
1577 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1581 return M_PROPERTY_NOT_IMPLEMENTED
;
1583 --mpctx
->global_sub_pos
;
1584 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1587 /// Selected subtitles from specific source (RW)
1588 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1591 int source
, is_cur_source
, offset
;
1592 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1593 return M_PROPERTY_UNAVAILABLE
;
1595 if (!strcmp(prop
->name
, "sub_file"))
1596 source
= SUB_SOURCE_SUBS
;
1597 else if (!strcmp(prop
->name
, "sub_vob"))
1598 source
= SUB_SOURCE_VOBSUB
;
1599 else if (!strcmp(prop
->name
, "sub_demux"))
1600 source
= SUB_SOURCE_DEMUX
;
1602 return M_PROPERTY_ERROR
;
1604 offset
= mpctx
->global_sub_indices
[source
];
1605 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1606 return M_PROPERTY_UNAVAILABLE
;
1608 is_cur_source
= sub_source(mpctx
) == source
;
1610 case M_PROPERTY_GET
:
1612 return M_PROPERTY_ERROR
;
1613 if (is_cur_source
) {
1614 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1615 if (source
== SUB_SOURCE_VOBSUB
)
1616 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1620 return M_PROPERTY_OK
;
1621 case M_PROPERTY_PRINT
:
1623 return M_PROPERTY_ERROR
;
1625 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1626 *(char **) arg
= malloc(64);
1627 (*(char **) arg
)[63] = 0;
1628 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1629 return M_PROPERTY_OK
;
1630 case M_PROPERTY_SET
:
1632 return M_PROPERTY_ERROR
;
1633 if (*(int *) arg
>= 0) {
1634 int index
= *(int *)arg
;
1635 if (source
== SUB_SOURCE_VOBSUB
)
1636 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1637 mpctx
->global_sub_pos
= offset
+ index
;
1638 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1639 || sub_source(mpctx
) != source
) {
1640 mpctx
->global_sub_pos
= -1;
1645 mpctx
->global_sub_pos
= -1;
1647 case M_PROPERTY_STEP_UP
:
1648 case M_PROPERTY_STEP_DOWN
: {
1649 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1650 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1651 int step
= (step_all
> 0) ? 1 : -1;
1652 int max_sub_pos_for_source
= -1;
1654 mpctx
->global_sub_pos
= -1;
1656 if (mpctx
->global_sub_pos
== -1) {
1658 mpctx
->global_sub_pos
= offset
;
1659 else if (max_sub_pos_for_source
== -1) {
1660 // Find max pos for specific source
1661 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1662 while (mpctx
->global_sub_pos
>= 0
1663 && sub_source(mpctx
) != source
)
1664 --mpctx
->global_sub_pos
;
1667 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1670 mpctx
->global_sub_pos
+= step
;
1671 if (mpctx
->global_sub_pos
< offset
||
1672 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1673 sub_source(mpctx
) != source
)
1674 mpctx
->global_sub_pos
= -1;
1681 return M_PROPERTY_NOT_IMPLEMENTED
;
1683 --mpctx
->global_sub_pos
;
1684 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1687 /// Subtitle delay (RW)
1688 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1691 if (!mpctx
->sh_video
)
1692 return M_PROPERTY_UNAVAILABLE
;
1693 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1696 /// Alignment of text subtitles (RW)
1697 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1698 void *arg
, MPContext
* mpctx
)
1700 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1702 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1703 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1704 return M_PROPERTY_UNAVAILABLE
;
1707 case M_PROPERTY_PRINT
:
1709 return M_PROPERTY_ERROR
;
1710 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1711 *(char **) arg
= strdup(name
[sub_alignment
]);
1712 return M_PROPERTY_OK
;
1713 case M_PROPERTY_SET
:
1715 return M_PROPERTY_ERROR
;
1716 case M_PROPERTY_STEP_UP
:
1717 case M_PROPERTY_STEP_DOWN
:
1718 vo_osd_changed(OSDTYPE_SUBTITLE
);
1720 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1724 /// Subtitle visibility (RW)
1725 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1726 void *arg
, MPContext
* mpctx
)
1728 if (!mpctx
->sh_video
)
1729 return M_PROPERTY_UNAVAILABLE
;
1732 case M_PROPERTY_SET
:
1734 return M_PROPERTY_ERROR
;
1735 case M_PROPERTY_STEP_UP
:
1736 case M_PROPERTY_STEP_DOWN
:
1737 vo_osd_changed(OSDTYPE_SUBTITLE
);
1739 vo_osd_changed(OSDTYPE_SPU
);
1741 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1746 /// Use margins for libass subtitles (RW)
1747 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1748 void *arg
, MPContext
* mpctx
)
1750 if (!mpctx
->sh_video
)
1751 return M_PROPERTY_UNAVAILABLE
;
1754 case M_PROPERTY_SET
:
1756 return M_PROPERTY_ERROR
;
1757 case M_PROPERTY_STEP_UP
:
1758 case M_PROPERTY_STEP_DOWN
:
1759 ass_force_reload
= 1;
1761 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1766 /// Show only forced subtitles (RW)
1767 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1768 void *arg
, MPContext
* mpctx
)
1771 return M_PROPERTY_UNAVAILABLE
;
1774 case M_PROPERTY_SET
:
1776 return M_PROPERTY_ERROR
;
1777 case M_PROPERTY_STEP_UP
:
1778 case M_PROPERTY_STEP_DOWN
:
1779 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1780 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1781 return M_PROPERTY_OK
;
1783 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1788 #ifdef HAVE_FREETYPE
1789 /// Subtitle scale (RW)
1790 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1795 case M_PROPERTY_SET
:
1797 return M_PROPERTY_ERROR
;
1798 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1801 ass_font_scale
= *(float *) arg
;
1802 ass_force_reload
= 1;
1806 text_font_scale_factor
= *(float *) arg
;
1807 force_load_font
= 1;
1811 return M_PROPERTY_OK
;
1812 case M_PROPERTY_STEP_UP
:
1813 case M_PROPERTY_STEP_DOWN
:
1816 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1817 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1818 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1819 ass_force_reload
= 1;
1823 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1824 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1825 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1826 force_load_font
= 1;
1830 return M_PROPERTY_OK
;
1834 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1837 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1844 /// \defgroup TVProperties TV properties
1845 /// \ingroup Properties
1850 /// TV color settings (RW)
1851 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1855 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1856 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1857 return M_PROPERTY_UNAVAILABLE
;
1860 case M_PROPERTY_SET
:
1862 return M_PROPERTY_ERROR
;
1863 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1864 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1865 case M_PROPERTY_GET
:
1866 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1867 case M_PROPERTY_STEP_UP
:
1868 case M_PROPERTY_STEP_DOWN
:
1869 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1871 return M_PROPERTY_ERROR
;
1872 val
+= (arg
? *(int *) arg
: 1) *
1873 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1874 M_PROPERTY_CLAMP(prop
, val
);
1875 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1877 return M_PROPERTY_ERROR
;
1879 return M_PROPERTY_NOT_IMPLEMENTED
;
1884 #ifdef HAVE_TV_TELETEXT
1885 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1889 int base_ioctl
=(int)prop
->priv
;
1891 for teletext's GET,SET,STEP ioctls this is not 0
1895 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1896 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1897 return M_PROPERTY_UNAVAILABLE
;
1899 return M_PROPERTY_ERROR
;
1902 case M_PROPERTY_GET
:
1904 return M_PROPERTY_ERROR
;
1905 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1907 case M_PROPERTY_SET
:
1909 return M_PROPERTY_ERROR
;
1910 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1911 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1913 case M_PROPERTY_STEP_UP
:
1914 case M_PROPERTY_STEP_DOWN
:
1915 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1916 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1917 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1920 return M_PROPERTY_NOT_IMPLEMENTED
;
1923 return (result
==TVI_CONTROL_TRUE
?M_PROPERTY_OK
:M_PROPERTY_ERROR
);
1926 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1929 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1933 //with tvh==NULL will fail too
1934 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1935 if(result
!=M_PROPERTY_OK
)
1938 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1939 mp_input_set_section("teletext");
1941 mp_input_set_section("tv");
1942 return M_PROPERTY_OK
;
1945 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1948 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1952 case M_PROPERTY_STEP_UP
:
1953 case M_PROPERTY_STEP_DOWN
:
1954 //This should be handled separately
1955 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1956 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1959 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1965 #endif /* HAVE_TV_TELETEXT */
1969 /// All properties available in MPlayer.
1970 /** \ingroup Properties
1972 static const m_option_t mp_properties
[] = {
1974 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1975 M_OPT_RANGE
, 0, 3, NULL
},
1976 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1977 M_OPT_MIN
, -1, 0, NULL
},
1978 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1979 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1980 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1982 { "path", mp_property_path
, CONF_TYPE_STRING
,
1984 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1986 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1987 M_OPT_MIN
, 0, 0, NULL
},
1988 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1989 M_OPT_MIN
, 0, 0, NULL
},
1990 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1991 M_OPT_MIN
, 0, 0, NULL
},
1992 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1993 M_OPT_MIN
, 0, 0, NULL
},
1994 { "length", mp_property_length
, CONF_TYPE_TIME
,
1995 M_OPT_MIN
, 0, 0, NULL
},
1996 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1997 M_OPT_RANGE
, 0, 100, NULL
},
1998 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1999 M_OPT_MIN
, 0, 0, NULL
},
2000 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2001 M_OPT_MIN
, 1, 0, NULL
},
2002 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2003 CONF_RANGE
, -2, 10, NULL
},
2004 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2008 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2009 M_OPT_RANGE
, 0, 100, NULL
},
2010 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2011 M_OPT_RANGE
, 0, 1, NULL
},
2012 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2013 M_OPT_RANGE
, -100, 100, NULL
},
2014 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2016 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2018 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2020 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2022 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2024 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2025 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2026 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2027 M_OPT_RANGE
, -1, 1, NULL
},
2030 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2031 M_OPT_RANGE
, 0, 1, NULL
},
2032 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2033 M_OPT_RANGE
, 0, 1, NULL
},
2034 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2035 M_OPT_RANGE
, 0, 1, NULL
},
2036 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2037 M_OPT_RANGE
, 0, 1, NULL
},
2038 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2039 M_OPT_RANGE
, 0, 1, NULL
},
2040 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2041 M_OPT_RANGE
, 0, 2, NULL
},
2042 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2043 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2044 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2045 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2046 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2047 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2048 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2049 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2050 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2051 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2052 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2053 M_OPT_RANGE
, 0, 1, NULL
},
2054 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2055 M_OPT_RANGE
, 0, 1, NULL
},
2056 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2058 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2060 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2062 { "width", mp_property_width
, CONF_TYPE_INT
,
2064 { "height", mp_property_height
, CONF_TYPE_INT
,
2066 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2068 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2070 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2071 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2072 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2073 CONF_RANGE
, -1, 65535, NULL
},
2076 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2077 M_OPT_MIN
, -1, 0, NULL
},
2078 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2080 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2081 M_OPT_MIN
, -1, 0, NULL
},
2082 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2083 M_OPT_MIN
, -1, 0, NULL
},
2084 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2085 M_OPT_MIN
, -1, 0, NULL
},
2086 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2088 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2089 M_OPT_RANGE
, 0, 100, NULL
},
2090 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2091 M_OPT_RANGE
, 0, 2, NULL
},
2092 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2093 M_OPT_RANGE
, 0, 1, NULL
},
2094 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2095 M_OPT_RANGE
, 0, 1, NULL
},
2096 #ifdef HAVE_FREETYPE
2097 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2098 M_OPT_RANGE
, 0, 100, NULL
},
2101 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2102 M_OPT_RANGE
, 0, 1, NULL
},
2106 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2107 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2108 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2109 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2110 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2111 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2112 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2116 #ifdef HAVE_TV_TELETEXT
2117 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2118 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2119 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2120 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2121 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2122 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2123 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2124 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2125 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2126 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2129 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2133 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2135 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2138 char* mp_property_print(const char *name
, void* ctx
)
2141 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2146 char *property_expand_string(MPContext
* mpctx
, char *str
)
2148 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2151 void property_print_help(void)
2153 m_properties_print_help_list(mp_properties
);
2162 * \defgroup Command2Property Command to property bridge
2164 * It is used to handle most commands that just set a property
2165 * and optionally display something on the OSD.
2166 * Two kinds of commands are handled: adjust or toggle.
2168 * Adjust commands take 1 or 2 parameters: <value> <abs>
2169 * If <abs> is non-zero the property is set to the given value
2170 * otherwise it is adjusted.
2172 * Toggle commands take 0 or 1 parameters. With no parameter
2173 * or a value less than the property minimum it just steps the
2174 * property to its next value. Otherwise it sets it to the given
2180 /// List of the commands that can be handled by setting a property.
2186 /// set/adjust or toggle command
2188 /// progressbar type
2190 /// osd msg id if it must be shared
2192 /// osd msg template
2193 const char *osd_msg
;
2194 } set_prop_cmd
[] = {
2196 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2197 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2198 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2200 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2201 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2202 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2203 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2204 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2206 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2207 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2208 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2209 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2210 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2211 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2212 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2213 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2214 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2215 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2216 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2217 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2219 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2220 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2221 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2222 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2223 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2224 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2225 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2226 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2227 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2228 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2229 #ifdef HAVE_FREETYPE
2230 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2233 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2236 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2237 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2238 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2239 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2241 { NULL
, 0, 0, 0, -1, NULL
}
2245 /// Handle commands that set a property.
2246 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2252 // look for the command
2253 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2254 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2256 if (!(pname
= set_prop_cmd
[i
].name
))
2259 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2263 if (set_prop_cmd
[i
].toggle
) {
2265 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2266 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2268 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2269 } else if (cmd
->args
[1].v
.i
) //set
2270 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2272 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2277 if (set_prop_cmd
[i
].osd_progbar
) {
2278 if (prop
->type
== CONF_TYPE_INT
) {
2279 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2280 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2281 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2282 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2284 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2285 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2286 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2288 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2289 "Property use an unsupported type.\n");
2293 if (set_prop_cmd
[i
].osd_msg
) {
2294 char *val
= mp_property_print(pname
, mpctx
);
2296 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2297 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2298 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2306 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2308 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2309 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2311 if (!set_property_command(mpctx
, cmd
))
2317 mpctx
->osd_show_percentage
= sh_video
->fps
;
2318 v
= cmd
->args
[0].v
.f
;
2319 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2320 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2323 mpctx
->osd_function
=
2324 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2326 } else if (abs
) { /* Absolute seek by percentage */
2329 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2330 rel_seek_secs
= v
/ 100.0;
2333 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2339 case MP_CMD_SET_PROPERTY
:{
2340 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2341 cmd
->args
[1].v
.s
, mpctx
);
2342 if (r
== M_PROPERTY_UNKNOWN
)
2343 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2344 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2346 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2347 "Failed to set property '%s' to '%s'.\n",
2348 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2352 case MP_CMD_STEP_PROPERTY
:{
2357 if (cmd
->args
[1].v
.f
) {
2359 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2360 M_PROPERTY_GET_TYPE
,
2361 &prop
, mpctx
)) <= 0)
2363 if(prop
->type
== CONF_TYPE_INT
||
2364 prop
->type
== CONF_TYPE_FLAG
)
2365 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2366 else if(prop
->type
== CONF_TYPE_FLOAT
)
2367 arg
= &cmd
->args
[1].v
.f
;
2368 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2369 prop
->type
== CONF_TYPE_TIME
)
2370 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2371 else if(prop
->type
== CONF_TYPE_POSITION
)
2372 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2374 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2375 "Ignoring step size stepping property '%s'.\n",
2378 r
= mp_property_do(cmd
->args
[0].v
.s
,
2379 cmd
->args
[2].v
.i
< 0 ?
2380 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2383 if (r
== M_PROPERTY_UNKNOWN
)
2384 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2385 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2387 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2388 "Failed to increment property '%s' by %f.\n",
2389 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2393 case MP_CMD_GET_PROPERTY
:{
2395 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2396 &tmp
, mpctx
) <= 0) {
2397 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2398 "Failed to get value of property '%s'.\n",
2402 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2403 cmd
->args
[0].v
.s
, tmp
);
2408 case MP_CMD_EDL_MARK
:
2410 float v
= sh_video
? sh_video
->pts
:
2411 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2414 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2415 mpctx
->begin_skip
= v
;
2416 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2418 if (mpctx
->begin_skip
> v
)
2419 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2421 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2422 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2424 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2429 case MP_CMD_SWITCH_RATIO
:
2430 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2431 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2433 movie_aspect
= cmd
->args
[0].v
.f
;
2434 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2437 case MP_CMD_SPEED_INCR
:{
2438 float v
= cmd
->args
[0].v
.f
;
2439 playback_speed
+= v
;
2440 build_afilter_chain(sh_audio
, &ao_data
);
2441 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2445 case MP_CMD_SPEED_MULT
:{
2446 float v
= cmd
->args
[0].v
.f
;
2447 playback_speed
*= v
;
2448 build_afilter_chain(sh_audio
, &ao_data
);
2449 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2453 case MP_CMD_SPEED_SET
:{
2454 float v
= cmd
->args
[0].v
.f
;
2456 build_afilter_chain(sh_audio
, &ao_data
);
2457 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2461 case MP_CMD_FRAME_STEP
:
2467 case MP_CMD_FILE_FILTER
:
2468 file_filter
= cmd
->args
[0].v
.i
;
2472 exit_player_with_rc(MSGTR_Exit_quit
,
2473 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2475 case MP_CMD_PLAY_TREE_STEP
:{
2476 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2477 int force
= cmd
->args
[1].v
.i
;
2483 for (i
= 0; i
< n
; i
++)
2486 for (i
= 0; i
< -1 * n
; i
++)
2491 if (!force
&& mpctx
->playtree_iter
) {
2492 play_tree_iter_t
*i
=
2493 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2494 if (play_tree_iter_step(i
, n
, 0) ==
2495 PLAY_TREE_ITER_ENTRY
)
2497 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2498 play_tree_iter_free(i
);
2500 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2502 mpctx
->play_tree_step
= n
;
2508 case MP_CMD_PLAY_TREE_UP_STEP
:{
2509 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2510 int force
= cmd
->args
[1].v
.i
;
2512 if (!force
&& mpctx
->playtree_iter
) {
2513 play_tree_iter_t
*i
=
2514 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2515 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2516 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2517 play_tree_iter_free(i
);
2519 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2524 case MP_CMD_PLAY_ALT_SRC_STEP
:
2525 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2526 int v
= cmd
->args
[0].v
.i
;
2528 && mpctx
->playtree_iter
->file
<
2529 mpctx
->playtree_iter
->num_files
)
2530 mpctx
->eof
= PT_NEXT_SRC
;
2531 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2532 mpctx
->eof
= PT_PREV_SRC
;
2537 case MP_CMD_SUB_STEP
:
2539 int movement
= cmd
->args
[0].v
.i
;
2540 step_sub(subdata
, sh_video
->pts
, movement
);
2544 ass_step_sub(ass_track
,
2546 sub_delay
) * 1000 + .5, movement
) / 1000.;
2548 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2549 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2553 case MP_CMD_SUB_LOG
:
2558 int v
= cmd
->args
[0].v
.i
;
2560 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2561 if (osd_level
> max
)
2564 osd_level
= (osd_level
+ 1) % (max
+ 1);
2566 osd_level
= v
> max
? max
: v
;
2567 /* Show OSD state when disabled, but not when an explicit
2568 argument is given to the OSD command, i.e. in slave mode. */
2569 if (v
== -1 && osd_level
<= 1)
2570 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2572 osd_level
? MSGTR_OSDenabled
:
2575 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2579 case MP_CMD_OSD_SHOW_TEXT
:
2580 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2582 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2583 "%-.63s", cmd
->args
[0].v
.s
);
2586 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2587 char *txt
= m_properties_expand_string(mp_properties
,
2590 /* if no argument supplied take default osd_duration, else <arg> ms. */
2592 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2594 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2601 case MP_CMD_LOADFILE
:{
2602 play_tree_t
*e
= play_tree_new();
2603 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2605 if (cmd
->args
[1].v
.i
) // append
2606 play_tree_append_entry(mpctx
->playtree
, e
);
2608 // Go back to the starting point.
2609 while (play_tree_iter_up_step
2610 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2612 play_tree_free_list(mpctx
->playtree
->child
, 1);
2613 play_tree_set_child(mpctx
->playtree
, e
);
2614 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2615 mpctx
->eof
= PT_NEXT_SRC
;
2621 case MP_CMD_LOADLIST
:{
2622 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2624 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2625 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2627 if (cmd
->args
[1].v
.i
) // append
2628 play_tree_append_entry(mpctx
->playtree
, e
);
2630 // Go back to the starting point.
2631 while (play_tree_iter_up_step
2632 (mpctx
->playtree_iter
, 0, 1)
2633 != PLAY_TREE_ITER_END
)
2635 play_tree_free_list(mpctx
->playtree
->child
, 1);
2636 play_tree_set_child(mpctx
->playtree
, e
);
2637 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2638 mpctx
->eof
= PT_NEXT_SRC
;
2646 case MP_CMD_RADIO_STEP_CHANNEL
:
2647 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2648 int v
= cmd
->args
[0].v
.i
;
2650 radio_step_channel(mpctx
->demuxer
->stream
,
2651 RADIO_CHANNEL_HIGHER
);
2653 radio_step_channel(mpctx
->demuxer
->stream
,
2654 RADIO_CHANNEL_LOWER
);
2655 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2656 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2658 radio_get_channel_name(mpctx
->demuxer
->stream
));
2663 case MP_CMD_RADIO_SET_CHANNEL
:
2664 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2665 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2666 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2667 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2669 radio_get_channel_name(mpctx
->demuxer
->stream
));
2674 case MP_CMD_RADIO_SET_FREQ
:
2675 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2676 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2679 case MP_CMD_RADIO_STEP_FREQ
:
2680 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2681 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2686 case MP_CMD_TV_START_SCAN
:
2687 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2688 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2690 case MP_CMD_TV_SET_FREQ
:
2691 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2692 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2693 cmd
->args
[0].v
.f
* 16.0);
2695 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2696 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2697 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2698 pvr_get_current_channelname (mpctx
->stream
),
2699 pvr_get_current_stationname (mpctx
->stream
));
2701 #endif /* HAVE_PVR */
2704 case MP_CMD_TV_STEP_FREQ
:
2705 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2706 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2707 cmd
->args
[0].v
.f
* 16.0);
2709 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2710 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2711 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2712 pvr_get_current_channelname (mpctx
->stream
),
2713 pvr_get_current_frequency (mpctx
->stream
));
2715 #endif /* HAVE_PVR */
2718 case MP_CMD_TV_SET_NORM
:
2719 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2720 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2724 case MP_CMD_TV_STEP_CHANNEL
:{
2725 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2726 int v
= cmd
->args
[0].v
.i
;
2728 tv_step_channel((tvi_handle_t
*) (mpctx
->
2732 tv_step_channel((tvi_handle_t
*) (mpctx
->
2736 if (tv_channel_list
) {
2737 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2738 MSGTR_OSDChannel
, tv_channel_current
->name
);
2739 //vo_osd_changed(OSDTYPE_SUBTITLE);
2743 else if (mpctx
->stream
&&
2744 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2745 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2746 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2747 pvr_get_current_channelname (mpctx
->stream
),
2748 pvr_get_current_stationname (mpctx
->stream
));
2750 #endif /* HAVE_PVR */
2752 #ifdef HAS_DVBIN_SUPPORT
2753 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2755 int v
= cmd
->args
[0].v
.i
;
2757 mpctx
->last_dvb_step
= v
;
2759 dir
= DVB_CHANNEL_HIGHER
;
2761 dir
= DVB_CHANNEL_LOWER
;
2764 if (dvb_step_channel(mpctx
->stream
, dir
))
2765 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2767 #endif /* HAS_DVBIN_SUPPORT */
2770 case MP_CMD_TV_SET_CHANNEL
:
2771 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2772 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2774 if (tv_channel_list
) {
2775 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2776 MSGTR_OSDChannel
, tv_channel_current
->name
);
2777 //vo_osd_changed(OSDTYPE_SUBTITLE);
2781 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2782 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2783 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2784 pvr_get_current_channelname (mpctx
->stream
),
2785 pvr_get_current_stationname (mpctx
->stream
));
2787 #endif /* HAVE_PVR */
2790 #ifdef HAS_DVBIN_SUPPORT
2791 case MP_CMD_DVB_SET_CHANNEL
:
2792 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2793 mpctx
->last_dvb_step
= 1;
2796 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2797 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2800 #endif /* HAS_DVBIN_SUPPORT */
2802 case MP_CMD_TV_LAST_CHANNEL
:
2803 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2804 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2805 if (tv_channel_list
) {
2806 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2807 MSGTR_OSDChannel
, tv_channel_current
->name
);
2808 //vo_osd_changed(OSDTYPE_SUBTITLE);
2812 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2813 pvr_set_lastchannel (mpctx
->stream
);
2814 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2815 pvr_get_current_channelname (mpctx
->stream
),
2816 pvr_get_current_stationname (mpctx
->stream
));
2818 #endif /* HAVE_PVR */
2821 case MP_CMD_TV_STEP_NORM
:
2822 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2823 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2826 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2827 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2828 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2830 #ifdef HAVE_TV_TELETEXT
2831 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2833 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2834 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2835 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2838 case MP_CMD_TV_TELETEXT_GO_LINK
:
2840 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2841 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2842 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2845 #endif /* HAVE_TV_TELETEXT */
2848 case MP_CMD_SUB_LOAD
:
2850 int n
= mpctx
->set_of_sub_size
;
2851 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2852 if (n
!= mpctx
->set_of_sub_size
) {
2853 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2854 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2855 mpctx
->global_sub_size
;
2856 ++mpctx
->global_sub_size
;
2861 case MP_CMD_SUB_REMOVE
:
2863 int v
= cmd
->args
[0].v
.i
;
2866 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2867 subd
= mpctx
->set_of_subtitles
[v
];
2868 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2869 MSGTR_RemovedSubtitleFile
, v
+ 1,
2870 filename_recode(subd
->filename
));
2872 mpctx
->set_of_subtitles
[v
] = NULL
;
2874 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2875 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2876 mpctx
->set_of_sub_size
= 0;
2877 if (mpctx
->set_of_sub_pos
>= 0) {
2878 mpctx
->global_sub_pos
= -2;
2880 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2882 } else if (v
< mpctx
->set_of_sub_size
) {
2883 subd
= mpctx
->set_of_subtitles
[v
];
2884 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2885 MSGTR_RemovedSubtitleFile
, v
+ 1,
2886 filename_recode(subd
->filename
));
2888 if (mpctx
->set_of_sub_pos
== v
) {
2889 mpctx
->global_sub_pos
= -2;
2891 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2892 } else if (mpctx
->set_of_sub_pos
> v
) {
2893 --mpctx
->set_of_sub_pos
;
2894 --mpctx
->global_sub_pos
;
2896 while (++v
< mpctx
->set_of_sub_size
)
2897 mpctx
->set_of_subtitles
[v
- 1] =
2898 mpctx
->set_of_subtitles
[v
];
2899 --mpctx
->set_of_sub_size
;
2900 --mpctx
->global_sub_size
;
2901 if (mpctx
->set_of_sub_size
<= 0)
2902 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2903 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2908 case MP_CMD_GET_SUB_VISIBILITY
:
2910 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2911 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2915 case MP_CMD_SCREENSHOT
:
2916 if (vo_config_count
) {
2917 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2919 ((vf_instance_t
*) sh_video
->vfilter
)->
2920 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2922 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2926 case MP_CMD_VF_CHANGE_RECTANGLE
:
2927 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2930 case MP_CMD_GET_TIME_LENGTH
:{
2931 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2932 demuxer_get_time_length(mpctx
->demuxer
));
2936 case MP_CMD_GET_FILENAME
:{
2937 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2938 get_metadata(META_NAME
));
2942 case MP_CMD_GET_VIDEO_CODEC
:{
2943 char *inf
= get_metadata(META_VIDEO_CODEC
);
2946 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2951 case MP_CMD_GET_VIDEO_BITRATE
:{
2952 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2955 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2960 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2961 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2964 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2965 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2970 case MP_CMD_GET_AUDIO_CODEC
:{
2971 char *inf
= get_metadata(META_AUDIO_CODEC
);
2974 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2979 case MP_CMD_GET_AUDIO_BITRATE
:{
2980 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2983 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
2988 case MP_CMD_GET_AUDIO_SAMPLES
:{
2989 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
2992 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
2997 case MP_CMD_GET_META_TITLE
:{
2998 char *inf
= get_metadata(META_INFO_TITLE
);
3001 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3006 case MP_CMD_GET_META_ARTIST
:{
3007 char *inf
= get_metadata(META_INFO_ARTIST
);
3010 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3015 case MP_CMD_GET_META_ALBUM
:{
3016 char *inf
= get_metadata(META_INFO_ALBUM
);
3019 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3024 case MP_CMD_GET_META_YEAR
:{
3025 char *inf
= get_metadata(META_INFO_YEAR
);
3028 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3033 case MP_CMD_GET_META_COMMENT
:{
3034 char *inf
= get_metadata(META_INFO_COMMENT
);
3037 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3042 case MP_CMD_GET_META_TRACK
:{
3043 char *inf
= get_metadata(META_INFO_TRACK
);
3046 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3051 case MP_CMD_GET_META_GENRE
:{
3052 char *inf
= get_metadata(META_INFO_GENRE
);
3055 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3060 case MP_CMD_GET_VO_FULLSCREEN
:
3061 if (mpctx
->video_out
&& vo_config_count
)
3062 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3065 case MP_CMD_GET_PERCENT_POS
:
3066 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3067 demuxer_get_percent_pos(mpctx
->demuxer
));
3070 case MP_CMD_GET_TIME_POS
:{
3073 pos
= sh_video
->pts
;
3074 else if (sh_audio
&& mpctx
->audio_out
)
3076 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3078 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3085 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3091 case MP_CMD_KEYDOWN_EVENTS
:
3092 mplayer_put_key(cmd
->args
[0].v
.i
);
3095 case MP_CMD_SET_MOUSE_POS
:{
3096 int pointer_x
, pointer_y
;
3098 pointer_x
= cmd
->args
[0].v
.i
;
3099 pointer_y
= cmd
->args
[1].v
.i
;
3100 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3102 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3103 && dx
> 0.0 && dy
> 0.0) {
3105 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3106 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3107 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3108 pointer_x
, pointer_y
, &button
);
3110 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3111 "Selected button number %d", button
);
3115 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3116 menu_update_mouse_pos(dx
, dy
);
3122 case MP_CMD_DVDNAV
:{
3124 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3127 mp_dvdnav_handle_input(mpctx
->stream
,cmd
->args
[0].v
.i
,&button
);
3129 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3130 "Selected button number %d", button
);
3134 case MP_CMD_SWITCH_TITLE
:
3135 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3136 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3143 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3144 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3147 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3148 "Received unknown cmd %s\n", cmd
->name
);
3151 switch (cmd
->pausing
) {
3152 case 1: // "pausing"
3153 mpctx
->osd_function
= OSD_PAUSE
;
3155 case 3: // "pausing_toggle"
3156 mpctx
->was_paused
= !mpctx
->was_paused
;
3157 if (mpctx
->was_paused
)
3158 mpctx
->osd_function
= OSD_PAUSE
;
3159 else if (mpctx
->osd_function
== OSD_PAUSE
)
3160 mpctx
->osd_function
= OSD_PLAY
;
3162 case 2: // "pausing_keep"
3163 if (mpctx
->was_paused
)
3164 mpctx
->osd_function
= OSD_PAUSE
;