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"
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
;
389 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
391 return M_PROPERTY_UNAVAILABLE
;
396 return M_PROPERTY_ERROR
;
397 *(int *) arg
= chapter
;
398 return M_PROPERTY_OK
;
399 case M_PROPERTY_PRINT
: {
401 return M_PROPERTY_ERROR
;
402 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
404 return M_PROPERTY_UNAVAILABLE
;
405 *(char **) arg
= chapter_name
;
406 return M_PROPERTY_OK
;
410 return M_PROPERTY_ERROR
;
411 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
412 step_all
= *(int *)arg
- (chapter
+ 1);
415 case M_PROPERTY_STEP_UP
:
416 case M_PROPERTY_STEP_DOWN
: {
417 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
418 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
425 return M_PROPERTY_NOT_IMPLEMENTED
;
429 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
430 &next_pts
, &chapter_num
, &chapter_name
);
432 if (next_pts
> -1.0) {
433 abs_seek_pos
= SEEK_ABSOLUTE
;
434 rel_seek_secs
= next_pts
;
437 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
438 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
440 else if (step_all
> 0)
441 rel_seek_secs
= 1000000000.;
443 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
444 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
447 return M_PROPERTY_OK
;
450 /// Number of chapters in file
451 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
455 return M_PROPERTY_UNAVAILABLE
;
456 if (mpctx
->demuxer
->num_chapters
== 0)
457 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
458 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
461 /// Current dvd angle (RW)
462 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
467 char *angle_name
= NULL
;
470 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
472 return M_PROPERTY_UNAVAILABLE
;
473 angles
= demuxer_angles_count(mpctx
->demuxer
);
475 return M_PROPERTY_UNAVAILABLE
;
480 return M_PROPERTY_ERROR
;
481 *(int *) arg
= angle
;
482 return M_PROPERTY_OK
;
483 case M_PROPERTY_PRINT
: {
485 return M_PROPERTY_ERROR
;
486 angle_name
= calloc(1, 64);
488 return M_PROPERTY_UNAVAILABLE
;
489 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
490 *(char **) arg
= angle_name
;
491 return M_PROPERTY_OK
;
495 return M_PROPERTY_ERROR
;
497 M_PROPERTY_CLAMP(prop
, angle
);
499 case M_PROPERTY_STEP_UP
:
500 case M_PROPERTY_STEP_DOWN
: {
506 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
508 if (angle
< 1) //cycle
513 return M_PROPERTY_NOT_IMPLEMENTED
;
515 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
516 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
517 MSGTR_OSDAngle
, angle
, angles
);
520 return M_PROPERTY_OK
;
523 /// Demuxer meta data
524 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
526 m_property_action_t
* ka
;
528 static m_option_t key_type
=
529 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
531 return M_PROPERTY_UNAVAILABLE
;
535 if(!arg
) return M_PROPERTY_ERROR
;
536 *(char***)arg
= mpctx
->demuxer
->info
;
537 return M_PROPERTY_OK
;
538 case M_PROPERTY_KEY_ACTION
:
539 if(!arg
) return M_PROPERTY_ERROR
;
541 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
542 return M_PROPERTY_UNKNOWN
;
545 if(!ka
->arg
) return M_PROPERTY_ERROR
;
546 *(char**)ka
->arg
= meta
;
547 return M_PROPERTY_OK
;
548 case M_PROPERTY_GET_TYPE
:
549 if(!ka
->arg
) return M_PROPERTY_ERROR
;
550 *(m_option_t
**)ka
->arg
= &key_type
;
551 return M_PROPERTY_OK
;
554 return M_PROPERTY_NOT_IMPLEMENTED
;
557 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
560 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
566 /// \defgroup AudioProperties Audio properties
567 /// \ingroup Properties
571 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
575 if (!mpctx
->sh_audio
)
576 return M_PROPERTY_UNAVAILABLE
;
581 return M_PROPERTY_ERROR
;
582 mixer_getbothvolume(&mpctx
->mixer
, arg
);
583 return M_PROPERTY_OK
;
584 case M_PROPERTY_PRINT
:{
587 return M_PROPERTY_ERROR
;
588 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
589 return m_property_float_range(prop
, action
, arg
, &vol
);
591 case M_PROPERTY_STEP_UP
:
592 case M_PROPERTY_STEP_DOWN
:
596 return M_PROPERTY_NOT_IMPLEMENTED
;
599 if (mpctx
->edl_muted
)
600 return M_PROPERTY_DISABLED
;
601 mpctx
->user_muted
= 0;
606 return M_PROPERTY_ERROR
;
607 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
608 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
609 return M_PROPERTY_OK
;
610 case M_PROPERTY_STEP_UP
:
611 if (arg
&& *(float *) arg
<= 0)
612 mixer_decvolume(&mpctx
->mixer
);
614 mixer_incvolume(&mpctx
->mixer
);
615 return M_PROPERTY_OK
;
616 case M_PROPERTY_STEP_DOWN
:
617 if (arg
&& *(float *) arg
<= 0)
618 mixer_incvolume(&mpctx
->mixer
);
620 mixer_decvolume(&mpctx
->mixer
);
621 return M_PROPERTY_OK
;
623 return M_PROPERTY_NOT_IMPLEMENTED
;
627 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
631 if (!mpctx
->sh_audio
)
632 return M_PROPERTY_UNAVAILABLE
;
636 if (mpctx
->edl_muted
)
637 return M_PROPERTY_DISABLED
;
639 return M_PROPERTY_ERROR
;
640 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
641 mixer_mute(&mpctx
->mixer
);
642 mpctx
->user_muted
= mpctx
->mixer
.muted
;
643 return M_PROPERTY_OK
;
644 case M_PROPERTY_STEP_UP
:
645 case M_PROPERTY_STEP_DOWN
:
646 if (mpctx
->edl_muted
)
647 return M_PROPERTY_DISABLED
;
648 mixer_mute(&mpctx
->mixer
);
649 mpctx
->user_muted
= mpctx
->mixer
.muted
;
650 return M_PROPERTY_OK
;
651 case M_PROPERTY_PRINT
:
653 return M_PROPERTY_ERROR
;
654 if (mpctx
->edl_muted
) {
655 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
656 return M_PROPERTY_OK
;
659 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
665 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
666 void *arg
, MPContext
* mpctx
)
668 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
669 return M_PROPERTY_UNAVAILABLE
;
672 case M_PROPERTY_STEP_UP
:
673 case M_PROPERTY_STEP_DOWN
: {
675 float delay
= audio_delay
;
676 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
677 if (ret
!= M_PROPERTY_OK
)
680 mpctx
->delay
-= audio_delay
- delay
;
682 return M_PROPERTY_OK
;
684 return m_property_delay(prop
, action
, arg
, &audio_delay
);
688 /// Audio codec tag (RO)
689 static int mp_property_audio_format(m_option_t
* prop
, int action
,
690 void *arg
, MPContext
* mpctx
)
692 if (!mpctx
->sh_audio
)
693 return M_PROPERTY_UNAVAILABLE
;
694 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
697 /// Audio codec name (RO)
698 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
699 void *arg
, MPContext
* mpctx
)
701 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
702 return M_PROPERTY_UNAVAILABLE
;
703 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
706 /// Audio bitrate (RO)
707 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
708 void *arg
, MPContext
* mpctx
)
710 if (!mpctx
->sh_audio
)
711 return M_PROPERTY_UNAVAILABLE
;
712 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
716 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
719 if (!mpctx
->sh_audio
)
720 return M_PROPERTY_UNAVAILABLE
;
722 case M_PROPERTY_PRINT
:
723 if(!arg
) return M_PROPERTY_ERROR
;
724 *(char**)arg
= malloc(16);
725 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
726 return M_PROPERTY_OK
;
728 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
731 /// Number of channels (RO)
732 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
735 if (!mpctx
->sh_audio
)
736 return M_PROPERTY_UNAVAILABLE
;
738 case M_PROPERTY_PRINT
:
740 return M_PROPERTY_ERROR
;
741 switch (mpctx
->sh_audio
->channels
) {
743 *(char **) arg
= strdup("mono");
746 *(char **) arg
= strdup("stereo");
749 *(char **) arg
= malloc(32);
750 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
752 return M_PROPERTY_OK
;
754 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
758 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
763 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
764 return M_PROPERTY_UNAVAILABLE
;
769 return M_PROPERTY_ERROR
;
770 mixer_getbalance(&mpctx
->mixer
, arg
);
771 return M_PROPERTY_OK
;
772 case M_PROPERTY_PRINT
: {
775 return M_PROPERTY_ERROR
;
776 mixer_getbalance(&mpctx
->mixer
, &bal
);
778 *str
= strdup("center");
779 else if (bal
== -1.f
)
780 *str
= strdup("left only");
782 *str
= strdup("right only");
784 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
785 *str
= malloc(sizeof("left xxx%, right xxx%"));
786 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
788 return M_PROPERTY_OK
;
790 case M_PROPERTY_STEP_UP
:
791 case M_PROPERTY_STEP_DOWN
:
792 mixer_getbalance(&mpctx
->mixer
, &bal
);
793 bal
+= (arg
? *(float*)arg
: .1f
) *
794 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
795 M_PROPERTY_CLAMP(prop
, bal
);
796 mixer_setbalance(&mpctx
->mixer
, bal
);
797 return M_PROPERTY_OK
;
800 return M_PROPERTY_ERROR
;
801 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
802 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
803 return M_PROPERTY_OK
;
805 return M_PROPERTY_NOT_IMPLEMENTED
;
808 /// Selected audio id (RW)
809 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
812 int current_id
= -1, tmp
;
816 if (!mpctx
->sh_audio
)
817 return M_PROPERTY_UNAVAILABLE
;
819 return M_PROPERTY_ERROR
;
820 *(int *) arg
= audio_id
;
821 return M_PROPERTY_OK
;
822 case M_PROPERTY_PRINT
:
823 if (!mpctx
->sh_audio
)
824 return M_PROPERTY_UNAVAILABLE
;
826 return M_PROPERTY_ERROR
;
829 *(char **) arg
= strdup(MSGTR_Disabled
);
831 char lang
[40] = MSGTR_Unknown
;
832 sh_audio_t
* sh
= mpctx
->sh_audio
;
834 av_strlcpy(lang
, sh
->lang
, 40);
835 #ifdef CONFIG_DVDREAD
836 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
837 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
847 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
848 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
850 *(char **) arg
= malloc(64);
851 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
853 return M_PROPERTY_OK
;
855 case M_PROPERTY_STEP_UP
:
858 return M_PROPERTY_UNAVAILABLE
;
859 if (action
== M_PROPERTY_SET
&& arg
)
860 tmp
= *((int *) arg
);
863 current_id
= mpctx
->demuxer
->audio
->id
;
864 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
867 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
868 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
869 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
871 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
873 sh2
->ds
= mpctx
->demuxer
->audio
;
874 mpctx
->sh_audio
= sh2
;
875 reinit_audio_chain();
878 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
879 return M_PROPERTY_OK
;
881 return M_PROPERTY_NOT_IMPLEMENTED
;
886 /// Selected video id (RW)
887 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
890 int current_id
= -1, tmp
;
894 if (!mpctx
->sh_video
)
895 return M_PROPERTY_UNAVAILABLE
;
897 return M_PROPERTY_ERROR
;
898 *(int *) arg
= video_id
;
899 return M_PROPERTY_OK
;
900 case M_PROPERTY_PRINT
:
901 if (!mpctx
->sh_video
)
902 return M_PROPERTY_UNAVAILABLE
;
904 return M_PROPERTY_ERROR
;
907 *(char **) arg
= strdup(MSGTR_Disabled
);
909 char lang
[40] = MSGTR_Unknown
;
910 *(char **) arg
= malloc(64);
911 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
913 return M_PROPERTY_OK
;
915 case M_PROPERTY_STEP_UP
:
917 current_id
= mpctx
->demuxer
->video
->id
;
918 if (action
== M_PROPERTY_SET
&& arg
)
919 tmp
= *((int *) arg
);
922 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
924 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
925 && current_id
!= -2))
926 uninit_player(INITIALIZED_VCODEC
|
927 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
928 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
930 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
932 sh2
->ds
= mpctx
->demuxer
->video
;
933 mpctx
->sh_video
= sh2
;
934 reinit_video_chain();
937 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
938 return M_PROPERTY_OK
;
941 return M_PROPERTY_NOT_IMPLEMENTED
;
945 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
948 demux_program_t prog
;
951 case M_PROPERTY_STEP_UP
:
953 if (action
== M_PROPERTY_SET
&& arg
)
954 prog
.progid
= *((int *) arg
);
958 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
959 &prog
) == DEMUXER_CTRL_NOTIMPL
)
960 return M_PROPERTY_ERROR
;
962 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
963 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
964 return M_PROPERTY_OK
;
967 return M_PROPERTY_NOT_IMPLEMENTED
;
973 /// \defgroup VideoProperties Video properties
974 /// \ingroup Properties
977 /// Fullscreen state (RW)
978 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
982 if (!mpctx
->video_out
)
983 return M_PROPERTY_UNAVAILABLE
;
988 return M_PROPERTY_ERROR
;
989 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
990 if (vo_fs
== !!*(int *) arg
)
991 return M_PROPERTY_OK
;
992 case M_PROPERTY_STEP_UP
:
993 case M_PROPERTY_STEP_DOWN
:
996 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
1000 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
1001 return M_PROPERTY_OK
;
1003 return m_property_flag(prop
, action
, arg
, &vo_fs
);
1007 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
1008 void *arg
, MPContext
* mpctx
)
1012 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1013 return M_PROPERTY_UNAVAILABLE
;
1014 vf
= mpctx
->sh_video
->vfilter
;
1016 case M_PROPERTY_GET
:
1018 return M_PROPERTY_ERROR
;
1019 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1020 return M_PROPERTY_OK
;
1021 case M_PROPERTY_SET
:
1023 return M_PROPERTY_ERROR
;
1024 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1025 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1026 return M_PROPERTY_OK
;
1027 case M_PROPERTY_STEP_UP
:
1028 case M_PROPERTY_STEP_DOWN
:
1029 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1030 deinterlace
= !deinterlace
;
1031 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1032 return M_PROPERTY_OK
;
1034 return M_PROPERTY_NOT_IMPLEMENTED
;
1038 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1042 if (!mpctx
->video_out
1043 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1044 return M_PROPERTY_UNAVAILABLE
;
1047 case M_PROPERTY_SET
:
1049 return M_PROPERTY_ERROR
;
1050 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1051 vo_panscan
= *(float *) arg
;
1052 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1053 return M_PROPERTY_OK
;
1054 case M_PROPERTY_STEP_UP
:
1055 case M_PROPERTY_STEP_DOWN
:
1056 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1057 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1060 else if (vo_panscan
< 0)
1062 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1063 return M_PROPERTY_OK
;
1065 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1069 /// Helper to set vo flags.
1070 /** \ingroup PropertyImplHelper
1072 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1073 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1076 if (!mpctx
->video_out
)
1077 return M_PROPERTY_UNAVAILABLE
;
1080 case M_PROPERTY_SET
:
1082 return M_PROPERTY_ERROR
;
1083 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1084 if (*vo_var
== !!*(int *) arg
)
1085 return M_PROPERTY_OK
;
1086 case M_PROPERTY_STEP_UP
:
1087 case M_PROPERTY_STEP_DOWN
:
1088 if (vo_config_count
)
1089 mpctx
->video_out
->control(vo_ctrl
, 0);
1090 return M_PROPERTY_OK
;
1092 return m_property_flag(prop
, action
, arg
, vo_var
);
1096 /// Window always on top (RW)
1097 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1100 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1104 /// Display in the root window (RW)
1105 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1108 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1109 &vo_rootwin
, mpctx
);
1112 /// Show window borders (RW)
1113 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1116 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1120 /// Framedropping state (RW)
1121 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1122 void *arg
, MPContext
* mpctx
)
1125 if (!mpctx
->sh_video
)
1126 return M_PROPERTY_UNAVAILABLE
;
1129 case M_PROPERTY_PRINT
:
1131 return M_PROPERTY_ERROR
;
1132 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1133 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1135 return M_PROPERTY_OK
;
1137 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1141 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1142 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1145 int *gamma
= prop
->priv
, r
, val
;
1147 if (!mpctx
->sh_video
)
1148 return M_PROPERTY_UNAVAILABLE
;
1150 if (gamma
[0] == 1000) {
1152 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1156 case M_PROPERTY_SET
:
1158 return M_PROPERTY_ERROR
;
1159 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1160 *gamma
= *(int *) arg
;
1161 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1165 case M_PROPERTY_GET
:
1166 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1168 return M_PROPERTY_ERROR
;
1170 return M_PROPERTY_OK
;
1173 case M_PROPERTY_STEP_UP
:
1174 case M_PROPERTY_STEP_DOWN
:
1175 *gamma
+= (arg
? *(int *) arg
: 1) *
1176 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1177 M_PROPERTY_CLAMP(prop
, *gamma
);
1178 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1183 return M_PROPERTY_NOT_IMPLEMENTED
;
1187 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1188 int l
= strlen(prop
->name
);
1189 char tv_prop
[3 + l
+ 1];
1190 sprintf(tv_prop
, "tv_%s", prop
->name
);
1191 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1195 return M_PROPERTY_UNAVAILABLE
;
1199 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1202 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1205 /// Video codec tag (RO)
1206 static int mp_property_video_format(m_option_t
* prop
, int action
,
1207 void *arg
, MPContext
* mpctx
)
1210 if (!mpctx
->sh_video
)
1211 return M_PROPERTY_UNAVAILABLE
;
1213 case M_PROPERTY_PRINT
:
1215 return M_PROPERTY_ERROR
;
1216 switch(mpctx
->sh_video
->format
) {
1218 meta
= strdup ("mpeg1"); break;
1220 meta
= strdup ("mpeg2"); break;
1222 meta
= strdup ("mpeg4"); break;
1224 meta
= strdup ("h264"); break;
1226 if(mpctx
->sh_video
->format
>= 0x20202020) {
1228 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1231 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1234 *(char**)arg
= meta
;
1235 return M_PROPERTY_OK
;
1237 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1240 /// Video codec name (RO)
1241 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1242 void *arg
, MPContext
* mpctx
)
1244 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1245 return M_PROPERTY_UNAVAILABLE
;
1246 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1250 /// Video bitrate (RO)
1251 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1252 void *arg
, MPContext
* mpctx
)
1254 if (!mpctx
->sh_video
)
1255 return M_PROPERTY_UNAVAILABLE
;
1256 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1259 /// Video display width (RO)
1260 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1263 if (!mpctx
->sh_video
)
1264 return M_PROPERTY_UNAVAILABLE
;
1265 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1268 /// Video display height (RO)
1269 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1272 if (!mpctx
->sh_video
)
1273 return M_PROPERTY_UNAVAILABLE
;
1274 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1278 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1281 if (!mpctx
->sh_video
)
1282 return M_PROPERTY_UNAVAILABLE
;
1283 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1286 /// Video aspect (RO)
1287 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1290 if (!mpctx
->sh_video
)
1291 return M_PROPERTY_UNAVAILABLE
;
1292 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1297 /// \defgroup SubProprties Subtitles properties
1298 /// \ingroup Properties
1301 /// Text subtitle position (RW)
1302 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1305 if (!mpctx
->sh_video
)
1306 return M_PROPERTY_UNAVAILABLE
;
1309 case M_PROPERTY_SET
:
1311 return M_PROPERTY_ERROR
;
1312 case M_PROPERTY_STEP_UP
:
1313 case M_PROPERTY_STEP_DOWN
:
1314 vo_osd_changed(OSDTYPE_SUBTITLE
);
1316 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1320 /// Selected subtitles (RW)
1321 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1324 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1325 const int global_sub_size
= mpctx
->global_sub_size
;
1326 int source
= -1, reset_spu
= 0;
1329 if (global_sub_size
<= 0)
1330 return M_PROPERTY_UNAVAILABLE
;
1333 case M_PROPERTY_GET
:
1335 return M_PROPERTY_ERROR
;
1336 *(int *) arg
= mpctx
->global_sub_pos
;
1337 return M_PROPERTY_OK
;
1338 case M_PROPERTY_PRINT
:
1340 return M_PROPERTY_ERROR
;
1341 *(char **) arg
= malloc(64);
1342 (*(char **) arg
)[63] = 0;
1345 sub_name
= subdata
->filename
;
1347 if (ass_track
&& ass_track
->name
)
1348 sub_name
= ass_track
->name
;
1353 if ((tmp2
= strrchr(tmp
, '/')))
1356 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1357 mpctx
->set_of_sub_pos
+ 1,
1358 strlen(tmp
) < 20 ? "" : "...",
1359 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1360 return M_PROPERTY_OK
;
1362 #ifdef CONFIG_DVDNAV
1363 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1364 if (vo_spudec
&& dvdsub_id
>= 0) {
1365 unsigned char lang
[3];
1366 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1367 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1368 return M_PROPERTY_OK
;
1374 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1375 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1376 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1377 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1378 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1379 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1380 if (!lang
) lang
= MSGTR_Unknown
;
1381 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1382 return M_PROPERTY_OK
;
1385 if (vo_vobsub
&& vobsub_id
>= 0) {
1386 const char *language
= MSGTR_Unknown
;
1387 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1388 snprintf(*(char **) arg
, 63, "(%d) %s",
1389 vobsub_id
, language
? language
: MSGTR_Unknown
);
1390 return M_PROPERTY_OK
;
1392 #ifdef CONFIG_DVDREAD
1393 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1394 && dvdsub_id
>= 0) {
1396 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1397 lang
[0] = code
>> 8;
1400 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1401 return M_PROPERTY_OK
;
1404 if (dvdsub_id
>= 0) {
1405 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1406 return M_PROPERTY_OK
;
1408 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1409 return M_PROPERTY_OK
;
1411 case M_PROPERTY_SET
:
1413 return M_PROPERTY_ERROR
;
1414 if (*(int *) arg
< -1)
1416 else if (*(int *) arg
>= global_sub_size
)
1417 *(int *) arg
= global_sub_size
- 1;
1418 mpctx
->global_sub_pos
= *(int *) arg
;
1420 case M_PROPERTY_STEP_UP
:
1421 mpctx
->global_sub_pos
+= 2;
1422 mpctx
->global_sub_pos
=
1423 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1425 case M_PROPERTY_STEP_DOWN
:
1426 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1427 mpctx
->global_sub_pos
=
1428 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1431 return M_PROPERTY_NOT_IMPLEMENTED
;
1434 if (mpctx
->global_sub_pos
>= 0)
1435 source
= sub_source(mpctx
);
1437 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1438 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1440 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1441 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1442 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1443 mpctx
->global_sub_pos
, source
);
1445 mpctx
->set_of_sub_pos
= -1;
1459 if (source
== SUB_SOURCE_VOBSUB
) {
1460 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1461 } else if (source
== SUB_SOURCE_SUBS
) {
1462 mpctx
->set_of_sub_pos
=
1463 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1465 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1466 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1470 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1471 vo_osd_changed(OSDTYPE_SUBTITLE
);
1473 } else if (source
== SUB_SOURCE_DEMUX
) {
1475 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1476 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1478 // default: assume 1:1 mapping of sid and stream id
1479 d_sub
->id
= dvdsub_id
;
1480 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1481 ds_free_packs(d_sub
);
1482 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1483 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1484 if (sh
&& sh
->sid
== dvdsub_id
) {
1490 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1491 sh_sub_t
*sh
= d_sub
->sh
;
1492 if (sh
->type
== 'v')
1495 else if (ass_enabled
)
1496 ass_track
= sh
->ass_track
;
1504 #ifdef CONFIG_DVDREAD
1506 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1507 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1508 && dvdsub_id
< 0 && reset_spu
) {
1510 d_sub
->id
= dvdsub_id
;
1513 update_subtitles(mpctx
->sh_video
, d_sub
, 1);
1515 return M_PROPERTY_OK
;
1518 /// Selected sub source (RW)
1519 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1523 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1524 return M_PROPERTY_UNAVAILABLE
;
1527 case M_PROPERTY_GET
:
1529 return M_PROPERTY_ERROR
;
1530 *(int *) arg
= sub_source(mpctx
);
1531 return M_PROPERTY_OK
;
1532 case M_PROPERTY_PRINT
:
1534 return M_PROPERTY_ERROR
;
1535 *(char **) arg
= malloc(64);
1536 (*(char **) arg
)[63] = 0;
1537 switch (sub_source(mpctx
))
1539 case SUB_SOURCE_SUBS
:
1540 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1542 case SUB_SOURCE_VOBSUB
:
1543 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1545 case SUB_SOURCE_DEMUX
:
1546 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1549 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1551 return M_PROPERTY_OK
;
1552 case M_PROPERTY_SET
:
1554 return M_PROPERTY_ERROR
;
1555 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1556 if (*(int *) arg
< 0)
1557 mpctx
->global_sub_pos
= -1;
1558 else if (*(int *) arg
!= sub_source(mpctx
)) {
1559 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1560 return M_PROPERTY_UNAVAILABLE
;
1561 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1564 case M_PROPERTY_STEP_UP
:
1565 case M_PROPERTY_STEP_DOWN
: {
1566 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1567 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1568 int step
= (step_all
> 0) ? 1 : -1;
1569 int cur_source
= sub_source(mpctx
);
1570 source
= cur_source
;
1573 if (source
>= SUB_SOURCES
)
1575 else if (source
< -1)
1576 source
= SUB_SOURCES
- 1;
1577 if (source
== cur_source
|| source
== -1 ||
1578 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1581 if (source
== cur_source
)
1582 return M_PROPERTY_OK
;
1584 mpctx
->global_sub_pos
= -1;
1586 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1590 return M_PROPERTY_NOT_IMPLEMENTED
;
1592 --mpctx
->global_sub_pos
;
1593 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1596 /// Selected subtitles from specific source (RW)
1597 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1600 int source
, is_cur_source
, offset
;
1601 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1602 return M_PROPERTY_UNAVAILABLE
;
1604 if (!strcmp(prop
->name
, "sub_file"))
1605 source
= SUB_SOURCE_SUBS
;
1606 else if (!strcmp(prop
->name
, "sub_vob"))
1607 source
= SUB_SOURCE_VOBSUB
;
1608 else if (!strcmp(prop
->name
, "sub_demux"))
1609 source
= SUB_SOURCE_DEMUX
;
1611 return M_PROPERTY_ERROR
;
1613 offset
= mpctx
->global_sub_indices
[source
];
1614 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1615 return M_PROPERTY_UNAVAILABLE
;
1617 is_cur_source
= sub_source(mpctx
) == source
;
1619 case M_PROPERTY_GET
:
1621 return M_PROPERTY_ERROR
;
1622 if (is_cur_source
) {
1623 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1624 if (source
== SUB_SOURCE_VOBSUB
)
1625 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1629 return M_PROPERTY_OK
;
1630 case M_PROPERTY_PRINT
:
1632 return M_PROPERTY_ERROR
;
1634 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1635 *(char **) arg
= malloc(64);
1636 (*(char **) arg
)[63] = 0;
1637 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1638 return M_PROPERTY_OK
;
1639 case M_PROPERTY_SET
:
1641 return M_PROPERTY_ERROR
;
1642 if (*(int *) arg
>= 0) {
1643 int index
= *(int *)arg
;
1644 if (source
== SUB_SOURCE_VOBSUB
)
1645 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1646 mpctx
->global_sub_pos
= offset
+ index
;
1647 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1648 || sub_source(mpctx
) != source
) {
1649 mpctx
->global_sub_pos
= -1;
1654 mpctx
->global_sub_pos
= -1;
1656 case M_PROPERTY_STEP_UP
:
1657 case M_PROPERTY_STEP_DOWN
: {
1658 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1659 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1660 int step
= (step_all
> 0) ? 1 : -1;
1661 int max_sub_pos_for_source
= -1;
1663 mpctx
->global_sub_pos
= -1;
1665 if (mpctx
->global_sub_pos
== -1) {
1667 mpctx
->global_sub_pos
= offset
;
1668 else if (max_sub_pos_for_source
== -1) {
1669 // Find max pos for specific source
1670 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1671 while (mpctx
->global_sub_pos
>= 0
1672 && sub_source(mpctx
) != source
)
1673 --mpctx
->global_sub_pos
;
1676 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1679 mpctx
->global_sub_pos
+= step
;
1680 if (mpctx
->global_sub_pos
< offset
||
1681 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1682 sub_source(mpctx
) != source
)
1683 mpctx
->global_sub_pos
= -1;
1690 return M_PROPERTY_NOT_IMPLEMENTED
;
1692 --mpctx
->global_sub_pos
;
1693 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1696 /// Subtitle delay (RW)
1697 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1700 if (!mpctx
->sh_video
)
1701 return M_PROPERTY_UNAVAILABLE
;
1702 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1705 /// Alignment of text subtitles (RW)
1706 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1707 void *arg
, MPContext
* mpctx
)
1709 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1711 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1712 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1713 return M_PROPERTY_UNAVAILABLE
;
1716 case M_PROPERTY_PRINT
:
1718 return M_PROPERTY_ERROR
;
1719 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1720 *(char **) arg
= strdup(name
[sub_alignment
]);
1721 return M_PROPERTY_OK
;
1722 case M_PROPERTY_SET
:
1724 return M_PROPERTY_ERROR
;
1725 case M_PROPERTY_STEP_UP
:
1726 case M_PROPERTY_STEP_DOWN
:
1727 vo_osd_changed(OSDTYPE_SUBTITLE
);
1729 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1733 /// Subtitle visibility (RW)
1734 static int mp_property_sub_visibility(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 vo_osd_changed(OSDTYPE_SUBTITLE
);
1748 vo_osd_changed(OSDTYPE_SPU
);
1750 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1755 /// Use margins for libass subtitles (RW)
1756 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1757 void *arg
, MPContext
* mpctx
)
1759 if (!mpctx
->sh_video
)
1760 return M_PROPERTY_UNAVAILABLE
;
1763 case M_PROPERTY_SET
:
1765 return M_PROPERTY_ERROR
;
1766 case M_PROPERTY_STEP_UP
:
1767 case M_PROPERTY_STEP_DOWN
:
1768 ass_force_reload
= 1;
1770 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1775 /// Show only forced subtitles (RW)
1776 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1777 void *arg
, MPContext
* mpctx
)
1780 return M_PROPERTY_UNAVAILABLE
;
1783 case M_PROPERTY_SET
:
1785 return M_PROPERTY_ERROR
;
1786 case M_PROPERTY_STEP_UP
:
1787 case M_PROPERTY_STEP_DOWN
:
1788 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1789 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1790 return M_PROPERTY_OK
;
1792 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1797 #ifdef CONFIG_FREETYPE
1798 /// Subtitle scale (RW)
1799 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1804 case M_PROPERTY_SET
:
1806 return M_PROPERTY_ERROR
;
1807 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1810 ass_font_scale
= *(float *) arg
;
1811 ass_force_reload
= 1;
1814 text_font_scale_factor
= *(float *) arg
;
1815 force_load_font
= 1;
1816 return M_PROPERTY_OK
;
1817 case M_PROPERTY_STEP_UP
:
1818 case M_PROPERTY_STEP_DOWN
:
1821 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1822 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1823 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1824 ass_force_reload
= 1;
1827 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1828 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1829 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1830 force_load_font
= 1;
1831 return M_PROPERTY_OK
;
1835 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1838 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1845 /// \defgroup TVProperties TV properties
1846 /// \ingroup Properties
1851 /// TV color settings (RW)
1852 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1856 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1857 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1858 return M_PROPERTY_UNAVAILABLE
;
1861 case M_PROPERTY_SET
:
1863 return M_PROPERTY_ERROR
;
1864 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1865 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1866 case M_PROPERTY_GET
:
1867 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1868 case M_PROPERTY_STEP_UP
:
1869 case M_PROPERTY_STEP_DOWN
:
1870 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1872 return M_PROPERTY_ERROR
;
1873 val
+= (arg
? *(int *) arg
: 1) *
1874 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1875 M_PROPERTY_CLAMP(prop
, val
);
1876 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1878 return M_PROPERTY_ERROR
;
1880 return M_PROPERTY_NOT_IMPLEMENTED
;
1885 #ifdef CONFIG_TV_TELETEXT
1886 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1890 int base_ioctl
=(int)prop
->priv
;
1892 for teletext's GET,SET,STEP ioctls this is not 0
1896 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1897 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1898 return M_PROPERTY_UNAVAILABLE
;
1900 return M_PROPERTY_ERROR
;
1903 case M_PROPERTY_GET
:
1905 return M_PROPERTY_ERROR
;
1906 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1908 case M_PROPERTY_SET
:
1910 return M_PROPERTY_ERROR
;
1911 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1912 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1914 case M_PROPERTY_STEP_UP
:
1915 case M_PROPERTY_STEP_DOWN
:
1916 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1917 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1918 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1921 return M_PROPERTY_NOT_IMPLEMENTED
;
1924 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1927 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1930 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1934 //with tvh==NULL will fail too
1935 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1936 if(result
!=M_PROPERTY_OK
)
1939 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1940 mp_input_set_section("teletext");
1942 mp_input_set_section("tv");
1943 return M_PROPERTY_OK
;
1946 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1949 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1953 case M_PROPERTY_STEP_UP
:
1954 case M_PROPERTY_STEP_DOWN
:
1955 //This should be handled separately
1956 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1957 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1960 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1966 #endif /* CONFIG_TV_TELETEXT */
1970 /// All properties available in MPlayer.
1971 /** \ingroup Properties
1973 static const m_option_t mp_properties
[] = {
1975 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1976 M_OPT_RANGE
, 0, 3, NULL
},
1977 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1978 M_OPT_MIN
, -1, 0, NULL
},
1979 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1980 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1981 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1983 { "path", mp_property_path
, CONF_TYPE_STRING
,
1985 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1987 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1988 M_OPT_MIN
, 0, 0, NULL
},
1989 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1990 M_OPT_MIN
, 0, 0, NULL
},
1991 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1992 M_OPT_MIN
, 0, 0, NULL
},
1993 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1994 M_OPT_MIN
, 0, 0, NULL
},
1995 { "length", mp_property_length
, CONF_TYPE_TIME
,
1996 M_OPT_MIN
, 0, 0, NULL
},
1997 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1998 M_OPT_RANGE
, 0, 100, NULL
},
1999 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
2000 M_OPT_MIN
, 0, 0, NULL
},
2001 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
2002 M_OPT_MIN
, 1, 0, NULL
},
2003 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2005 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2006 CONF_RANGE
, -2, 10, NULL
},
2007 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2009 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2010 M_OPT_RANGE
, 0, 1, NULL
},
2013 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2014 M_OPT_RANGE
, 0, 100, NULL
},
2015 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2016 M_OPT_RANGE
, 0, 1, NULL
},
2017 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2018 M_OPT_RANGE
, -100, 100, NULL
},
2019 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2021 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2023 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2025 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2027 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2029 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2030 CONF_RANGE
, -2, MAX_A_STREAMS
- 1, NULL
},
2031 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2032 M_OPT_RANGE
, -1, 1, NULL
},
2035 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2036 M_OPT_RANGE
, 0, 1, NULL
},
2037 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2038 M_OPT_RANGE
, 0, 1, NULL
},
2039 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2040 M_OPT_RANGE
, 0, 1, NULL
},
2041 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2042 M_OPT_RANGE
, 0, 1, NULL
},
2043 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2044 M_OPT_RANGE
, 0, 1, NULL
},
2045 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2046 M_OPT_RANGE
, 0, 2, NULL
},
2047 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2048 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2049 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2050 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2051 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2052 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2053 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2054 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2055 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2056 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2057 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2058 M_OPT_RANGE
, 0, 1, NULL
},
2059 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2060 M_OPT_RANGE
, 0, 1, NULL
},
2061 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2063 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2065 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2067 { "width", mp_property_width
, CONF_TYPE_INT
,
2069 { "height", mp_property_height
, CONF_TYPE_INT
,
2071 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2073 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2075 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2076 CONF_RANGE
, -2, MAX_V_STREAMS
- 1, NULL
},
2077 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2078 CONF_RANGE
, -1, 65535, NULL
},
2081 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2082 M_OPT_MIN
, -1, 0, NULL
},
2083 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2084 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2085 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2086 M_OPT_MIN
, -1, 0, NULL
},
2087 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2088 M_OPT_MIN
, -1, 0, NULL
},
2089 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2090 M_OPT_MIN
, -1, 0, NULL
},
2091 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2093 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2094 M_OPT_RANGE
, 0, 100, NULL
},
2095 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2096 M_OPT_RANGE
, 0, 2, NULL
},
2097 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2098 M_OPT_RANGE
, 0, 1, NULL
},
2099 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2100 M_OPT_RANGE
, 0, 1, NULL
},
2101 #ifdef CONFIG_FREETYPE
2102 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2103 M_OPT_RANGE
, 0, 100, NULL
},
2106 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2107 M_OPT_RANGE
, 0, 1, NULL
},
2111 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2112 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2113 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2114 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2115 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2116 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2117 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2118 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2121 #ifdef CONFIG_TV_TELETEXT
2122 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2123 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2124 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2125 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2126 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2127 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2128 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2129 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2130 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2131 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2134 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2138 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2140 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2143 char* mp_property_print(const char *name
, void* ctx
)
2146 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2151 char *property_expand_string(MPContext
* mpctx
, char *str
)
2153 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2156 void property_print_help(void)
2158 m_properties_print_help_list(mp_properties
);
2167 * \defgroup Command2Property Command to property bridge
2169 * It is used to handle most commands that just set a property
2170 * and optionally display something on the OSD.
2171 * Two kinds of commands are handled: adjust or toggle.
2173 * Adjust commands take 1 or 2 parameters: <value> <abs>
2174 * If <abs> is non-zero the property is set to the given value
2175 * otherwise it is adjusted.
2177 * Toggle commands take 0 or 1 parameters. With no parameter
2178 * or a value less than the property minimum it just steps the
2179 * property to its next value. Otherwise it sets it to the given
2185 /// List of the commands that can be handled by setting a property.
2191 /// set/adjust or toggle command
2193 /// progressbar type
2195 /// osd msg id if it must be shared
2197 /// osd msg template
2198 const char *osd_msg
;
2199 } set_prop_cmd
[] = {
2201 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2202 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2203 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2205 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2206 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2207 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2208 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2209 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2211 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2212 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2213 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2214 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2215 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2216 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2217 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2218 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2219 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2220 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2221 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2222 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2224 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2225 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2226 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2227 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2228 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2229 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2230 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2231 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2232 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2233 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2234 #ifdef CONFIG_FREETYPE
2235 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2238 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2241 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2242 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2243 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2244 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2246 { NULL
, 0, 0, 0, -1, NULL
}
2250 /// Handle commands that set a property.
2251 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2257 // look for the command
2258 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2259 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2261 if (!(pname
= set_prop_cmd
[i
].name
))
2264 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2268 if (set_prop_cmd
[i
].toggle
) {
2270 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2271 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2273 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2274 } else if (cmd
->args
[1].v
.i
) //set
2275 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2277 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2282 if (set_prop_cmd
[i
].osd_progbar
) {
2283 if (prop
->type
== CONF_TYPE_INT
) {
2284 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2285 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2286 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2287 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2289 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2290 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2291 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2293 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2294 "Property use an unsupported type.\n");
2298 if (set_prop_cmd
[i
].osd_msg
) {
2299 char *val
= mp_property_print(pname
, mpctx
);
2301 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2302 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2303 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2310 #ifdef CONFIG_DVDNAV
2311 static const struct {
2313 const mp_command_type cmd
;
2314 } mp_dvdnav_bindings
[] = {
2315 { "up", MP_CMD_DVDNAV_UP
},
2316 { "down", MP_CMD_DVDNAV_DOWN
},
2317 { "left", MP_CMD_DVDNAV_LEFT
},
2318 { "right", MP_CMD_DVDNAV_RIGHT
},
2319 { "menu", MP_CMD_DVDNAV_MENU
},
2320 { "select", MP_CMD_DVDNAV_SELECT
},
2321 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2322 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2325 * keep old dvdnav sub-command options for a while in order not to
2326 * break slave-mode API too suddenly.
2328 { "1", MP_CMD_DVDNAV_UP
},
2329 { "2", MP_CMD_DVDNAV_DOWN
},
2330 { "3", MP_CMD_DVDNAV_LEFT
},
2331 { "4", MP_CMD_DVDNAV_RIGHT
},
2332 { "5", MP_CMD_DVDNAV_MENU
},
2333 { "6", MP_CMD_DVDNAV_SELECT
},
2334 { "7", MP_CMD_DVDNAV_PREVMENU
},
2335 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2340 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2342 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2343 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2345 if (!set_property_command(mpctx
, cmd
))
2351 mpctx
->osd_show_percentage
= sh_video
->fps
;
2352 v
= cmd
->args
[0].v
.f
;
2353 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2354 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2355 abs_seek_pos
= SEEK_ABSOLUTE
;
2357 mpctx
->osd_function
=
2358 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2360 } else if (abs
) { /* Absolute seek by percentage */
2361 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2363 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2364 rel_seek_secs
= v
/ 100.0;
2367 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2373 case MP_CMD_SET_PROPERTY
:{
2374 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2375 cmd
->args
[1].v
.s
, mpctx
);
2376 if (r
== M_PROPERTY_UNKNOWN
)
2377 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2378 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2380 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2381 "Failed to set property '%s' to '%s'.\n",
2382 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2386 case MP_CMD_STEP_PROPERTY
:{
2391 if (cmd
->args
[1].v
.f
) {
2393 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2394 M_PROPERTY_GET_TYPE
,
2395 &prop
, mpctx
)) <= 0)
2397 if(prop
->type
== CONF_TYPE_INT
||
2398 prop
->type
== CONF_TYPE_FLAG
)
2399 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2400 else if(prop
->type
== CONF_TYPE_FLOAT
)
2401 arg
= &cmd
->args
[1].v
.f
;
2402 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2403 prop
->type
== CONF_TYPE_TIME
)
2404 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2405 else if(prop
->type
== CONF_TYPE_POSITION
)
2406 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2408 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2409 "Ignoring step size stepping property '%s'.\n",
2412 r
= mp_property_do(cmd
->args
[0].v
.s
,
2413 cmd
->args
[2].v
.i
< 0 ?
2414 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2417 if (r
== M_PROPERTY_UNKNOWN
)
2418 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2419 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2421 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2422 "Failed to increment property '%s' by %f.\n",
2423 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2427 case MP_CMD_GET_PROPERTY
:{
2429 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2430 &tmp
, mpctx
) <= 0) {
2431 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2432 "Failed to get value of property '%s'.\n",
2436 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2437 cmd
->args
[0].v
.s
, tmp
);
2442 case MP_CMD_EDL_MARK
:
2444 float v
= sh_video
? sh_video
->pts
:
2445 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2448 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2449 mpctx
->begin_skip
= v
;
2450 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2452 if (mpctx
->begin_skip
> v
)
2453 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2455 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2456 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2458 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2463 case MP_CMD_SWITCH_RATIO
:
2464 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2465 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2467 movie_aspect
= cmd
->args
[0].v
.f
;
2468 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2471 case MP_CMD_SPEED_INCR
:{
2472 float v
= cmd
->args
[0].v
.f
;
2473 playback_speed
+= v
;
2474 build_afilter_chain(sh_audio
, &ao_data
);
2475 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2479 case MP_CMD_SPEED_MULT
:{
2480 float v
= cmd
->args
[0].v
.f
;
2481 playback_speed
*= v
;
2482 build_afilter_chain(sh_audio
, &ao_data
);
2483 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2487 case MP_CMD_SPEED_SET
:{
2488 float v
= cmd
->args
[0].v
.f
;
2490 build_afilter_chain(sh_audio
, &ao_data
);
2491 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2495 case MP_CMD_FRAME_STEP
:
2501 case MP_CMD_FILE_FILTER
:
2502 file_filter
= cmd
->args
[0].v
.i
;
2506 exit_player_with_rc(MSGTR_Exit_quit
,
2507 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2509 case MP_CMD_PLAY_TREE_STEP
:{
2510 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2511 int force
= cmd
->args
[1].v
.i
;
2517 for (i
= 0; i
< n
; i
++)
2520 for (i
= 0; i
< -1 * n
; i
++)
2525 if (!force
&& mpctx
->playtree_iter
) {
2526 play_tree_iter_t
*i
=
2527 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2528 if (play_tree_iter_step(i
, n
, 0) ==
2529 PLAY_TREE_ITER_ENTRY
)
2531 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2532 play_tree_iter_free(i
);
2534 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2536 mpctx
->play_tree_step
= n
;
2542 case MP_CMD_PLAY_TREE_UP_STEP
:{
2543 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2544 int force
= cmd
->args
[1].v
.i
;
2546 if (!force
&& mpctx
->playtree_iter
) {
2547 play_tree_iter_t
*i
=
2548 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2549 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2550 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2551 play_tree_iter_free(i
);
2553 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2558 case MP_CMD_PLAY_ALT_SRC_STEP
:
2559 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2560 int v
= cmd
->args
[0].v
.i
;
2562 && mpctx
->playtree_iter
->file
<
2563 mpctx
->playtree_iter
->num_files
)
2564 mpctx
->eof
= PT_NEXT_SRC
;
2565 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2566 mpctx
->eof
= PT_PREV_SRC
;
2571 case MP_CMD_SUB_STEP
:
2573 int movement
= cmd
->args
[0].v
.i
;
2574 step_sub(subdata
, sh_video
->pts
, movement
);
2578 ass_step_sub(ass_track
,
2580 sub_delay
) * 1000 + .5, movement
) / 1000.;
2582 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2583 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2587 case MP_CMD_SUB_LOG
:
2592 int v
= cmd
->args
[0].v
.i
;
2594 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2595 if (osd_level
> max
)
2598 osd_level
= (osd_level
+ 1) % (max
+ 1);
2600 osd_level
= v
> max
? max
: v
;
2601 /* Show OSD state when disabled, but not when an explicit
2602 argument is given to the OSD command, i.e. in slave mode. */
2603 if (v
== -1 && osd_level
<= 1)
2604 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2606 osd_level
? MSGTR_OSDenabled
:
2609 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2613 case MP_CMD_OSD_SHOW_TEXT
:
2614 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2616 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2617 "%-.63s", cmd
->args
[0].v
.s
);
2620 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2621 char *txt
= m_properties_expand_string(mp_properties
,
2624 /* if no argument supplied take default osd_duration, else <arg> ms. */
2626 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2628 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2635 case MP_CMD_LOADFILE
:{
2636 play_tree_t
*e
= play_tree_new();
2637 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2639 if (cmd
->args
[1].v
.i
) // append
2640 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2642 // Go back to the starting point.
2643 while (play_tree_iter_up_step
2644 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2646 play_tree_free_list(mpctx
->playtree
->child
, 1);
2647 play_tree_set_child(mpctx
->playtree
, e
);
2648 pt_iter_goto_head(mpctx
->playtree_iter
);
2649 mpctx
->eof
= PT_NEXT_SRC
;
2655 case MP_CMD_LOADLIST
:{
2656 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2658 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2659 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2661 if (cmd
->args
[1].v
.i
) // append
2662 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2664 // Go back to the starting point.
2665 while (play_tree_iter_up_step
2666 (mpctx
->playtree_iter
, 0, 1)
2667 != PLAY_TREE_ITER_END
)
2669 play_tree_free_list(mpctx
->playtree
->child
, 1);
2670 play_tree_set_child(mpctx
->playtree
, e
);
2671 pt_iter_goto_head(mpctx
->playtree_iter
);
2672 mpctx
->eof
= PT_NEXT_SRC
;
2680 // Go back to the starting point.
2681 while (play_tree_iter_up_step
2682 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2684 mpctx
->eof
= PT_STOP
;
2689 case MP_CMD_RADIO_STEP_CHANNEL
:
2690 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2691 int v
= cmd
->args
[0].v
.i
;
2693 radio_step_channel(mpctx
->demuxer
->stream
,
2694 RADIO_CHANNEL_HIGHER
);
2696 radio_step_channel(mpctx
->demuxer
->stream
,
2697 RADIO_CHANNEL_LOWER
);
2698 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2699 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2701 radio_get_channel_name(mpctx
->demuxer
->stream
));
2706 case MP_CMD_RADIO_SET_CHANNEL
:
2707 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2708 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2709 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2710 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2712 radio_get_channel_name(mpctx
->demuxer
->stream
));
2717 case MP_CMD_RADIO_SET_FREQ
:
2718 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2719 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2722 case MP_CMD_RADIO_STEP_FREQ
:
2723 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2724 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2729 case MP_CMD_TV_START_SCAN
:
2730 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2731 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2733 case MP_CMD_TV_SET_FREQ
:
2734 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2735 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2736 cmd
->args
[0].v
.f
* 16.0);
2738 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2739 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2740 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2741 pvr_get_current_channelname (mpctx
->stream
),
2742 pvr_get_current_stationname (mpctx
->stream
));
2744 #endif /* CONFIG_PVR */
2747 case MP_CMD_TV_STEP_FREQ
:
2748 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2749 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2750 cmd
->args
[0].v
.f
* 16.0);
2752 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2753 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2754 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2755 pvr_get_current_channelname (mpctx
->stream
),
2756 pvr_get_current_frequency (mpctx
->stream
));
2758 #endif /* CONFIG_PVR */
2761 case MP_CMD_TV_SET_NORM
:
2762 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2763 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2767 case MP_CMD_TV_STEP_CHANNEL
:{
2768 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2769 int v
= cmd
->args
[0].v
.i
;
2771 tv_step_channel((tvi_handle_t
*) (mpctx
->
2775 tv_step_channel((tvi_handle_t
*) (mpctx
->
2779 if (tv_channel_list
) {
2780 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2781 MSGTR_OSDChannel
, tv_channel_current
->name
);
2782 //vo_osd_changed(OSDTYPE_SUBTITLE);
2786 else if (mpctx
->stream
&&
2787 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2788 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2789 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2790 pvr_get_current_channelname (mpctx
->stream
),
2791 pvr_get_current_stationname (mpctx
->stream
));
2793 #endif /* CONFIG_PVR */
2796 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2798 int v
= cmd
->args
[0].v
.i
;
2800 mpctx
->last_dvb_step
= v
;
2802 dir
= DVB_CHANNEL_HIGHER
;
2804 dir
= DVB_CHANNEL_LOWER
;
2807 if (dvb_step_channel(mpctx
->stream
, dir
))
2808 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2810 #endif /* CONFIG_DVBIN */
2813 case MP_CMD_TV_SET_CHANNEL
:
2814 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2815 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2817 if (tv_channel_list
) {
2818 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2819 MSGTR_OSDChannel
, tv_channel_current
->name
);
2820 //vo_osd_changed(OSDTYPE_SUBTITLE);
2824 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2825 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2826 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2827 pvr_get_current_channelname (mpctx
->stream
),
2828 pvr_get_current_stationname (mpctx
->stream
));
2830 #endif /* CONFIG_PVR */
2834 case MP_CMD_DVB_SET_CHANNEL
:
2835 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2836 mpctx
->last_dvb_step
= 1;
2839 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2840 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2843 #endif /* CONFIG_DVBIN */
2845 case MP_CMD_TV_LAST_CHANNEL
:
2846 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2847 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2848 if (tv_channel_list
) {
2849 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2850 MSGTR_OSDChannel
, tv_channel_current
->name
);
2851 //vo_osd_changed(OSDTYPE_SUBTITLE);
2855 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2856 pvr_set_lastchannel (mpctx
->stream
);
2857 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2858 pvr_get_current_channelname (mpctx
->stream
),
2859 pvr_get_current_stationname (mpctx
->stream
));
2861 #endif /* CONFIG_PVR */
2864 case MP_CMD_TV_STEP_NORM
:
2865 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2866 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2869 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2870 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2871 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2873 #ifdef CONFIG_TV_TELETEXT
2874 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2876 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2877 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2878 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2881 case MP_CMD_TV_TELETEXT_GO_LINK
:
2883 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2884 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2885 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2888 #endif /* CONFIG_TV_TELETEXT */
2889 #endif /* CONFIG_TV */
2891 case MP_CMD_SUB_LOAD
:
2893 int n
= mpctx
->set_of_sub_size
;
2894 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2895 if (n
!= mpctx
->set_of_sub_size
) {
2896 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2897 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2898 mpctx
->global_sub_size
;
2899 ++mpctx
->global_sub_size
;
2904 case MP_CMD_SUB_REMOVE
:
2906 int v
= cmd
->args
[0].v
.i
;
2909 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2910 subd
= mpctx
->set_of_subtitles
[v
];
2911 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2912 MSGTR_RemovedSubtitleFile
, v
+ 1,
2913 filename_recode(subd
->filename
));
2915 mpctx
->set_of_subtitles
[v
] = NULL
;
2917 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2918 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2919 mpctx
->set_of_sub_size
= 0;
2920 if (mpctx
->set_of_sub_pos
>= 0) {
2921 mpctx
->global_sub_pos
= -2;
2923 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2925 } else if (v
< mpctx
->set_of_sub_size
) {
2926 subd
= mpctx
->set_of_subtitles
[v
];
2927 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2928 MSGTR_RemovedSubtitleFile
, v
+ 1,
2929 filename_recode(subd
->filename
));
2931 if (mpctx
->set_of_sub_pos
== v
) {
2932 mpctx
->global_sub_pos
= -2;
2934 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2935 } else if (mpctx
->set_of_sub_pos
> v
) {
2936 --mpctx
->set_of_sub_pos
;
2937 --mpctx
->global_sub_pos
;
2939 while (++v
< mpctx
->set_of_sub_size
)
2940 mpctx
->set_of_subtitles
[v
- 1] =
2941 mpctx
->set_of_subtitles
[v
];
2942 --mpctx
->set_of_sub_size
;
2943 --mpctx
->global_sub_size
;
2944 if (mpctx
->set_of_sub_size
<= 0)
2945 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2946 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2951 case MP_CMD_GET_SUB_VISIBILITY
:
2953 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2954 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2958 case MP_CMD_SCREENSHOT
:
2959 if (vo_config_count
) {
2960 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2962 ((vf_instance_t
*) sh_video
->vfilter
)->
2963 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2965 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2969 case MP_CMD_VF_CHANGE_RECTANGLE
:
2970 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2973 case MP_CMD_GET_TIME_LENGTH
:{
2974 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2975 demuxer_get_time_length(mpctx
->demuxer
));
2979 case MP_CMD_GET_FILENAME
:{
2980 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2981 get_metadata(META_NAME
));
2985 case MP_CMD_GET_VIDEO_CODEC
:{
2986 char *inf
= get_metadata(META_VIDEO_CODEC
);
2989 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2994 case MP_CMD_GET_VIDEO_BITRATE
:{
2995 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2998 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3003 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3004 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
3007 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3008 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3013 case MP_CMD_GET_AUDIO_CODEC
:{
3014 char *inf
= get_metadata(META_AUDIO_CODEC
);
3017 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3022 case MP_CMD_GET_AUDIO_BITRATE
:{
3023 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3026 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3031 case MP_CMD_GET_AUDIO_SAMPLES
:{
3032 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3035 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3040 case MP_CMD_GET_META_TITLE
:{
3041 char *inf
= get_metadata(META_INFO_TITLE
);
3044 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3049 case MP_CMD_GET_META_ARTIST
:{
3050 char *inf
= get_metadata(META_INFO_ARTIST
);
3053 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3058 case MP_CMD_GET_META_ALBUM
:{
3059 char *inf
= get_metadata(META_INFO_ALBUM
);
3062 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3067 case MP_CMD_GET_META_YEAR
:{
3068 char *inf
= get_metadata(META_INFO_YEAR
);
3071 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3076 case MP_CMD_GET_META_COMMENT
:{
3077 char *inf
= get_metadata(META_INFO_COMMENT
);
3080 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3085 case MP_CMD_GET_META_TRACK
:{
3086 char *inf
= get_metadata(META_INFO_TRACK
);
3089 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3094 case MP_CMD_GET_META_GENRE
:{
3095 char *inf
= get_metadata(META_INFO_GENRE
);
3098 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3103 case MP_CMD_GET_VO_FULLSCREEN
:
3104 if (mpctx
->video_out
&& vo_config_count
)
3105 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3108 case MP_CMD_GET_PERCENT_POS
:
3109 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3110 demuxer_get_percent_pos(mpctx
->demuxer
));
3113 case MP_CMD_GET_TIME_POS
:{
3116 pos
= sh_video
->pts
;
3117 else if (sh_audio
&& mpctx
->audio_out
)
3119 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3121 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3128 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3134 case MP_CMD_KEYDOWN_EVENTS
:
3135 mplayer_put_key(cmd
->args
[0].v
.i
);
3138 case MP_CMD_SET_MOUSE_POS
:{
3139 int pointer_x
, pointer_y
;
3141 pointer_x
= cmd
->args
[0].v
.i
;
3142 pointer_y
= cmd
->args
[1].v
.i
;
3143 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3144 #ifdef CONFIG_DVDNAV
3145 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3146 && dx
> 0.0 && dy
> 0.0) {
3148 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3149 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3150 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3151 pointer_x
, pointer_y
, &button
);
3152 if (osd_level
> 1 && button
> 0)
3153 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3154 "Selected button number %d", button
);
3158 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3159 menu_update_mouse_pos(dx
, dy
);
3164 #ifdef CONFIG_DVDNAV
3165 case MP_CMD_DVDNAV
:{
3168 mp_command_type command
= 0;
3169 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3172 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3173 if (cmd
->args
[0].v
.s
&&
3174 !strcasecmp (cmd
->args
[0].v
.s
,
3175 mp_dvdnav_bindings
[i
].name
))
3176 command
= mp_dvdnav_bindings
[i
].cmd
;
3178 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3179 if (osd_level
> 1 && button
> 0)
3180 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3181 "Selected button number %d", button
);
3185 case MP_CMD_SWITCH_TITLE
:
3186 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3187 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3194 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3195 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3198 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3199 "Received unknown cmd %s\n", cmd
->name
);
3202 switch (cmd
->pausing
) {
3203 case 1: // "pausing"
3204 mpctx
->osd_function
= OSD_PAUSE
;
3206 case 3: // "pausing_toggle"
3207 mpctx
->was_paused
= !mpctx
->was_paused
;
3208 if (mpctx
->was_paused
)
3209 mpctx
->osd_function
= OSD_PAUSE
;
3210 else if (mpctx
->osd_function
== OSD_PAUSE
)
3211 mpctx
->osd_function
= OSD_PLAY
;
3213 case 2: // "pausing_keep"
3214 if (mpctx
->was_paused
)
3215 mpctx
->osd_function
= OSD_PAUSE
;