8 #include "input/input.h"
9 #include "stream/stream.h"
10 #include "libmpdemux/demuxer.h"
11 #include "libmpdemux/stheader.h"
12 #include "codec-cfg.h"
14 #include "libvo/sub.h"
16 #include "m_property.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 "libmpcodecs/dec_video.h"
32 #include "stream/tv.h"
35 #include "stream/stream_radio.h"
38 #include "stream/pvr.h"
40 #ifdef HAS_DVBIN_SUPPORT
41 #include "stream/dvbin.h"
44 #include "stream/stream_dvd.h"
47 #include "stream/stream_dvdnav.h"
50 #include "libass/ass.h"
51 #include "libass/ass_mp.h"
55 #include "libmenu/menu.h"
58 #include "gui/interface.h"
63 #include "libavutil/avstring.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
));
347 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
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
);
362 abs_seek_pos
= SEEK_ABSOLUTE
;
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) {
432 abs_seek_pos
= SEEK_ABSOLUTE
;
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 sh_audio_t
* sh
= mpctx
->sh_audio
;
815 av_strlcpy(lang
, sh
->lang
, 40);
817 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
818 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
828 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
829 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
831 *(char **) arg
= malloc(64);
832 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
834 return M_PROPERTY_OK
;
836 case M_PROPERTY_STEP_UP
:
838 if (action
== M_PROPERTY_SET
&& arg
)
839 tmp
= *((int *) arg
);
842 current_id
= mpctx
->demuxer
->audio
->id
;
843 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
846 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
847 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
848 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
850 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
852 sh2
->ds
= mpctx
->demuxer
->audio
;
853 mpctx
->sh_audio
= sh2
;
854 reinit_audio_chain();
857 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
858 return M_PROPERTY_OK
;
860 return M_PROPERTY_NOT_IMPLEMENTED
;
865 /// Selected video id (RW)
866 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
869 int current_id
= -1, tmp
;
873 if (!mpctx
->sh_video
)
874 return M_PROPERTY_UNAVAILABLE
;
876 return M_PROPERTY_ERROR
;
877 *(int *) arg
= video_id
;
878 return M_PROPERTY_OK
;
879 case M_PROPERTY_PRINT
:
880 if (!mpctx
->sh_video
)
881 return M_PROPERTY_UNAVAILABLE
;
883 return M_PROPERTY_ERROR
;
886 *(char **) arg
= strdup(MSGTR_Disabled
);
888 char lang
[40] = MSGTR_Unknown
;
889 *(char **) arg
= malloc(64);
890 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
892 return M_PROPERTY_OK
;
894 case M_PROPERTY_STEP_UP
:
896 current_id
= mpctx
->demuxer
->video
->id
;
897 if (action
== M_PROPERTY_SET
&& arg
)
898 tmp
= *((int *) arg
);
901 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
903 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
904 && current_id
!= -2))
905 uninit_player(INITIALIZED_VCODEC
|
906 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
907 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
909 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
911 sh2
->ds
= mpctx
->demuxer
->video
;
912 mpctx
->sh_video
= sh2
;
913 reinit_video_chain();
916 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
917 return M_PROPERTY_OK
;
920 return M_PROPERTY_NOT_IMPLEMENTED
;
924 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
927 demux_program_t prog
;
930 case M_PROPERTY_STEP_UP
:
932 if (action
== M_PROPERTY_SET
&& arg
)
933 prog
.progid
= *((int *) arg
);
937 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
938 &prog
) == DEMUXER_CTRL_NOTIMPL
)
939 return M_PROPERTY_ERROR
;
941 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
942 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
943 return M_PROPERTY_OK
;
946 return M_PROPERTY_NOT_IMPLEMENTED
;
952 /// \defgroup VideoProperties Video properties
953 /// \ingroup Properties
956 /// Fullscreen state (RW)
957 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
961 if (!mpctx
->video_out
)
962 return M_PROPERTY_UNAVAILABLE
;
967 return M_PROPERTY_ERROR
;
968 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
969 if (vo_fs
== !!*(int *) arg
)
970 return M_PROPERTY_OK
;
971 case M_PROPERTY_STEP_UP
:
972 case M_PROPERTY_STEP_DOWN
:
975 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
979 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
980 return M_PROPERTY_OK
;
982 return m_property_flag(prop
, action
, arg
, &vo_fs
);
986 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
987 void *arg
, MPContext
* mpctx
)
991 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
992 return M_PROPERTY_UNAVAILABLE
;
993 vf
= mpctx
->sh_video
->vfilter
;
997 return M_PROPERTY_ERROR
;
998 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
999 return M_PROPERTY_OK
;
1000 case M_PROPERTY_SET
:
1002 return M_PROPERTY_ERROR
;
1003 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1004 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1005 return M_PROPERTY_OK
;
1006 case M_PROPERTY_STEP_UP
:
1007 case M_PROPERTY_STEP_DOWN
:
1008 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1009 deinterlace
= !deinterlace
;
1010 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1011 return M_PROPERTY_OK
;
1013 return M_PROPERTY_NOT_IMPLEMENTED
;
1017 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1021 if (!mpctx
->video_out
1022 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1023 return M_PROPERTY_UNAVAILABLE
;
1026 case M_PROPERTY_SET
:
1028 return M_PROPERTY_ERROR
;
1029 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1030 vo_panscan
= *(float *) arg
;
1031 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1032 return M_PROPERTY_OK
;
1033 case M_PROPERTY_STEP_UP
:
1034 case M_PROPERTY_STEP_DOWN
:
1035 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1036 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1039 else if (vo_panscan
< 0)
1041 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1042 return M_PROPERTY_OK
;
1044 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1048 /// Helper to set vo flags.
1049 /** \ingroup PropertyImplHelper
1051 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1052 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1055 if (!mpctx
->video_out
)
1056 return M_PROPERTY_UNAVAILABLE
;
1059 case M_PROPERTY_SET
:
1061 return M_PROPERTY_ERROR
;
1062 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1063 if (*vo_var
== !!*(int *) arg
)
1064 return M_PROPERTY_OK
;
1065 case M_PROPERTY_STEP_UP
:
1066 case M_PROPERTY_STEP_DOWN
:
1067 if (vo_config_count
)
1068 mpctx
->video_out
->control(vo_ctrl
, 0);
1069 return M_PROPERTY_OK
;
1071 return m_property_flag(prop
, action
, arg
, vo_var
);
1075 /// Window always on top (RW)
1076 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1079 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1083 /// Display in the root window (RW)
1084 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1087 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1088 &vo_rootwin
, mpctx
);
1091 /// Show window borders (RW)
1092 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1095 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1099 /// Framedropping state (RW)
1100 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1101 void *arg
, MPContext
* mpctx
)
1104 if (!mpctx
->sh_video
)
1105 return M_PROPERTY_UNAVAILABLE
;
1108 case M_PROPERTY_PRINT
:
1110 return M_PROPERTY_ERROR
;
1111 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1112 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1114 return M_PROPERTY_OK
;
1116 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1120 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1121 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1124 int *gamma
= prop
->priv
, r
, val
;
1126 if (!mpctx
->sh_video
)
1127 return M_PROPERTY_UNAVAILABLE
;
1129 if (gamma
[0] == 1000) {
1131 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1135 case M_PROPERTY_SET
:
1137 return M_PROPERTY_ERROR
;
1138 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1139 *gamma
= *(int *) arg
;
1140 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1144 case M_PROPERTY_GET
:
1145 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1147 return M_PROPERTY_ERROR
;
1149 return M_PROPERTY_OK
;
1152 case M_PROPERTY_STEP_UP
:
1153 case M_PROPERTY_STEP_DOWN
:
1154 *gamma
+= (arg
? *(int *) arg
: 1) *
1155 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1156 M_PROPERTY_CLAMP(prop
, *gamma
);
1157 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1162 return M_PROPERTY_NOT_IMPLEMENTED
;
1166 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1167 int l
= strlen(prop
->name
);
1168 char tv_prop
[3 + l
+ 1];
1169 sprintf(tv_prop
, "tv_%s", prop
->name
);
1170 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1174 return M_PROPERTY_UNAVAILABLE
;
1178 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1181 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1184 /// Video codec tag (RO)
1185 static int mp_property_video_format(m_option_t
* prop
, int action
,
1186 void *arg
, MPContext
* mpctx
)
1189 if (!mpctx
->sh_video
)
1190 return M_PROPERTY_UNAVAILABLE
;
1192 case M_PROPERTY_PRINT
:
1194 return M_PROPERTY_ERROR
;
1195 switch(mpctx
->sh_video
->format
) {
1197 meta
= strdup ("mpeg1"); break;
1199 meta
= strdup ("mpeg2"); break;
1201 meta
= strdup ("mpeg4"); break;
1203 meta
= strdup ("h264"); break;
1205 if(mpctx
->sh_video
->format
>= 0x20202020) {
1207 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1210 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1213 *(char**)arg
= meta
;
1214 return M_PROPERTY_OK
;
1216 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1219 /// Video codec name (RO)
1220 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1221 void *arg
, MPContext
* mpctx
)
1223 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1224 return M_PROPERTY_UNAVAILABLE
;
1225 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1229 /// Video bitrate (RO)
1230 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1231 void *arg
, MPContext
* mpctx
)
1233 if (!mpctx
->sh_video
)
1234 return M_PROPERTY_UNAVAILABLE
;
1235 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1238 /// Video display width (RO)
1239 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1242 if (!mpctx
->sh_video
)
1243 return M_PROPERTY_UNAVAILABLE
;
1244 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1247 /// Video display height (RO)
1248 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1251 if (!mpctx
->sh_video
)
1252 return M_PROPERTY_UNAVAILABLE
;
1253 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1257 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1260 if (!mpctx
->sh_video
)
1261 return M_PROPERTY_UNAVAILABLE
;
1262 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1265 /// Video aspect (RO)
1266 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1269 if (!mpctx
->sh_video
)
1270 return M_PROPERTY_UNAVAILABLE
;
1271 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1276 /// \defgroup SubProprties Subtitles properties
1277 /// \ingroup Properties
1280 /// Text subtitle position (RW)
1281 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1284 if (!mpctx
->sh_video
)
1285 return M_PROPERTY_UNAVAILABLE
;
1288 case M_PROPERTY_SET
:
1290 return M_PROPERTY_ERROR
;
1291 case M_PROPERTY_STEP_UP
:
1292 case M_PROPERTY_STEP_DOWN
:
1293 vo_osd_changed(OSDTYPE_SUBTITLE
);
1295 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1299 /// Selected subtitles (RW)
1300 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1303 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1304 const int global_sub_size
= mpctx
->global_sub_size
;
1305 int source
= -1, reset_spu
= 0;
1308 if (global_sub_size
<= 0)
1309 return M_PROPERTY_UNAVAILABLE
;
1312 case M_PROPERTY_GET
:
1314 return M_PROPERTY_ERROR
;
1315 *(int *) arg
= mpctx
->global_sub_pos
;
1316 return M_PROPERTY_OK
;
1317 case M_PROPERTY_PRINT
:
1319 return M_PROPERTY_ERROR
;
1320 *(char **) arg
= malloc(64);
1321 (*(char **) arg
)[63] = 0;
1324 sub_name
= subdata
->filename
;
1326 if (ass_track
&& ass_track
->name
)
1327 sub_name
= ass_track
->name
;
1332 if ((tmp2
= strrchr(tmp
, '/')))
1335 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1336 mpctx
->set_of_sub_pos
+ 1,
1337 strlen(tmp
) < 20 ? "" : "...",
1338 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1339 return M_PROPERTY_OK
;
1342 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1343 if (vo_spudec
&& dvdsub_id
>= 0) {
1344 unsigned char lang
[3];
1345 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1346 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1347 return M_PROPERTY_OK
;
1353 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1354 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1355 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1356 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1357 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1358 if (!lang
) lang
= MSGTR_Unknown
;
1359 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1360 return M_PROPERTY_OK
;
1363 if (vo_vobsub
&& vobsub_id
>= 0) {
1364 const char *language
= MSGTR_Unknown
;
1365 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1366 snprintf(*(char **) arg
, 63, "(%d) %s",
1367 vobsub_id
, language
? language
: MSGTR_Unknown
);
1368 return M_PROPERTY_OK
;
1371 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1372 && dvdsub_id
>= 0) {
1374 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1375 lang
[0] = code
>> 8;
1378 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1379 return M_PROPERTY_OK
;
1382 if (dvdsub_id
>= 0) {
1383 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1384 return M_PROPERTY_OK
;
1386 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1387 return M_PROPERTY_OK
;
1389 case M_PROPERTY_SET
:
1391 return M_PROPERTY_ERROR
;
1392 if (*(int *) arg
< -1)
1394 else if (*(int *) arg
>= global_sub_size
)
1395 *(int *) arg
= global_sub_size
- 1;
1396 mpctx
->global_sub_pos
= *(int *) arg
;
1398 case M_PROPERTY_STEP_UP
:
1399 mpctx
->global_sub_pos
+= 2;
1400 mpctx
->global_sub_pos
=
1401 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1403 case M_PROPERTY_STEP_DOWN
:
1404 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1405 mpctx
->global_sub_pos
=
1406 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1409 return M_PROPERTY_NOT_IMPLEMENTED
;
1412 if (mpctx
->global_sub_pos
>= 0)
1413 source
= sub_source(mpctx
);
1415 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1416 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1418 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1419 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1420 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1421 mpctx
->global_sub_pos
, source
);
1423 mpctx
->set_of_sub_pos
= -1;
1437 if (source
== SUB_SOURCE_VOBSUB
) {
1438 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1439 } else if (source
== SUB_SOURCE_SUBS
) {
1440 mpctx
->set_of_sub_pos
=
1441 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1443 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1444 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1448 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1449 vo_osd_changed(OSDTYPE_SUBTITLE
);
1451 } else if (source
== SUB_SOURCE_DEMUX
) {
1453 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1454 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1456 // default: assume 1:1 mapping of sid and stream id
1457 d_sub
->id
= dvdsub_id
;
1458 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1459 ds_free_packs(d_sub
);
1460 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1461 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1462 if (sh
&& sh
->sid
== dvdsub_id
) {
1468 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1469 sh_sub_t
*sh
= d_sub
->sh
;
1470 if (sh
->type
== 'v')
1473 else if (ass_enabled
)
1474 ass_track
= sh
->ass_track
;
1484 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1485 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1486 && dvdsub_id
< 0 && reset_spu
) {
1488 d_sub
->id
= dvdsub_id
;
1491 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1493 return M_PROPERTY_OK
;
1496 /// Selected sub source (RW)
1497 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1501 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1502 return M_PROPERTY_UNAVAILABLE
;
1505 case M_PROPERTY_GET
:
1507 return M_PROPERTY_ERROR
;
1508 *(int *) arg
= sub_source(mpctx
);
1509 return M_PROPERTY_OK
;
1510 case M_PROPERTY_PRINT
:
1512 return M_PROPERTY_ERROR
;
1513 *(char **) arg
= malloc(64);
1514 (*(char **) arg
)[63] = 0;
1515 switch (sub_source(mpctx
))
1517 case SUB_SOURCE_SUBS
:
1518 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1520 case SUB_SOURCE_VOBSUB
:
1521 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1523 case SUB_SOURCE_DEMUX
:
1524 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1527 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1529 return M_PROPERTY_OK
;
1530 case M_PROPERTY_SET
:
1532 return M_PROPERTY_ERROR
;
1533 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1534 if (*(int *) arg
< 0)
1535 mpctx
->global_sub_pos
= -1;
1536 else if (*(int *) arg
!= sub_source(mpctx
)) {
1537 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1538 return M_PROPERTY_UNAVAILABLE
;
1539 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1542 case M_PROPERTY_STEP_UP
:
1543 case M_PROPERTY_STEP_DOWN
: {
1544 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1545 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1546 int step
= (step_all
> 0) ? 1 : -1;
1547 int cur_source
= sub_source(mpctx
);
1548 source
= cur_source
;
1551 if (source
>= SUB_SOURCES
)
1553 else if (source
< -1)
1554 source
= SUB_SOURCES
- 1;
1555 if (source
== cur_source
|| source
== -1 ||
1556 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1559 if (source
== cur_source
)
1560 return M_PROPERTY_OK
;
1562 mpctx
->global_sub_pos
= -1;
1564 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1568 return M_PROPERTY_NOT_IMPLEMENTED
;
1570 --mpctx
->global_sub_pos
;
1571 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1574 /// Selected subtitles from specific source (RW)
1575 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1578 int source
, is_cur_source
, offset
;
1579 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1580 return M_PROPERTY_UNAVAILABLE
;
1582 if (!strcmp(prop
->name
, "sub_file"))
1583 source
= SUB_SOURCE_SUBS
;
1584 else if (!strcmp(prop
->name
, "sub_vob"))
1585 source
= SUB_SOURCE_VOBSUB
;
1586 else if (!strcmp(prop
->name
, "sub_demux"))
1587 source
= SUB_SOURCE_DEMUX
;
1589 return M_PROPERTY_ERROR
;
1591 offset
= mpctx
->global_sub_indices
[source
];
1592 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1593 return M_PROPERTY_UNAVAILABLE
;
1595 is_cur_source
= sub_source(mpctx
) == source
;
1597 case M_PROPERTY_GET
:
1599 return M_PROPERTY_ERROR
;
1600 if (is_cur_source
) {
1601 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1602 if (source
== SUB_SOURCE_VOBSUB
)
1603 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1607 return M_PROPERTY_OK
;
1608 case M_PROPERTY_PRINT
:
1610 return M_PROPERTY_ERROR
;
1612 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1613 *(char **) arg
= malloc(64);
1614 (*(char **) arg
)[63] = 0;
1615 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1616 return M_PROPERTY_OK
;
1617 case M_PROPERTY_SET
:
1619 return M_PROPERTY_ERROR
;
1620 if (*(int *) arg
>= 0) {
1621 int index
= *(int *)arg
;
1622 if (source
== SUB_SOURCE_VOBSUB
)
1623 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1624 mpctx
->global_sub_pos
= offset
+ index
;
1625 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1626 || sub_source(mpctx
) != source
) {
1627 mpctx
->global_sub_pos
= -1;
1632 mpctx
->global_sub_pos
= -1;
1634 case M_PROPERTY_STEP_UP
:
1635 case M_PROPERTY_STEP_DOWN
: {
1636 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1637 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1638 int step
= (step_all
> 0) ? 1 : -1;
1639 int max_sub_pos_for_source
= -1;
1641 mpctx
->global_sub_pos
= -1;
1643 if (mpctx
->global_sub_pos
== -1) {
1645 mpctx
->global_sub_pos
= offset
;
1646 else if (max_sub_pos_for_source
== -1) {
1647 // Find max pos for specific source
1648 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1649 while (mpctx
->global_sub_pos
>= 0
1650 && sub_source(mpctx
) != source
)
1651 --mpctx
->global_sub_pos
;
1654 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1657 mpctx
->global_sub_pos
+= step
;
1658 if (mpctx
->global_sub_pos
< offset
||
1659 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1660 sub_source(mpctx
) != source
)
1661 mpctx
->global_sub_pos
= -1;
1668 return M_PROPERTY_NOT_IMPLEMENTED
;
1670 --mpctx
->global_sub_pos
;
1671 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1674 /// Subtitle delay (RW)
1675 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1678 if (!mpctx
->sh_video
)
1679 return M_PROPERTY_UNAVAILABLE
;
1680 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1683 /// Alignment of text subtitles (RW)
1684 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1685 void *arg
, MPContext
* mpctx
)
1687 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1689 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1690 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1691 return M_PROPERTY_UNAVAILABLE
;
1694 case M_PROPERTY_PRINT
:
1696 return M_PROPERTY_ERROR
;
1697 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1698 *(char **) arg
= strdup(name
[sub_alignment
]);
1699 return M_PROPERTY_OK
;
1700 case M_PROPERTY_SET
:
1702 return M_PROPERTY_ERROR
;
1703 case M_PROPERTY_STEP_UP
:
1704 case M_PROPERTY_STEP_DOWN
:
1705 vo_osd_changed(OSDTYPE_SUBTITLE
);
1707 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1711 /// Subtitle visibility (RW)
1712 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1713 void *arg
, MPContext
* mpctx
)
1715 if (!mpctx
->sh_video
)
1716 return M_PROPERTY_UNAVAILABLE
;
1719 case M_PROPERTY_SET
:
1721 return M_PROPERTY_ERROR
;
1722 case M_PROPERTY_STEP_UP
:
1723 case M_PROPERTY_STEP_DOWN
:
1724 vo_osd_changed(OSDTYPE_SUBTITLE
);
1726 vo_osd_changed(OSDTYPE_SPU
);
1728 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1733 /// Use margins for libass subtitles (RW)
1734 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1735 void *arg
, MPContext
* mpctx
)
1737 if (!mpctx
->sh_video
)
1738 return M_PROPERTY_UNAVAILABLE
;
1741 case M_PROPERTY_SET
:
1743 return M_PROPERTY_ERROR
;
1744 case M_PROPERTY_STEP_UP
:
1745 case M_PROPERTY_STEP_DOWN
:
1746 ass_force_reload
= 1;
1748 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1753 /// Show only forced subtitles (RW)
1754 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1755 void *arg
, MPContext
* mpctx
)
1758 return M_PROPERTY_UNAVAILABLE
;
1761 case M_PROPERTY_SET
:
1763 return M_PROPERTY_ERROR
;
1764 case M_PROPERTY_STEP_UP
:
1765 case M_PROPERTY_STEP_DOWN
:
1766 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1767 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1768 return M_PROPERTY_OK
;
1770 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1775 #ifdef HAVE_FREETYPE
1776 /// Subtitle scale (RW)
1777 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1782 case M_PROPERTY_SET
:
1784 return M_PROPERTY_ERROR
;
1785 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1788 ass_font_scale
= *(float *) arg
;
1789 ass_force_reload
= 1;
1792 text_font_scale_factor
= *(float *) arg
;
1793 force_load_font
= 1;
1794 return M_PROPERTY_OK
;
1795 case M_PROPERTY_STEP_UP
:
1796 case M_PROPERTY_STEP_DOWN
:
1799 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1800 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1801 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1802 ass_force_reload
= 1;
1805 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1806 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1807 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1808 force_load_font
= 1;
1809 return M_PROPERTY_OK
;
1813 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1816 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1823 /// \defgroup TVProperties TV properties
1824 /// \ingroup Properties
1829 /// TV color settings (RW)
1830 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1834 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1835 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1836 return M_PROPERTY_UNAVAILABLE
;
1839 case M_PROPERTY_SET
:
1841 return M_PROPERTY_ERROR
;
1842 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1843 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1844 case M_PROPERTY_GET
:
1845 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1846 case M_PROPERTY_STEP_UP
:
1847 case M_PROPERTY_STEP_DOWN
:
1848 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1850 return M_PROPERTY_ERROR
;
1851 val
+= (arg
? *(int *) arg
: 1) *
1852 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1853 M_PROPERTY_CLAMP(prop
, val
);
1854 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1856 return M_PROPERTY_ERROR
;
1858 return M_PROPERTY_NOT_IMPLEMENTED
;
1863 #ifdef HAVE_TV_TELETEXT
1864 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1868 int base_ioctl
=(int)prop
->priv
;
1870 for teletext's GET,SET,STEP ioctls this is not 0
1874 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1875 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1876 return M_PROPERTY_UNAVAILABLE
;
1878 return M_PROPERTY_ERROR
;
1881 case M_PROPERTY_GET
:
1883 return M_PROPERTY_ERROR
;
1884 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1886 case M_PROPERTY_SET
:
1888 return M_PROPERTY_ERROR
;
1889 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1890 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1892 case M_PROPERTY_STEP_UP
:
1893 case M_PROPERTY_STEP_DOWN
:
1894 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1895 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1896 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1899 return M_PROPERTY_NOT_IMPLEMENTED
;
1902 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1905 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1908 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1912 //with tvh==NULL will fail too
1913 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1914 if(result
!=M_PROPERTY_OK
)
1917 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1918 mp_input_set_section("teletext");
1920 mp_input_set_section("tv");
1921 return M_PROPERTY_OK
;
1924 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1927 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1931 case M_PROPERTY_STEP_UP
:
1932 case M_PROPERTY_STEP_DOWN
:
1933 //This should be handled separately
1934 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1935 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1938 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1944 #endif /* HAVE_TV_TELETEXT */
1948 /// All properties available in MPlayer.
1949 /** \ingroup Properties
1951 static const m_option_t mp_properties
[] = {
1953 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1954 M_OPT_RANGE
, 0, 3, NULL
},
1955 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1956 M_OPT_MIN
, -1, 0, NULL
},
1957 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1958 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1959 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1961 { "path", mp_property_path
, CONF_TYPE_STRING
,
1963 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1965 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1966 M_OPT_MIN
, 0, 0, NULL
},
1967 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1968 M_OPT_MIN
, 0, 0, NULL
},
1969 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1970 M_OPT_MIN
, 0, 0, NULL
},
1971 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1972 M_OPT_MIN
, 0, 0, NULL
},
1973 { "length", mp_property_length
, CONF_TYPE_TIME
,
1974 M_OPT_MIN
, 0, 0, NULL
},
1975 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1976 M_OPT_RANGE
, 0, 100, NULL
},
1977 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1978 M_OPT_MIN
, 0, 0, NULL
},
1979 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1980 M_OPT_MIN
, 1, 0, NULL
},
1981 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1982 CONF_RANGE
, -2, 10, NULL
},
1983 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1987 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1988 M_OPT_RANGE
, 0, 100, NULL
},
1989 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
1990 M_OPT_RANGE
, 0, 1, NULL
},
1991 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
1992 M_OPT_RANGE
, -100, 100, NULL
},
1993 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
1995 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
1997 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
1999 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2001 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2003 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2004 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2005 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2006 M_OPT_RANGE
, -1, 1, NULL
},
2009 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2010 M_OPT_RANGE
, 0, 1, NULL
},
2011 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2012 M_OPT_RANGE
, 0, 1, NULL
},
2013 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2014 M_OPT_RANGE
, 0, 1, NULL
},
2015 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2016 M_OPT_RANGE
, 0, 1, NULL
},
2017 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2018 M_OPT_RANGE
, 0, 1, NULL
},
2019 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2020 M_OPT_RANGE
, 0, 2, NULL
},
2021 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2022 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2023 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2024 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2025 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2026 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2027 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2028 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2029 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2030 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2031 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2032 M_OPT_RANGE
, 0, 1, NULL
},
2033 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2034 M_OPT_RANGE
, 0, 1, NULL
},
2035 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2037 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2039 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2041 { "width", mp_property_width
, CONF_TYPE_INT
,
2043 { "height", mp_property_height
, CONF_TYPE_INT
,
2045 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2047 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2049 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2050 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2051 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2052 CONF_RANGE
, -1, 65535, NULL
},
2055 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2056 M_OPT_MIN
, -1, 0, NULL
},
2057 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2058 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2059 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2060 M_OPT_MIN
, -1, 0, NULL
},
2061 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2062 M_OPT_MIN
, -1, 0, NULL
},
2063 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2064 M_OPT_MIN
, -1, 0, NULL
},
2065 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2067 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2068 M_OPT_RANGE
, 0, 100, NULL
},
2069 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2070 M_OPT_RANGE
, 0, 2, NULL
},
2071 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2072 M_OPT_RANGE
, 0, 1, NULL
},
2073 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2074 M_OPT_RANGE
, 0, 1, NULL
},
2075 #ifdef HAVE_FREETYPE
2076 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2077 M_OPT_RANGE
, 0, 100, NULL
},
2080 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2081 M_OPT_RANGE
, 0, 1, NULL
},
2085 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2086 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2087 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2088 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2089 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2090 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2091 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2092 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2095 #ifdef HAVE_TV_TELETEXT
2096 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2097 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2098 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2099 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2100 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2101 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2102 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2103 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2104 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2105 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2108 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2112 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2114 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2117 char* mp_property_print(const char *name
, void* ctx
)
2120 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2125 char *property_expand_string(MPContext
* mpctx
, char *str
)
2127 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2130 void property_print_help(void)
2132 m_properties_print_help_list(mp_properties
);
2141 * \defgroup Command2Property Command to property bridge
2143 * It is used to handle most commands that just set a property
2144 * and optionally display something on the OSD.
2145 * Two kinds of commands are handled: adjust or toggle.
2147 * Adjust commands take 1 or 2 parameters: <value> <abs>
2148 * If <abs> is non-zero the property is set to the given value
2149 * otherwise it is adjusted.
2151 * Toggle commands take 0 or 1 parameters. With no parameter
2152 * or a value less than the property minimum it just steps the
2153 * property to its next value. Otherwise it sets it to the given
2159 /// List of the commands that can be handled by setting a property.
2165 /// set/adjust or toggle command
2167 /// progressbar type
2169 /// osd msg id if it must be shared
2171 /// osd msg template
2172 const char *osd_msg
;
2173 } set_prop_cmd
[] = {
2175 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2176 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2177 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2179 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2180 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2181 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2182 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2183 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2185 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2186 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2187 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2188 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2189 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2190 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2191 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2192 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2193 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2194 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2195 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2196 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2198 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2199 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2200 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2201 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2202 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2203 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2204 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2205 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2206 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2207 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2208 #ifdef HAVE_FREETYPE
2209 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2212 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2215 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2216 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2217 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2218 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2220 { NULL
, 0, 0, 0, -1, NULL
}
2224 /// Handle commands that set a property.
2225 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2231 // look for the command
2232 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2233 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2235 if (!(pname
= set_prop_cmd
[i
].name
))
2238 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2242 if (set_prop_cmd
[i
].toggle
) {
2244 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2245 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2247 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2248 } else if (cmd
->args
[1].v
.i
) //set
2249 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2251 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2256 if (set_prop_cmd
[i
].osd_progbar
) {
2257 if (prop
->type
== CONF_TYPE_INT
) {
2258 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2259 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2260 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2261 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2263 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2264 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2265 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2267 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2268 "Property use an unsupported type.\n");
2272 if (set_prop_cmd
[i
].osd_msg
) {
2273 char *val
= mp_property_print(pname
, mpctx
);
2275 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2276 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2277 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2285 static const struct {
2287 const mp_command_type cmd
;
2288 } mp_dvdnav_bindings
[] = {
2289 { "up", MP_CMD_DVDNAV_UP
},
2290 { "down", MP_CMD_DVDNAV_DOWN
},
2291 { "left", MP_CMD_DVDNAV_LEFT
},
2292 { "right", MP_CMD_DVDNAV_RIGHT
},
2293 { "menu", MP_CMD_DVDNAV_MENU
},
2294 { "select", MP_CMD_DVDNAV_SELECT
},
2295 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2296 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2299 * keep old dvdnav sub-command options for a while in order not to
2300 * break slave-mode API too suddenly.
2302 { "1", MP_CMD_DVDNAV_UP
},
2303 { "2", MP_CMD_DVDNAV_DOWN
},
2304 { "3", MP_CMD_DVDNAV_LEFT
},
2305 { "4", MP_CMD_DVDNAV_RIGHT
},
2306 { "5", MP_CMD_DVDNAV_MENU
},
2307 { "6", MP_CMD_DVDNAV_SELECT
},
2308 { "7", MP_CMD_DVDNAV_PREVMENU
},
2309 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2314 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2316 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2317 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2319 if (!set_property_command(mpctx
, cmd
))
2325 mpctx
->osd_show_percentage
= sh_video
->fps
;
2326 v
= cmd
->args
[0].v
.f
;
2327 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2328 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2329 abs_seek_pos
= SEEK_ABSOLUTE
;
2331 mpctx
->osd_function
=
2332 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2334 } else if (abs
) { /* Absolute seek by percentage */
2335 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2337 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2338 rel_seek_secs
= v
/ 100.0;
2341 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2347 case MP_CMD_SET_PROPERTY
:{
2348 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2349 cmd
->args
[1].v
.s
, mpctx
);
2350 if (r
== M_PROPERTY_UNKNOWN
)
2351 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2352 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2354 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2355 "Failed to set property '%s' to '%s'.\n",
2356 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2360 case MP_CMD_STEP_PROPERTY
:{
2365 if (cmd
->args
[1].v
.f
) {
2367 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2368 M_PROPERTY_GET_TYPE
,
2369 &prop
, mpctx
)) <= 0)
2371 if(prop
->type
== CONF_TYPE_INT
||
2372 prop
->type
== CONF_TYPE_FLAG
)
2373 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2374 else if(prop
->type
== CONF_TYPE_FLOAT
)
2375 arg
= &cmd
->args
[1].v
.f
;
2376 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2377 prop
->type
== CONF_TYPE_TIME
)
2378 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2379 else if(prop
->type
== CONF_TYPE_POSITION
)
2380 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2382 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2383 "Ignoring step size stepping property '%s'.\n",
2386 r
= mp_property_do(cmd
->args
[0].v
.s
,
2387 cmd
->args
[2].v
.i
< 0 ?
2388 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2391 if (r
== M_PROPERTY_UNKNOWN
)
2392 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2393 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2395 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2396 "Failed to increment property '%s' by %f.\n",
2397 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2401 case MP_CMD_GET_PROPERTY
:{
2403 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2404 &tmp
, mpctx
) <= 0) {
2405 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2406 "Failed to get value of property '%s'.\n",
2410 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2411 cmd
->args
[0].v
.s
, tmp
);
2416 case MP_CMD_EDL_MARK
:
2418 float v
= sh_video
? sh_video
->pts
:
2419 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2422 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2423 mpctx
->begin_skip
= v
;
2424 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2426 if (mpctx
->begin_skip
> v
)
2427 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2429 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2430 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2432 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2437 case MP_CMD_SWITCH_RATIO
:
2438 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2439 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2441 movie_aspect
= cmd
->args
[0].v
.f
;
2442 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2445 case MP_CMD_SPEED_INCR
:{
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_MULT
:{
2454 float v
= cmd
->args
[0].v
.f
;
2455 playback_speed
*= v
;
2456 build_afilter_chain(sh_audio
, &ao_data
);
2457 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2461 case MP_CMD_SPEED_SET
:{
2462 float v
= cmd
->args
[0].v
.f
;
2464 build_afilter_chain(sh_audio
, &ao_data
);
2465 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2469 case MP_CMD_FRAME_STEP
:
2475 case MP_CMD_FILE_FILTER
:
2476 file_filter
= cmd
->args
[0].v
.i
;
2480 exit_player_with_rc(MSGTR_Exit_quit
,
2481 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2483 case MP_CMD_PLAY_TREE_STEP
:{
2484 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2485 int force
= cmd
->args
[1].v
.i
;
2491 for (i
= 0; i
< n
; i
++)
2494 for (i
= 0; i
< -1 * n
; i
++)
2499 if (!force
&& mpctx
->playtree_iter
) {
2500 play_tree_iter_t
*i
=
2501 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2502 if (play_tree_iter_step(i
, n
, 0) ==
2503 PLAY_TREE_ITER_ENTRY
)
2505 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2506 play_tree_iter_free(i
);
2508 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2510 mpctx
->play_tree_step
= n
;
2516 case MP_CMD_PLAY_TREE_UP_STEP
:{
2517 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2518 int force
= cmd
->args
[1].v
.i
;
2520 if (!force
&& mpctx
->playtree_iter
) {
2521 play_tree_iter_t
*i
=
2522 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2523 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2524 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2525 play_tree_iter_free(i
);
2527 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2532 case MP_CMD_PLAY_ALT_SRC_STEP
:
2533 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2534 int v
= cmd
->args
[0].v
.i
;
2536 && mpctx
->playtree_iter
->file
<
2537 mpctx
->playtree_iter
->num_files
)
2538 mpctx
->eof
= PT_NEXT_SRC
;
2539 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2540 mpctx
->eof
= PT_PREV_SRC
;
2545 case MP_CMD_SUB_STEP
:
2547 int movement
= cmd
->args
[0].v
.i
;
2548 step_sub(subdata
, sh_video
->pts
, movement
);
2552 ass_step_sub(ass_track
,
2554 sub_delay
) * 1000 + .5, movement
) / 1000.;
2556 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2557 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2561 case MP_CMD_SUB_LOG
:
2566 int v
= cmd
->args
[0].v
.i
;
2568 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2569 if (osd_level
> max
)
2572 osd_level
= (osd_level
+ 1) % (max
+ 1);
2574 osd_level
= v
> max
? max
: v
;
2575 /* Show OSD state when disabled, but not when an explicit
2576 argument is given to the OSD command, i.e. in slave mode. */
2577 if (v
== -1 && osd_level
<= 1)
2578 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2580 osd_level
? MSGTR_OSDenabled
:
2583 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2587 case MP_CMD_OSD_SHOW_TEXT
:
2588 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2590 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2591 "%-.63s", cmd
->args
[0].v
.s
);
2594 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2595 char *txt
= m_properties_expand_string(mp_properties
,
2598 /* if no argument supplied take default osd_duration, else <arg> ms. */
2600 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2602 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2609 case MP_CMD_LOADFILE
:{
2610 play_tree_t
*e
= play_tree_new();
2611 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2613 if (cmd
->args
[1].v
.i
) // append
2614 play_tree_append_entry(mpctx
->playtree
, e
);
2616 // Go back to the starting point.
2617 while (play_tree_iter_up_step
2618 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2620 play_tree_free_list(mpctx
->playtree
->child
, 1);
2621 play_tree_set_child(mpctx
->playtree
, e
);
2622 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2623 mpctx
->eof
= PT_NEXT_SRC
;
2629 case MP_CMD_LOADLIST
:{
2630 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2632 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2633 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2635 if (cmd
->args
[1].v
.i
) // append
2636 play_tree_append_entry(mpctx
->playtree
, e
);
2638 // Go back to the starting point.
2639 while (play_tree_iter_up_step
2640 (mpctx
->playtree_iter
, 0, 1)
2641 != PLAY_TREE_ITER_END
)
2643 play_tree_free_list(mpctx
->playtree
->child
, 1);
2644 play_tree_set_child(mpctx
->playtree
, e
);
2645 play_tree_iter_step(mpctx
->playtree_iter
, 0, 0);
2646 mpctx
->eof
= PT_NEXT_SRC
;
2654 mpctx
->eof
= PT_STOP
;
2659 case MP_CMD_RADIO_STEP_CHANNEL
:
2660 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2661 int v
= cmd
->args
[0].v
.i
;
2663 radio_step_channel(mpctx
->demuxer
->stream
,
2664 RADIO_CHANNEL_HIGHER
);
2666 radio_step_channel(mpctx
->demuxer
->stream
,
2667 RADIO_CHANNEL_LOWER
);
2668 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2669 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2671 radio_get_channel_name(mpctx
->demuxer
->stream
));
2676 case MP_CMD_RADIO_SET_CHANNEL
:
2677 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2678 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2679 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2680 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2682 radio_get_channel_name(mpctx
->demuxer
->stream
));
2687 case MP_CMD_RADIO_SET_FREQ
:
2688 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2689 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2692 case MP_CMD_RADIO_STEP_FREQ
:
2693 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2694 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2699 case MP_CMD_TV_START_SCAN
:
2700 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2701 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2703 case MP_CMD_TV_SET_FREQ
:
2704 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2705 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2706 cmd
->args
[0].v
.f
* 16.0);
2708 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2709 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2710 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2711 pvr_get_current_channelname (mpctx
->stream
),
2712 pvr_get_current_stationname (mpctx
->stream
));
2714 #endif /* HAVE_PVR */
2717 case MP_CMD_TV_STEP_FREQ
:
2718 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2719 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2720 cmd
->args
[0].v
.f
* 16.0);
2722 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2723 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2724 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2725 pvr_get_current_channelname (mpctx
->stream
),
2726 pvr_get_current_frequency (mpctx
->stream
));
2728 #endif /* HAVE_PVR */
2731 case MP_CMD_TV_SET_NORM
:
2732 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2733 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2737 case MP_CMD_TV_STEP_CHANNEL
:{
2738 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2739 int v
= cmd
->args
[0].v
.i
;
2741 tv_step_channel((tvi_handle_t
*) (mpctx
->
2745 tv_step_channel((tvi_handle_t
*) (mpctx
->
2749 if (tv_channel_list
) {
2750 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2751 MSGTR_OSDChannel
, tv_channel_current
->name
);
2752 //vo_osd_changed(OSDTYPE_SUBTITLE);
2756 else if (mpctx
->stream
&&
2757 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2758 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2759 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2760 pvr_get_current_channelname (mpctx
->stream
),
2761 pvr_get_current_stationname (mpctx
->stream
));
2763 #endif /* HAVE_PVR */
2765 #ifdef HAS_DVBIN_SUPPORT
2766 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2768 int v
= cmd
->args
[0].v
.i
;
2770 mpctx
->last_dvb_step
= v
;
2772 dir
= DVB_CHANNEL_HIGHER
;
2774 dir
= DVB_CHANNEL_LOWER
;
2777 if (dvb_step_channel(mpctx
->stream
, dir
))
2778 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2780 #endif /* HAS_DVBIN_SUPPORT */
2783 case MP_CMD_TV_SET_CHANNEL
:
2784 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2785 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2787 if (tv_channel_list
) {
2788 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2789 MSGTR_OSDChannel
, tv_channel_current
->name
);
2790 //vo_osd_changed(OSDTYPE_SUBTITLE);
2794 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2795 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2796 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2797 pvr_get_current_channelname (mpctx
->stream
),
2798 pvr_get_current_stationname (mpctx
->stream
));
2800 #endif /* HAVE_PVR */
2803 #ifdef HAS_DVBIN_SUPPORT
2804 case MP_CMD_DVB_SET_CHANNEL
:
2805 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2806 mpctx
->last_dvb_step
= 1;
2809 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2810 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2813 #endif /* HAS_DVBIN_SUPPORT */
2815 case MP_CMD_TV_LAST_CHANNEL
:
2816 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2817 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2818 if (tv_channel_list
) {
2819 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2820 MSGTR_OSDChannel
, tv_channel_current
->name
);
2821 //vo_osd_changed(OSDTYPE_SUBTITLE);
2825 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2826 pvr_set_lastchannel (mpctx
->stream
);
2827 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2828 pvr_get_current_channelname (mpctx
->stream
),
2829 pvr_get_current_stationname (mpctx
->stream
));
2831 #endif /* HAVE_PVR */
2834 case MP_CMD_TV_STEP_NORM
:
2835 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2836 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2839 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2840 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2841 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2843 #ifdef HAVE_TV_TELETEXT
2844 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2846 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2847 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2848 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2851 case MP_CMD_TV_TELETEXT_GO_LINK
:
2853 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2854 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2855 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2858 #endif /* HAVE_TV_TELETEXT */
2861 case MP_CMD_SUB_LOAD
:
2863 int n
= mpctx
->set_of_sub_size
;
2864 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2865 if (n
!= mpctx
->set_of_sub_size
) {
2866 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2867 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2868 mpctx
->global_sub_size
;
2869 ++mpctx
->global_sub_size
;
2874 case MP_CMD_SUB_REMOVE
:
2876 int v
= cmd
->args
[0].v
.i
;
2879 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2880 subd
= mpctx
->set_of_subtitles
[v
];
2881 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2882 MSGTR_RemovedSubtitleFile
, v
+ 1,
2883 filename_recode(subd
->filename
));
2885 mpctx
->set_of_subtitles
[v
] = NULL
;
2887 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2888 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2889 mpctx
->set_of_sub_size
= 0;
2890 if (mpctx
->set_of_sub_pos
>= 0) {
2891 mpctx
->global_sub_pos
= -2;
2893 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2895 } else if (v
< mpctx
->set_of_sub_size
) {
2896 subd
= mpctx
->set_of_subtitles
[v
];
2897 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2898 MSGTR_RemovedSubtitleFile
, v
+ 1,
2899 filename_recode(subd
->filename
));
2901 if (mpctx
->set_of_sub_pos
== v
) {
2902 mpctx
->global_sub_pos
= -2;
2904 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2905 } else if (mpctx
->set_of_sub_pos
> v
) {
2906 --mpctx
->set_of_sub_pos
;
2907 --mpctx
->global_sub_pos
;
2909 while (++v
< mpctx
->set_of_sub_size
)
2910 mpctx
->set_of_subtitles
[v
- 1] =
2911 mpctx
->set_of_subtitles
[v
];
2912 --mpctx
->set_of_sub_size
;
2913 --mpctx
->global_sub_size
;
2914 if (mpctx
->set_of_sub_size
<= 0)
2915 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2916 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2921 case MP_CMD_GET_SUB_VISIBILITY
:
2923 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2924 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2928 case MP_CMD_SCREENSHOT
:
2929 if (vo_config_count
) {
2930 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2932 ((vf_instance_t
*) sh_video
->vfilter
)->
2933 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2935 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2939 case MP_CMD_VF_CHANGE_RECTANGLE
:
2940 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2943 case MP_CMD_GET_TIME_LENGTH
:{
2944 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2945 demuxer_get_time_length(mpctx
->demuxer
));
2949 case MP_CMD_GET_FILENAME
:{
2950 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2951 get_metadata(META_NAME
));
2955 case MP_CMD_GET_VIDEO_CODEC
:{
2956 char *inf
= get_metadata(META_VIDEO_CODEC
);
2959 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2964 case MP_CMD_GET_VIDEO_BITRATE
:{
2965 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2968 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2973 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2974 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2977 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2978 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
2983 case MP_CMD_GET_AUDIO_CODEC
:{
2984 char *inf
= get_metadata(META_AUDIO_CODEC
);
2987 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
2992 case MP_CMD_GET_AUDIO_BITRATE
:{
2993 char *inf
= get_metadata(META_AUDIO_BITRATE
);
2996 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3001 case MP_CMD_GET_AUDIO_SAMPLES
:{
3002 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3005 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3010 case MP_CMD_GET_META_TITLE
:{
3011 char *inf
= get_metadata(META_INFO_TITLE
);
3014 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3019 case MP_CMD_GET_META_ARTIST
:{
3020 char *inf
= get_metadata(META_INFO_ARTIST
);
3023 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3028 case MP_CMD_GET_META_ALBUM
:{
3029 char *inf
= get_metadata(META_INFO_ALBUM
);
3032 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3037 case MP_CMD_GET_META_YEAR
:{
3038 char *inf
= get_metadata(META_INFO_YEAR
);
3041 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3046 case MP_CMD_GET_META_COMMENT
:{
3047 char *inf
= get_metadata(META_INFO_COMMENT
);
3050 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3055 case MP_CMD_GET_META_TRACK
:{
3056 char *inf
= get_metadata(META_INFO_TRACK
);
3059 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3064 case MP_CMD_GET_META_GENRE
:{
3065 char *inf
= get_metadata(META_INFO_GENRE
);
3068 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3073 case MP_CMD_GET_VO_FULLSCREEN
:
3074 if (mpctx
->video_out
&& vo_config_count
)
3075 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3078 case MP_CMD_GET_PERCENT_POS
:
3079 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3080 demuxer_get_percent_pos(mpctx
->demuxer
));
3083 case MP_CMD_GET_TIME_POS
:{
3086 pos
= sh_video
->pts
;
3087 else if (sh_audio
&& mpctx
->audio_out
)
3089 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3091 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3098 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3104 case MP_CMD_KEYDOWN_EVENTS
:
3105 mplayer_put_key(cmd
->args
[0].v
.i
);
3108 case MP_CMD_SET_MOUSE_POS
:{
3109 int pointer_x
, pointer_y
;
3111 pointer_x
= cmd
->args
[0].v
.i
;
3112 pointer_y
= cmd
->args
[1].v
.i
;
3113 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3115 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3116 && dx
> 0.0 && dy
> 0.0) {
3118 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3119 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3120 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3121 pointer_x
, pointer_y
, &button
);
3122 if (osd_level
> 1 && button
> 0)
3123 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3124 "Selected button number %d", button
);
3128 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3129 menu_update_mouse_pos(dx
, dy
);
3135 case MP_CMD_DVDNAV
:{
3138 mp_command_type command
= 0;
3139 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3142 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3143 if (cmd
->args
[0].v
.s
&&
3144 !strcasecmp (cmd
->args
[0].v
.s
,
3145 mp_dvdnav_bindings
[i
].name
))
3146 command
= mp_dvdnav_bindings
[i
].cmd
;
3148 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3149 if (osd_level
> 1 && button
> 0)
3150 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3151 "Selected button number %d", button
);
3155 case MP_CMD_SWITCH_TITLE
:
3156 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3157 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3164 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3165 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3168 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3169 "Received unknown cmd %s\n", cmd
->name
);
3172 switch (cmd
->pausing
) {
3173 case 1: // "pausing"
3174 mpctx
->osd_function
= OSD_PAUSE
;
3176 case 3: // "pausing_toggle"
3177 mpctx
->was_paused
= !mpctx
->was_paused
;
3178 if (mpctx
->was_paused
)
3179 mpctx
->osd_function
= OSD_PAUSE
;
3180 else if (mpctx
->osd_function
== OSD_PAUSE
)
3181 mpctx
->osd_function
= OSD_PLAY
;
3183 case 2: // "pausing_keep"
3184 if (mpctx
->was_paused
)
3185 mpctx
->osd_function
= OSD_PAUSE
;