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"
31 #include "stream/tv.h"
32 #include "stream/stream_radio.h"
33 #include "stream/pvr.h"
35 #include "stream/dvbin.h"
38 #include "stream/stream_dvd.h"
40 #include "stream/stream_dvdnav.h"
41 #include "libass/ass.h"
42 #include "libass/ass_mp.h"
44 #include "libmenu/menu.h"
45 #include "gui/interface.h"
49 #include "libavutil/avstring.h"
51 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
55 static void rescale_input_coordinates(int ix
, int iy
, double *dx
, double *dy
)
57 //remove the borders, if any, and rescale to the range [0,1],[0,1]
58 if (vo_fs
) { //we are in full-screen mode
59 if (vo_screenwidth
> vo_dwidth
) //there are borders along the x axis
60 ix
-= (vo_screenwidth
- vo_dwidth
) / 2;
61 if (vo_screenheight
> vo_dheight
) //there are borders along the y axis (usual way)
62 iy
-= (vo_screenheight
- vo_dheight
) / 2;
64 if (ix
< 0 || ix
> vo_dwidth
) {
67 } //we are on one of the borders
68 if (iy
< 0 || iy
> vo_dheight
) {
71 } //we are on one of the borders
74 *dx
= (double) ix
/ (double) vo_dwidth
;
75 *dy
= (double) iy
/ (double) vo_dheight
;
77 mp_msg(MSGT_CPLAYER
, MSGL_V
,
78 "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
79 *dx
, *dy
, vo_screenwidth
, vo_screenheight
, vo_dwidth
,
83 static int sub_source_by_pos(MPContext
* mpctx
, int pos
)
88 for (i
= 0; i
< SUB_SOURCES
; i
++) {
89 int j
= mpctx
->global_sub_indices
[i
];
90 if ((j
>= 0) && (j
> top
) && (pos
>= j
)) {
98 static int sub_source(MPContext
* mpctx
)
100 return sub_source_by_pos(mpctx
, mpctx
->global_sub_pos
);
104 * \brief Log the currently displayed subtitle to a file
106 * Logs the current or last displayed subtitle together with filename
107 * and time information to ~/.mplayer/subtitle_log
109 * Intended purpose is to allow convenient marking of bogus subtitles
110 * which need to be fixed while watching the movie.
113 static void log_sub(void)
119 if (subdata
== NULL
|| vo_sub_last
== NULL
)
121 fname
= get_path("subtitle_log");
122 f
= fopen(fname
, "a");
125 fprintf(f
, "----------------------------------------------------------\n");
126 if (subdata
->sub_uses_time
) {
128 "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n",
129 filename
, vo_sub_last
->start
/ 360000,
130 (vo_sub_last
->start
/ 6000) % 60,
131 (vo_sub_last
->start
/ 100) % 60, vo_sub_last
->start
% 100,
132 vo_sub_last
->end
/ 360000, (vo_sub_last
->end
/ 6000) % 60,
133 (vo_sub_last
->end
/ 100) % 60, vo_sub_last
->end
% 100);
135 fprintf(f
, "N: %s S: %ld E: %ld\n", filename
, vo_sub_last
->start
,
138 for (i
= 0; i
< vo_sub_last
->lines
; i
++) {
139 fprintf(f
, "%s\n", vo_sub_last
->text
[i
]);
145 /// \defgroup Properties
148 /// \defgroup GeneralProperties General properties
149 /// \ingroup Properties
153 static int mp_property_osdlevel(m_option_t
* prop
, int action
, void *arg
,
156 return m_property_choice(prop
, action
, arg
, &osd_level
);
160 static int mp_property_loop(m_option_t
* prop
, int action
, void *arg
,
164 case M_PROPERTY_PRINT
:
165 if (!arg
) return M_PROPERTY_ERROR
;
166 if (mpctx
->loop_times
< 0)
167 *(char**)arg
= strdup("off");
168 else if (mpctx
->loop_times
== 0)
169 *(char**)arg
= strdup("inf");
172 return M_PROPERTY_OK
;
174 return m_property_int_range(prop
, action
, arg
, &mpctx
->loop_times
);
177 /// Playback speed (RW)
178 static int mp_property_playback_speed(m_option_t
* prop
, int action
,
179 void *arg
, MPContext
* mpctx
)
184 return M_PROPERTY_ERROR
;
185 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
186 playback_speed
= *(float *) arg
;
187 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
188 return M_PROPERTY_OK
;
189 case M_PROPERTY_STEP_UP
:
190 case M_PROPERTY_STEP_DOWN
:
191 playback_speed
+= (arg
? *(float *) arg
: 0.1) *
192 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
193 M_PROPERTY_CLAMP(prop
, playback_speed
);
194 build_afilter_chain(mpctx
->sh_audio
, &ao_data
);
195 return M_PROPERTY_OK
;
197 return m_property_float_range(prop
, action
, arg
, &playback_speed
);
200 /// filename with path (RO)
201 static int mp_property_path(m_option_t
* prop
, int action
, void *arg
,
204 return m_property_string_ro(prop
, action
, arg
, filename
);
207 /// filename without path (RO)
208 static int mp_property_filename(m_option_t
* prop
, int action
, void *arg
,
213 return M_PROPERTY_UNAVAILABLE
;
214 if (((f
= strrchr(filename
, '/')) || (f
= strrchr(filename
, '\\'))) && f
[1])
218 return m_property_string_ro(prop
, action
, arg
, f
);
221 /// Demuxer name (RO)
222 static int mp_property_demuxer(m_option_t
* prop
, int action
, void *arg
,
226 return M_PROPERTY_UNAVAILABLE
;
227 return m_property_string_ro(prop
, action
, arg
,
228 (char *) mpctx
->demuxer
->desc
->name
);
231 /// Position in the stream (RW)
232 static int mp_property_stream_pos(m_option_t
* prop
, int action
, void *arg
,
235 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
236 return M_PROPERTY_UNAVAILABLE
;
238 return M_PROPERTY_ERROR
;
241 *(off_t
*) arg
= stream_tell(mpctx
->demuxer
->stream
);
242 return M_PROPERTY_OK
;
244 M_PROPERTY_CLAMP(prop
, *(off_t
*) arg
);
245 stream_seek(mpctx
->demuxer
->stream
, *(off_t
*) arg
);
246 return M_PROPERTY_OK
;
248 return M_PROPERTY_NOT_IMPLEMENTED
;
251 /// Stream start offset (RO)
252 static int mp_property_stream_start(m_option_t
* prop
, int action
,
253 void *arg
, MPContext
* mpctx
)
255 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
256 return M_PROPERTY_UNAVAILABLE
;
259 *(off_t
*) arg
= mpctx
->demuxer
->stream
->start_pos
;
260 return M_PROPERTY_OK
;
262 return M_PROPERTY_NOT_IMPLEMENTED
;
265 /// Stream end offset (RO)
266 static int mp_property_stream_end(m_option_t
* prop
, int action
, void *arg
,
269 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
270 return M_PROPERTY_UNAVAILABLE
;
273 *(off_t
*) arg
= mpctx
->demuxer
->stream
->end_pos
;
274 return M_PROPERTY_OK
;
276 return M_PROPERTY_NOT_IMPLEMENTED
;
279 /// Stream length (RO)
280 static int mp_property_stream_length(m_option_t
* prop
, int action
,
281 void *arg
, MPContext
* mpctx
)
283 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->stream
)
284 return M_PROPERTY_UNAVAILABLE
;
288 mpctx
->demuxer
->stream
->end_pos
- mpctx
->demuxer
->stream
->start_pos
;
289 return M_PROPERTY_OK
;
291 return M_PROPERTY_NOT_IMPLEMENTED
;
294 /// Media length in seconds (RO)
295 static int mp_property_length(m_option_t
* prop
, int action
, void *arg
,
300 if (!mpctx
->demuxer
||
301 !(int) (len
= demuxer_get_time_length(mpctx
->demuxer
)))
302 return M_PROPERTY_UNAVAILABLE
;
304 return m_property_time_ro(prop
, action
, arg
, len
);
307 /// Current position in percent (RW)
308 static int mp_property_percent_pos(m_option_t
* prop
, int action
,
309 void *arg
, MPContext
* mpctx
) {
313 return M_PROPERTY_UNAVAILABLE
;
317 if(!arg
) return M_PROPERTY_ERROR
;
318 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
321 case M_PROPERTY_STEP_UP
:
322 case M_PROPERTY_STEP_DOWN
:
323 pos
= demuxer_get_percent_pos(mpctx
->demuxer
);
324 pos
+= (arg
? *(int*)arg
: 10) *
325 (action
== M_PROPERTY_STEP_UP
? 1 : -1);
326 M_PROPERTY_CLAMP(prop
, pos
);
329 return m_property_int_ro(prop
, action
, arg
,
330 demuxer_get_percent_pos(mpctx
->demuxer
));
333 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
334 rel_seek_secs
= pos
/ 100.0;
335 return M_PROPERTY_OK
;
338 /// Current position in seconds (RW)
339 static int mp_property_time_pos(m_option_t
* prop
, int action
,
340 void *arg
, MPContext
* mpctx
) {
341 if (!(mpctx
->sh_video
|| (mpctx
->sh_audio
&& mpctx
->audio_out
)))
342 return M_PROPERTY_UNAVAILABLE
;
346 if(!arg
) return M_PROPERTY_ERROR
;
347 M_PROPERTY_CLAMP(prop
, *(double*)arg
);
348 abs_seek_pos
= SEEK_ABSOLUTE
;
349 rel_seek_secs
= *(double*)arg
;
350 return M_PROPERTY_OK
;
351 case M_PROPERTY_STEP_UP
:
352 case M_PROPERTY_STEP_DOWN
:
353 rel_seek_secs
+= (arg
? *(double*)arg
: 10.0) *
354 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
355 return M_PROPERTY_OK
;
357 return m_property_time_ro(prop
, action
, arg
,
358 mpctx
->sh_video
? mpctx
->sh_video
->pts
:
359 playing_audio_pts(mpctx
->sh_audio
,
364 /// Current chapter (RW)
365 static int mp_property_chapter(m_option_t
*prop
, int action
, void *arg
,
372 char *chapter_name
= NULL
;
375 chapter
= demuxer_get_current_chapter(mpctx
->demuxer
);
377 return M_PROPERTY_UNAVAILABLE
;
382 return M_PROPERTY_ERROR
;
383 *(int *) arg
= chapter
;
384 return M_PROPERTY_OK
;
385 case M_PROPERTY_PRINT
: {
387 return M_PROPERTY_ERROR
;
388 chapter_name
= demuxer_chapter_display_name(mpctx
->demuxer
, chapter
);
390 return M_PROPERTY_UNAVAILABLE
;
391 *(char **) arg
= chapter_name
;
392 return M_PROPERTY_OK
;
396 return M_PROPERTY_ERROR
;
397 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
398 step_all
= *(int *)arg
- chapter
;
401 case M_PROPERTY_STEP_UP
:
402 case M_PROPERTY_STEP_DOWN
: {
403 step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
404 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
411 return M_PROPERTY_NOT_IMPLEMENTED
;
415 chapter
= demuxer_seek_chapter(mpctx
->demuxer
, chapter
, 1,
416 &next_pts
, &chapter_num
, &chapter_name
);
418 if (next_pts
> -1.0) {
419 abs_seek_pos
= SEEK_ABSOLUTE
;
420 rel_seek_secs
= next_pts
;
423 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
424 MSGTR_OSDChapter
, chapter
+ 1, chapter_name
);
426 else if (step_all
> 0)
427 rel_seek_secs
= 1000000000.;
429 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
430 MSGTR_OSDChapter
, 0, MSGTR_Unknown
);
433 return M_PROPERTY_OK
;
436 /// Number of chapters in file
437 static int mp_property_chapters(m_option_t
*prop
, int action
, void *arg
,
441 return M_PROPERTY_UNAVAILABLE
;
442 if (mpctx
->demuxer
->num_chapters
== 0)
443 stream_control(mpctx
->demuxer
->stream
, STREAM_CTRL_GET_NUM_CHAPTERS
, &mpctx
->demuxer
->num_chapters
);
444 return m_property_int_ro(prop
, action
, arg
, mpctx
->demuxer
->num_chapters
);
447 /// Current dvd angle (RW)
448 static int mp_property_angle(m_option_t
*prop
, int action
, void *arg
,
453 char *angle_name
= NULL
;
456 angle
= demuxer_get_current_angle(mpctx
->demuxer
);
458 return M_PROPERTY_UNAVAILABLE
;
459 angles
= demuxer_angles_count(mpctx
->demuxer
);
461 return M_PROPERTY_UNAVAILABLE
;
466 return M_PROPERTY_ERROR
;
467 *(int *) arg
= angle
;
468 return M_PROPERTY_OK
;
469 case M_PROPERTY_PRINT
: {
471 return M_PROPERTY_ERROR
;
472 angle_name
= calloc(1, 64);
474 return M_PROPERTY_UNAVAILABLE
;
475 snprintf(angle_name
, 64, "%d/%d", angle
, angles
);
476 *(char **) arg
= angle_name
;
477 return M_PROPERTY_OK
;
481 return M_PROPERTY_ERROR
;
483 M_PROPERTY_CLAMP(prop
, angle
);
485 case M_PROPERTY_STEP_UP
:
486 case M_PROPERTY_STEP_DOWN
: {
492 step
*= (action
== M_PROPERTY_STEP_UP
? 1 : -1);
494 if (angle
< 1) //cycle
499 return M_PROPERTY_NOT_IMPLEMENTED
;
501 angle
= demuxer_set_angle(mpctx
->demuxer
, angle
);
502 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
503 MSGTR_OSDAngle
, angle
, angles
);
506 return M_PROPERTY_OK
;
509 /// Demuxer meta data
510 static int mp_property_metadata(m_option_t
* prop
, int action
, void *arg
,
512 m_property_action_t
* ka
;
514 static m_option_t key_type
=
515 { "metadata", NULL
, CONF_TYPE_STRING
, 0, 0, 0, NULL
};
517 return M_PROPERTY_UNAVAILABLE
;
521 if(!arg
) return M_PROPERTY_ERROR
;
522 *(char***)arg
= mpctx
->demuxer
->info
;
523 return M_PROPERTY_OK
;
524 case M_PROPERTY_KEY_ACTION
:
525 if(!arg
) return M_PROPERTY_ERROR
;
527 if(!(meta
= demux_info_get(mpctx
->demuxer
,ka
->key
)))
528 return M_PROPERTY_UNKNOWN
;
531 if(!ka
->arg
) return M_PROPERTY_ERROR
;
532 *(char**)ka
->arg
= meta
;
533 return M_PROPERTY_OK
;
534 case M_PROPERTY_GET_TYPE
:
535 if(!ka
->arg
) return M_PROPERTY_ERROR
;
536 *(m_option_t
**)ka
->arg
= &key_type
;
537 return M_PROPERTY_OK
;
540 return M_PROPERTY_NOT_IMPLEMENTED
;
543 static int mp_property_pause(m_option_t
* prop
, int action
, void *arg
,
546 return m_property_flag_ro(prop
, action
, arg
, mpctx
->osd_function
== OSD_PAUSE
);
552 /// \defgroup AudioProperties Audio properties
553 /// \ingroup Properties
557 static int mp_property_volume(m_option_t
* prop
, int action
, void *arg
,
561 if (!mpctx
->sh_audio
)
562 return M_PROPERTY_UNAVAILABLE
;
567 return M_PROPERTY_ERROR
;
568 mixer_getbothvolume(&mpctx
->mixer
, arg
);
569 return M_PROPERTY_OK
;
570 case M_PROPERTY_PRINT
:{
573 return M_PROPERTY_ERROR
;
574 mixer_getbothvolume(&mpctx
->mixer
, &vol
);
575 return m_property_float_range(prop
, action
, arg
, &vol
);
577 case M_PROPERTY_STEP_UP
:
578 case M_PROPERTY_STEP_DOWN
:
582 return M_PROPERTY_NOT_IMPLEMENTED
;
585 if (mpctx
->edl_muted
)
586 return M_PROPERTY_DISABLED
;
587 mpctx
->user_muted
= 0;
592 return M_PROPERTY_ERROR
;
593 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
594 mixer_setvolume(&mpctx
->mixer
, *(float *) arg
, *(float *) arg
);
595 return M_PROPERTY_OK
;
596 case M_PROPERTY_STEP_UP
:
597 if (arg
&& *(float *) arg
<= 0)
598 mixer_decvolume(&mpctx
->mixer
);
600 mixer_incvolume(&mpctx
->mixer
);
601 return M_PROPERTY_OK
;
602 case M_PROPERTY_STEP_DOWN
:
603 if (arg
&& *(float *) arg
<= 0)
604 mixer_incvolume(&mpctx
->mixer
);
606 mixer_decvolume(&mpctx
->mixer
);
607 return M_PROPERTY_OK
;
609 return M_PROPERTY_NOT_IMPLEMENTED
;
613 static int mp_property_mute(m_option_t
* prop
, int action
, void *arg
,
617 if (!mpctx
->sh_audio
)
618 return M_PROPERTY_UNAVAILABLE
;
622 if (mpctx
->edl_muted
)
623 return M_PROPERTY_DISABLED
;
625 return M_PROPERTY_ERROR
;
626 if ((!!*(int *) arg
) != mpctx
->mixer
.muted
)
627 mixer_mute(&mpctx
->mixer
);
628 mpctx
->user_muted
= mpctx
->mixer
.muted
;
629 return M_PROPERTY_OK
;
630 case M_PROPERTY_STEP_UP
:
631 case M_PROPERTY_STEP_DOWN
:
632 if (mpctx
->edl_muted
)
633 return M_PROPERTY_DISABLED
;
634 mixer_mute(&mpctx
->mixer
);
635 mpctx
->user_muted
= mpctx
->mixer
.muted
;
636 return M_PROPERTY_OK
;
637 case M_PROPERTY_PRINT
:
639 return M_PROPERTY_ERROR
;
640 if (mpctx
->edl_muted
) {
641 *(char **) arg
= strdup(MSGTR_EnabledEdl
);
642 return M_PROPERTY_OK
;
645 return m_property_flag(prop
, action
, arg
, &mpctx
->mixer
.muted
);
651 static int mp_property_audio_delay(m_option_t
* prop
, int action
,
652 void *arg
, MPContext
* mpctx
)
654 if (!(mpctx
->sh_audio
&& mpctx
->sh_video
))
655 return M_PROPERTY_UNAVAILABLE
;
658 case M_PROPERTY_STEP_UP
:
659 case M_PROPERTY_STEP_DOWN
: {
661 float delay
= audio_delay
;
662 ret
= m_property_delay(prop
, action
, arg
, &audio_delay
);
663 if (ret
!= M_PROPERTY_OK
)
666 mpctx
->delay
-= audio_delay
- delay
;
668 return M_PROPERTY_OK
;
670 return m_property_delay(prop
, action
, arg
, &audio_delay
);
674 /// Audio codec tag (RO)
675 static int mp_property_audio_format(m_option_t
* prop
, int action
,
676 void *arg
, MPContext
* mpctx
)
678 if (!mpctx
->sh_audio
)
679 return M_PROPERTY_UNAVAILABLE
;
680 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->format
);
683 /// Audio codec name (RO)
684 static int mp_property_audio_codec(m_option_t
* prop
, int action
,
685 void *arg
, MPContext
* mpctx
)
687 if (!mpctx
->sh_audio
|| !mpctx
->sh_audio
->codec
)
688 return M_PROPERTY_UNAVAILABLE
;
689 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_audio
->codec
->name
);
692 /// Audio bitrate (RO)
693 static int mp_property_audio_bitrate(m_option_t
* prop
, int action
,
694 void *arg
, MPContext
* mpctx
)
696 if (!mpctx
->sh_audio
)
697 return M_PROPERTY_UNAVAILABLE
;
698 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_audio
->i_bps
);
702 static int mp_property_samplerate(m_option_t
* prop
, int action
, void *arg
,
705 if (!mpctx
->sh_audio
)
706 return M_PROPERTY_UNAVAILABLE
;
708 case M_PROPERTY_PRINT
:
709 if(!arg
) return M_PROPERTY_ERROR
;
710 *(char**)arg
= malloc(16);
711 sprintf(*(char**)arg
,"%d kHz",mpctx
->sh_audio
->samplerate
/1000);
712 return M_PROPERTY_OK
;
714 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->samplerate
);
717 /// Number of channels (RO)
718 static int mp_property_channels(m_option_t
* prop
, int action
, void *arg
,
721 if (!mpctx
->sh_audio
)
722 return M_PROPERTY_UNAVAILABLE
;
724 case M_PROPERTY_PRINT
:
726 return M_PROPERTY_ERROR
;
727 switch (mpctx
->sh_audio
->channels
) {
729 *(char **) arg
= strdup("mono");
732 *(char **) arg
= strdup("stereo");
735 *(char **) arg
= malloc(32);
736 sprintf(*(char **) arg
, "%d channels", mpctx
->sh_audio
->channels
);
738 return M_PROPERTY_OK
;
740 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_audio
->channels
);
744 static int mp_property_balance(m_option_t
* prop
, int action
, void *arg
,
749 if (!mpctx
->sh_audio
|| mpctx
->sh_audio
->channels
< 2)
750 return M_PROPERTY_UNAVAILABLE
;
755 return M_PROPERTY_ERROR
;
756 mixer_getbalance(&mpctx
->mixer
, arg
);
757 return M_PROPERTY_OK
;
758 case M_PROPERTY_PRINT
: {
761 return M_PROPERTY_ERROR
;
762 mixer_getbalance(&mpctx
->mixer
, &bal
);
764 *str
= strdup("center");
765 else if (bal
== -1.f
)
766 *str
= strdup("left only");
768 *str
= strdup("right only");
770 unsigned right
= (bal
+ 1.f
) / 2.f
* 100.f
;
771 *str
= malloc(sizeof("left xxx%, right xxx%"));
772 sprintf(*str
, "left %d%%, right %d%%", 100 - right
, right
);
774 return M_PROPERTY_OK
;
776 case M_PROPERTY_STEP_UP
:
777 case M_PROPERTY_STEP_DOWN
:
778 mixer_getbalance(&mpctx
->mixer
, &bal
);
779 bal
+= (arg
? *(float*)arg
: .1f
) *
780 (action
== M_PROPERTY_STEP_UP
? 1.f
: -1.f
);
781 M_PROPERTY_CLAMP(prop
, bal
);
782 mixer_setbalance(&mpctx
->mixer
, bal
);
783 return M_PROPERTY_OK
;
786 return M_PROPERTY_ERROR
;
787 M_PROPERTY_CLAMP(prop
, *(float*)arg
);
788 mixer_setbalance(&mpctx
->mixer
, *(float*)arg
);
789 return M_PROPERTY_OK
;
791 return M_PROPERTY_NOT_IMPLEMENTED
;
794 /// Selected audio id (RW)
795 static int mp_property_audio(m_option_t
* prop
, int action
, void *arg
,
798 int current_id
= -1, tmp
;
802 if (!mpctx
->sh_audio
)
803 return M_PROPERTY_UNAVAILABLE
;
805 return M_PROPERTY_ERROR
;
806 *(int *) arg
= audio_id
;
807 return M_PROPERTY_OK
;
808 case M_PROPERTY_PRINT
:
809 if (!mpctx
->sh_audio
)
810 return M_PROPERTY_UNAVAILABLE
;
812 return M_PROPERTY_ERROR
;
815 *(char **) arg
= strdup(MSGTR_Disabled
);
817 char lang
[40] = MSGTR_Unknown
;
818 sh_audio_t
* sh
= mpctx
->sh_audio
;
820 av_strlcpy(lang
, sh
->lang
, 40);
821 #ifdef CONFIG_DVDREAD
822 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
823 int code
= dvd_lang_from_aid(mpctx
->stream
, audio_id
);
833 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
834 mp_dvdnav_lang_from_aid(mpctx
->stream
, audio_id
, lang
);
836 *(char **) arg
= malloc(64);
837 snprintf(*(char **) arg
, 64, "(%d) %s", audio_id
, lang
);
839 return M_PROPERTY_OK
;
841 case M_PROPERTY_STEP_UP
:
844 return M_PROPERTY_UNAVAILABLE
;
845 if (action
== M_PROPERTY_SET
&& arg
)
846 tmp
= *((int *) arg
);
849 current_id
= mpctx
->demuxer
->audio
->id
;
850 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
853 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
854 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
855 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
857 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
859 sh2
->ds
= mpctx
->demuxer
->audio
;
860 mpctx
->sh_audio
= sh2
;
861 reinit_audio_chain();
864 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
865 return M_PROPERTY_OK
;
867 return M_PROPERTY_NOT_IMPLEMENTED
;
872 /// Selected video id (RW)
873 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
876 int current_id
= -1, tmp
;
880 if (!mpctx
->sh_video
)
881 return M_PROPERTY_UNAVAILABLE
;
883 return M_PROPERTY_ERROR
;
884 *(int *) arg
= video_id
;
885 return M_PROPERTY_OK
;
886 case M_PROPERTY_PRINT
:
887 if (!mpctx
->sh_video
)
888 return M_PROPERTY_UNAVAILABLE
;
890 return M_PROPERTY_ERROR
;
893 *(char **) arg
= strdup(MSGTR_Disabled
);
895 char lang
[40] = MSGTR_Unknown
;
896 *(char **) arg
= malloc(64);
897 snprintf(*(char **) arg
, 64, "(%d) %s", video_id
, lang
);
899 return M_PROPERTY_OK
;
901 case M_PROPERTY_STEP_UP
:
903 current_id
= mpctx
->demuxer
->video
->id
;
904 if (action
== M_PROPERTY_SET
&& arg
)
905 tmp
= *((int *) arg
);
908 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
910 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
911 && current_id
!= -2))
912 uninit_player(INITIALIZED_VCODEC
|
913 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
914 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
916 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
918 sh2
->ds
= mpctx
->demuxer
->video
;
919 mpctx
->sh_video
= sh2
;
920 reinit_video_chain();
923 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
924 return M_PROPERTY_OK
;
927 return M_PROPERTY_NOT_IMPLEMENTED
;
931 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
934 demux_program_t prog
;
937 case M_PROPERTY_STEP_UP
:
939 if (action
== M_PROPERTY_SET
&& arg
)
940 prog
.progid
= *((int *) arg
);
944 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
945 &prog
) == DEMUXER_CTRL_NOTIMPL
)
946 return M_PROPERTY_ERROR
;
948 if (prog
.aid
< 0 && prog
.vid
< 0) {
949 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
950 return M_PROPERTY_ERROR
;
952 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
953 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
954 return M_PROPERTY_OK
;
957 return M_PROPERTY_NOT_IMPLEMENTED
;
963 /// \defgroup VideoProperties Video properties
964 /// \ingroup Properties
967 /// Fullscreen state (RW)
968 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
972 if (!mpctx
->video_out
)
973 return M_PROPERTY_UNAVAILABLE
;
978 return M_PROPERTY_ERROR
;
979 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
980 if (vo_fs
== !!*(int *) arg
)
981 return M_PROPERTY_OK
;
982 case M_PROPERTY_STEP_UP
:
983 case M_PROPERTY_STEP_DOWN
:
986 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
990 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
991 return M_PROPERTY_OK
;
993 return m_property_flag(prop
, action
, arg
, &vo_fs
);
997 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
998 void *arg
, MPContext
* mpctx
)
1002 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
1003 return M_PROPERTY_UNAVAILABLE
;
1004 vf
= mpctx
->sh_video
->vfilter
;
1006 case M_PROPERTY_GET
:
1008 return M_PROPERTY_ERROR
;
1009 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1010 return M_PROPERTY_OK
;
1011 case M_PROPERTY_SET
:
1013 return M_PROPERTY_ERROR
;
1014 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1015 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1016 return M_PROPERTY_OK
;
1017 case M_PROPERTY_STEP_UP
:
1018 case M_PROPERTY_STEP_DOWN
:
1019 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1020 deinterlace
= !deinterlace
;
1021 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1022 return M_PROPERTY_OK
;
1024 return M_PROPERTY_NOT_IMPLEMENTED
;
1028 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1032 if (!mpctx
->video_out
1033 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1034 return M_PROPERTY_UNAVAILABLE
;
1037 case M_PROPERTY_SET
:
1039 return M_PROPERTY_ERROR
;
1040 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1041 vo_panscan
= *(float *) arg
;
1042 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1043 return M_PROPERTY_OK
;
1044 case M_PROPERTY_STEP_UP
:
1045 case M_PROPERTY_STEP_DOWN
:
1046 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1047 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1050 else if (vo_panscan
< 0)
1052 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1053 return M_PROPERTY_OK
;
1055 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1059 /// Helper to set vo flags.
1060 /** \ingroup PropertyImplHelper
1062 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1063 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1066 if (!mpctx
->video_out
)
1067 return M_PROPERTY_UNAVAILABLE
;
1070 case M_PROPERTY_SET
:
1072 return M_PROPERTY_ERROR
;
1073 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1074 if (*vo_var
== !!*(int *) arg
)
1075 return M_PROPERTY_OK
;
1076 case M_PROPERTY_STEP_UP
:
1077 case M_PROPERTY_STEP_DOWN
:
1078 if (vo_config_count
)
1079 mpctx
->video_out
->control(vo_ctrl
, 0);
1080 return M_PROPERTY_OK
;
1082 return m_property_flag(prop
, action
, arg
, vo_var
);
1086 /// Window always on top (RW)
1087 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1090 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1094 /// Display in the root window (RW)
1095 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1098 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1099 &vo_rootwin
, mpctx
);
1102 /// Show window borders (RW)
1103 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1106 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1110 /// Framedropping state (RW)
1111 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1112 void *arg
, MPContext
* mpctx
)
1115 if (!mpctx
->sh_video
)
1116 return M_PROPERTY_UNAVAILABLE
;
1119 case M_PROPERTY_PRINT
:
1121 return M_PROPERTY_ERROR
;
1122 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1123 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1125 return M_PROPERTY_OK
;
1127 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1131 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1132 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1135 int *gamma
= prop
->priv
, r
, val
;
1137 if (!mpctx
->sh_video
)
1138 return M_PROPERTY_UNAVAILABLE
;
1140 if (gamma
[0] == 1000) {
1142 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1146 case M_PROPERTY_SET
:
1148 return M_PROPERTY_ERROR
;
1149 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1150 *gamma
= *(int *) arg
;
1151 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1155 case M_PROPERTY_GET
:
1156 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1158 return M_PROPERTY_ERROR
;
1160 return M_PROPERTY_OK
;
1163 case M_PROPERTY_STEP_UP
:
1164 case M_PROPERTY_STEP_DOWN
:
1165 *gamma
+= (arg
? *(int *) arg
: 1) *
1166 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1167 M_PROPERTY_CLAMP(prop
, *gamma
);
1168 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1173 return M_PROPERTY_NOT_IMPLEMENTED
;
1177 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1178 int l
= strlen(prop
->name
);
1179 char tv_prop
[3 + l
+ 1];
1180 sprintf(tv_prop
, "tv_%s", prop
->name
);
1181 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1185 return M_PROPERTY_UNAVAILABLE
;
1189 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1192 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1195 /// Video codec tag (RO)
1196 static int mp_property_video_format(m_option_t
* prop
, int action
,
1197 void *arg
, MPContext
* mpctx
)
1200 if (!mpctx
->sh_video
)
1201 return M_PROPERTY_UNAVAILABLE
;
1203 case M_PROPERTY_PRINT
:
1205 return M_PROPERTY_ERROR
;
1206 switch(mpctx
->sh_video
->format
) {
1208 meta
= strdup ("mpeg1"); break;
1210 meta
= strdup ("mpeg2"); break;
1212 meta
= strdup ("mpeg4"); break;
1214 meta
= strdup ("h264"); break;
1216 if(mpctx
->sh_video
->format
>= 0x20202020) {
1218 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1221 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1224 *(char**)arg
= meta
;
1225 return M_PROPERTY_OK
;
1227 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1230 /// Video codec name (RO)
1231 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1232 void *arg
, MPContext
* mpctx
)
1234 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1235 return M_PROPERTY_UNAVAILABLE
;
1236 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1240 /// Video bitrate (RO)
1241 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1242 void *arg
, MPContext
* mpctx
)
1244 if (!mpctx
->sh_video
)
1245 return M_PROPERTY_UNAVAILABLE
;
1246 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1249 /// Video display width (RO)
1250 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1253 if (!mpctx
->sh_video
)
1254 return M_PROPERTY_UNAVAILABLE
;
1255 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1258 /// Video display height (RO)
1259 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1262 if (!mpctx
->sh_video
)
1263 return M_PROPERTY_UNAVAILABLE
;
1264 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1268 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1271 if (!mpctx
->sh_video
)
1272 return M_PROPERTY_UNAVAILABLE
;
1273 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1276 /// Video aspect (RO)
1277 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1280 if (!mpctx
->sh_video
)
1281 return M_PROPERTY_UNAVAILABLE
;
1282 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1287 /// \defgroup SubProprties Subtitles properties
1288 /// \ingroup Properties
1291 /// Text subtitle position (RW)
1292 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1295 if (!mpctx
->sh_video
)
1296 return M_PROPERTY_UNAVAILABLE
;
1299 case M_PROPERTY_SET
:
1301 return M_PROPERTY_ERROR
;
1302 case M_PROPERTY_STEP_UP
:
1303 case M_PROPERTY_STEP_DOWN
:
1304 vo_osd_changed(OSDTYPE_SUBTITLE
);
1306 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1310 /// Selected subtitles (RW)
1311 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1314 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1315 const int global_sub_size
= mpctx
->global_sub_size
;
1316 int source
= -1, reset_spu
= 0;
1320 if (global_sub_size
<= 0)
1321 return M_PROPERTY_UNAVAILABLE
;
1324 case M_PROPERTY_GET
:
1326 return M_PROPERTY_ERROR
;
1327 *(int *) arg
= mpctx
->global_sub_pos
;
1328 return M_PROPERTY_OK
;
1329 case M_PROPERTY_PRINT
:
1331 return M_PROPERTY_ERROR
;
1332 *(char **) arg
= malloc(64);
1333 (*(char **) arg
)[63] = 0;
1336 sub_name
= subdata
->filename
;
1338 if (ass_track
&& ass_track
->name
)
1339 sub_name
= ass_track
->name
;
1344 if ((tmp2
= strrchr(tmp
, '/')))
1347 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1348 mpctx
->set_of_sub_pos
+ 1,
1349 strlen(tmp
) < 20 ? "" : "...",
1350 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1351 return M_PROPERTY_OK
;
1353 #ifdef CONFIG_DVDNAV
1354 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1355 if (vo_spudec
&& dvdsub_id
>= 0) {
1356 unsigned char lang
[3];
1357 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1358 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1359 return M_PROPERTY_OK
;
1365 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1366 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1367 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1368 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1369 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1370 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1371 if (!lang
) lang
= MSGTR_Unknown
;
1372 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1373 return M_PROPERTY_OK
;
1376 if (vo_vobsub
&& vobsub_id
>= 0) {
1377 const char *language
= MSGTR_Unknown
;
1378 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1379 snprintf(*(char **) arg
, 63, "(%d) %s",
1380 vobsub_id
, language
? language
: MSGTR_Unknown
);
1381 return M_PROPERTY_OK
;
1383 #ifdef CONFIG_DVDREAD
1384 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1385 && dvdsub_id
>= 0) {
1387 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1388 lang
[0] = code
>> 8;
1391 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1392 return M_PROPERTY_OK
;
1395 if (dvdsub_id
>= 0) {
1396 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1397 return M_PROPERTY_OK
;
1399 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1400 return M_PROPERTY_OK
;
1402 case M_PROPERTY_SET
:
1404 return M_PROPERTY_ERROR
;
1405 if (*(int *) arg
< -1)
1407 else if (*(int *) arg
>= global_sub_size
)
1408 *(int *) arg
= global_sub_size
- 1;
1409 mpctx
->global_sub_pos
= *(int *) arg
;
1411 case M_PROPERTY_STEP_UP
:
1412 mpctx
->global_sub_pos
+= 2;
1413 mpctx
->global_sub_pos
=
1414 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1416 case M_PROPERTY_STEP_DOWN
:
1417 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1418 mpctx
->global_sub_pos
=
1419 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1422 return M_PROPERTY_NOT_IMPLEMENTED
;
1425 if (mpctx
->global_sub_pos
>= 0)
1426 source
= sub_source(mpctx
);
1428 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1429 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1431 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1432 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1433 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1434 mpctx
->global_sub_pos
, source
);
1436 mpctx
->set_of_sub_pos
= -1;
1450 if (source
== SUB_SOURCE_VOBSUB
) {
1451 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1452 } else if (source
== SUB_SOURCE_SUBS
) {
1453 mpctx
->set_of_sub_pos
=
1454 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1456 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1457 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1461 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1462 vo_osd_changed(OSDTYPE_SUBTITLE
);
1464 } else if (source
== SUB_SOURCE_DEMUX
) {
1466 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1467 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1469 // default: assume 1:1 mapping of sid and stream id
1470 d_sub
->id
= dvdsub_id
;
1471 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1472 ds_free_packs(d_sub
);
1473 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1474 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1475 if (sh
&& sh
->sid
== dvdsub_id
) {
1481 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1482 sh_sub_t
*sh
= d_sub
->sh
;
1483 if (sh
->type
== 'v')
1486 else if (ass_enabled
)
1487 ass_track
= sh
->ass_track
;
1495 #ifdef CONFIG_DVDREAD
1497 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1498 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1499 && dvdsub_id
< 0 && reset_spu
) {
1501 d_sub
->id
= dvdsub_id
;
1504 if (mpctx
->sh_audio
)
1505 pts
= mpctx
->sh_audio
->pts
;
1506 if (mpctx
->sh_video
)
1507 pts
= mpctx
->sh_video
->pts
;
1508 update_subtitles(mpctx
->sh_video
, pts
, d_sub
, 1);
1510 return M_PROPERTY_OK
;
1513 /// Selected sub source (RW)
1514 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1518 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1519 return M_PROPERTY_UNAVAILABLE
;
1522 case M_PROPERTY_GET
:
1524 return M_PROPERTY_ERROR
;
1525 *(int *) arg
= sub_source(mpctx
);
1526 return M_PROPERTY_OK
;
1527 case M_PROPERTY_PRINT
:
1529 return M_PROPERTY_ERROR
;
1530 *(char **) arg
= malloc(64);
1531 (*(char **) arg
)[63] = 0;
1532 switch (sub_source(mpctx
))
1534 case SUB_SOURCE_SUBS
:
1535 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1537 case SUB_SOURCE_VOBSUB
:
1538 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1540 case SUB_SOURCE_DEMUX
:
1541 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1544 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1546 return M_PROPERTY_OK
;
1547 case M_PROPERTY_SET
:
1549 return M_PROPERTY_ERROR
;
1550 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1551 if (*(int *) arg
< 0)
1552 mpctx
->global_sub_pos
= -1;
1553 else if (*(int *) arg
!= sub_source(mpctx
)) {
1554 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1555 return M_PROPERTY_UNAVAILABLE
;
1556 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1559 case M_PROPERTY_STEP_UP
:
1560 case M_PROPERTY_STEP_DOWN
: {
1561 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1562 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1563 int step
= (step_all
> 0) ? 1 : -1;
1564 int cur_source
= sub_source(mpctx
);
1565 source
= cur_source
;
1568 if (source
>= SUB_SOURCES
)
1570 else if (source
< -1)
1571 source
= SUB_SOURCES
- 1;
1572 if (source
== cur_source
|| source
== -1 ||
1573 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1576 if (source
== cur_source
)
1577 return M_PROPERTY_OK
;
1579 mpctx
->global_sub_pos
= -1;
1581 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1585 return M_PROPERTY_NOT_IMPLEMENTED
;
1587 --mpctx
->global_sub_pos
;
1588 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1591 /// Selected subtitles from specific source (RW)
1592 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1595 int source
, is_cur_source
, offset
;
1596 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1597 return M_PROPERTY_UNAVAILABLE
;
1599 if (!strcmp(prop
->name
, "sub_file"))
1600 source
= SUB_SOURCE_SUBS
;
1601 else if (!strcmp(prop
->name
, "sub_vob"))
1602 source
= SUB_SOURCE_VOBSUB
;
1603 else if (!strcmp(prop
->name
, "sub_demux"))
1604 source
= SUB_SOURCE_DEMUX
;
1606 return M_PROPERTY_ERROR
;
1608 offset
= mpctx
->global_sub_indices
[source
];
1609 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1610 return M_PROPERTY_UNAVAILABLE
;
1612 is_cur_source
= sub_source(mpctx
) == source
;
1614 case M_PROPERTY_GET
:
1616 return M_PROPERTY_ERROR
;
1617 if (is_cur_source
) {
1618 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1619 if (source
== SUB_SOURCE_VOBSUB
)
1620 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1624 return M_PROPERTY_OK
;
1625 case M_PROPERTY_PRINT
:
1627 return M_PROPERTY_ERROR
;
1629 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1630 *(char **) arg
= malloc(64);
1631 (*(char **) arg
)[63] = 0;
1632 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1633 return M_PROPERTY_OK
;
1634 case M_PROPERTY_SET
:
1636 return M_PROPERTY_ERROR
;
1637 if (*(int *) arg
>= 0) {
1638 int index
= *(int *)arg
;
1639 if (source
== SUB_SOURCE_VOBSUB
)
1640 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1641 mpctx
->global_sub_pos
= offset
+ index
;
1642 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1643 || sub_source(mpctx
) != source
) {
1644 mpctx
->global_sub_pos
= -1;
1649 mpctx
->global_sub_pos
= -1;
1651 case M_PROPERTY_STEP_UP
:
1652 case M_PROPERTY_STEP_DOWN
: {
1653 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1654 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1655 int step
= (step_all
> 0) ? 1 : -1;
1656 int max_sub_pos_for_source
= -1;
1658 mpctx
->global_sub_pos
= -1;
1660 if (mpctx
->global_sub_pos
== -1) {
1662 mpctx
->global_sub_pos
= offset
;
1663 else if (max_sub_pos_for_source
== -1) {
1664 // Find max pos for specific source
1665 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1666 while (mpctx
->global_sub_pos
>= 0
1667 && sub_source(mpctx
) != source
)
1668 --mpctx
->global_sub_pos
;
1671 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1674 mpctx
->global_sub_pos
+= step
;
1675 if (mpctx
->global_sub_pos
< offset
||
1676 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1677 sub_source(mpctx
) != source
)
1678 mpctx
->global_sub_pos
= -1;
1685 return M_PROPERTY_NOT_IMPLEMENTED
;
1687 --mpctx
->global_sub_pos
;
1688 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1691 /// Subtitle delay (RW)
1692 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1695 if (!mpctx
->sh_video
)
1696 return M_PROPERTY_UNAVAILABLE
;
1697 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1700 /// Alignment of text subtitles (RW)
1701 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1702 void *arg
, MPContext
* mpctx
)
1704 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1706 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1707 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1708 return M_PROPERTY_UNAVAILABLE
;
1711 case M_PROPERTY_PRINT
:
1713 return M_PROPERTY_ERROR
;
1714 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1715 *(char **) arg
= strdup(name
[sub_alignment
]);
1716 return M_PROPERTY_OK
;
1717 case M_PROPERTY_SET
:
1719 return M_PROPERTY_ERROR
;
1720 case M_PROPERTY_STEP_UP
:
1721 case M_PROPERTY_STEP_DOWN
:
1722 vo_osd_changed(OSDTYPE_SUBTITLE
);
1724 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1728 /// Subtitle visibility (RW)
1729 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1730 void *arg
, MPContext
* mpctx
)
1732 if (!mpctx
->sh_video
)
1733 return M_PROPERTY_UNAVAILABLE
;
1736 case M_PROPERTY_SET
:
1738 return M_PROPERTY_ERROR
;
1739 case M_PROPERTY_STEP_UP
:
1740 case M_PROPERTY_STEP_DOWN
:
1741 vo_osd_changed(OSDTYPE_SUBTITLE
);
1743 vo_osd_changed(OSDTYPE_SPU
);
1745 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1750 /// Use margins for libass subtitles (RW)
1751 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1752 void *arg
, MPContext
* mpctx
)
1754 if (!mpctx
->sh_video
)
1755 return M_PROPERTY_UNAVAILABLE
;
1758 case M_PROPERTY_SET
:
1760 return M_PROPERTY_ERROR
;
1761 case M_PROPERTY_STEP_UP
:
1762 case M_PROPERTY_STEP_DOWN
:
1763 ass_force_reload
= 1;
1765 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1770 /// Show only forced subtitles (RW)
1771 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1772 void *arg
, MPContext
* mpctx
)
1775 return M_PROPERTY_UNAVAILABLE
;
1778 case M_PROPERTY_SET
:
1780 return M_PROPERTY_ERROR
;
1781 case M_PROPERTY_STEP_UP
:
1782 case M_PROPERTY_STEP_DOWN
:
1783 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1784 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1785 return M_PROPERTY_OK
;
1787 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1792 #ifdef CONFIG_FREETYPE
1793 /// Subtitle scale (RW)
1794 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1799 case M_PROPERTY_SET
:
1801 return M_PROPERTY_ERROR
;
1802 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1805 ass_font_scale
= *(float *) arg
;
1806 ass_force_reload
= 1;
1809 text_font_scale_factor
= *(float *) arg
;
1810 force_load_font
= 1;
1811 return M_PROPERTY_OK
;
1812 case M_PROPERTY_STEP_UP
:
1813 case M_PROPERTY_STEP_DOWN
:
1816 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1817 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1818 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1819 ass_force_reload
= 1;
1822 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1823 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1824 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1825 force_load_font
= 1;
1826 return M_PROPERTY_OK
;
1830 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1833 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1840 /// \defgroup TVProperties TV properties
1841 /// \ingroup Properties
1846 /// TV color settings (RW)
1847 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1851 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1852 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1853 return M_PROPERTY_UNAVAILABLE
;
1856 case M_PROPERTY_SET
:
1858 return M_PROPERTY_ERROR
;
1859 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1860 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1861 case M_PROPERTY_GET
:
1862 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1863 case M_PROPERTY_STEP_UP
:
1864 case M_PROPERTY_STEP_DOWN
:
1865 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1867 return M_PROPERTY_ERROR
;
1868 val
+= (arg
? *(int *) arg
: 1) *
1869 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1870 M_PROPERTY_CLAMP(prop
, val
);
1871 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1873 return M_PROPERTY_ERROR
;
1875 return M_PROPERTY_NOT_IMPLEMENTED
;
1880 #ifdef CONFIG_TV_TELETEXT
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 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1892 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1893 return M_PROPERTY_UNAVAILABLE
;
1895 return M_PROPERTY_ERROR
;
1898 case M_PROPERTY_GET
:
1900 return M_PROPERTY_ERROR
;
1901 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, arg
);
1903 case M_PROPERTY_SET
:
1905 return M_PROPERTY_ERROR
;
1906 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1907 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, arg
);
1909 case M_PROPERTY_STEP_UP
:
1910 case M_PROPERTY_STEP_DOWN
:
1911 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
, &val
);
1912 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1913 result
=tvh
->functions
->control(tvh
->priv
, base_ioctl
+1, &val
);
1916 return M_PROPERTY_NOT_IMPLEMENTED
;
1919 return result
== TVI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1922 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1925 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1929 //with tvh==NULL will fail too
1930 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1931 if(result
!=M_PROPERTY_OK
)
1934 if(tvh
->functions
->control(tvh
->priv
, prop
->priv
, &val
)==TVI_CONTROL_TRUE
&& val
)
1935 mp_input_set_section("teletext");
1937 mp_input_set_section("tv");
1938 return M_PROPERTY_OK
;
1941 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1944 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1947 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1948 return M_PROPERTY_UNAVAILABLE
;
1950 case M_PROPERTY_STEP_UP
:
1951 case M_PROPERTY_STEP_DOWN
:
1952 //This should be handled separately
1953 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1954 result
=tvh
->functions
->control(tvh
->priv
, TV_VBI_CONTROL_STEP_PAGE
, &val
);
1957 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1963 #endif /* CONFIG_TV_TELETEXT */
1967 /// All properties available in MPlayer.
1968 /** \ingroup Properties
1970 static const m_option_t mp_properties
[] = {
1972 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1973 M_OPT_RANGE
, 0, 3, NULL
},
1974 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1975 M_OPT_MIN
, -1, 0, NULL
},
1976 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1977 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1978 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1980 { "path", mp_property_path
, CONF_TYPE_STRING
,
1982 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1984 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1985 M_OPT_MIN
, 0, 0, NULL
},
1986 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1987 M_OPT_MIN
, 0, 0, NULL
},
1988 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1989 M_OPT_MIN
, 0, 0, NULL
},
1990 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1991 M_OPT_MIN
, 0, 0, NULL
},
1992 { "length", mp_property_length
, CONF_TYPE_TIME
,
1993 M_OPT_MIN
, 0, 0, NULL
},
1994 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1995 M_OPT_RANGE
, 0, 100, NULL
},
1996 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1997 M_OPT_MIN
, 0, 0, NULL
},
1998 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1999 M_OPT_MIN
, 0, 0, NULL
},
2000 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
2002 { "angle", mp_property_angle
, CONF_TYPE_INT
,
2003 CONF_RANGE
, -2, 10, NULL
},
2004 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
2006 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
2007 M_OPT_RANGE
, 0, 1, NULL
},
2010 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
2011 M_OPT_RANGE
, 0, 100, NULL
},
2012 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2013 M_OPT_RANGE
, 0, 1, NULL
},
2014 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2015 M_OPT_RANGE
, -100, 100, NULL
},
2016 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2018 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2020 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2022 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2024 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2026 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2027 CONF_RANGE
, -2, 65535, NULL
},
2028 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2029 M_OPT_RANGE
, -1, 1, NULL
},
2032 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2033 M_OPT_RANGE
, 0, 1, NULL
},
2034 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2035 M_OPT_RANGE
, 0, 1, NULL
},
2036 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2037 M_OPT_RANGE
, 0, 1, NULL
},
2038 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2039 M_OPT_RANGE
, 0, 1, NULL
},
2040 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2041 M_OPT_RANGE
, 0, 1, NULL
},
2042 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2043 M_OPT_RANGE
, 0, 2, NULL
},
2044 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2045 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2046 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2047 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2048 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2049 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2050 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2051 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2052 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2053 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2054 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2055 M_OPT_RANGE
, 0, 1, NULL
},
2056 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2057 M_OPT_RANGE
, 0, 1, NULL
},
2058 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2060 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2062 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2064 { "width", mp_property_width
, CONF_TYPE_INT
,
2066 { "height", mp_property_height
, CONF_TYPE_INT
,
2068 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2070 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2072 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2073 CONF_RANGE
, -2, 65535, NULL
},
2074 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2075 CONF_RANGE
, -1, 65535, NULL
},
2078 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2079 M_OPT_MIN
, -1, 0, NULL
},
2080 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2081 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2082 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2083 M_OPT_MIN
, -1, 0, NULL
},
2084 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2085 M_OPT_MIN
, -1, 0, NULL
},
2086 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2087 M_OPT_MIN
, -1, 0, NULL
},
2088 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2090 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2091 M_OPT_RANGE
, 0, 100, NULL
},
2092 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2093 M_OPT_RANGE
, 0, 2, NULL
},
2094 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2095 M_OPT_RANGE
, 0, 1, NULL
},
2096 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2097 M_OPT_RANGE
, 0, 1, NULL
},
2098 #ifdef CONFIG_FREETYPE
2099 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2100 M_OPT_RANGE
, 0, 100, NULL
},
2103 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2104 M_OPT_RANGE
, 0, 1, NULL
},
2108 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2109 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2110 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2111 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2112 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2113 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2114 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2115 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2118 #ifdef CONFIG_TV_TELETEXT
2119 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2120 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2121 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2122 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2123 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2124 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2125 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2126 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2127 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2128 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2131 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2135 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2137 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2140 char* mp_property_print(const char *name
, void* ctx
)
2143 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2148 char *property_expand_string(MPContext
* mpctx
, char *str
)
2150 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2153 void property_print_help(void)
2155 m_properties_print_help_list(mp_properties
);
2164 * \defgroup Command2Property Command to property bridge
2166 * It is used to handle most commands that just set a property
2167 * and optionally display something on the OSD.
2168 * Two kinds of commands are handled: adjust or toggle.
2170 * Adjust commands take 1 or 2 parameters: <value> <abs>
2171 * If <abs> is non-zero the property is set to the given value
2172 * otherwise it is adjusted.
2174 * Toggle commands take 0 or 1 parameters. With no parameter
2175 * or a value less than the property minimum it just steps the
2176 * property to its next value. Otherwise it sets it to the given
2182 /// List of the commands that can be handled by setting a property.
2188 /// set/adjust or toggle command
2190 /// progressbar type
2192 /// osd msg id if it must be shared
2194 /// osd msg template
2195 const char *osd_msg
;
2196 } set_prop_cmd
[] = {
2198 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2199 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2200 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2202 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2203 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2204 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2205 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2206 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2208 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2209 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2210 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2211 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2212 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2213 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2214 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2215 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2216 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2217 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2218 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2219 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2221 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2222 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2223 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2224 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2225 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2226 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2227 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2228 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2229 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2230 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2231 #ifdef CONFIG_FREETYPE
2232 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2235 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2238 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2239 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2240 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2241 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2243 { NULL
, 0, 0, 0, -1, NULL
}
2247 /// Handle commands that set a property.
2248 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2254 // look for the command
2255 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2256 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2258 if (!(pname
= set_prop_cmd
[i
].name
))
2261 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2265 if (set_prop_cmd
[i
].toggle
) {
2267 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2268 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2270 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2271 } else if (cmd
->args
[1].v
.i
) //set
2272 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2274 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2279 if (set_prop_cmd
[i
].osd_progbar
) {
2280 if (prop
->type
== CONF_TYPE_INT
) {
2281 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2282 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2283 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2284 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2286 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2287 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2288 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2290 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2291 "Property use an unsupported type.\n");
2295 if (set_prop_cmd
[i
].osd_msg
) {
2296 char *val
= mp_property_print(pname
, mpctx
);
2298 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2299 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2300 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2307 #ifdef CONFIG_DVDNAV
2308 static const struct {
2310 const mp_command_type cmd
;
2311 } mp_dvdnav_bindings
[] = {
2312 { "up", MP_CMD_DVDNAV_UP
},
2313 { "down", MP_CMD_DVDNAV_DOWN
},
2314 { "left", MP_CMD_DVDNAV_LEFT
},
2315 { "right", MP_CMD_DVDNAV_RIGHT
},
2316 { "menu", MP_CMD_DVDNAV_MENU
},
2317 { "select", MP_CMD_DVDNAV_SELECT
},
2318 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2319 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2322 * keep old dvdnav sub-command options for a while in order not to
2323 * break slave-mode API too suddenly.
2325 { "1", MP_CMD_DVDNAV_UP
},
2326 { "2", MP_CMD_DVDNAV_DOWN
},
2327 { "3", MP_CMD_DVDNAV_LEFT
},
2328 { "4", MP_CMD_DVDNAV_RIGHT
},
2329 { "5", MP_CMD_DVDNAV_MENU
},
2330 { "6", MP_CMD_DVDNAV_SELECT
},
2331 { "7", MP_CMD_DVDNAV_PREVMENU
},
2332 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2337 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2339 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2340 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2342 if (!set_property_command(mpctx
, cmd
))
2348 mpctx
->osd_show_percentage
= sh_video
->fps
;
2349 v
= cmd
->args
[0].v
.f
;
2350 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2351 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2352 abs_seek_pos
= SEEK_ABSOLUTE
;
2354 mpctx
->osd_function
=
2355 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2357 } else if (abs
) { /* Absolute seek by percentage */
2358 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2360 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2361 rel_seek_secs
= v
/ 100.0;
2364 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2370 case MP_CMD_SET_PROPERTY
:{
2371 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2372 cmd
->args
[1].v
.s
, mpctx
);
2373 if (r
== M_PROPERTY_UNKNOWN
)
2374 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2375 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2377 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2378 "Failed to set property '%s' to '%s'.\n",
2379 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2383 case MP_CMD_STEP_PROPERTY
:{
2388 if (cmd
->args
[1].v
.f
) {
2390 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2391 M_PROPERTY_GET_TYPE
,
2392 &prop
, mpctx
)) <= 0)
2394 if(prop
->type
== CONF_TYPE_INT
||
2395 prop
->type
== CONF_TYPE_FLAG
)
2396 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2397 else if(prop
->type
== CONF_TYPE_FLOAT
)
2398 arg
= &cmd
->args
[1].v
.f
;
2399 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2400 prop
->type
== CONF_TYPE_TIME
)
2401 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2402 else if(prop
->type
== CONF_TYPE_POSITION
)
2403 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2405 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2406 "Ignoring step size stepping property '%s'.\n",
2409 r
= mp_property_do(cmd
->args
[0].v
.s
,
2410 cmd
->args
[2].v
.i
< 0 ?
2411 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2414 if (r
== M_PROPERTY_UNKNOWN
)
2415 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2416 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2418 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2419 "Failed to increment property '%s' by %f.\n",
2420 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2424 case MP_CMD_GET_PROPERTY
:{
2426 if (mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2427 &tmp
, mpctx
) <= 0) {
2428 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2429 "Failed to get value of property '%s'.\n",
2433 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2434 cmd
->args
[0].v
.s
, tmp
);
2439 case MP_CMD_EDL_MARK
:
2441 float v
= sh_video
? sh_video
->pts
:
2442 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2445 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2446 mpctx
->begin_skip
= v
;
2447 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2449 if (mpctx
->begin_skip
> v
)
2450 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2452 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2453 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2455 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2460 case MP_CMD_SWITCH_RATIO
:
2463 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2464 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2466 movie_aspect
= cmd
->args
[0].v
.f
;
2467 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2470 case MP_CMD_SPEED_INCR
:{
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_MULT
:{
2479 float v
= cmd
->args
[0].v
.f
;
2480 playback_speed
*= v
;
2481 build_afilter_chain(sh_audio
, &ao_data
);
2482 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2486 case MP_CMD_SPEED_SET
:{
2487 float v
= cmd
->args
[0].v
.f
;
2489 build_afilter_chain(sh_audio
, &ao_data
);
2490 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2494 case MP_CMD_FRAME_STEP
:
2500 case MP_CMD_FILE_FILTER
:
2501 file_filter
= cmd
->args
[0].v
.i
;
2505 exit_player_with_rc(EXIT_QUIT
,
2506 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2508 case MP_CMD_PLAY_TREE_STEP
:{
2509 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2510 int force
= cmd
->args
[1].v
.i
;
2516 for (i
= 0; i
< n
; i
++)
2519 for (i
= 0; i
< -1 * n
; i
++)
2524 if (!force
&& mpctx
->playtree_iter
) {
2525 play_tree_iter_t
*i
=
2526 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2527 if (play_tree_iter_step(i
, n
, 0) ==
2528 PLAY_TREE_ITER_ENTRY
)
2530 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2531 play_tree_iter_free(i
);
2533 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2535 mpctx
->play_tree_step
= n
;
2541 case MP_CMD_PLAY_TREE_UP_STEP
:{
2542 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2543 int force
= cmd
->args
[1].v
.i
;
2545 if (!force
&& mpctx
->playtree_iter
) {
2546 play_tree_iter_t
*i
=
2547 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2548 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2549 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2550 play_tree_iter_free(i
);
2552 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2557 case MP_CMD_PLAY_ALT_SRC_STEP
:
2558 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2559 int v
= cmd
->args
[0].v
.i
;
2561 && mpctx
->playtree_iter
->file
<
2562 mpctx
->playtree_iter
->num_files
)
2563 mpctx
->eof
= PT_NEXT_SRC
;
2564 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2565 mpctx
->eof
= PT_PREV_SRC
;
2570 case MP_CMD_SUB_STEP
:
2572 int movement
= cmd
->args
[0].v
.i
;
2573 step_sub(subdata
, sh_video
->pts
, movement
);
2577 ass_step_sub(ass_track
,
2579 sub_delay
) * 1000 + .5, movement
) / 1000.;
2581 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2582 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2586 case MP_CMD_SUB_LOG
:
2591 int v
= cmd
->args
[0].v
.i
;
2593 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2594 if (osd_level
> max
)
2597 osd_level
= (osd_level
+ 1) % (max
+ 1);
2599 osd_level
= v
> max
? max
: v
;
2600 /* Show OSD state when disabled, but not when an explicit
2601 argument is given to the OSD command, i.e. in slave mode. */
2602 if (v
== -1 && osd_level
<= 1)
2603 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2605 osd_level
? MSGTR_OSDenabled
:
2608 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2612 case MP_CMD_OSD_SHOW_TEXT
:
2613 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2615 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2616 "%-.63s", cmd
->args
[0].v
.s
);
2619 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2620 char *txt
= m_properties_expand_string(mp_properties
,
2623 /* if no argument supplied take default osd_duration, else <arg> ms. */
2625 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2627 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2634 case MP_CMD_LOADFILE
:{
2635 play_tree_t
*e
= play_tree_new();
2636 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2638 if (cmd
->args
[1].v
.i
) // append
2639 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2641 // Go back to the starting point.
2642 while (play_tree_iter_up_step
2643 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2645 play_tree_free_list(mpctx
->playtree
->child
, 1);
2646 play_tree_set_child(mpctx
->playtree
, e
);
2647 pt_iter_goto_head(mpctx
->playtree_iter
);
2648 mpctx
->eof
= PT_NEXT_SRC
;
2654 case MP_CMD_LOADLIST
:{
2655 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2657 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2658 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2660 if (cmd
->args
[1].v
.i
) // append
2661 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2663 // Go back to the starting point.
2664 while (play_tree_iter_up_step
2665 (mpctx
->playtree_iter
, 0, 1)
2666 != PLAY_TREE_ITER_END
)
2668 play_tree_free_list(mpctx
->playtree
->child
, 1);
2669 play_tree_set_child(mpctx
->playtree
, e
);
2670 pt_iter_goto_head(mpctx
->playtree_iter
);
2671 mpctx
->eof
= PT_NEXT_SRC
;
2679 // Go back to the starting point.
2680 while (play_tree_iter_up_step
2681 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2683 mpctx
->eof
= PT_STOP
;
2688 case MP_CMD_RADIO_STEP_CHANNEL
:
2689 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2690 int v
= cmd
->args
[0].v
.i
;
2692 radio_step_channel(mpctx
->demuxer
->stream
,
2693 RADIO_CHANNEL_HIGHER
);
2695 radio_step_channel(mpctx
->demuxer
->stream
,
2696 RADIO_CHANNEL_LOWER
);
2697 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2698 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2700 radio_get_channel_name(mpctx
->demuxer
->stream
));
2705 case MP_CMD_RADIO_SET_CHANNEL
:
2706 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2707 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2708 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2709 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2711 radio_get_channel_name(mpctx
->demuxer
->stream
));
2716 case MP_CMD_RADIO_SET_FREQ
:
2717 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2718 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2721 case MP_CMD_RADIO_STEP_FREQ
:
2722 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2723 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2728 case MP_CMD_TV_START_SCAN
:
2729 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2730 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2732 case MP_CMD_TV_SET_FREQ
:
2733 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2734 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2735 cmd
->args
[0].v
.f
* 16.0);
2737 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2738 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2739 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2740 pvr_get_current_channelname (mpctx
->stream
),
2741 pvr_get_current_stationname (mpctx
->stream
));
2743 #endif /* CONFIG_PVR */
2746 case MP_CMD_TV_STEP_FREQ
:
2747 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2748 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2749 cmd
->args
[0].v
.f
* 16.0);
2751 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2752 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2753 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2754 pvr_get_current_channelname (mpctx
->stream
),
2755 pvr_get_current_frequency (mpctx
->stream
));
2757 #endif /* CONFIG_PVR */
2760 case MP_CMD_TV_SET_NORM
:
2761 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2762 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2766 case MP_CMD_TV_STEP_CHANNEL
:{
2767 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2768 int v
= cmd
->args
[0].v
.i
;
2770 tv_step_channel((tvi_handle_t
*) (mpctx
->
2774 tv_step_channel((tvi_handle_t
*) (mpctx
->
2778 if (tv_channel_list
) {
2779 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2780 MSGTR_OSDChannel
, tv_channel_current
->name
);
2781 //vo_osd_changed(OSDTYPE_SUBTITLE);
2785 else if (mpctx
->stream
&&
2786 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2787 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2788 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2789 pvr_get_current_channelname (mpctx
->stream
),
2790 pvr_get_current_stationname (mpctx
->stream
));
2792 #endif /* CONFIG_PVR */
2795 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2797 int v
= cmd
->args
[0].v
.i
;
2799 mpctx
->last_dvb_step
= v
;
2801 dir
= DVB_CHANNEL_HIGHER
;
2803 dir
= DVB_CHANNEL_LOWER
;
2806 if (dvb_step_channel(mpctx
->stream
, dir
))
2807 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2809 #endif /* CONFIG_DVBIN */
2812 case MP_CMD_TV_SET_CHANNEL
:
2813 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2814 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2816 if (tv_channel_list
) {
2817 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2818 MSGTR_OSDChannel
, tv_channel_current
->name
);
2819 //vo_osd_changed(OSDTYPE_SUBTITLE);
2823 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2824 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2825 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2826 pvr_get_current_channelname (mpctx
->stream
),
2827 pvr_get_current_stationname (mpctx
->stream
));
2829 #endif /* CONFIG_PVR */
2833 case MP_CMD_DVB_SET_CHANNEL
:
2834 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2835 mpctx
->last_dvb_step
= 1;
2838 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2839 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2842 #endif /* CONFIG_DVBIN */
2844 case MP_CMD_TV_LAST_CHANNEL
:
2845 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2846 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2847 if (tv_channel_list
) {
2848 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2849 MSGTR_OSDChannel
, tv_channel_current
->name
);
2850 //vo_osd_changed(OSDTYPE_SUBTITLE);
2854 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2855 pvr_set_lastchannel (mpctx
->stream
);
2856 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2857 pvr_get_current_channelname (mpctx
->stream
),
2858 pvr_get_current_stationname (mpctx
->stream
));
2860 #endif /* CONFIG_PVR */
2863 case MP_CMD_TV_STEP_NORM
:
2864 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2865 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2868 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2869 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2870 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2872 #ifdef CONFIG_TV_TELETEXT
2873 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2875 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2876 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2877 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_ADD_DEC
,&(cmd
->args
[0].v
.s
));
2880 case MP_CMD_TV_TELETEXT_GO_LINK
:
2882 tvi_handle_t
* tvh
=(tvi_handle_t
*)(mpctx
->demuxer
->priv
);
2883 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2884 tvh
->functions
->control(tvh
->priv
,TV_VBI_CONTROL_GO_LINK
,&(cmd
->args
[0].v
.i
));
2887 #endif /* CONFIG_TV_TELETEXT */
2888 #endif /* CONFIG_TV */
2890 case MP_CMD_SUB_LOAD
:
2892 int n
= mpctx
->set_of_sub_size
;
2893 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2894 if (n
!= mpctx
->set_of_sub_size
) {
2895 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2896 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2897 mpctx
->global_sub_size
;
2898 ++mpctx
->global_sub_size
;
2903 case MP_CMD_SUB_REMOVE
:
2905 int v
= cmd
->args
[0].v
.i
;
2908 for (v
= 0; v
< mpctx
->set_of_sub_size
; ++v
) {
2909 subd
= mpctx
->set_of_subtitles
[v
];
2910 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2911 MSGTR_RemovedSubtitleFile
, v
+ 1,
2912 filename_recode(subd
->filename
));
2914 mpctx
->set_of_subtitles
[v
] = NULL
;
2916 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2917 mpctx
->global_sub_size
-= mpctx
->set_of_sub_size
;
2918 mpctx
->set_of_sub_size
= 0;
2919 if (mpctx
->set_of_sub_pos
>= 0) {
2920 mpctx
->global_sub_pos
= -2;
2922 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2924 } else if (v
< mpctx
->set_of_sub_size
) {
2925 subd
= mpctx
->set_of_subtitles
[v
];
2926 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2927 MSGTR_RemovedSubtitleFile
, v
+ 1,
2928 filename_recode(subd
->filename
));
2930 if (mpctx
->set_of_sub_pos
== v
) {
2931 mpctx
->global_sub_pos
= -2;
2933 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2934 } else if (mpctx
->set_of_sub_pos
> v
) {
2935 --mpctx
->set_of_sub_pos
;
2936 --mpctx
->global_sub_pos
;
2938 while (++v
< mpctx
->set_of_sub_size
)
2939 mpctx
->set_of_subtitles
[v
- 1] =
2940 mpctx
->set_of_subtitles
[v
];
2941 --mpctx
->set_of_sub_size
;
2942 --mpctx
->global_sub_size
;
2943 if (mpctx
->set_of_sub_size
<= 0)
2944 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2945 mpctx
->set_of_subtitles
[mpctx
->set_of_sub_size
] = NULL
;
2950 case MP_CMD_GET_SUB_VISIBILITY
:
2952 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2953 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2957 case MP_CMD_SCREENSHOT
:
2958 if (vo_config_count
) {
2959 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2961 ((vf_instance_t
*) sh_video
->vfilter
)->
2962 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2964 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2968 case MP_CMD_VF_CHANGE_RECTANGLE
:
2971 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2974 case MP_CMD_GET_TIME_LENGTH
:{
2975 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2976 demuxer_get_time_length(mpctx
->demuxer
));
2980 case MP_CMD_GET_FILENAME
:{
2981 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
2982 get_metadata(META_NAME
));
2986 case MP_CMD_GET_VIDEO_CODEC
:{
2987 char *inf
= get_metadata(META_VIDEO_CODEC
);
2990 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
2995 case MP_CMD_GET_VIDEO_BITRATE
:{
2996 char *inf
= get_metadata(META_VIDEO_BITRATE
);
2999 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3004 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3005 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
3008 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3009 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3014 case MP_CMD_GET_AUDIO_CODEC
:{
3015 char *inf
= get_metadata(META_AUDIO_CODEC
);
3018 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3023 case MP_CMD_GET_AUDIO_BITRATE
:{
3024 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3027 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3032 case MP_CMD_GET_AUDIO_SAMPLES
:{
3033 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3036 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3041 case MP_CMD_GET_META_TITLE
:{
3042 char *inf
= get_metadata(META_INFO_TITLE
);
3045 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3050 case MP_CMD_GET_META_ARTIST
:{
3051 char *inf
= get_metadata(META_INFO_ARTIST
);
3054 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3059 case MP_CMD_GET_META_ALBUM
:{
3060 char *inf
= get_metadata(META_INFO_ALBUM
);
3063 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3068 case MP_CMD_GET_META_YEAR
:{
3069 char *inf
= get_metadata(META_INFO_YEAR
);
3072 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3077 case MP_CMD_GET_META_COMMENT
:{
3078 char *inf
= get_metadata(META_INFO_COMMENT
);
3081 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3086 case MP_CMD_GET_META_TRACK
:{
3087 char *inf
= get_metadata(META_INFO_TRACK
);
3090 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3095 case MP_CMD_GET_META_GENRE
:{
3096 char *inf
= get_metadata(META_INFO_GENRE
);
3099 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3104 case MP_CMD_GET_VO_FULLSCREEN
:
3105 if (mpctx
->video_out
&& vo_config_count
)
3106 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3109 case MP_CMD_GET_PERCENT_POS
:
3110 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3111 demuxer_get_percent_pos(mpctx
->demuxer
));
3114 case MP_CMD_GET_TIME_POS
:{
3117 pos
= sh_video
->pts
;
3118 else if (sh_audio
&& mpctx
->audio_out
)
3120 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3122 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3129 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3135 case MP_CMD_KEYDOWN_EVENTS
:
3136 mplayer_put_key(cmd
->args
[0].v
.i
);
3139 case MP_CMD_SET_MOUSE_POS
:{
3140 int pointer_x
, pointer_y
;
3142 pointer_x
= cmd
->args
[0].v
.i
;
3143 pointer_y
= cmd
->args
[1].v
.i
;
3144 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3145 #ifdef CONFIG_DVDNAV
3146 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3147 && dx
> 0.0 && dy
> 0.0) {
3149 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3150 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3151 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3152 pointer_x
, pointer_y
, &button
);
3153 if (osd_level
> 1 && button
> 0)
3154 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3155 "Selected button number %d", button
);
3159 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3160 menu_update_mouse_pos(dx
, dy
);
3165 #ifdef CONFIG_DVDNAV
3166 case MP_CMD_DVDNAV
:{
3169 mp_command_type command
= 0;
3170 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3173 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3174 if (cmd
->args
[0].v
.s
&&
3175 !strcasecmp (cmd
->args
[0].v
.s
,
3176 mp_dvdnav_bindings
[i
].name
))
3177 command
= mp_dvdnav_bindings
[i
].cmd
;
3179 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3180 if (osd_level
> 1 && button
> 0)
3181 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3182 "Selected button number %d", button
);
3186 case MP_CMD_SWITCH_TITLE
:
3187 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3188 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3195 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3196 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3199 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3200 "Received unknown cmd %s\n", cmd
->name
);
3203 switch (cmd
->pausing
) {
3204 case 1: // "pausing"
3205 mpctx
->osd_function
= OSD_PAUSE
;
3207 case 3: // "pausing_toggle"
3208 mpctx
->was_paused
= !mpctx
->was_paused
;
3209 if (mpctx
->was_paused
)
3210 mpctx
->osd_function
= OSD_PAUSE
;
3211 else if (mpctx
->osd_function
== OSD_PAUSE
)
3212 mpctx
->osd_function
= OSD_PLAY
;
3214 case 2: // "pausing_keep"
3215 if (mpctx
->was_paused
)
3216 mpctx
->osd_function
= OSD_PAUSE
;