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"
28 #include "libmpcodecs/dec_teletext.h"
32 #include "stream/tv.h"
33 #include "stream/stream_radio.h"
34 #include "stream/pvr.h"
36 #include "stream/dvbin.h"
39 #include "stream/stream_dvd.h"
41 #include "stream/stream_dvdnav.h"
42 #include "libass/ass.h"
43 #include "libass/ass_mp.h"
45 #include "libmenu/menu.h"
46 #include "gui/interface.h"
50 #include "libavutil/avstring.h"
52 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
56 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
58 //remove the borders, if any, and rescale to the range [0,1],[0,1]
59 if (vo_fs
) { //we are in full-screen mode
60 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
61 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
62 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
63 iy
-= (vo_screenheight
- vo_dheight
) / 2;
65 if (ix
< 0 || ix
> vo_dwidth
) {
68 } //we are on one of the borders
69 if (iy
< 0 || iy
> vo_dheight
) {
72 } //we are on one of the borders
75 *dx
= (double) ix
/ (double) vo_dwidth
;
76 *dy
= (double) iy
/ (double) vo_dheight
;
78 mp_msg(MSGT_CPLAYER
, MSGL_V
,
79 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
80 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
84 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
89 for (i
= 0; i
< SUB_SOURCES
; i
++) {
90 int j
= mpctx
->global_sub_indices
[i
];
91 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
99 static int sub_source(MPContext
* mpctx
)
101 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
105 * \brief Log the currently displayed subtitle to a file
107 * Logs the current or last displayed subtitle together with filename
108 * and time information to ~/.mplayer/subtitle_log
110 * Intended purpose is to allow convenient marking of bogus subtitles
111 * which need to be fixed while watching the movie.
114 static void log_sub(void)
120 if (subdata
== NULL
|| vo_sub_last
== NULL
)
122 fname
= get_path("subtitle_log");
123 f
= fopen(fname
, "a");
126 fprintf(f
, "----------------------------------------------------------\n");
127 if (subdata
->sub_uses_time
) {
129 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
130 filename
, vo_sub_last
->start
/ 360000,
131 (vo_sub_last
->start
/ 6000) % 60,
132 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
133 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
134 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
136 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
139 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
140 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
146 /// \defgroup Properties
149 /// \defgroup GeneralProperties General properties
150 /// \ingroup Properties
154 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
157 return m_property_choice(prop
, action
, arg
, &osd_level
);
161 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
165 case M_PROPERTY_PRINT
:
166 if (!arg
) return M_PROPERTY_ERROR
;
167 if (mpctx
->loop_times
< 0)
168 *(char**)arg
= strdup("off");
169 else if (mpctx
->loop_times
== 0)
170 *(char**)arg
= strdup("inf");
173 return M_PROPERTY_OK
;
175 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
178 /// Playback speed (RW)
179 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
180 void *arg
, MPContext
* mpctx
)
185 return M_PROPERTY_ERROR
;
186 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
187 playback_speed
= *(float *) arg
;
188 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
189 return M_PROPERTY_OK
;
190 case M_PROPERTY_STEP_UP
:
191 case M_PROPERTY_STEP_DOWN
:
192 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
193 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
194 M_PROPERTY_CLAMP(prop
, playback_speed
);
195 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
196 return M_PROPERTY_OK
;
198 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
201 /// filename with path (RO)
202 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
205 return m_property_string_ro(prop
, action
, arg
, filename
);
208 /// filename without path (RO)
209 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
214 return M_PROPERTY_UNAVAILABLE
;
215 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
219 return m_property_string_ro(prop
, action
, arg
, f
);
222 /// Demuxer name (RO)
223 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
227 return M_PROPERTY_UNAVAILABLE
;
228 return m_property_string_ro(prop
, action
, arg
,
229 (char *) mpctx
->demuxer
->desc
->name
);
232 /// Position in the stream (RW)
233 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
236 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
237 return M_PROPERTY_UNAVAILABLE
;
239 return M_PROPERTY_ERROR
;
242 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
243 return M_PROPERTY_OK
;
245 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
246 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
247 return M_PROPERTY_OK
;
249 return M_PROPERTY_NOT_IMPLEMENTED
;
252 /// Stream start offset (RO)
253 static int mp_property_stream_start(m_option_t
* prop
, int action
,
254 void *arg
, MPContext
* mpctx
)
256 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
257 return M_PROPERTY_UNAVAILABLE
;
260 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
261 return M_PROPERTY_OK
;
263 return M_PROPERTY_NOT_IMPLEMENTED
;
266 /// Stream end offset (RO)
267 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
270 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
271 return M_PROPERTY_UNAVAILABLE
;
274 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
275 return M_PROPERTY_OK
;
277 return M_PROPERTY_NOT_IMPLEMENTED
;
280 /// Stream length (RO)
281 static int mp_property_stream_length(m_option_t
* prop
, int action
,
282 void *arg
, MPContext
* mpctx
)
284 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
285 return M_PROPERTY_UNAVAILABLE
;
289 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
290 return M_PROPERTY_OK
;
292 return M_PROPERTY_NOT_IMPLEMENTED
;
295 /// Media length in seconds (RO)
296 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
301 if (!mpctx
->demuxer
||
302 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
303 return M_PROPERTY_UNAVAILABLE
;
305 return m_property_time_ro(prop
, action
, arg
, len
);
308 /// Current position in percent (RW)
309 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
310 void *arg
, MPContext
* mpctx
) {
314 return M_PROPERTY_UNAVAILABLE
;
318 if(!arg
) return M_PROPERTY_ERROR
;
319 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
322 case M_PROPERTY_STEP_UP
:
323 case M_PROPERTY_STEP_DOWN
:
324 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
325 pos
+= (arg
? *(int*)arg
: 10) *
326 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
327 M_PROPERTY_CLAMP(prop
, pos
);
330 return m_property_int_ro(prop
, action
, arg
,
331 demuxer_get_percent_pos(mpctx
->demuxer
));
334 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
335 rel_seek_secs
= pos
/ 100.0;
336 return M_PROPERTY_OK
;
339 /// Current position in seconds (RW)
340 static int mp_property_time_pos(m_option_t
* prop
, int action
,
341 void *arg
, MPContext
* mpctx
) {
342 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
343 return M_PROPERTY_UNAVAILABLE
;
347 if(!arg
) return M_PROPERTY_ERROR
;
348 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
349 abs_seek_pos
= SEEK_ABSOLUTE
;
350 rel_seek_secs
= *(double*)arg
;
351 return M_PROPERTY_OK
;
352 case M_PROPERTY_STEP_UP
:
353 case M_PROPERTY_STEP_DOWN
:
354 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
355 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
356 return M_PROPERTY_OK
;
358 return m_property_time_ro(prop
, action
, arg
,
359 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
360 playing_audio_pts(mpctx
->sh_audio
,
365 /// Current chapter (RW)
366 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
373 char *chapter_name
= NULL
;
376 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
378 return M_PROPERTY_UNAVAILABLE
;
383 return M_PROPERTY_ERROR
;
384 *(int *) arg
= chapter
;
385 return M_PROPERTY_OK
;
386 case M_PROPERTY_PRINT
: {
388 return M_PROPERTY_ERROR
;
389 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
391 return M_PROPERTY_UNAVAILABLE
;
392 *(char **) arg
= chapter_name
;
393 return M_PROPERTY_OK
;
397 return M_PROPERTY_ERROR
;
398 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
399 step_all
= *(int *)arg
- chapter
;
402 case M_PROPERTY_STEP_UP
:
403 case M_PROPERTY_STEP_DOWN
: {
404 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
405 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
412 return M_PROPERTY_NOT_IMPLEMENTED
;
416 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
417 &next_pts
, &chapter_num
, &chapter_name
);
419 if (next_pts
> -1.0) {
420 abs_seek_pos
= SEEK_ABSOLUTE
;
421 rel_seek_secs
= next_pts
;
424 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
425 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
427 else if (step_all
> 0)
428 rel_seek_secs
= 1000000000.;
430 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
431 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
434 return M_PROPERTY_OK
;
437 /// Number of chapters in file
438 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
442 return M_PROPERTY_UNAVAILABLE
;
443 if (mpctx
->demuxer
->num_chapters
== 0)
444 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
445 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
448 /// Current dvd angle (RW)
449 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
454 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
;
544 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
547 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
553 /// \defgroup AudioProperties Audio properties
554 /// \ingroup Properties
558 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
562 if (!mpctx
->sh_audio
)
563 return M_PROPERTY_UNAVAILABLE
;
568 return M_PROPERTY_ERROR
;
569 mixer_getbothvolume(&mpctx
->mixer
, arg
);
570 return M_PROPERTY_OK
;
571 case M_PROPERTY_PRINT
:{
574 return M_PROPERTY_ERROR
;
575 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
576 return m_property_float_range(prop
, action
, arg
, &vol
);
578 case M_PROPERTY_STEP_UP
:
579 case M_PROPERTY_STEP_DOWN
:
583 return M_PROPERTY_NOT_IMPLEMENTED
;
586 if (mpctx
->edl_muted
)
587 return M_PROPERTY_DISABLED
;
588 mpctx
->user_muted
= 0;
593 return M_PROPERTY_ERROR
;
594 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
595 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
596 return M_PROPERTY_OK
;
597 case M_PROPERTY_STEP_UP
:
598 if (arg
&& *(float *) arg
<= 0)
599 mixer_decvolume(&mpctx
->mixer
);
601 mixer_incvolume(&mpctx
->mixer
);
602 return M_PROPERTY_OK
;
603 case M_PROPERTY_STEP_DOWN
:
604 if (arg
&& *(float *) arg
<= 0)
605 mixer_incvolume(&mpctx
->mixer
);
607 mixer_decvolume(&mpctx
->mixer
);
608 return M_PROPERTY_OK
;
610 return M_PROPERTY_NOT_IMPLEMENTED
;
614 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
618 if (!mpctx
->sh_audio
)
619 return M_PROPERTY_UNAVAILABLE
;
623 if (mpctx
->edl_muted
)
624 return M_PROPERTY_DISABLED
;
626 return M_PROPERTY_ERROR
;
627 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
628 mixer_mute(&mpctx
->mixer
);
629 mpctx
->user_muted
= mpctx
->mixer
.muted
;
630 return M_PROPERTY_OK
;
631 case M_PROPERTY_STEP_UP
:
632 case M_PROPERTY_STEP_DOWN
:
633 if (mpctx
->edl_muted
)
634 return M_PROPERTY_DISABLED
;
635 mixer_mute(&mpctx
->mixer
);
636 mpctx
->user_muted
= mpctx
->mixer
.muted
;
637 return M_PROPERTY_OK
;
638 case M_PROPERTY_PRINT
:
640 return M_PROPERTY_ERROR
;
641 if (mpctx
->edl_muted
) {
642 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
643 return M_PROPERTY_OK
;
646 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
652 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
653 void *arg
, MPContext
* mpctx
)
655 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
656 return M_PROPERTY_UNAVAILABLE
;
659 case M_PROPERTY_STEP_UP
:
660 case M_PROPERTY_STEP_DOWN
: {
662 float delay
= audio_delay
;
663 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
664 if (ret
!= M_PROPERTY_OK
)
667 mpctx
->delay
-= audio_delay
- delay
;
669 return M_PROPERTY_OK
;
671 return m_property_delay(prop
, action
, arg
, &audio_delay
);
675 /// Audio codec tag (RO)
676 static int mp_property_audio_format(m_option_t
* prop
, int action
,
677 void *arg
, MPContext
* mpctx
)
679 if (!mpctx
->sh_audio
)
680 return M_PROPERTY_UNAVAILABLE
;
681 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
684 /// Audio codec name (RO)
685 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
686 void *arg
, MPContext
* mpctx
)
688 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
689 return M_PROPERTY_UNAVAILABLE
;
690 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
693 /// Audio bitrate (RO)
694 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
695 void *arg
, MPContext
* mpctx
)
697 if (!mpctx
->sh_audio
)
698 return M_PROPERTY_UNAVAILABLE
;
699 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
703 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
706 if (!mpctx
->sh_audio
)
707 return M_PROPERTY_UNAVAILABLE
;
709 case M_PROPERTY_PRINT
:
710 if(!arg
) return M_PROPERTY_ERROR
;
711 *(char**)arg
= malloc(16);
712 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
713 return M_PROPERTY_OK
;
715 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
718 /// Number of channels (RO)
719 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
722 if (!mpctx
->sh_audio
)
723 return M_PROPERTY_UNAVAILABLE
;
725 case M_PROPERTY_PRINT
:
727 return M_PROPERTY_ERROR
;
728 switch (mpctx
->sh_audio
->channels
) {
730 *(char **) arg
= strdup("mono");
733 *(char **) arg
= strdup("stereo");
736 *(char **) arg
= malloc(32);
737 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
739 return M_PROPERTY_OK
;
741 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
745 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
750 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
751 return M_PROPERTY_UNAVAILABLE
;
756 return M_PROPERTY_ERROR
;
757 mixer_getbalance(&mpctx
->mixer
, arg
);
758 return M_PROPERTY_OK
;
759 case M_PROPERTY_PRINT
: {
762 return M_PROPERTY_ERROR
;
763 mixer_getbalance(&mpctx
->mixer
, &bal
);
765 *str
= strdup("center");
766 else if (bal
== -1.f
)
767 *str
= strdup("left only");
769 *str
= strdup("right only");
771 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
772 *str
= malloc(sizeof("left xxx%, right xxx%"));
773 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
775 return M_PROPERTY_OK
;
777 case M_PROPERTY_STEP_UP
:
778 case M_PROPERTY_STEP_DOWN
:
779 mixer_getbalance(&mpctx
->mixer
, &bal
);
780 bal
+= (arg
? *(float*)arg
: .1f
) *
781 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
782 M_PROPERTY_CLAMP(prop
, bal
);
783 mixer_setbalance(&mpctx
->mixer
, bal
);
784 return M_PROPERTY_OK
;
787 return M_PROPERTY_ERROR
;
788 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
789 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
790 return M_PROPERTY_OK
;
792 return M_PROPERTY_NOT_IMPLEMENTED
;
795 /// Selected audio id (RW)
796 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
799 int current_id
= -1, tmp
;
803 if (!mpctx
->sh_audio
)
804 return M_PROPERTY_UNAVAILABLE
;
806 return M_PROPERTY_ERROR
;
807 *(int *) arg
= audio_id
;
808 return M_PROPERTY_OK
;
809 case M_PROPERTY_PRINT
:
810 if (!mpctx
->sh_audio
)
811 return M_PROPERTY_UNAVAILABLE
;
813 return M_PROPERTY_ERROR
;
816 *(char **) arg
= strdup(MSGTR_Disabled
);
818 char lang
[40] = MSGTR_Unknown
;
819 sh_audio_t
* sh
= mpctx
->sh_audio
;
821 av_strlcpy(lang
, sh
->lang
, 40);
822 #ifdef CONFIG_DVDREAD
823 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
824 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
834 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
835 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
837 *(char **) arg
= malloc(64);
838 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
840 return M_PROPERTY_OK
;
842 case M_PROPERTY_STEP_UP
:
845 return M_PROPERTY_UNAVAILABLE
;
846 if (action
== M_PROPERTY_SET
&& arg
)
847 tmp
= *((int *) arg
);
850 current_id
= mpctx
->demuxer
->audio
->id
;
851 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
854 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
855 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
856 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
858 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
860 sh2
->ds
= mpctx
->demuxer
->audio
;
861 mpctx
->sh_audio
= sh2
;
862 reinit_audio_chain();
865 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
866 return M_PROPERTY_OK
;
868 return M_PROPERTY_NOT_IMPLEMENTED
;
873 /// Selected video id (RW)
874 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
877 int current_id
= -1, tmp
;
881 if (!mpctx
->sh_video
)
882 return M_PROPERTY_UNAVAILABLE
;
884 return M_PROPERTY_ERROR
;
885 *(int *) arg
= video_id
;
886 return M_PROPERTY_OK
;
887 case M_PROPERTY_PRINT
:
888 if (!mpctx
->sh_video
)
889 return M_PROPERTY_UNAVAILABLE
;
891 return M_PROPERTY_ERROR
;
894 *(char **) arg
= strdup(MSGTR_Disabled
);
896 char lang
[40] = MSGTR_Unknown
;
897 *(char **) arg
= malloc(64);
898 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
900 return M_PROPERTY_OK
;
902 case M_PROPERTY_STEP_UP
:
904 current_id
= mpctx
->demuxer
->video
->id
;
905 if (action
== M_PROPERTY_SET
&& arg
)
906 tmp
= *((int *) arg
);
909 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
911 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
912 && current_id
!= -2))
913 uninit_player(INITIALIZED_VCODEC
|
914 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
915 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
917 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
919 sh2
->ds
= mpctx
->demuxer
->video
;
920 mpctx
->sh_video
= sh2
;
921 reinit_video_chain();
924 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
925 return M_PROPERTY_OK
;
928 return M_PROPERTY_NOT_IMPLEMENTED
;
932 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
935 demux_program_t prog
;
938 case M_PROPERTY_STEP_UP
:
940 if (action
== M_PROPERTY_SET
&& arg
)
941 prog
.progid
= *((int *) arg
);
945 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
946 &prog
) == DEMUXER_CTRL_NOTIMPL
)
947 return M_PROPERTY_ERROR
;
949 if (prog
.aid
< 0 && prog
.vid
< 0) {
950 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
951 return M_PROPERTY_ERROR
;
953 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
954 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
955 return M_PROPERTY_OK
;
958 return M_PROPERTY_NOT_IMPLEMENTED
;
964 /// \defgroup VideoProperties Video properties
965 /// \ingroup Properties
968 /// Fullscreen state (RW)
969 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
973 if (!mpctx
->video_out
)
974 return M_PROPERTY_UNAVAILABLE
;
979 return M_PROPERTY_ERROR
;
980 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
981 if (vo_fs
== !!*(int *) arg
)
982 return M_PROPERTY_OK
;
983 case M_PROPERTY_STEP_UP
:
984 case M_PROPERTY_STEP_DOWN
:
987 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
991 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
992 return M_PROPERTY_OK
;
994 return m_property_flag(prop
, action
, arg
, &vo_fs
);
998 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
999 void *arg
, MPContext
* mpctx
)
1003 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1004 return M_PROPERTY_UNAVAILABLE
;
1005 vf
= mpctx
->sh_video
->vfilter
;
1007 case M_PROPERTY_GET
:
1009 return M_PROPERTY_ERROR
;
1010 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1011 return M_PROPERTY_OK
;
1012 case M_PROPERTY_SET
:
1014 return M_PROPERTY_ERROR
;
1015 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1016 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1017 return M_PROPERTY_OK
;
1018 case M_PROPERTY_STEP_UP
:
1019 case M_PROPERTY_STEP_DOWN
:
1020 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1021 deinterlace
= !deinterlace
;
1022 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1023 return M_PROPERTY_OK
;
1025 return M_PROPERTY_NOT_IMPLEMENTED
;
1029 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1033 if (!mpctx
->video_out
1034 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1035 return M_PROPERTY_UNAVAILABLE
;
1038 case M_PROPERTY_SET
:
1040 return M_PROPERTY_ERROR
;
1041 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1042 vo_panscan
= *(float *) arg
;
1043 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1044 return M_PROPERTY_OK
;
1045 case M_PROPERTY_STEP_UP
:
1046 case M_PROPERTY_STEP_DOWN
:
1047 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1048 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1051 else if (vo_panscan
< 0)
1053 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1054 return M_PROPERTY_OK
;
1056 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1060 /// Helper to set vo flags.
1061 /** \ingroup PropertyImplHelper
1063 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1064 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1067 if (!mpctx
->video_out
)
1068 return M_PROPERTY_UNAVAILABLE
;
1071 case M_PROPERTY_SET
:
1073 return M_PROPERTY_ERROR
;
1074 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1075 if (*vo_var
== !!*(int *) arg
)
1076 return M_PROPERTY_OK
;
1077 case M_PROPERTY_STEP_UP
:
1078 case M_PROPERTY_STEP_DOWN
:
1079 if (vo_config_count
)
1080 mpctx
->video_out
->control(vo_ctrl
, 0);
1081 return M_PROPERTY_OK
;
1083 return m_property_flag(prop
, action
, arg
, vo_var
);
1087 /// Window always on top (RW)
1088 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1091 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1095 /// Display in the root window (RW)
1096 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1099 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1100 &vo_rootwin
, mpctx
);
1103 /// Show window borders (RW)
1104 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1107 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1111 /// Framedropping state (RW)
1112 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1113 void *arg
, MPContext
* mpctx
)
1116 if (!mpctx
->sh_video
)
1117 return M_PROPERTY_UNAVAILABLE
;
1120 case M_PROPERTY_PRINT
:
1122 return M_PROPERTY_ERROR
;
1123 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1124 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1126 return M_PROPERTY_OK
;
1128 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1132 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1133 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1136 int *gamma
= prop
->priv
, r
, val
;
1138 if (!mpctx
->sh_video
)
1139 return M_PROPERTY_UNAVAILABLE
;
1141 if (gamma
[0] == 1000) {
1143 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1147 case M_PROPERTY_SET
:
1149 return M_PROPERTY_ERROR
;
1150 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1151 *gamma
= *(int *) arg
;
1152 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1156 case M_PROPERTY_GET
:
1157 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1159 return M_PROPERTY_ERROR
;
1161 return M_PROPERTY_OK
;
1164 case M_PROPERTY_STEP_UP
:
1165 case M_PROPERTY_STEP_DOWN
:
1166 *gamma
+= (arg
? *(int *) arg
: 1) *
1167 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1168 M_PROPERTY_CLAMP(prop
, *gamma
);
1169 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1174 return M_PROPERTY_NOT_IMPLEMENTED
;
1178 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1179 int l
= strlen(prop
->name
);
1180 char tv_prop
[3 + l
+ 1];
1181 sprintf(tv_prop
, "tv_%s", prop
->name
);
1182 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1186 return M_PROPERTY_UNAVAILABLE
;
1190 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1193 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1196 /// Video codec tag (RO)
1197 static int mp_property_video_format(m_option_t
* prop
, int action
,
1198 void *arg
, MPContext
* mpctx
)
1201 if (!mpctx
->sh_video
)
1202 return M_PROPERTY_UNAVAILABLE
;
1204 case M_PROPERTY_PRINT
:
1206 return M_PROPERTY_ERROR
;
1207 switch(mpctx
->sh_video
->format
) {
1209 meta
= strdup ("mpeg1"); break;
1211 meta
= strdup ("mpeg2"); break;
1213 meta
= strdup ("mpeg4"); break;
1215 meta
= strdup ("h264"); break;
1217 if(mpctx
->sh_video
->format
>= 0x20202020) {
1219 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1222 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1225 *(char**)arg
= meta
;
1226 return M_PROPERTY_OK
;
1228 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1231 /// Video codec name (RO)
1232 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1233 void *arg
, MPContext
* mpctx
)
1235 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1236 return M_PROPERTY_UNAVAILABLE
;
1237 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1241 /// Video bitrate (RO)
1242 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1243 void *arg
, MPContext
* mpctx
)
1245 if (!mpctx
->sh_video
)
1246 return M_PROPERTY_UNAVAILABLE
;
1247 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1250 /// Video display width (RO)
1251 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1254 if (!mpctx
->sh_video
)
1255 return M_PROPERTY_UNAVAILABLE
;
1256 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1259 /// Video display height (RO)
1260 static int mp_property_height(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_h
);
1269 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1272 if (!mpctx
->sh_video
)
1273 return M_PROPERTY_UNAVAILABLE
;
1274 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1277 /// Video aspect (RO)
1278 static int mp_property_aspect(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
->aspect
);
1288 /// \defgroup SubProprties Subtitles properties
1289 /// \ingroup Properties
1292 /// Text subtitle position (RW)
1293 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1296 if (!mpctx
->sh_video
)
1297 return M_PROPERTY_UNAVAILABLE
;
1300 case M_PROPERTY_SET
:
1302 return M_PROPERTY_ERROR
;
1303 case M_PROPERTY_STEP_UP
:
1304 case M_PROPERTY_STEP_DOWN
:
1305 vo_osd_changed(OSDTYPE_SUBTITLE
);
1307 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1311 /// Selected subtitles (RW)
1312 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1315 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1316 const int global_sub_size
= mpctx
->global_sub_size
;
1317 int source
= -1, reset_spu
= 0;
1321 if (global_sub_size
<= 0)
1322 return M_PROPERTY_UNAVAILABLE
;
1325 case M_PROPERTY_GET
:
1327 return M_PROPERTY_ERROR
;
1328 *(int *) arg
= mpctx
->global_sub_pos
;
1329 return M_PROPERTY_OK
;
1330 case M_PROPERTY_PRINT
:
1332 return M_PROPERTY_ERROR
;
1333 *(char **) arg
= malloc(64);
1334 (*(char **) arg
)[63] = 0;
1337 sub_name
= subdata
->filename
;
1339 if (ass_track
&& ass_track
->name
)
1340 sub_name
= ass_track
->name
;
1345 if ((tmp2
= strrchr(tmp
, '/')))
1348 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1349 mpctx
->set_of_sub_pos
+ 1,
1350 strlen(tmp
) < 20 ? "" : "...",
1351 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1352 return M_PROPERTY_OK
;
1354 #ifdef CONFIG_DVDNAV
1355 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1356 if (vo_spudec
&& dvdsub_id
>= 0) {
1357 unsigned char lang
[3];
1358 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1359 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1360 return M_PROPERTY_OK
;
1366 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1367 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1368 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1369 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1370 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1371 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1372 if (!lang
) lang
= MSGTR_Unknown
;
1373 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1374 return M_PROPERTY_OK
;
1377 if (vo_vobsub
&& vobsub_id
>= 0) {
1378 const char *language
= MSGTR_Unknown
;
1379 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1380 snprintf(*(char **) arg
, 63, "(%d) %s",
1381 vobsub_id
, language
? language
: MSGTR_Unknown
);
1382 return M_PROPERTY_OK
;
1384 #ifdef CONFIG_DVDREAD
1385 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1386 && dvdsub_id
>= 0) {
1388 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1389 lang
[0] = code
>> 8;
1392 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1393 return M_PROPERTY_OK
;
1396 if (dvdsub_id
>= 0) {
1397 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1398 return M_PROPERTY_OK
;
1400 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1401 return M_PROPERTY_OK
;
1403 case M_PROPERTY_SET
:
1405 return M_PROPERTY_ERROR
;
1406 if (*(int *) arg
< -1)
1408 else if (*(int *) arg
>= global_sub_size
)
1409 *(int *) arg
= global_sub_size
- 1;
1410 mpctx
->global_sub_pos
= *(int *) arg
;
1412 case M_PROPERTY_STEP_UP
:
1413 mpctx
->global_sub_pos
+= 2;
1414 mpctx
->global_sub_pos
=
1415 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1417 case M_PROPERTY_STEP_DOWN
:
1418 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1419 mpctx
->global_sub_pos
=
1420 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1423 return M_PROPERTY_NOT_IMPLEMENTED
;
1426 if (mpctx
->global_sub_pos
>= 0)
1427 source
= sub_source(mpctx
);
1429 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1430 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1432 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1433 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1434 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1435 mpctx
->global_sub_pos
, source
);
1437 mpctx
->set_of_sub_pos
= -1;
1451 if (source
== SUB_SOURCE_VOBSUB
) {
1452 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1453 } else if (source
== SUB_SOURCE_SUBS
) {
1454 mpctx
->set_of_sub_pos
=
1455 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1457 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1458 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1462 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1463 vo_osd_changed(OSDTYPE_SUBTITLE
);
1465 } else if (source
== SUB_SOURCE_DEMUX
) {
1467 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1468 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1470 // default: assume 1:1 mapping of sid and stream id
1471 d_sub
->id
= dvdsub_id
;
1472 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1473 ds_free_packs(d_sub
);
1474 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1475 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1476 if (sh
&& sh
->sid
== dvdsub_id
) {
1482 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1483 sh_sub_t
*sh
= d_sub
->sh
;
1484 if (sh
->type
== 'v')
1487 else if (ass_enabled
)
1488 ass_track
= sh
->ass_track
;
1496 #ifdef CONFIG_DVDREAD
1498 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1499 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1500 && dvdsub_id
< 0 && reset_spu
) {
1502 d_sub
->id
= dvdsub_id
;
1505 if (mpctx
->sh_audio
)
1506 pts
= mpctx
->sh_audio
->pts
;
1507 if (mpctx
->sh_video
)
1508 pts
= mpctx
->sh_video
->pts
;
1509 update_subtitles(mpctx
->sh_video
, pts
, d_sub
, 1);
1511 return M_PROPERTY_OK
;
1514 /// Selected sub source (RW)
1515 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1519 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1520 return M_PROPERTY_UNAVAILABLE
;
1523 case M_PROPERTY_GET
:
1525 return M_PROPERTY_ERROR
;
1526 *(int *) arg
= sub_source(mpctx
);
1527 return M_PROPERTY_OK
;
1528 case M_PROPERTY_PRINT
:
1530 return M_PROPERTY_ERROR
;
1531 *(char **) arg
= malloc(64);
1532 (*(char **) arg
)[63] = 0;
1533 switch (sub_source(mpctx
))
1535 case SUB_SOURCE_SUBS
:
1536 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1538 case SUB_SOURCE_VOBSUB
:
1539 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1541 case SUB_SOURCE_DEMUX
:
1542 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1545 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1547 return M_PROPERTY_OK
;
1548 case M_PROPERTY_SET
:
1550 return M_PROPERTY_ERROR
;
1551 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1552 if (*(int *) arg
< 0)
1553 mpctx
->global_sub_pos
= -1;
1554 else if (*(int *) arg
!= sub_source(mpctx
)) {
1555 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1556 return M_PROPERTY_UNAVAILABLE
;
1557 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1560 case M_PROPERTY_STEP_UP
:
1561 case M_PROPERTY_STEP_DOWN
: {
1562 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1563 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1564 int step
= (step_all
> 0) ? 1 : -1;
1565 int cur_source
= sub_source(mpctx
);
1566 source
= cur_source
;
1569 if (source
>= SUB_SOURCES
)
1571 else if (source
< -1)
1572 source
= SUB_SOURCES
- 1;
1573 if (source
== cur_source
|| source
== -1 ||
1574 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1577 if (source
== cur_source
)
1578 return M_PROPERTY_OK
;
1580 mpctx
->global_sub_pos
= -1;
1582 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1586 return M_PROPERTY_NOT_IMPLEMENTED
;
1588 --mpctx
->global_sub_pos
;
1589 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1592 /// Selected subtitles from specific source (RW)
1593 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1596 int source
, is_cur_source
, offset
;
1597 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1598 return M_PROPERTY_UNAVAILABLE
;
1600 if (!strcmp(prop
->name
, "sub_file"))
1601 source
= SUB_SOURCE_SUBS
;
1602 else if (!strcmp(prop
->name
, "sub_vob"))
1603 source
= SUB_SOURCE_VOBSUB
;
1604 else if (!strcmp(prop
->name
, "sub_demux"))
1605 source
= SUB_SOURCE_DEMUX
;
1607 return M_PROPERTY_ERROR
;
1609 offset
= mpctx
->global_sub_indices
[source
];
1610 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1611 return M_PROPERTY_UNAVAILABLE
;
1613 is_cur_source
= sub_source(mpctx
) == source
;
1615 case M_PROPERTY_GET
:
1617 return M_PROPERTY_ERROR
;
1618 if (is_cur_source
) {
1619 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1620 if (source
== SUB_SOURCE_VOBSUB
)
1621 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1625 return M_PROPERTY_OK
;
1626 case M_PROPERTY_PRINT
:
1628 return M_PROPERTY_ERROR
;
1630 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1631 *(char **) arg
= malloc(64);
1632 (*(char **) arg
)[63] = 0;
1633 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1634 return M_PROPERTY_OK
;
1635 case M_PROPERTY_SET
:
1637 return M_PROPERTY_ERROR
;
1638 if (*(int *) arg
>= 0) {
1639 int index
= *(int *)arg
;
1640 if (source
== SUB_SOURCE_VOBSUB
)
1641 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1642 mpctx
->global_sub_pos
= offset
+ index
;
1643 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1644 || sub_source(mpctx
) != source
) {
1645 mpctx
->global_sub_pos
= -1;
1650 mpctx
->global_sub_pos
= -1;
1652 case M_PROPERTY_STEP_UP
:
1653 case M_PROPERTY_STEP_DOWN
: {
1654 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1655 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1656 int step
= (step_all
> 0) ? 1 : -1;
1657 int max_sub_pos_for_source
= -1;
1659 mpctx
->global_sub_pos
= -1;
1661 if (mpctx
->global_sub_pos
== -1) {
1663 mpctx
->global_sub_pos
= offset
;
1664 else if (max_sub_pos_for_source
== -1) {
1665 // Find max pos for specific source
1666 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1667 while (mpctx
->global_sub_pos
>= 0
1668 && sub_source(mpctx
) != source
)
1669 --mpctx
->global_sub_pos
;
1672 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1675 mpctx
->global_sub_pos
+= step
;
1676 if (mpctx
->global_sub_pos
< offset
||
1677 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1678 sub_source(mpctx
) != source
)
1679 mpctx
->global_sub_pos
= -1;
1686 return M_PROPERTY_NOT_IMPLEMENTED
;
1688 --mpctx
->global_sub_pos
;
1689 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1692 /// Subtitle delay (RW)
1693 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1696 if (!mpctx
->sh_video
)
1697 return M_PROPERTY_UNAVAILABLE
;
1698 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1701 /// Alignment of text subtitles (RW)
1702 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1703 void *arg
, MPContext
* mpctx
)
1705 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1707 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1708 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1709 return M_PROPERTY_UNAVAILABLE
;
1712 case M_PROPERTY_PRINT
:
1714 return M_PROPERTY_ERROR
;
1715 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1716 *(char **) arg
= strdup(name
[sub_alignment
]);
1717 return M_PROPERTY_OK
;
1718 case M_PROPERTY_SET
:
1720 return M_PROPERTY_ERROR
;
1721 case M_PROPERTY_STEP_UP
:
1722 case M_PROPERTY_STEP_DOWN
:
1723 vo_osd_changed(OSDTYPE_SUBTITLE
);
1725 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1729 /// Subtitle visibility (RW)
1730 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1731 void *arg
, MPContext
* mpctx
)
1733 if (!mpctx
->sh_video
)
1734 return M_PROPERTY_UNAVAILABLE
;
1737 case M_PROPERTY_SET
:
1739 return M_PROPERTY_ERROR
;
1740 case M_PROPERTY_STEP_UP
:
1741 case M_PROPERTY_STEP_DOWN
:
1742 vo_osd_changed(OSDTYPE_SUBTITLE
);
1744 vo_osd_changed(OSDTYPE_SPU
);
1746 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1751 /// Use margins for libass subtitles (RW)
1752 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1753 void *arg
, MPContext
* mpctx
)
1755 if (!mpctx
->sh_video
)
1756 return M_PROPERTY_UNAVAILABLE
;
1759 case M_PROPERTY_SET
:
1761 return M_PROPERTY_ERROR
;
1762 case M_PROPERTY_STEP_UP
:
1763 case M_PROPERTY_STEP_DOWN
:
1764 ass_force_reload
= 1;
1766 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1771 /// Show only forced subtitles (RW)
1772 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1773 void *arg
, MPContext
* mpctx
)
1776 return M_PROPERTY_UNAVAILABLE
;
1779 case M_PROPERTY_SET
:
1781 return M_PROPERTY_ERROR
;
1782 case M_PROPERTY_STEP_UP
:
1783 case M_PROPERTY_STEP_DOWN
:
1784 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1785 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1786 return M_PROPERTY_OK
;
1788 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1793 #ifdef CONFIG_FREETYPE
1794 /// Subtitle scale (RW)
1795 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1800 case M_PROPERTY_SET
:
1802 return M_PROPERTY_ERROR
;
1803 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1806 ass_font_scale
= *(float *) arg
;
1807 ass_force_reload
= 1;
1810 text_font_scale_factor
= *(float *) arg
;
1811 force_load_font
= 1;
1812 return M_PROPERTY_OK
;
1813 case M_PROPERTY_STEP_UP
:
1814 case M_PROPERTY_STEP_DOWN
:
1817 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1818 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1819 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1820 ass_force_reload
= 1;
1823 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1824 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1825 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1826 force_load_font
= 1;
1827 return M_PROPERTY_OK
;
1831 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1834 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1841 /// \defgroup TVProperties TV properties
1842 /// \ingroup Properties
1847 /// TV color settings (RW)
1848 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1852 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1853 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1854 return M_PROPERTY_UNAVAILABLE
;
1857 case M_PROPERTY_SET
:
1859 return M_PROPERTY_ERROR
;
1860 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1861 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1862 case M_PROPERTY_GET
:
1863 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1864 case M_PROPERTY_STEP_UP
:
1865 case M_PROPERTY_STEP_DOWN
:
1866 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1868 return M_PROPERTY_ERROR
;
1869 val
+= (arg
? *(int *) arg
: 1) *
1870 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1871 M_PROPERTY_CLAMP(prop
, val
);
1872 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1874 return M_PROPERTY_ERROR
;
1876 return M_PROPERTY_NOT_IMPLEMENTED
;
1881 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1885 int base_ioctl
=(int)prop
->priv
;
1887 for teletext's GET,SET,STEP ioctls this is not 0
1891 if (!mpctx
->demuxer
->teletext
)
1892 return M_PROPERTY_UNAVAILABLE
;
1894 return M_PROPERTY_ERROR
;
1897 case M_PROPERTY_GET
:
1899 return M_PROPERTY_ERROR
;
1900 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1902 case M_PROPERTY_SET
:
1904 return M_PROPERTY_ERROR
;
1905 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1906 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1908 case M_PROPERTY_STEP_UP
:
1909 case M_PROPERTY_STEP_DOWN
:
1910 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1911 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1912 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
1915 return M_PROPERTY_NOT_IMPLEMENTED
;
1918 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1921 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1927 //with tvh==NULL will fail too
1928 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1929 if(result
!=M_PROPERTY_OK
)
1932 if(teletext_control(mpctx
->demuxer
->teletext
,
1933 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
1934 mp_input_set_section("teletext");
1936 mp_input_set_section("tv");
1937 return M_PROPERTY_OK
;
1940 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1945 if (!mpctx
->demuxer
->teletext
)
1946 return M_PROPERTY_UNAVAILABLE
;
1948 case M_PROPERTY_STEP_UP
:
1949 case M_PROPERTY_STEP_DOWN
:
1950 //This should be handled separately
1951 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1952 result
=teletext_control(mpctx
->demuxer
->teletext
,
1953 TV_VBI_CONTROL_STEP_PAGE
, &val
);
1956 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1963 /// All properties available in MPlayer.
1964 /** \ingroup Properties
1966 static const m_option_t mp_properties
[] = {
1968 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1969 M_OPT_RANGE
, 0, 3, NULL
},
1970 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1971 M_OPT_MIN
, -1, 0, NULL
},
1972 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1973 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1974 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1976 { "path", mp_property_path
, CONF_TYPE_STRING
,
1978 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1980 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1981 M_OPT_MIN
, 0, 0, NULL
},
1982 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1983 M_OPT_MIN
, 0, 0, NULL
},
1984 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1985 M_OPT_MIN
, 0, 0, NULL
},
1986 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1987 M_OPT_MIN
, 0, 0, NULL
},
1988 { "length", mp_property_length
, CONF_TYPE_TIME
,
1989 M_OPT_MIN
, 0, 0, NULL
},
1990 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1991 M_OPT_RANGE
, 0, 100, NULL
},
1992 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1993 M_OPT_MIN
, 0, 0, NULL
},
1994 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1995 M_OPT_MIN
, 0, 0, NULL
},
1996 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
1998 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1999 CONF_RANGE
, -2, 10, NULL
},
2000 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2002 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2003 M_OPT_RANGE
, 0, 1, NULL
},
2006 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2007 M_OPT_RANGE
, 0, 100, NULL
},
2008 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2009 M_OPT_RANGE
, 0, 1, NULL
},
2010 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2011 M_OPT_RANGE
, -100, 100, NULL
},
2012 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2014 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2016 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2018 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2020 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2022 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2023 CONF_RANGE
, -2, 65535, NULL
},
2024 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2025 M_OPT_RANGE
, -1, 1, NULL
},
2028 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2029 M_OPT_RANGE
, 0, 1, NULL
},
2030 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2031 M_OPT_RANGE
, 0, 1, NULL
},
2032 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2033 M_OPT_RANGE
, 0, 1, NULL
},
2034 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2035 M_OPT_RANGE
, 0, 1, NULL
},
2036 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2037 M_OPT_RANGE
, 0, 1, NULL
},
2038 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2039 M_OPT_RANGE
, 0, 2, NULL
},
2040 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2041 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2042 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2043 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2044 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2045 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2046 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2047 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2048 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2049 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2050 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2051 M_OPT_RANGE
, 0, 1, NULL
},
2052 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2053 M_OPT_RANGE
, 0, 1, NULL
},
2054 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2056 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2058 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2060 { "width", mp_property_width
, CONF_TYPE_INT
,
2062 { "height", mp_property_height
, CONF_TYPE_INT
,
2064 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2066 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2068 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2069 CONF_RANGE
, -2, 65535, NULL
},
2070 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2071 CONF_RANGE
, -1, 65535, NULL
},
2074 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2075 M_OPT_MIN
, -1, 0, NULL
},
2076 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2077 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2078 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2079 M_OPT_MIN
, -1, 0, NULL
},
2080 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2081 M_OPT_MIN
, -1, 0, NULL
},
2082 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2083 M_OPT_MIN
, -1, 0, NULL
},
2084 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2086 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2087 M_OPT_RANGE
, 0, 100, NULL
},
2088 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2089 M_OPT_RANGE
, 0, 2, NULL
},
2090 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2091 M_OPT_RANGE
, 0, 1, NULL
},
2092 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2093 M_OPT_RANGE
, 0, 1, NULL
},
2094 #ifdef CONFIG_FREETYPE
2095 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2096 M_OPT_RANGE
, 0, 100, NULL
},
2099 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2100 M_OPT_RANGE
, 0, 1, NULL
},
2104 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2105 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2106 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2107 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2108 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2109 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2110 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2111 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2113 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2114 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2115 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2116 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2117 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2118 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2119 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2120 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2121 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2122 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2123 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2127 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2129 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2132 char* mp_property_print(const char *name
, void* ctx
)
2135 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2140 char *property_expand_string(MPContext
* mpctx
, char *str
)
2142 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2145 void property_print_help(void)
2147 m_properties_print_help_list(mp_properties
);
2156 * \defgroup Command2Property Command to property bridge
2158 * It is used to handle most commands that just set a property
2159 * and optionally display something on the OSD.
2160 * Two kinds of commands are handled: adjust or toggle.
2162 * Adjust commands take 1 or 2 parameters: <value> <abs>
2163 * If <abs> is non-zero the property is set to the given value
2164 * otherwise it is adjusted.
2166 * Toggle commands take 0 or 1 parameters. With no parameter
2167 * or a value less than the property minimum it just steps the
2168 * property to its next value. Otherwise it sets it to the given
2174 /// List of the commands that can be handled by setting a property.
2180 /// set/adjust or toggle command
2182 /// progressbar type
2184 /// osd msg id if it must be shared
2186 /// osd msg template
2187 const char *osd_msg
;
2188 } set_prop_cmd
[] = {
2190 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2191 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2192 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2194 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2195 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2196 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2197 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2198 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2200 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2201 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2202 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2203 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2204 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2205 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2206 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2207 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2208 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2209 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2210 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2211 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2213 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2214 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2215 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2216 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2217 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2218 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2219 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2220 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2221 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2222 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2223 #ifdef CONFIG_FREETYPE
2224 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2227 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2230 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2231 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2232 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2233 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2235 { NULL
, 0, 0, 0, -1, NULL
}
2239 /// Handle commands that set a property.
2240 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2246 // look for the command
2247 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2248 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2250 if (!(pname
= set_prop_cmd
[i
].name
))
2253 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2257 if (set_prop_cmd
[i
].toggle
) {
2259 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2260 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2262 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2263 } else if (cmd
->args
[1].v
.i
) //set
2264 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2266 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2271 if (set_prop_cmd
[i
].osd_progbar
) {
2272 if (prop
->type
== CONF_TYPE_INT
) {
2273 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2274 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2275 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2276 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2278 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2279 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2280 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2282 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2283 "Property use an unsupported type.\n");
2287 if (set_prop_cmd
[i
].osd_msg
) {
2288 char *val
= mp_property_print(pname
, mpctx
);
2290 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2291 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2292 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2299 #ifdef CONFIG_DVDNAV
2300 static const struct {
2302 const mp_command_type cmd
;
2303 } mp_dvdnav_bindings
[] = {
2304 { "up", MP_CMD_DVDNAV_UP
},
2305 { "down", MP_CMD_DVDNAV_DOWN
},
2306 { "left", MP_CMD_DVDNAV_LEFT
},
2307 { "right", MP_CMD_DVDNAV_RIGHT
},
2308 { "menu", MP_CMD_DVDNAV_MENU
},
2309 { "select", MP_CMD_DVDNAV_SELECT
},
2310 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2311 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2314 * keep old dvdnav sub-command options for a while in order not to
2315 * break slave-mode API too suddenly.
2317 { "1", MP_CMD_DVDNAV_UP
},
2318 { "2", MP_CMD_DVDNAV_DOWN
},
2319 { "3", MP_CMD_DVDNAV_LEFT
},
2320 { "4", MP_CMD_DVDNAV_RIGHT
},
2321 { "5", MP_CMD_DVDNAV_MENU
},
2322 { "6", MP_CMD_DVDNAV_SELECT
},
2323 { "7", MP_CMD_DVDNAV_PREVMENU
},
2324 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2329 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2331 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2332 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2334 if (!set_property_command(mpctx
, cmd
))
2340 mpctx
->osd_show_percentage
= sh_video
->fps
;
2341 v
= cmd
->args
[0].v
.f
;
2342 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2343 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2344 abs_seek_pos
= SEEK_ABSOLUTE
;
2346 mpctx
->osd_function
=
2347 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2349 } else if (abs
) { /* Absolute seek by percentage */
2350 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2352 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2353 rel_seek_secs
= v
/ 100.0;
2356 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2362 case MP_CMD_SET_PROPERTY
:{
2363 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2364 cmd
->args
[1].v
.s
, mpctx
);
2365 if (r
== M_PROPERTY_UNKNOWN
)
2366 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2367 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2369 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2370 "Failed to set property '%s' to '%s'.\n",
2371 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2375 case MP_CMD_STEP_PROPERTY
:{
2380 if (cmd
->args
[1].v
.f
) {
2382 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2383 M_PROPERTY_GET_TYPE
,
2384 &prop
, mpctx
)) <= 0)
2386 if(prop
->type
== CONF_TYPE_INT
||
2387 prop
->type
== CONF_TYPE_FLAG
)
2388 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2389 else if(prop
->type
== CONF_TYPE_FLOAT
)
2390 arg
= &cmd
->args
[1].v
.f
;
2391 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2392 prop
->type
== CONF_TYPE_TIME
)
2393 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2394 else if(prop
->type
== CONF_TYPE_POSITION
)
2395 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2397 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2398 "Ignoring step size stepping property '%s'.\n",
2401 r
= mp_property_do(cmd
->args
[0].v
.s
,
2402 cmd
->args
[2].v
.i
< 0 ?
2403 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2406 if (r
== M_PROPERTY_UNKNOWN
)
2407 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2408 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2410 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2411 "Failed to increment property '%s' by %f.\n",
2412 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2416 case MP_CMD_GET_PROPERTY
:{
2418 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2419 &tmp
, mpctx
) <= 0) {
2420 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2421 "Failed to get value of property '%s'.\n",
2425 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2426 cmd
->args
[0].v
.s
, tmp
);
2431 case MP_CMD_EDL_MARK
:
2433 float v
= sh_video
? sh_video
->pts
:
2434 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2437 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2438 mpctx
->begin_skip
= v
;
2439 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2441 if (mpctx
->begin_skip
> v
)
2442 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2444 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2445 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2447 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2452 case MP_CMD_SWITCH_RATIO
:
2455 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2456 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2458 movie_aspect
= cmd
->args
[0].v
.f
;
2459 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2462 case MP_CMD_SPEED_INCR
:{
2463 float v
= cmd
->args
[0].v
.f
;
2464 playback_speed
+= v
;
2465 build_afilter_chain(sh_audio
, &ao_data
);
2466 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2470 case MP_CMD_SPEED_MULT
:{
2471 float v
= cmd
->args
[0].v
.f
;
2472 playback_speed
*= v
;
2473 build_afilter_chain(sh_audio
, &ao_data
);
2474 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2478 case MP_CMD_SPEED_SET
:{
2479 float v
= cmd
->args
[0].v
.f
;
2481 build_afilter_chain(sh_audio
, &ao_data
);
2482 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2486 case MP_CMD_FRAME_STEP
:
2492 case MP_CMD_FILE_FILTER
:
2493 file_filter
= cmd
->args
[0].v
.i
;
2497 exit_player_with_rc(EXIT_QUIT
,
2498 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2500 case MP_CMD_PLAY_TREE_STEP
:{
2501 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2502 int force
= cmd
->args
[1].v
.i
;
2508 for (i
= 0; i
< n
; i
++)
2511 for (i
= 0; i
< -1 * n
; i
++)
2516 if (!force
&& mpctx
->playtree_iter
) {
2517 play_tree_iter_t
*i
=
2518 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2519 if (play_tree_iter_step(i
, n
, 0) ==
2520 PLAY_TREE_ITER_ENTRY
)
2522 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2523 play_tree_iter_free(i
);
2525 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2527 mpctx
->play_tree_step
= n
;
2533 case MP_CMD_PLAY_TREE_UP_STEP
:{
2534 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2535 int force
= cmd
->args
[1].v
.i
;
2537 if (!force
&& mpctx
->playtree_iter
) {
2538 play_tree_iter_t
*i
=
2539 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2540 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2541 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2542 play_tree_iter_free(i
);
2544 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2549 case MP_CMD_PLAY_ALT_SRC_STEP
:
2550 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2551 int v
= cmd
->args
[0].v
.i
;
2553 && mpctx
->playtree_iter
->file
<
2554 mpctx
->playtree_iter
->num_files
)
2555 mpctx
->eof
= PT_NEXT_SRC
;
2556 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2557 mpctx
->eof
= PT_PREV_SRC
;
2562 case MP_CMD_SUB_STEP
:
2564 int movement
= cmd
->args
[0].v
.i
;
2565 step_sub(subdata
, sh_video
->pts
, movement
);
2569 ass_step_sub(ass_track
,
2571 sub_delay
) * 1000 + .5, movement
) / 1000.;
2573 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2574 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2578 case MP_CMD_SUB_LOG
:
2583 int v
= cmd
->args
[0].v
.i
;
2585 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2586 if (osd_level
> max
)
2589 osd_level
= (osd_level
+ 1) % (max
+ 1);
2591 osd_level
= v
> max
? max
: v
;
2592 /* Show OSD state when disabled, but not when an explicit
2593 argument is given to the OSD command, i.e. in slave mode. */
2594 if (v
== -1 && osd_level
<= 1)
2595 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2597 osd_level
? MSGTR_OSDenabled
:
2600 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2604 case MP_CMD_OSD_SHOW_TEXT
:
2605 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2607 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2608 "%-.63s", cmd
->args
[0].v
.s
);
2611 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2612 char *txt
= m_properties_expand_string(mp_properties
,
2615 /* if no argument supplied take default osd_duration, else <arg> ms. */
2617 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2619 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2626 case MP_CMD_LOADFILE
:{
2627 play_tree_t
*e
= play_tree_new();
2628 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2630 if (cmd
->args
[1].v
.i
) // append
2631 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2633 // Go back to the starting point.
2634 while (play_tree_iter_up_step
2635 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2637 play_tree_free_list(mpctx
->playtree
->child
, 1);
2638 play_tree_set_child(mpctx
->playtree
, e
);
2639 pt_iter_goto_head(mpctx
->playtree_iter
);
2640 mpctx
->eof
= PT_NEXT_SRC
;
2646 case MP_CMD_LOADLIST
:{
2647 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2649 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2650 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2652 if (cmd
->args
[1].v
.i
) // append
2653 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2655 // Go back to the starting point.
2656 while (play_tree_iter_up_step
2657 (mpctx
->playtree_iter
, 0, 1)
2658 != PLAY_TREE_ITER_END
)
2660 play_tree_free_list(mpctx
->playtree
->child
, 1);
2661 play_tree_set_child(mpctx
->playtree
, e
);
2662 pt_iter_goto_head(mpctx
->playtree_iter
);
2663 mpctx
->eof
= PT_NEXT_SRC
;
2671 // Go back to the starting point.
2672 while (play_tree_iter_up_step
2673 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2675 mpctx
->eof
= PT_STOP
;
2680 case MP_CMD_RADIO_STEP_CHANNEL
:
2681 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2682 int v
= cmd
->args
[0].v
.i
;
2684 radio_step_channel(mpctx
->demuxer
->stream
,
2685 RADIO_CHANNEL_HIGHER
);
2687 radio_step_channel(mpctx
->demuxer
->stream
,
2688 RADIO_CHANNEL_LOWER
);
2689 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2690 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2692 radio_get_channel_name(mpctx
->demuxer
->stream
));
2697 case MP_CMD_RADIO_SET_CHANNEL
:
2698 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2699 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2700 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2701 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2703 radio_get_channel_name(mpctx
->demuxer
->stream
));
2708 case MP_CMD_RADIO_SET_FREQ
:
2709 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2710 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2713 case MP_CMD_RADIO_STEP_FREQ
:
2714 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2715 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2720 case MP_CMD_TV_START_SCAN
:
2721 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2722 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2724 case MP_CMD_TV_SET_FREQ
:
2725 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2726 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2727 cmd
->args
[0].v
.f
* 16.0);
2729 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2730 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2731 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2732 pvr_get_current_channelname (mpctx
->stream
),
2733 pvr_get_current_stationname (mpctx
->stream
));
2735 #endif /* CONFIG_PVR */
2738 case MP_CMD_TV_STEP_FREQ
:
2739 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2740 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2741 cmd
->args
[0].v
.f
* 16.0);
2743 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2744 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2745 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2746 pvr_get_current_channelname (mpctx
->stream
),
2747 pvr_get_current_frequency (mpctx
->stream
));
2749 #endif /* CONFIG_PVR */
2752 case MP_CMD_TV_SET_NORM
:
2753 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2754 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2758 case MP_CMD_TV_STEP_CHANNEL
:{
2759 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2760 int v
= cmd
->args
[0].v
.i
;
2762 tv_step_channel((tvi_handle_t
*) (mpctx
->
2766 tv_step_channel((tvi_handle_t
*) (mpctx
->
2770 if (tv_channel_list
) {
2771 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2772 MSGTR_OSDChannel
, tv_channel_current
->name
);
2773 //vo_osd_changed(OSDTYPE_SUBTITLE);
2777 else if (mpctx
->stream
&&
2778 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2779 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2780 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2781 pvr_get_current_channelname (mpctx
->stream
),
2782 pvr_get_current_stationname (mpctx
->stream
));
2784 #endif /* CONFIG_PVR */
2787 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2789 int v
= cmd
->args
[0].v
.i
;
2791 mpctx
->last_dvb_step
= v
;
2793 dir
= DVB_CHANNEL_HIGHER
;
2795 dir
= DVB_CHANNEL_LOWER
;
2798 if (dvb_step_channel(mpctx
->stream
, dir
))
2799 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2801 #endif /* CONFIG_DVBIN */
2804 case MP_CMD_TV_SET_CHANNEL
:
2805 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2806 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2808 if (tv_channel_list
) {
2809 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2810 MSGTR_OSDChannel
, tv_channel_current
->name
);
2811 //vo_osd_changed(OSDTYPE_SUBTITLE);
2815 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2816 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2817 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2818 pvr_get_current_channelname (mpctx
->stream
),
2819 pvr_get_current_stationname (mpctx
->stream
));
2821 #endif /* CONFIG_PVR */
2825 case MP_CMD_DVB_SET_CHANNEL
:
2826 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2827 mpctx
->last_dvb_step
= 1;
2830 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2831 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2834 #endif /* CONFIG_DVBIN */
2836 case MP_CMD_TV_LAST_CHANNEL
:
2837 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2838 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2839 if (tv_channel_list
) {
2840 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2841 MSGTR_OSDChannel
, tv_channel_current
->name
);
2842 //vo_osd_changed(OSDTYPE_SUBTITLE);
2846 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2847 pvr_set_lastchannel (mpctx
->stream
);
2848 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2849 pvr_get_current_channelname (mpctx
->stream
),
2850 pvr_get_current_stationname (mpctx
->stream
));
2852 #endif /* CONFIG_PVR */
2855 case MP_CMD_TV_STEP_NORM
:
2856 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2857 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2860 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2861 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2862 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2864 #endif /* CONFIG_TV */
2865 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2867 if (mpctx
->demuxer
->teletext
)
2868 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
2869 &(cmd
->args
[0].v
.s
));
2872 case MP_CMD_TV_TELETEXT_GO_LINK
:
2874 if (mpctx
->demuxer
->teletext
)
2875 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
2876 &(cmd
->args
[0].v
.i
));
2880 case MP_CMD_SUB_LOAD
:
2882 int n
= mpctx
->set_of_sub_size
;
2883 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2884 if (n
!= mpctx
->set_of_sub_size
) {
2885 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2886 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2887 mpctx
->global_sub_size
;
2888 ++mpctx
->global_sub_size
;
2893 case MP_CMD_SUB_REMOVE
:
2895 int v
= cmd
->args
[0].v
.i
;
2898 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2899 subd
= mpctx
->set_of_subtitles
[v
];
2900 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2901 MSGTR_RemovedSubtitleFile
, v
+ 1,
2902 filename_recode(subd
->filename
));
2904 mpctx
->set_of_subtitles
[v
] = NULL
;
2906 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2907 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2908 mpctx
->set_of_sub_size
= 0;
2909 if (mpctx
->set_of_sub_pos
>= 0) {
2910 mpctx
->global_sub_pos
= -2;
2912 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2914 } else if (v
< mpctx
->set_of_sub_size
) {
2915 subd
= mpctx
->set_of_subtitles
[v
];
2916 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2917 MSGTR_RemovedSubtitleFile
, v
+ 1,
2918 filename_recode(subd
->filename
));
2920 if (mpctx
->set_of_sub_pos
== v
) {
2921 mpctx
->global_sub_pos
= -2;
2923 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2924 } else if (mpctx
->set_of_sub_pos
> v
) {
2925 --mpctx
->set_of_sub_pos
;
2926 --mpctx
->global_sub_pos
;
2928 while (++v
< mpctx
->set_of_sub_size
)
2929 mpctx
->set_of_subtitles
[v
- 1] =
2930 mpctx
->set_of_subtitles
[v
];
2931 --mpctx
->set_of_sub_size
;
2932 --mpctx
->global_sub_size
;
2933 if (mpctx
->set_of_sub_size
<= 0)
2934 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2935 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2940 case MP_CMD_GET_SUB_VISIBILITY
:
2942 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2943 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2947 case MP_CMD_SCREENSHOT
:
2948 if (vo_config_count
) {
2949 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2951 ((vf_instance_t
*) sh_video
->vfilter
)->
2952 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2954 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2958 case MP_CMD_VF_CHANGE_RECTANGLE
:
2961 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2964 case MP_CMD_GET_TIME_LENGTH
:{
2965 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2966 demuxer_get_time_length(mpctx
->demuxer
));
2970 case MP_CMD_GET_FILENAME
:{
2971 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2972 get_metadata(META_NAME
));
2976 case MP_CMD_GET_VIDEO_CODEC
:{
2977 char *inf
= get_metadata(META_VIDEO_CODEC
);
2980 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2985 case MP_CMD_GET_VIDEO_BITRATE
:{
2986 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2989 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
2994 case MP_CMD_GET_VIDEO_RESOLUTION
:{
2995 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
2998 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2999 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3004 case MP_CMD_GET_AUDIO_CODEC
:{
3005 char *inf
= get_metadata(META_AUDIO_CODEC
);
3008 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3013 case MP_CMD_GET_AUDIO_BITRATE
:{
3014 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3017 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3022 case MP_CMD_GET_AUDIO_SAMPLES
:{
3023 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3026 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3031 case MP_CMD_GET_META_TITLE
:{
3032 char *inf
= get_metadata(META_INFO_TITLE
);
3035 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3040 case MP_CMD_GET_META_ARTIST
:{
3041 char *inf
= get_metadata(META_INFO_ARTIST
);
3044 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3049 case MP_CMD_GET_META_ALBUM
:{
3050 char *inf
= get_metadata(META_INFO_ALBUM
);
3053 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3058 case MP_CMD_GET_META_YEAR
:{
3059 char *inf
= get_metadata(META_INFO_YEAR
);
3062 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3067 case MP_CMD_GET_META_COMMENT
:{
3068 char *inf
= get_metadata(META_INFO_COMMENT
);
3071 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3076 case MP_CMD_GET_META_TRACK
:{
3077 char *inf
= get_metadata(META_INFO_TRACK
);
3080 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3085 case MP_CMD_GET_META_GENRE
:{
3086 char *inf
= get_metadata(META_INFO_GENRE
);
3089 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3094 case MP_CMD_GET_VO_FULLSCREEN
:
3095 if (mpctx
->video_out
&& vo_config_count
)
3096 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3099 case MP_CMD_GET_PERCENT_POS
:
3100 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3101 demuxer_get_percent_pos(mpctx
->demuxer
));
3104 case MP_CMD_GET_TIME_POS
:{
3107 pos
= sh_video
->pts
;
3108 else if (sh_audio
&& mpctx
->audio_out
)
3110 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3112 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3119 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3125 case MP_CMD_KEYDOWN_EVENTS
:
3126 mplayer_put_key(cmd
->args
[0].v
.i
);
3129 case MP_CMD_SET_MOUSE_POS
:{
3130 int pointer_x
, pointer_y
;
3132 pointer_x
= cmd
->args
[0].v
.i
;
3133 pointer_y
= cmd
->args
[1].v
.i
;
3134 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3135 #ifdef CONFIG_DVDNAV
3136 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3137 && dx
> 0.0 && dy
> 0.0) {
3139 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3140 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3141 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3142 pointer_x
, pointer_y
, &button
);
3143 if (osd_level
> 1 && button
> 0)
3144 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3145 "Selected button number %d", button
);
3149 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3150 menu_update_mouse_pos(dx
, dy
);
3155 #ifdef CONFIG_DVDNAV
3156 case MP_CMD_DVDNAV
:{
3159 mp_command_type command
= 0;
3160 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3163 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3164 if (cmd
->args
[0].v
.s
&&
3165 !strcasecmp (cmd
->args
[0].v
.s
,
3166 mp_dvdnav_bindings
[i
].name
))
3167 command
= mp_dvdnav_bindings
[i
].cmd
;
3169 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3170 if (osd_level
> 1 && button
> 0)
3171 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3172 "Selected button number %d", button
);
3176 case MP_CMD_SWITCH_TITLE
:
3177 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3178 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3185 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3186 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3189 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3190 "Received unknown cmd %s\n", cmd
->name
);
3193 switch (cmd
->pausing
) {
3194 case 1: // "pausing"
3195 mpctx
->osd_function
= OSD_PAUSE
;
3197 case 3: // "pausing_toggle"
3198 mpctx
->was_paused
= !mpctx
->was_paused
;
3199 if (mpctx
->was_paused
)
3200 mpctx
->osd_function
= OSD_PAUSE
;
3201 else if (mpctx
->osd_function
== OSD_PAUSE
)
3202 mpctx
->osd_function
= OSD_PLAY
;
3204 case 2: // "pausing_keep"
3205 if (mpctx
->was_paused
)
3206 mpctx
->osd_function
= OSD_PAUSE
;