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_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
,
799 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->audio
)
800 return M_PROPERTY_UNAVAILABLE
;
801 current_id
= mpctx
->demuxer
->audio
->id
;
806 return M_PROPERTY_ERROR
;
807 *(int *) arg
= current_id
;
808 return M_PROPERTY_OK
;
809 case M_PROPERTY_PRINT
:
811 return M_PROPERTY_ERROR
;
814 *(char **) arg
= strdup(MSGTR_Disabled
);
816 char lang
[40] = MSGTR_Unknown
;
817 sh_audio_t
* sh
= mpctx
->sh_audio
;
819 av_strlcpy(lang
, sh
->lang
, 40);
820 #ifdef CONFIG_DVDREAD
821 else if (mpctx
->stream
->type
== STREAMTYPE_DVD
) {
822 int code
= dvd_lang_from_aid(mpctx
->stream
, current_id
);
832 else if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
833 mp_dvdnav_lang_from_aid(mpctx
->stream
, current_id
, lang
);
835 *(char **) arg
= malloc(64);
836 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
838 return M_PROPERTY_OK
;
840 case M_PROPERTY_STEP_UP
:
842 if (action
== M_PROPERTY_SET
&& arg
)
843 tmp
= *((int *) arg
);
846 audio_id
= demuxer_switch_audio(mpctx
->demuxer
, tmp
);
849 && mpctx
->demuxer
->audio
->id
!= current_id
&& current_id
!= -2))
850 uninit_player(INITIALIZED_AO
| INITIALIZED_ACODEC
);
851 if (audio_id
> -1 && mpctx
->demuxer
->audio
->id
!= current_id
) {
853 sh2
= mpctx
->demuxer
->a_streams
[mpctx
->demuxer
->audio
->id
];
855 sh2
->ds
= mpctx
->demuxer
->audio
;
856 mpctx
->sh_audio
= sh2
;
857 reinit_audio_chain();
860 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_TRACK=%d\n", audio_id
);
861 return M_PROPERTY_OK
;
863 return M_PROPERTY_NOT_IMPLEMENTED
;
868 /// Selected video id (RW)
869 static int mp_property_video(m_option_t
* prop
, int action
, void *arg
,
873 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->video
)
874 return M_PROPERTY_UNAVAILABLE
;
875 current_id
= mpctx
->demuxer
->video
->id
;
880 return M_PROPERTY_ERROR
;
881 *(int *) arg
= current_id
;
882 return M_PROPERTY_OK
;
883 case M_PROPERTY_PRINT
:
885 return M_PROPERTY_ERROR
;
888 *(char **) arg
= strdup(MSGTR_Disabled
);
890 char lang
[40] = MSGTR_Unknown
;
891 *(char **) arg
= malloc(64);
892 snprintf(*(char **) arg
, 64, "(%d) %s", current_id
, lang
);
894 return M_PROPERTY_OK
;
896 case M_PROPERTY_STEP_UP
:
898 if (action
== M_PROPERTY_SET
&& arg
)
899 tmp
= *((int *) arg
);
902 video_id
= demuxer_switch_video(mpctx
->demuxer
, tmp
);
904 || (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
905 && current_id
!= -2))
906 uninit_player(INITIALIZED_VCODEC
|
907 (fixed_vo
&& video_id
!= -2 ? 0 : INITIALIZED_VO
));
908 if (video_id
> -1 && mpctx
->demuxer
->video
->id
!= current_id
) {
910 sh2
= mpctx
->demuxer
->v_streams
[mpctx
->demuxer
->video
->id
];
912 sh2
->ds
= mpctx
->demuxer
->video
;
913 mpctx
->sh_video
= sh2
;
914 reinit_video_chain();
917 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_VIDEO_TRACK=%d\n", video_id
);
918 return M_PROPERTY_OK
;
921 return M_PROPERTY_NOT_IMPLEMENTED
;
925 static int mp_property_program(m_option_t
* prop
, int action
, void *arg
,
928 demux_program_t prog
;
931 case M_PROPERTY_STEP_UP
:
933 if (action
== M_PROPERTY_SET
&& arg
)
934 prog
.progid
= *((int *) arg
);
938 (mpctx
->demuxer
, DEMUXER_CTRL_IDENTIFY_PROGRAM
,
939 &prog
) == DEMUXER_CTRL_NOTIMPL
)
940 return M_PROPERTY_ERROR
;
942 if (prog
.aid
< 0 && prog
.vid
< 0) {
943 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, "Selected program contains no audio or video streams!\n");
944 return M_PROPERTY_ERROR
;
946 mp_property_do("switch_audio", M_PROPERTY_SET
, &prog
.aid
, mpctx
);
947 mp_property_do("switch_video", M_PROPERTY_SET
, &prog
.vid
, mpctx
);
948 return M_PROPERTY_OK
;
951 return M_PROPERTY_NOT_IMPLEMENTED
;
957 /// \defgroup VideoProperties Video properties
958 /// \ingroup Properties
961 /// Fullscreen state (RW)
962 static int mp_property_fullscreen(m_option_t
* prop
, int action
, void *arg
,
966 if (!mpctx
->video_out
)
967 return M_PROPERTY_UNAVAILABLE
;
972 return M_PROPERTY_ERROR
;
973 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
974 if (vo_fs
== !!*(int *) arg
)
975 return M_PROPERTY_OK
;
976 case M_PROPERTY_STEP_UP
:
977 case M_PROPERTY_STEP_DOWN
:
980 guiGetEvent(guiIEvent
, (char *) MP_CMD_GUI_FULLSCREEN
);
984 mpctx
->video_out
->control(VOCTRL_FULLSCREEN
, 0);
985 return M_PROPERTY_OK
;
987 return m_property_flag(prop
, action
, arg
, &vo_fs
);
991 static int mp_property_deinterlace(m_option_t
* prop
, int action
,
992 void *arg
, MPContext
* mpctx
)
996 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->vfilter
)
997 return M_PROPERTY_UNAVAILABLE
;
998 vf
= mpctx
->sh_video
->vfilter
;
1000 case M_PROPERTY_GET
:
1002 return M_PROPERTY_ERROR
;
1003 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, arg
);
1004 return M_PROPERTY_OK
;
1005 case M_PROPERTY_SET
:
1007 return M_PROPERTY_ERROR
;
1008 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1009 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, arg
);
1010 return M_PROPERTY_OK
;
1011 case M_PROPERTY_STEP_UP
:
1012 case M_PROPERTY_STEP_DOWN
:
1013 vf
->control(vf
, VFCTRL_GET_DEINTERLACE
, &deinterlace
);
1014 deinterlace
= !deinterlace
;
1015 vf
->control(vf
, VFCTRL_SET_DEINTERLACE
, &deinterlace
);
1016 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDDeinterlace
,
1017 deinterlace
? MSGTR_Enabled
: MSGTR_Disabled
);
1018 return M_PROPERTY_OK
;
1020 return M_PROPERTY_NOT_IMPLEMENTED
;
1024 static int mp_property_panscan(m_option_t
* prop
, int action
, void *arg
,
1028 if (!mpctx
->video_out
1029 || mpctx
->video_out
->control(VOCTRL_GET_PANSCAN
, NULL
) != VO_TRUE
)
1030 return M_PROPERTY_UNAVAILABLE
;
1033 case M_PROPERTY_SET
:
1035 return M_PROPERTY_ERROR
;
1036 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1037 vo_panscan
= *(float *) arg
;
1038 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1039 return M_PROPERTY_OK
;
1040 case M_PROPERTY_STEP_UP
:
1041 case M_PROPERTY_STEP_DOWN
:
1042 vo_panscan
+= (arg
? *(float *) arg
: 0.1) *
1043 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1046 else if (vo_panscan
< 0)
1048 mpctx
->video_out
->control(VOCTRL_SET_PANSCAN
, NULL
);
1049 return M_PROPERTY_OK
;
1051 return m_property_float_range(prop
, action
, arg
, &vo_panscan
);
1055 /// Helper to set vo flags.
1056 /** \ingroup PropertyImplHelper
1058 static int mp_property_vo_flag(m_option_t
* prop
, int action
, void *arg
,
1059 int vo_ctrl
, int *vo_var
, MPContext
* mpctx
)
1062 if (!mpctx
->video_out
)
1063 return M_PROPERTY_UNAVAILABLE
;
1066 case M_PROPERTY_SET
:
1068 return M_PROPERTY_ERROR
;
1069 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1070 if (*vo_var
== !!*(int *) arg
)
1071 return M_PROPERTY_OK
;
1072 case M_PROPERTY_STEP_UP
:
1073 case M_PROPERTY_STEP_DOWN
:
1074 if (vo_config_count
)
1075 mpctx
->video_out
->control(vo_ctrl
, 0);
1076 return M_PROPERTY_OK
;
1078 return m_property_flag(prop
, action
, arg
, vo_var
);
1082 /// Window always on top (RW)
1083 static int mp_property_ontop(m_option_t
* prop
, int action
, void *arg
,
1086 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ONTOP
, &vo_ontop
,
1090 /// Display in the root window (RW)
1091 static int mp_property_rootwin(m_option_t
* prop
, int action
, void *arg
,
1094 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_ROOTWIN
,
1095 &vo_rootwin
, mpctx
);
1098 /// Show window borders (RW)
1099 static int mp_property_border(m_option_t
* prop
, int action
, void *arg
,
1102 return mp_property_vo_flag(prop
, action
, arg
, VOCTRL_BORDER
,
1106 /// Framedropping state (RW)
1107 static int mp_property_framedropping(m_option_t
* prop
, int action
,
1108 void *arg
, MPContext
* mpctx
)
1111 if (!mpctx
->sh_video
)
1112 return M_PROPERTY_UNAVAILABLE
;
1115 case M_PROPERTY_PRINT
:
1117 return M_PROPERTY_ERROR
;
1118 *(char **) arg
= strdup(frame_dropping
== 1 ? MSGTR_Enabled
:
1119 (frame_dropping
== 2 ? MSGTR_HardFrameDrop
:
1121 return M_PROPERTY_OK
;
1123 return m_property_choice(prop
, action
, arg
, &frame_dropping
);
1127 /// Color settings, try to use vf/vo then fall back on TV. (RW)
1128 static int mp_property_gamma(m_option_t
* prop
, int action
, void *arg
,
1131 int *gamma
= prop
->priv
, r
, val
;
1133 if (!mpctx
->sh_video
)
1134 return M_PROPERTY_UNAVAILABLE
;
1136 if (gamma
[0] == 1000) {
1138 get_video_colors(mpctx
->sh_video
, prop
->name
, gamma
);
1142 case M_PROPERTY_SET
:
1144 return M_PROPERTY_ERROR
;
1145 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1146 *gamma
= *(int *) arg
;
1147 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1151 case M_PROPERTY_GET
:
1152 if (get_video_colors(mpctx
->sh_video
, prop
->name
, &val
) > 0) {
1154 return M_PROPERTY_ERROR
;
1156 return M_PROPERTY_OK
;
1159 case M_PROPERTY_STEP_UP
:
1160 case M_PROPERTY_STEP_DOWN
:
1161 *gamma
+= (arg
? *(int *) arg
: 1) *
1162 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1163 M_PROPERTY_CLAMP(prop
, *gamma
);
1164 r
= set_video_colors(mpctx
->sh_video
, prop
->name
, *gamma
);
1169 return M_PROPERTY_NOT_IMPLEMENTED
;
1173 if (mpctx
->demuxer
->type
== DEMUXER_TYPE_TV
) {
1174 int l
= strlen(prop
->name
);
1175 char tv_prop
[3 + l
+ 1];
1176 sprintf(tv_prop
, "tv_%s", prop
->name
);
1177 return mp_property_do(tv_prop
, action
, arg
, mpctx
);
1181 return M_PROPERTY_UNAVAILABLE
;
1185 static int mp_property_vsync(m_option_t
* prop
, int action
, void *arg
,
1188 return m_property_flag(prop
, action
, arg
, &vo_vsync
);
1191 /// Video codec tag (RO)
1192 static int mp_property_video_format(m_option_t
* prop
, int action
,
1193 void *arg
, MPContext
* mpctx
)
1196 if (!mpctx
->sh_video
)
1197 return M_PROPERTY_UNAVAILABLE
;
1199 case M_PROPERTY_PRINT
:
1201 return M_PROPERTY_ERROR
;
1202 switch(mpctx
->sh_video
->format
) {
1204 meta
= strdup ("mpeg1"); break;
1206 meta
= strdup ("mpeg2"); break;
1208 meta
= strdup ("mpeg4"); break;
1210 meta
= strdup ("h264"); break;
1212 if(mpctx
->sh_video
->format
>= 0x20202020) {
1214 sprintf (meta
, "%.4s", (char *) &mpctx
->sh_video
->format
);
1217 sprintf (meta
, "0x%08X", mpctx
->sh_video
->format
);
1220 *(char**)arg
= meta
;
1221 return M_PROPERTY_OK
;
1223 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->format
);
1226 /// Video codec name (RO)
1227 static int mp_property_video_codec(m_option_t
* prop
, int action
,
1228 void *arg
, MPContext
* mpctx
)
1230 if (!mpctx
->sh_video
|| !mpctx
->sh_video
->codec
)
1231 return M_PROPERTY_UNAVAILABLE
;
1232 return m_property_string_ro(prop
, action
, arg
, mpctx
->sh_video
->codec
->name
);
1236 /// Video bitrate (RO)
1237 static int mp_property_video_bitrate(m_option_t
* prop
, int action
,
1238 void *arg
, MPContext
* mpctx
)
1240 if (!mpctx
->sh_video
)
1241 return M_PROPERTY_UNAVAILABLE
;
1242 return m_property_bitrate(prop
, action
, arg
, mpctx
->sh_video
->i_bps
);
1245 /// Video display width (RO)
1246 static int mp_property_width(m_option_t
* prop
, int action
, void *arg
,
1249 if (!mpctx
->sh_video
)
1250 return M_PROPERTY_UNAVAILABLE
;
1251 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_w
);
1254 /// Video display height (RO)
1255 static int mp_property_height(m_option_t
* prop
, int action
, void *arg
,
1258 if (!mpctx
->sh_video
)
1259 return M_PROPERTY_UNAVAILABLE
;
1260 return m_property_int_ro(prop
, action
, arg
, mpctx
->sh_video
->disp_h
);
1264 static int mp_property_fps(m_option_t
* prop
, int action
, void *arg
,
1267 if (!mpctx
->sh_video
)
1268 return M_PROPERTY_UNAVAILABLE
;
1269 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->fps
);
1272 /// Video aspect (RO)
1273 static int mp_property_aspect(m_option_t
* prop
, int action
, void *arg
,
1276 if (!mpctx
->sh_video
)
1277 return M_PROPERTY_UNAVAILABLE
;
1278 return m_property_float_ro(prop
, action
, arg
, mpctx
->sh_video
->aspect
);
1283 /// \defgroup SubProprties Subtitles properties
1284 /// \ingroup Properties
1287 /// Text subtitle position (RW)
1288 static int mp_property_sub_pos(m_option_t
* prop
, int action
, void *arg
,
1292 case M_PROPERTY_SET
:
1294 return M_PROPERTY_ERROR
;
1295 case M_PROPERTY_STEP_UP
:
1296 case M_PROPERTY_STEP_DOWN
:
1297 vo_osd_changed(OSDTYPE_SUBTITLE
);
1299 return m_property_int_range(prop
, action
, arg
, &sub_pos
);
1303 /// Selected subtitles (RW)
1304 static int mp_property_sub(m_option_t
* prop
, int action
, void *arg
,
1307 demux_stream_t
*const d_sub
= mpctx
->d_sub
;
1308 const int global_sub_size
= mpctx
->global_sub_size
;
1309 int source
= -1, reset_spu
= 0;
1313 if (global_sub_size
<= 0)
1314 return M_PROPERTY_UNAVAILABLE
;
1317 case M_PROPERTY_GET
:
1319 return M_PROPERTY_ERROR
;
1320 *(int *) arg
= mpctx
->global_sub_pos
;
1321 return M_PROPERTY_OK
;
1322 case M_PROPERTY_PRINT
:
1324 return M_PROPERTY_ERROR
;
1325 *(char **) arg
= malloc(64);
1326 (*(char **) arg
)[63] = 0;
1329 sub_name
= subdata
->filename
;
1331 if (ass_track
&& ass_track
->name
)
1332 sub_name
= ass_track
->name
;
1337 if ((tmp2
= strrchr(tmp
, '/')))
1340 snprintf(*(char **) arg
, 63, "(%d) %s%s",
1341 mpctx
->set_of_sub_pos
+ 1,
1342 strlen(tmp
) < 20 ? "" : "...",
1343 strlen(tmp
) < 20 ? tmp
: tmp
+ strlen(tmp
) - 19);
1344 return M_PROPERTY_OK
;
1346 #ifdef CONFIG_DVDNAV
1347 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
) {
1348 if (vo_spudec
&& dvdsub_id
>= 0) {
1349 unsigned char lang
[3];
1350 if (mp_dvdnav_lang_from_sid(mpctx
->stream
, dvdsub_id
, lang
)) {
1351 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1352 return M_PROPERTY_OK
;
1358 if ((mpctx
->demuxer
->type
== DEMUXER_TYPE_MATROSKA
1359 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF
1360 || mpctx
->demuxer
->type
== DEMUXER_TYPE_LAVF_PREFERRED
1361 || mpctx
->demuxer
->type
== DEMUXER_TYPE_OGG
)
1362 && d_sub
&& d_sub
->sh
&& dvdsub_id
>= 0) {
1363 const char* lang
= ((sh_sub_t
*)d_sub
->sh
)->lang
;
1364 if (!lang
) lang
= MSGTR_Unknown
;
1365 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1366 return M_PROPERTY_OK
;
1369 if (vo_vobsub
&& vobsub_id
>= 0) {
1370 const char *language
= MSGTR_Unknown
;
1371 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
1372 snprintf(*(char **) arg
, 63, "(%d) %s",
1373 vobsub_id
, language
? language
: MSGTR_Unknown
);
1374 return M_PROPERTY_OK
;
1376 #ifdef CONFIG_DVDREAD
1377 if (vo_spudec
&& mpctx
->stream
->type
== STREAMTYPE_DVD
1378 && dvdsub_id
>= 0) {
1380 int code
= dvd_lang_from_sid(mpctx
->stream
, dvdsub_id
);
1381 lang
[0] = code
>> 8;
1384 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, lang
);
1385 return M_PROPERTY_OK
;
1388 if (dvdsub_id
>= 0) {
1389 snprintf(*(char **) arg
, 63, "(%d) %s", dvdsub_id
, MSGTR_Unknown
);
1390 return M_PROPERTY_OK
;
1392 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1393 return M_PROPERTY_OK
;
1395 case M_PROPERTY_SET
:
1397 return M_PROPERTY_ERROR
;
1398 if (*(int *) arg
< -1)
1400 else if (*(int *) arg
>= global_sub_size
)
1401 *(int *) arg
= global_sub_size
- 1;
1402 mpctx
->global_sub_pos
= *(int *) arg
;
1404 case M_PROPERTY_STEP_UP
:
1405 mpctx
->global_sub_pos
+= 2;
1406 mpctx
->global_sub_pos
=
1407 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1409 case M_PROPERTY_STEP_DOWN
:
1410 mpctx
->global_sub_pos
+= global_sub_size
+ 1;
1411 mpctx
->global_sub_pos
=
1412 (mpctx
->global_sub_pos
% (global_sub_size
+ 1)) - 1;
1415 return M_PROPERTY_NOT_IMPLEMENTED
;
1418 if (mpctx
->global_sub_pos
>= 0)
1419 source
= sub_source(mpctx
);
1421 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
,
1422 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
1424 mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
],
1425 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
],
1426 mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
],
1427 mpctx
->global_sub_pos
, source
);
1429 mpctx
->set_of_sub_pos
= -1;
1443 if (source
== SUB_SOURCE_VOBSUB
) {
1444 vobsub_id
= vobsub_get_id_by_index(vo_vobsub
, mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_VOBSUB
]);
1445 } else if (source
== SUB_SOURCE_SUBS
) {
1446 mpctx
->set_of_sub_pos
=
1447 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
];
1449 if (ass_enabled
&& mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
])
1450 ass_track
= mpctx
->set_of_ass_tracks
[mpctx
->set_of_sub_pos
];
1454 subdata
= mpctx
->set_of_subtitles
[mpctx
->set_of_sub_pos
];
1455 vo_osd_changed(OSDTYPE_SUBTITLE
);
1457 } else if (source
== SUB_SOURCE_DEMUX
) {
1459 mpctx
->global_sub_pos
- mpctx
->global_sub_indices
[SUB_SOURCE_DEMUX
];
1460 if (d_sub
&& dvdsub_id
< MAX_S_STREAMS
) {
1462 // default: assume 1:1 mapping of sid and stream id
1463 d_sub
->id
= dvdsub_id
;
1464 d_sub
->sh
= mpctx
->demuxer
->s_streams
[d_sub
->id
];
1465 ds_free_packs(d_sub
);
1466 for (i
= 0; i
< MAX_S_STREAMS
; i
++) {
1467 sh_sub_t
*sh
= mpctx
->demuxer
->s_streams
[i
];
1468 if (sh
&& sh
->sid
== dvdsub_id
) {
1474 if (d_sub
->sh
&& d_sub
->id
>= 0) {
1475 sh_sub_t
*sh
= d_sub
->sh
;
1476 if (sh
->type
== 'v')
1479 else if (ass_enabled
)
1480 ass_track
= sh
->ass_track
;
1488 #ifdef CONFIG_DVDREAD
1490 && (mpctx
->stream
->type
== STREAMTYPE_DVD
1491 || mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
1492 && dvdsub_id
< 0 && reset_spu
) {
1497 if (mpctx
->sh_audio
)
1498 pts
= mpctx
->sh_audio
->pts
;
1499 if (mpctx
->sh_video
)
1500 pts
= mpctx
->sh_video
->pts
;
1501 update_subtitles(mpctx
->sh_video
, pts
, d_sub
, 1);
1503 return M_PROPERTY_OK
;
1506 /// Selected sub source (RW)
1507 static int mp_property_sub_source(m_option_t
* prop
, int action
, void *arg
,
1511 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1512 return M_PROPERTY_UNAVAILABLE
;
1515 case M_PROPERTY_GET
:
1517 return M_PROPERTY_ERROR
;
1518 *(int *) arg
= sub_source(mpctx
);
1519 return M_PROPERTY_OK
;
1520 case M_PROPERTY_PRINT
:
1522 return M_PROPERTY_ERROR
;
1523 *(char **) arg
= malloc(64);
1524 (*(char **) arg
)[63] = 0;
1525 switch (sub_source(mpctx
))
1527 case SUB_SOURCE_SUBS
:
1528 snprintf(*(char **) arg
, 63, MSGTR_SubSourceFile
);
1530 case SUB_SOURCE_VOBSUB
:
1531 snprintf(*(char **) arg
, 63, MSGTR_SubSourceVobsub
);
1533 case SUB_SOURCE_DEMUX
:
1534 snprintf(*(char **) arg
, 63, MSGTR_SubSourceDemux
);
1537 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1539 return M_PROPERTY_OK
;
1540 case M_PROPERTY_SET
:
1542 return M_PROPERTY_ERROR
;
1543 M_PROPERTY_CLAMP(prop
, *(int*)arg
);
1544 if (*(int *) arg
< 0)
1545 mpctx
->global_sub_pos
= -1;
1546 else if (*(int *) arg
!= sub_source(mpctx
)) {
1547 if (*(int *) arg
!= sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[*(int *) arg
]))
1548 return M_PROPERTY_UNAVAILABLE
;
1549 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[*(int *) arg
];
1552 case M_PROPERTY_STEP_UP
:
1553 case M_PROPERTY_STEP_DOWN
: {
1554 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1555 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1556 int step
= (step_all
> 0) ? 1 : -1;
1557 int cur_source
= sub_source(mpctx
);
1558 source
= cur_source
;
1561 if (source
>= SUB_SOURCES
)
1563 else if (source
< -1)
1564 source
= SUB_SOURCES
- 1;
1565 if (source
== cur_source
|| source
== -1 ||
1566 source
== sub_source_by_pos(mpctx
, mpctx
->global_sub_indices
[source
]))
1569 if (source
== cur_source
)
1570 return M_PROPERTY_OK
;
1572 mpctx
->global_sub_pos
= -1;
1574 mpctx
->global_sub_pos
= mpctx
->global_sub_indices
[source
];
1578 return M_PROPERTY_NOT_IMPLEMENTED
;
1580 --mpctx
->global_sub_pos
;
1581 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1584 /// Selected subtitles from specific source (RW)
1585 static int mp_property_sub_by_type(m_option_t
* prop
, int action
, void *arg
,
1588 int source
, is_cur_source
, offset
;
1589 if (!mpctx
->sh_video
|| mpctx
->global_sub_size
<= 0)
1590 return M_PROPERTY_UNAVAILABLE
;
1592 if (!strcmp(prop
->name
, "sub_file"))
1593 source
= SUB_SOURCE_SUBS
;
1594 else if (!strcmp(prop
->name
, "sub_vob"))
1595 source
= SUB_SOURCE_VOBSUB
;
1596 else if (!strcmp(prop
->name
, "sub_demux"))
1597 source
= SUB_SOURCE_DEMUX
;
1599 return M_PROPERTY_ERROR
;
1601 offset
= mpctx
->global_sub_indices
[source
];
1602 if (offset
< 0 || source
!= sub_source_by_pos(mpctx
, offset
))
1603 return M_PROPERTY_UNAVAILABLE
;
1605 is_cur_source
= sub_source(mpctx
) == source
;
1607 case M_PROPERTY_GET
:
1609 return M_PROPERTY_ERROR
;
1610 if (is_cur_source
) {
1611 *(int *) arg
= mpctx
->global_sub_pos
- offset
;
1612 if (source
== SUB_SOURCE_VOBSUB
)
1613 *(int *) arg
= vobsub_get_id_by_index(vo_vobsub
, *(int *) arg
);
1617 return M_PROPERTY_OK
;
1618 case M_PROPERTY_PRINT
:
1620 return M_PROPERTY_ERROR
;
1622 return mp_property_sub(prop
, M_PROPERTY_PRINT
, arg
, mpctx
);
1623 *(char **) arg
= malloc(64);
1624 (*(char **) arg
)[63] = 0;
1625 snprintf(*(char **) arg
, 63, MSGTR_Disabled
);
1626 return M_PROPERTY_OK
;
1627 case M_PROPERTY_SET
:
1629 return M_PROPERTY_ERROR
;
1630 if (*(int *) arg
>= 0) {
1631 int index
= *(int *)arg
;
1632 if (source
== SUB_SOURCE_VOBSUB
)
1633 index
= vobsub_get_index_by_id(vo_vobsub
, index
);
1634 mpctx
->global_sub_pos
= offset
+ index
;
1635 if (index
< 0 || mpctx
->global_sub_pos
>= mpctx
->global_sub_size
1636 || sub_source(mpctx
) != source
) {
1637 mpctx
->global_sub_pos
= -1;
1642 mpctx
->global_sub_pos
= -1;
1644 case M_PROPERTY_STEP_UP
:
1645 case M_PROPERTY_STEP_DOWN
: {
1646 int step_all
= (arg
&& *(int*)arg
!= 0 ? *(int*)arg
: 1)
1647 * (action
== M_PROPERTY_STEP_UP
? 1 : -1);
1648 int step
= (step_all
> 0) ? 1 : -1;
1649 int max_sub_pos_for_source
= -1;
1651 mpctx
->global_sub_pos
= -1;
1653 if (mpctx
->global_sub_pos
== -1) {
1655 mpctx
->global_sub_pos
= offset
;
1656 else if (max_sub_pos_for_source
== -1) {
1657 // Find max pos for specific source
1658 mpctx
->global_sub_pos
= mpctx
->global_sub_size
- 1;
1659 while (mpctx
->global_sub_pos
>= 0
1660 && sub_source(mpctx
) != source
)
1661 --mpctx
->global_sub_pos
;
1664 mpctx
->global_sub_pos
= max_sub_pos_for_source
;
1667 mpctx
->global_sub_pos
+= step
;
1668 if (mpctx
->global_sub_pos
< offset
||
1669 mpctx
->global_sub_pos
>= mpctx
->global_sub_size
||
1670 sub_source(mpctx
) != source
)
1671 mpctx
->global_sub_pos
= -1;
1678 return M_PROPERTY_NOT_IMPLEMENTED
;
1680 --mpctx
->global_sub_pos
;
1681 return mp_property_sub(prop
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
1684 /// Subtitle delay (RW)
1685 static int mp_property_sub_delay(m_option_t
* prop
, int action
, void *arg
,
1688 if (!mpctx
->sh_video
)
1689 return M_PROPERTY_UNAVAILABLE
;
1690 return m_property_delay(prop
, action
, arg
, &sub_delay
);
1693 /// Alignment of text subtitles (RW)
1694 static int mp_property_sub_alignment(m_option_t
* prop
, int action
,
1695 void *arg
, MPContext
* mpctx
)
1697 char *name
[] = { MSGTR_Top
, MSGTR_Center
, MSGTR_Bottom
};
1699 if (!mpctx
->sh_video
|| mpctx
->global_sub_pos
< 0
1700 || sub_source(mpctx
) != SUB_SOURCE_SUBS
)
1701 return M_PROPERTY_UNAVAILABLE
;
1704 case M_PROPERTY_PRINT
:
1706 return M_PROPERTY_ERROR
;
1707 M_PROPERTY_CLAMP(prop
, sub_alignment
);
1708 *(char **) arg
= strdup(name
[sub_alignment
]);
1709 return M_PROPERTY_OK
;
1710 case M_PROPERTY_SET
:
1712 return M_PROPERTY_ERROR
;
1713 case M_PROPERTY_STEP_UP
:
1714 case M_PROPERTY_STEP_DOWN
:
1715 vo_osd_changed(OSDTYPE_SUBTITLE
);
1717 return m_property_choice(prop
, action
, arg
, &sub_alignment
);
1721 /// Subtitle visibility (RW)
1722 static int mp_property_sub_visibility(m_option_t
* prop
, int action
,
1723 void *arg
, MPContext
* mpctx
)
1725 if (!mpctx
->sh_video
)
1726 return M_PROPERTY_UNAVAILABLE
;
1729 case M_PROPERTY_SET
:
1731 return M_PROPERTY_ERROR
;
1732 case M_PROPERTY_STEP_UP
:
1733 case M_PROPERTY_STEP_DOWN
:
1734 vo_osd_changed(OSDTYPE_SUBTITLE
);
1736 vo_osd_changed(OSDTYPE_SPU
);
1738 return m_property_flag(prop
, action
, arg
, &sub_visibility
);
1743 /// Use margins for libass subtitles (RW)
1744 static int mp_property_ass_use_margins(m_option_t
* prop
, int action
,
1745 void *arg
, MPContext
* mpctx
)
1747 if (!mpctx
->sh_video
)
1748 return M_PROPERTY_UNAVAILABLE
;
1751 case M_PROPERTY_SET
:
1753 return M_PROPERTY_ERROR
;
1754 case M_PROPERTY_STEP_UP
:
1755 case M_PROPERTY_STEP_DOWN
:
1756 ass_force_reload
= 1;
1758 return m_property_flag(prop
, action
, arg
, &ass_use_margins
);
1763 /// Show only forced subtitles (RW)
1764 static int mp_property_sub_forced_only(m_option_t
* prop
, int action
,
1765 void *arg
, MPContext
* mpctx
)
1768 return M_PROPERTY_UNAVAILABLE
;
1771 case M_PROPERTY_SET
:
1773 return M_PROPERTY_ERROR
;
1774 case M_PROPERTY_STEP_UP
:
1775 case M_PROPERTY_STEP_DOWN
:
1776 m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1777 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
1778 return M_PROPERTY_OK
;
1780 return m_property_flag(prop
, action
, arg
, &forced_subs_only
);
1785 #ifdef CONFIG_FREETYPE
1786 /// Subtitle scale (RW)
1787 static int mp_property_sub_scale(m_option_t
* prop
, int action
, void *arg
,
1792 case M_PROPERTY_SET
:
1794 return M_PROPERTY_ERROR
;
1795 M_PROPERTY_CLAMP(prop
, *(float *) arg
);
1798 ass_font_scale
= *(float *) arg
;
1799 ass_force_reload
= 1;
1802 text_font_scale_factor
= *(float *) arg
;
1803 force_load_font
= 1;
1804 return M_PROPERTY_OK
;
1805 case M_PROPERTY_STEP_UP
:
1806 case M_PROPERTY_STEP_DOWN
:
1809 ass_font_scale
+= (arg
? *(float *) arg
: 0.1)*
1810 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1811 M_PROPERTY_CLAMP(prop
, ass_font_scale
);
1812 ass_force_reload
= 1;
1815 text_font_scale_factor
+= (arg
? *(float *) arg
: 0.1)*
1816 (action
== M_PROPERTY_STEP_UP
? 1.0 : -1.0);
1817 M_PROPERTY_CLAMP(prop
, text_font_scale_factor
);
1818 force_load_font
= 1;
1819 return M_PROPERTY_OK
;
1823 return m_property_float_ro(prop
, action
, arg
, ass_font_scale
);
1826 return m_property_float_ro(prop
, action
, arg
, text_font_scale_factor
);
1833 /// \defgroup TVProperties TV properties
1834 /// \ingroup Properties
1839 /// TV color settings (RW)
1840 static int mp_property_tv_color(m_option_t
* prop
, int action
, void *arg
,
1844 tvi_handle_t
*tvh
= mpctx
->demuxer
->priv
;
1845 if (mpctx
->demuxer
->type
!= DEMUXER_TYPE_TV
|| !tvh
)
1846 return M_PROPERTY_UNAVAILABLE
;
1849 case M_PROPERTY_SET
:
1851 return M_PROPERTY_ERROR
;
1852 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1853 return tv_set_color_options(tvh
, (int) prop
->priv
, *(int *) arg
);
1854 case M_PROPERTY_GET
:
1855 return tv_get_color_options(tvh
, (int) prop
->priv
, arg
);
1856 case M_PROPERTY_STEP_UP
:
1857 case M_PROPERTY_STEP_DOWN
:
1858 if ((r
= tv_get_color_options(tvh
, (int) prop
->priv
, &val
)) >= 0) {
1860 return M_PROPERTY_ERROR
;
1861 val
+= (arg
? *(int *) arg
: 1) *
1862 (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1863 M_PROPERTY_CLAMP(prop
, val
);
1864 return tv_set_color_options(tvh
, (int) prop
->priv
, val
);
1866 return M_PROPERTY_ERROR
;
1868 return M_PROPERTY_NOT_IMPLEMENTED
;
1873 static int mp_property_teletext_common(m_option_t
* prop
, int action
, void *arg
,
1877 int base_ioctl
=(int)prop
->priv
;
1879 for teletext's GET,SET,STEP ioctls this is not 0
1883 if (!mpctx
->demuxer
|| !mpctx
->demuxer
->teletext
)
1884 return M_PROPERTY_UNAVAILABLE
;
1886 return M_PROPERTY_ERROR
;
1889 case M_PROPERTY_GET
:
1891 return M_PROPERTY_ERROR
;
1892 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, arg
);
1894 case M_PROPERTY_SET
:
1896 return M_PROPERTY_ERROR
;
1897 M_PROPERTY_CLAMP(prop
, *(int *) arg
);
1898 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, arg
);
1900 case M_PROPERTY_STEP_UP
:
1901 case M_PROPERTY_STEP_DOWN
:
1902 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
, &val
);
1903 val
+= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1904 result
=teletext_control(mpctx
->demuxer
->teletext
, base_ioctl
+1, &val
);
1907 return M_PROPERTY_NOT_IMPLEMENTED
;
1910 return result
== VBI_CONTROL_TRUE
? M_PROPERTY_OK
: M_PROPERTY_ERROR
;
1913 static int mp_property_teletext_mode(m_option_t
* prop
, int action
, void *arg
,
1919 //with tvh==NULL will fail too
1920 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1921 if(result
!=M_PROPERTY_OK
)
1924 if(teletext_control(mpctx
->demuxer
->teletext
,
1925 (int)prop
->priv
, &val
)==VBI_CONTROL_TRUE
&& val
)
1926 mp_input_set_section("teletext");
1928 mp_input_set_section("tv");
1929 return M_PROPERTY_OK
;
1932 static int mp_property_teletext_page(m_option_t
* prop
, int action
, void *arg
,
1937 if (!mpctx
->demuxer
->teletext
)
1938 return M_PROPERTY_UNAVAILABLE
;
1940 case M_PROPERTY_STEP_UP
:
1941 case M_PROPERTY_STEP_DOWN
:
1942 //This should be handled separately
1943 val
= (arg
? *(int *) arg
: 1) * (action
== M_PROPERTY_STEP_DOWN
? -1 : 1);
1944 result
=teletext_control(mpctx
->demuxer
->teletext
,
1945 TV_VBI_CONTROL_STEP_PAGE
, &val
);
1948 result
=mp_property_teletext_common(prop
,action
,arg
,mpctx
);
1955 /// All properties available in MPlayer.
1956 /** \ingroup Properties
1958 static const m_option_t mp_properties
[] = {
1960 { "osdlevel", mp_property_osdlevel
, CONF_TYPE_INT
,
1961 M_OPT_RANGE
, 0, 3, NULL
},
1962 { "loop", mp_property_loop
, CONF_TYPE_INT
,
1963 M_OPT_MIN
, -1, 0, NULL
},
1964 { "speed", mp_property_playback_speed
, CONF_TYPE_FLOAT
,
1965 M_OPT_RANGE
, 0.01, 100.0, NULL
},
1966 { "filename", mp_property_filename
, CONF_TYPE_STRING
,
1968 { "path", mp_property_path
, CONF_TYPE_STRING
,
1970 { "demuxer", mp_property_demuxer
, CONF_TYPE_STRING
,
1972 { "stream_pos", mp_property_stream_pos
, CONF_TYPE_POSITION
,
1973 M_OPT_MIN
, 0, 0, NULL
},
1974 { "stream_start", mp_property_stream_start
, CONF_TYPE_POSITION
,
1975 M_OPT_MIN
, 0, 0, NULL
},
1976 { "stream_end", mp_property_stream_end
, CONF_TYPE_POSITION
,
1977 M_OPT_MIN
, 0, 0, NULL
},
1978 { "stream_length", mp_property_stream_length
, CONF_TYPE_POSITION
,
1979 M_OPT_MIN
, 0, 0, NULL
},
1980 { "length", mp_property_length
, CONF_TYPE_TIME
,
1981 M_OPT_MIN
, 0, 0, NULL
},
1982 { "percent_pos", mp_property_percent_pos
, CONF_TYPE_INT
,
1983 M_OPT_RANGE
, 0, 100, NULL
},
1984 { "time_pos", mp_property_time_pos
, CONF_TYPE_TIME
,
1985 M_OPT_MIN
, 0, 0, NULL
},
1986 { "chapter", mp_property_chapter
, CONF_TYPE_INT
,
1987 M_OPT_MIN
, 0, 0, NULL
},
1988 { "chapters", mp_property_chapters
, CONF_TYPE_INT
,
1990 { "angle", mp_property_angle
, CONF_TYPE_INT
,
1991 CONF_RANGE
, -2, 10, NULL
},
1992 { "metadata", mp_property_metadata
, CONF_TYPE_STRING_LIST
,
1994 { "pause", mp_property_pause
, CONF_TYPE_FLAG
,
1995 M_OPT_RANGE
, 0, 1, NULL
},
1998 { "volume", mp_property_volume
, CONF_TYPE_FLOAT
,
1999 M_OPT_RANGE
, 0, 100, NULL
},
2000 { "mute", mp_property_mute
, CONF_TYPE_FLAG
,
2001 M_OPT_RANGE
, 0, 1, NULL
},
2002 { "audio_delay", mp_property_audio_delay
, CONF_TYPE_FLOAT
,
2003 M_OPT_RANGE
, -100, 100, NULL
},
2004 { "audio_format", mp_property_audio_format
, CONF_TYPE_INT
,
2006 { "audio_codec", mp_property_audio_codec
, CONF_TYPE_STRING
,
2008 { "audio_bitrate", mp_property_audio_bitrate
, CONF_TYPE_INT
,
2010 { "samplerate", mp_property_samplerate
, CONF_TYPE_INT
,
2012 { "channels", mp_property_channels
, CONF_TYPE_INT
,
2014 { "switch_audio", mp_property_audio
, CONF_TYPE_INT
,
2015 CONF_RANGE
, -2, 65535, NULL
},
2016 { "balance", mp_property_balance
, CONF_TYPE_FLOAT
,
2017 M_OPT_RANGE
, -1, 1, NULL
},
2020 { "fullscreen", mp_property_fullscreen
, CONF_TYPE_FLAG
,
2021 M_OPT_RANGE
, 0, 1, NULL
},
2022 { "deinterlace", mp_property_deinterlace
, CONF_TYPE_FLAG
,
2023 M_OPT_RANGE
, 0, 1, NULL
},
2024 { "ontop", mp_property_ontop
, CONF_TYPE_FLAG
,
2025 M_OPT_RANGE
, 0, 1, NULL
},
2026 { "rootwin", mp_property_rootwin
, CONF_TYPE_FLAG
,
2027 M_OPT_RANGE
, 0, 1, NULL
},
2028 { "border", mp_property_border
, CONF_TYPE_FLAG
,
2029 M_OPT_RANGE
, 0, 1, NULL
},
2030 { "framedropping", mp_property_framedropping
, CONF_TYPE_INT
,
2031 M_OPT_RANGE
, 0, 2, NULL
},
2032 { "gamma", mp_property_gamma
, CONF_TYPE_INT
,
2033 M_OPT_RANGE
, -100, 100, &vo_gamma_gamma
},
2034 { "brightness", mp_property_gamma
, CONF_TYPE_INT
,
2035 M_OPT_RANGE
, -100, 100, &vo_gamma_brightness
},
2036 { "contrast", mp_property_gamma
, CONF_TYPE_INT
,
2037 M_OPT_RANGE
, -100, 100, &vo_gamma_contrast
},
2038 { "saturation", mp_property_gamma
, CONF_TYPE_INT
,
2039 M_OPT_RANGE
, -100, 100, &vo_gamma_saturation
},
2040 { "hue", mp_property_gamma
, CONF_TYPE_INT
,
2041 M_OPT_RANGE
, -100, 100, &vo_gamma_hue
},
2042 { "panscan", mp_property_panscan
, CONF_TYPE_FLOAT
,
2043 M_OPT_RANGE
, 0, 1, NULL
},
2044 { "vsync", mp_property_vsync
, CONF_TYPE_FLAG
,
2045 M_OPT_RANGE
, 0, 1, NULL
},
2046 { "video_format", mp_property_video_format
, CONF_TYPE_INT
,
2048 { "video_codec", mp_property_video_codec
, CONF_TYPE_STRING
,
2050 { "video_bitrate", mp_property_video_bitrate
, CONF_TYPE_INT
,
2052 { "width", mp_property_width
, CONF_TYPE_INT
,
2054 { "height", mp_property_height
, CONF_TYPE_INT
,
2056 { "fps", mp_property_fps
, CONF_TYPE_FLOAT
,
2058 { "aspect", mp_property_aspect
, CONF_TYPE_FLOAT
,
2060 { "switch_video", mp_property_video
, CONF_TYPE_INT
,
2061 CONF_RANGE
, -2, 65535, NULL
},
2062 { "switch_program", mp_property_program
, CONF_TYPE_INT
,
2063 CONF_RANGE
, -1, 65535, NULL
},
2066 { "sub", mp_property_sub
, CONF_TYPE_INT
,
2067 M_OPT_MIN
, -1, 0, NULL
},
2068 { "sub_source", mp_property_sub_source
, CONF_TYPE_INT
,
2069 M_OPT_RANGE
, -1, SUB_SOURCES
- 1, NULL
},
2070 { "sub_vob", mp_property_sub_by_type
, CONF_TYPE_INT
,
2071 M_OPT_MIN
, -1, 0, NULL
},
2072 { "sub_demux", mp_property_sub_by_type
, CONF_TYPE_INT
,
2073 M_OPT_MIN
, -1, 0, NULL
},
2074 { "sub_file", mp_property_sub_by_type
, CONF_TYPE_INT
,
2075 M_OPT_MIN
, -1, 0, NULL
},
2076 { "sub_delay", mp_property_sub_delay
, CONF_TYPE_FLOAT
,
2078 { "sub_pos", mp_property_sub_pos
, CONF_TYPE_INT
,
2079 M_OPT_RANGE
, 0, 100, NULL
},
2080 { "sub_alignment", mp_property_sub_alignment
, CONF_TYPE_INT
,
2081 M_OPT_RANGE
, 0, 2, NULL
},
2082 { "sub_visibility", mp_property_sub_visibility
, CONF_TYPE_FLAG
,
2083 M_OPT_RANGE
, 0, 1, NULL
},
2084 { "sub_forced_only", mp_property_sub_forced_only
, CONF_TYPE_FLAG
,
2085 M_OPT_RANGE
, 0, 1, NULL
},
2086 #ifdef CONFIG_FREETYPE
2087 { "sub_scale", mp_property_sub_scale
, CONF_TYPE_FLOAT
,
2088 M_OPT_RANGE
, 0, 100, NULL
},
2091 { "ass_use_margins", mp_property_ass_use_margins
, CONF_TYPE_FLAG
,
2092 M_OPT_RANGE
, 0, 1, NULL
},
2096 { "tv_brightness", mp_property_tv_color
, CONF_TYPE_INT
,
2097 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_BRIGHTNESS
},
2098 { "tv_contrast", mp_property_tv_color
, CONF_TYPE_INT
,
2099 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_CONTRAST
},
2100 { "tv_saturation", mp_property_tv_color
, CONF_TYPE_INT
,
2101 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_SATURATION
},
2102 { "tv_hue", mp_property_tv_color
, CONF_TYPE_INT
,
2103 M_OPT_RANGE
, -100, 100, (void *) TV_COLOR_HUE
},
2105 { "teletext_page", mp_property_teletext_page
, CONF_TYPE_INT
,
2106 M_OPT_RANGE
, 100, 899, (void*)TV_VBI_CONTROL_GET_PAGE
},
2107 { "teletext_subpage", mp_property_teletext_common
, CONF_TYPE_INT
,
2108 M_OPT_RANGE
, 0, 64, (void*)TV_VBI_CONTROL_GET_SUBPAGE
},
2109 { "teletext_mode", mp_property_teletext_mode
, CONF_TYPE_FLAG
,
2110 M_OPT_RANGE
, 0, 1, (void*)TV_VBI_CONTROL_GET_MODE
},
2111 { "teletext_format", mp_property_teletext_common
, CONF_TYPE_INT
,
2112 M_OPT_RANGE
, 0, 3, (void*)TV_VBI_CONTROL_GET_FORMAT
},
2113 { "teletext_half_page", mp_property_teletext_common
, CONF_TYPE_INT
,
2114 M_OPT_RANGE
, 0, 2, (void*)TV_VBI_CONTROL_GET_HALF_PAGE
},
2115 { NULL
, NULL
, NULL
, 0, 0, 0, NULL
}
2119 int mp_property_do(const char *name
, int action
, void *val
, void *ctx
)
2121 return m_property_do(mp_properties
, name
, action
, val
, ctx
);
2124 char* mp_property_print(const char *name
, void* ctx
)
2127 if(mp_property_do(name
,M_PROPERTY_PRINT
,&ret
,ctx
) <= 0)
2132 char *property_expand_string(MPContext
* mpctx
, char *str
)
2134 return m_properties_expand_string(mp_properties
, str
, mpctx
);
2137 void property_print_help(void)
2139 m_properties_print_help_list(mp_properties
);
2148 * \defgroup Command2Property Command to property bridge
2150 * It is used to handle most commands that just set a property
2151 * and optionally display something on the OSD.
2152 * Two kinds of commands are handled: adjust or toggle.
2154 * Adjust commands take 1 or 2 parameters: <value> <abs>
2155 * If <abs> is non-zero the property is set to the given value
2156 * otherwise it is adjusted.
2158 * Toggle commands take 0 or 1 parameters. With no parameter
2159 * or a value less than the property minimum it just steps the
2160 * property to its next value. Otherwise it sets it to the given
2166 /// List of the commands that can be handled by setting a property.
2172 /// set/adjust or toggle command
2174 /// progressbar type
2176 /// osd msg id if it must be shared
2178 /// osd msg template
2179 const char *osd_msg
;
2180 } set_prop_cmd
[] = {
2182 { "loop", MP_CMD_LOOP
, 0, 0, -1, MSGTR_LoopStatus
},
2183 { "chapter", MP_CMD_SEEK_CHAPTER
, 0, 0, -1, NULL
},
2184 { "angle", MP_CMD_SWITCH_ANGLE
, 0, 0, -1, NULL
},
2186 { "volume", MP_CMD_VOLUME
, 0, OSD_VOLUME
, -1, MSGTR_Volume
},
2187 { "mute", MP_CMD_MUTE
, 1, 0, -1, MSGTR_MuteStatus
},
2188 { "audio_delay", MP_CMD_AUDIO_DELAY
, 0, 0, -1, MSGTR_AVDelayStatus
},
2189 { "switch_audio", MP_CMD_SWITCH_AUDIO
, 1, 0, -1, MSGTR_OSDAudio
},
2190 { "balance", MP_CMD_BALANCE
, 0, OSD_BALANCE
, -1, MSGTR_Balance
},
2192 { "fullscreen", MP_CMD_VO_FULLSCREEN
, 1, 0, -1, NULL
},
2193 { "panscan", MP_CMD_PANSCAN
, 0, OSD_PANSCAN
, -1, MSGTR_Panscan
},
2194 { "ontop", MP_CMD_VO_ONTOP
, 1, 0, -1, MSGTR_OnTopStatus
},
2195 { "rootwin", MP_CMD_VO_ROOTWIN
, 1, 0, -1, MSGTR_RootwinStatus
},
2196 { "border", MP_CMD_VO_BORDER
, 1, 0, -1, MSGTR_BorderStatus
},
2197 { "framedropping", MP_CMD_FRAMEDROPPING
, 1, 0, -1, MSGTR_FramedroppingStatus
},
2198 { "gamma", MP_CMD_GAMMA
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Gamma
},
2199 { "brightness", MP_CMD_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2200 { "contrast", MP_CMD_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2201 { "saturation", MP_CMD_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2202 { "hue", MP_CMD_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2203 { "vsync", MP_CMD_SWITCH_VSYNC
, 1, 0, -1, MSGTR_VSyncStatus
},
2205 { "sub", MP_CMD_SUB_SELECT
, 1, 0, -1, MSGTR_SubSelectStatus
},
2206 { "sub_source", MP_CMD_SUB_SOURCE
, 1, 0, -1, MSGTR_SubSourceStatus
},
2207 { "sub_vob", MP_CMD_SUB_VOB
, 1, 0, -1, MSGTR_SubSelectStatus
},
2208 { "sub_demux", MP_CMD_SUB_DEMUX
, 1, 0, -1, MSGTR_SubSelectStatus
},
2209 { "sub_file", MP_CMD_SUB_FILE
, 1, 0, -1, MSGTR_SubSelectStatus
},
2210 { "sub_pos", MP_CMD_SUB_POS
, 0, 0, -1, MSGTR_SubPosStatus
},
2211 { "sub_alignment", MP_CMD_SUB_ALIGNMENT
, 1, 0, -1, MSGTR_SubAlignStatus
},
2212 { "sub_delay", MP_CMD_SUB_DELAY
, 0, 0, OSD_MSG_SUB_DELAY
, MSGTR_SubDelayStatus
},
2213 { "sub_visibility", MP_CMD_SUB_VISIBILITY
, 1, 0, -1, MSGTR_SubVisibleStatus
},
2214 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY
, 1, 0, -1, MSGTR_SubForcedOnlyStatus
},
2215 #ifdef CONFIG_FREETYPE
2216 { "sub_scale", MP_CMD_SUB_SCALE
, 0, 0, -1, MSGTR_SubScale
},
2219 { "ass_use_margins", MP_CMD_ASS_USE_MARGINS
, 1, 0, -1, NULL
},
2222 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS
, 0, OSD_BRIGHTNESS
, -1, MSGTR_Brightness
},
2223 { "tv_hue", MP_CMD_TV_SET_HUE
, 0, OSD_HUE
, -1, MSGTR_Hue
},
2224 { "tv_saturation", MP_CMD_TV_SET_SATURATION
, 0, OSD_SATURATION
, -1, MSGTR_Saturation
},
2225 { "tv_contrast", MP_CMD_TV_SET_CONTRAST
, 0, OSD_CONTRAST
, -1, MSGTR_Contrast
},
2227 { NULL
, 0, 0, 0, -1, NULL
}
2231 /// Handle commands that set a property.
2232 static int set_property_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2238 // look for the command
2239 for (i
= 0; set_prop_cmd
[i
].name
; i
++)
2240 if (set_prop_cmd
[i
].cmd
== cmd
->id
)
2242 if (!(pname
= set_prop_cmd
[i
].name
))
2245 if (mp_property_do(pname
,M_PROPERTY_GET_TYPE
,&prop
,mpctx
) <= 0 || !prop
)
2249 if (set_prop_cmd
[i
].toggle
) {
2251 if (cmd
->nargs
> 0 && cmd
->args
[0].v
.i
>= prop
->min
)
2252 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
.i
, mpctx
);
2254 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, NULL
, mpctx
);
2255 } else if (cmd
->args
[1].v
.i
) //set
2256 r
= mp_property_do(pname
, M_PROPERTY_SET
, &cmd
->args
[0].v
, mpctx
);
2258 r
= mp_property_do(pname
, M_PROPERTY_STEP_UP
, &cmd
->args
[0].v
, mpctx
);
2263 if (set_prop_cmd
[i
].osd_progbar
) {
2264 if (prop
->type
== CONF_TYPE_INT
) {
2265 if (mp_property_do(pname
, M_PROPERTY_GET
, &r
, mpctx
) > 0)
2266 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2267 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, r
);
2268 } else if (prop
->type
== CONF_TYPE_FLOAT
) {
2270 if (mp_property_do(pname
, M_PROPERTY_GET
, &f
, mpctx
) > 0)
2271 set_osd_bar(set_prop_cmd
[i
].osd_progbar
,
2272 set_prop_cmd
[i
].osd_msg
, prop
->min
, prop
->max
, f
);
2274 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2275 "Property use an unsupported type.\n");
2279 if (set_prop_cmd
[i
].osd_msg
) {
2280 char *val
= mp_property_print(pname
, mpctx
);
2282 set_osd_msg(set_prop_cmd
[i
].osd_id
>=
2283 0 ? set_prop_cmd
[i
].osd_id
: OSD_MSG_PROPERTY
+ i
,
2284 1, osd_duration
, set_prop_cmd
[i
].osd_msg
, val
);
2291 #ifdef CONFIG_DVDNAV
2292 static const struct {
2294 const mp_command_type cmd
;
2295 } mp_dvdnav_bindings
[] = {
2296 { "up", MP_CMD_DVDNAV_UP
},
2297 { "down", MP_CMD_DVDNAV_DOWN
},
2298 { "left", MP_CMD_DVDNAV_LEFT
},
2299 { "right", MP_CMD_DVDNAV_RIGHT
},
2300 { "menu", MP_CMD_DVDNAV_MENU
},
2301 { "select", MP_CMD_DVDNAV_SELECT
},
2302 { "prev", MP_CMD_DVDNAV_PREVMENU
},
2303 { "mouse", MP_CMD_DVDNAV_MOUSECLICK
},
2306 * keep old dvdnav sub-command options for a while in order not to
2307 * break slave-mode API too suddenly.
2309 { "1", MP_CMD_DVDNAV_UP
},
2310 { "2", MP_CMD_DVDNAV_DOWN
},
2311 { "3", MP_CMD_DVDNAV_LEFT
},
2312 { "4", MP_CMD_DVDNAV_RIGHT
},
2313 { "5", MP_CMD_DVDNAV_MENU
},
2314 { "6", MP_CMD_DVDNAV_SELECT
},
2315 { "7", MP_CMD_DVDNAV_PREVMENU
},
2316 { "8", MP_CMD_DVDNAV_MOUSECLICK
},
2321 static const char *property_error_string(int error_value
)
2323 switch (error_value
) {
2324 case M_PROPERTY_ERROR
:
2326 case M_PROPERTY_UNAVAILABLE
:
2327 return "PROPERTY_UNAVAILABLE";
2328 case M_PROPERTY_NOT_IMPLEMENTED
:
2329 return "NOT_IMPLEMENTED";
2330 case M_PROPERTY_UNKNOWN
:
2331 return "PROPERTY_UNKNOWN";
2332 case M_PROPERTY_DISABLED
:
2338 static void remove_subtitle_range(MPContext
*mpctx
, int start
, int count
)
2341 int end
= start
+ count
;
2342 int after
= mpctx
->set_of_sub_size
- end
;
2343 sub_data
**subs
= mpctx
->set_of_subtitles
;
2345 ass_track_t
**ass_tracks
= mpctx
->set_of_ass_tracks
;
2347 if (count
< 0 || count
> mpctx
->set_of_sub_size
||
2348 start
< 0 || start
> mpctx
->set_of_sub_size
- count
) {
2349 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2350 "Cannot remove invalid subtitle range %i +%i\n", start
, count
);
2353 for (idx
= start
; idx
< end
; idx
++) {
2354 sub_data
*subd
= subs
[idx
];
2355 mp_msg(MSGT_CPLAYER
, MSGL_STATUS
,
2356 MSGTR_RemovedSubtitleFile
, idx
+ 1,
2357 filename_recode(subd
->filename
));
2361 if (ass_tracks
[idx
])
2362 ass_free_track(ass_tracks
[idx
]);
2363 ass_tracks
[idx
] = NULL
;
2367 mpctx
->global_sub_size
-= count
;
2368 mpctx
->set_of_sub_size
-= count
;
2369 if (mpctx
->set_of_sub_size
<= 0)
2370 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] = -1;
2372 memmove(subs
+ start
, subs
+ end
, after
* sizeof(*subs
));
2373 memset(subs
+ start
+ after
, 0, count
* sizeof(*subs
));
2375 memmove(ass_tracks
+ start
, ass_tracks
+ end
, after
* sizeof(*ass_tracks
));
2376 memset(ass_tracks
+ start
+ after
, 0, count
* sizeof(*ass_tracks
));
2379 if (mpctx
->set_of_sub_pos
>= start
&& mpctx
->set_of_sub_pos
< end
) {
2380 mpctx
->global_sub_pos
= -2;
2385 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
2386 } else if (mpctx
->set_of_sub_pos
>= end
) {
2387 mpctx
->set_of_sub_pos
-= count
;
2388 mpctx
->global_sub_pos
-= count
;
2392 int run_command(MPContext
* mpctx
, mp_cmd_t
* cmd
)
2394 sh_audio_t
* const sh_audio
= mpctx
->sh_audio
;
2395 sh_video_t
* const sh_video
= mpctx
->sh_video
;
2397 if (!set_property_command(mpctx
, cmd
))
2403 mpctx
->osd_show_percentage
= sh_video
->fps
;
2404 v
= cmd
->args
[0].v
.f
;
2405 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2406 if (abs
== 2) { /* Absolute seek to a specific timestamp in seconds */
2407 abs_seek_pos
= SEEK_ABSOLUTE
;
2409 mpctx
->osd_function
=
2410 (v
> sh_video
->pts
) ? OSD_FFW
: OSD_REW
;
2412 } else if (abs
) { /* Absolute seek by percentage */
2413 abs_seek_pos
= SEEK_ABSOLUTE
| SEEK_FACTOR
;
2415 mpctx
->osd_function
= OSD_FFW
; // Direction isn't set correctly
2416 rel_seek_secs
= v
/ 100.0;
2419 mpctx
->osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2425 case MP_CMD_SET_PROPERTY
:{
2426 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_PARSE
,
2427 cmd
->args
[1].v
.s
, mpctx
);
2428 if (r
== M_PROPERTY_UNKNOWN
)
2429 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2430 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2432 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2433 "Failed to set property '%s' to '%s'.\n",
2434 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.s
);
2436 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2440 case MP_CMD_STEP_PROPERTY
:{
2445 if (cmd
->args
[1].v
.f
) {
2447 if((r
= mp_property_do(cmd
->args
[0].v
.s
,
2448 M_PROPERTY_GET_TYPE
,
2449 &prop
, mpctx
)) <= 0)
2451 if(prop
->type
== CONF_TYPE_INT
||
2452 prop
->type
== CONF_TYPE_FLAG
)
2453 i
= cmd
->args
[1].v
.f
, arg
= &i
;
2454 else if(prop
->type
== CONF_TYPE_FLOAT
)
2455 arg
= &cmd
->args
[1].v
.f
;
2456 else if(prop
->type
== CONF_TYPE_DOUBLE
||
2457 prop
->type
== CONF_TYPE_TIME
)
2458 d
= cmd
->args
[1].v
.f
, arg
= &d
;
2459 else if(prop
->type
== CONF_TYPE_POSITION
)
2460 o
= cmd
->args
[1].v
.f
, arg
= &o
;
2462 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2463 "Ignoring step size stepping property '%s'.\n",
2466 r
= mp_property_do(cmd
->args
[0].v
.s
,
2467 cmd
->args
[2].v
.i
< 0 ?
2468 M_PROPERTY_STEP_DOWN
: M_PROPERTY_STEP_UP
,
2471 if (r
== M_PROPERTY_UNKNOWN
)
2472 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2473 "Unknown property: '%s'\n", cmd
->args
[0].v
.s
);
2475 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2476 "Failed to increment property '%s' by %f.\n",
2477 cmd
->args
[0].v
.s
, cmd
->args
[1].v
.f
);
2479 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2483 case MP_CMD_GET_PROPERTY
:{
2485 int r
= mp_property_do(cmd
->args
[0].v
.s
, M_PROPERTY_TO_STRING
,
2488 mp_msg(MSGT_CPLAYER
, MSGL_WARN
,
2489 "Failed to get value of property '%s'.\n",
2491 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_ERROR=%s\n", property_error_string(r
));
2494 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_%s=%s\n",
2495 cmd
->args
[0].v
.s
, tmp
);
2500 case MP_CMD_EDL_MARK
:
2502 float v
= sh_video
? sh_video
->pts
:
2503 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
2506 if (mpctx
->begin_skip
== MP_NOPTS_VALUE
) {
2507 mpctx
->begin_skip
= v
;
2508 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutStartSkip
);
2510 if (mpctx
->begin_skip
> v
)
2511 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdloutBadStop
);
2513 fprintf(edl_fd
, "%f %f %d\n", mpctx
->begin_skip
, v
, 0);
2514 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdloutEndSkip
);
2516 mpctx
->begin_skip
= MP_NOPTS_VALUE
;
2521 case MP_CMD_SWITCH_RATIO
:
2524 if (cmd
->nargs
== 0 || cmd
->args
[0].v
.f
== -1)
2525 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2527 movie_aspect
= cmd
->args
[0].v
.f
;
2528 mpcodecs_config_vo(sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2531 case MP_CMD_SPEED_INCR
:{
2532 float v
= cmd
->args
[0].v
.f
;
2533 playback_speed
+= v
;
2534 build_afilter_chain(sh_audio
, &ao_data
);
2535 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2539 case MP_CMD_SPEED_MULT
:{
2540 float v
= cmd
->args
[0].v
.f
;
2541 playback_speed
*= v
;
2542 build_afilter_chain(sh_audio
, &ao_data
);
2543 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2547 case MP_CMD_SPEED_SET
:{
2548 float v
= cmd
->args
[0].v
.f
;
2550 build_afilter_chain(sh_audio
, &ao_data
);
2551 set_osd_msg(OSD_MSG_SPEED
, 1, osd_duration
, MSGTR_OSDSpeed
,
2555 case MP_CMD_FRAME_STEP
:
2561 case MP_CMD_FILE_FILTER
:
2562 file_filter
= cmd
->args
[0].v
.i
;
2566 exit_player_with_rc(EXIT_QUIT
,
2567 (cmd
->nargs
> 0) ? cmd
->args
[0].v
.i
: 0);
2569 case MP_CMD_PLAY_TREE_STEP
:{
2570 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2571 int force
= cmd
->args
[1].v
.i
;
2577 for (i
= 0; i
< n
; i
++)
2580 for (i
= 0; i
< -1 * n
; i
++)
2585 if (!force
&& mpctx
->playtree_iter
) {
2586 play_tree_iter_t
*i
=
2587 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2588 if (play_tree_iter_step(i
, n
, 0) ==
2589 PLAY_TREE_ITER_ENTRY
)
2591 (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2592 play_tree_iter_free(i
);
2594 mpctx
->eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2596 mpctx
->play_tree_step
= n
;
2602 case MP_CMD_PLAY_TREE_UP_STEP
:{
2603 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2604 int force
= cmd
->args
[1].v
.i
;
2606 if (!force
&& mpctx
->playtree_iter
) {
2607 play_tree_iter_t
*i
=
2608 play_tree_iter_new_copy(mpctx
->playtree_iter
);
2609 if (play_tree_iter_up_step(i
, n
, 0) == PLAY_TREE_ITER_ENTRY
)
2610 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2611 play_tree_iter_free(i
);
2613 mpctx
->eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2618 case MP_CMD_PLAY_ALT_SRC_STEP
:
2619 if (mpctx
->playtree_iter
&& mpctx
->playtree_iter
->num_files
> 1) {
2620 int v
= cmd
->args
[0].v
.i
;
2622 && mpctx
->playtree_iter
->file
<
2623 mpctx
->playtree_iter
->num_files
)
2624 mpctx
->eof
= PT_NEXT_SRC
;
2625 else if (v
< 0 && mpctx
->playtree_iter
->file
> 1)
2626 mpctx
->eof
= PT_PREV_SRC
;
2631 case MP_CMD_SUB_STEP
:
2633 int movement
= cmd
->args
[0].v
.i
;
2634 step_sub(subdata
, sh_video
->pts
, movement
);
2638 ass_step_sub(ass_track
,
2640 sub_delay
) * 1000 + .5, movement
) / 1000.;
2642 set_osd_msg(OSD_MSG_SUB_DELAY
, 1, osd_duration
,
2643 MSGTR_OSDSubDelay
, ROUND(sub_delay
* 1000));
2647 case MP_CMD_SUB_LOG
:
2652 int v
= cmd
->args
[0].v
.i
;
2654 && !sh_video
) ? MAX_TERM_OSD_LEVEL
: MAX_OSD_LEVEL
;
2655 if (osd_level
> max
)
2658 osd_level
= (osd_level
+ 1) % (max
+ 1);
2660 osd_level
= v
> max
? max
: v
;
2661 /* Show OSD state when disabled, but not when an explicit
2662 argument is given to the OSD command, i.e. in slave mode. */
2663 if (v
== -1 && osd_level
<= 1)
2664 set_osd_msg(OSD_MSG_OSD_STATUS
, 0, osd_duration
,
2666 osd_level
? MSGTR_OSDenabled
:
2669 rm_osd_msg(OSD_MSG_OSD_STATUS
);
2673 case MP_CMD_OSD_SHOW_TEXT
:
2674 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2676 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2677 "%-.63s", cmd
->args
[0].v
.s
);
2680 case MP_CMD_OSD_SHOW_PROPERTY_TEXT
:{
2681 char *txt
= m_properties_expand_string(mp_properties
,
2684 /* if no argument supplied take default osd_duration, else <arg> ms. */
2686 set_osd_msg(OSD_MSG_TEXT
, cmd
->args
[2].v
.i
,
2688 0 ? osd_duration
: cmd
->args
[1].v
.i
),
2695 case MP_CMD_LOADFILE
:{
2696 play_tree_t
*e
= play_tree_new();
2697 play_tree_add_file(e
, cmd
->args
[0].v
.s
);
2699 if (cmd
->args
[1].v
.i
) // append
2700 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2702 // Go back to the starting point.
2703 while (play_tree_iter_up_step
2704 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2706 play_tree_free_list(mpctx
->playtree
->child
, 1);
2707 play_tree_set_child(mpctx
->playtree
, e
);
2708 pt_iter_goto_head(mpctx
->playtree_iter
);
2709 mpctx
->eof
= PT_NEXT_SRC
;
2715 case MP_CMD_LOADLIST
:{
2716 play_tree_t
*e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2718 mp_msg(MSGT_CPLAYER
, MSGL_ERR
,
2719 MSGTR_PlaylistLoadUnable
, cmd
->args
[0].v
.s
);
2721 if (cmd
->args
[1].v
.i
) // append
2722 play_tree_append_entry(mpctx
->playtree
->child
, e
);
2724 // Go back to the starting point.
2725 while (play_tree_iter_up_step
2726 (mpctx
->playtree_iter
, 0, 1)
2727 != PLAY_TREE_ITER_END
)
2729 play_tree_free_list(mpctx
->playtree
->child
, 1);
2730 play_tree_set_child(mpctx
->playtree
, e
);
2731 pt_iter_goto_head(mpctx
->playtree_iter
);
2732 mpctx
->eof
= PT_NEXT_SRC
;
2740 // Go back to the starting point.
2741 while (play_tree_iter_up_step
2742 (mpctx
->playtree_iter
, 0, 1) != PLAY_TREE_ITER_END
)
2744 mpctx
->eof
= PT_STOP
;
2749 case MP_CMD_RADIO_STEP_CHANNEL
:
2750 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2751 int v
= cmd
->args
[0].v
.i
;
2753 radio_step_channel(mpctx
->demuxer
->stream
,
2754 RADIO_CHANNEL_HIGHER
);
2756 radio_step_channel(mpctx
->demuxer
->stream
,
2757 RADIO_CHANNEL_LOWER
);
2758 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2759 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2761 radio_get_channel_name(mpctx
->demuxer
->stream
));
2766 case MP_CMD_RADIO_SET_CHANNEL
:
2767 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
) {
2768 radio_set_channel(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.s
);
2769 if (radio_get_channel_name(mpctx
->demuxer
->stream
)) {
2770 set_osd_msg(OSD_MSG_RADIO_CHANNEL
, 1, osd_duration
,
2772 radio_get_channel_name(mpctx
->demuxer
->stream
));
2777 case MP_CMD_RADIO_SET_FREQ
:
2778 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2779 radio_set_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2782 case MP_CMD_RADIO_STEP_FREQ
:
2783 if (mpctx
->demuxer
->stream
->type
== STREAMTYPE_RADIO
)
2784 radio_step_freq(mpctx
->demuxer
->stream
, cmd
->args
[0].v
.f
);
2789 case MP_CMD_TV_START_SCAN
:
2790 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2791 tv_start_scan((tvi_handle_t
*) (mpctx
->demuxer
->priv
),1);
2793 case MP_CMD_TV_SET_FREQ
:
2794 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2795 tv_set_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2796 cmd
->args
[0].v
.f
* 16.0);
2798 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2799 pvr_set_freq (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2800 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2801 pvr_get_current_channelname (mpctx
->stream
),
2802 pvr_get_current_stationname (mpctx
->stream
));
2804 #endif /* CONFIG_PVR */
2807 case MP_CMD_TV_STEP_FREQ
:
2808 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2809 tv_step_freq((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2810 cmd
->args
[0].v
.f
* 16.0);
2812 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2813 pvr_force_freq_step (mpctx
->stream
, ROUND (cmd
->args
[0].v
.f
));
2814 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: f %d",
2815 pvr_get_current_channelname (mpctx
->stream
),
2816 pvr_get_current_frequency (mpctx
->stream
));
2818 #endif /* CONFIG_PVR */
2821 case MP_CMD_TV_SET_NORM
:
2822 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2823 tv_set_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2827 case MP_CMD_TV_STEP_CHANNEL
:{
2828 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2829 int v
= cmd
->args
[0].v
.i
;
2831 tv_step_channel((tvi_handle_t
*) (mpctx
->
2835 tv_step_channel((tvi_handle_t
*) (mpctx
->
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
&&
2847 mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2848 pvr_set_channel_step (mpctx
->stream
, cmd
->args
[0].v
.i
);
2849 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2850 pvr_get_current_channelname (mpctx
->stream
),
2851 pvr_get_current_stationname (mpctx
->stream
));
2853 #endif /* CONFIG_PVR */
2856 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2858 int v
= cmd
->args
[0].v
.i
;
2860 mpctx
->last_dvb_step
= v
;
2862 dir
= DVB_CHANNEL_HIGHER
;
2864 dir
= DVB_CHANNEL_LOWER
;
2867 if (dvb_step_channel(mpctx
->stream
, dir
))
2868 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2870 #endif /* CONFIG_DVBIN */
2873 case MP_CMD_TV_SET_CHANNEL
:
2874 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2875 tv_set_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
),
2877 if (tv_channel_list
) {
2878 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2879 MSGTR_OSDChannel
, tv_channel_current
->name
);
2880 //vo_osd_changed(OSDTYPE_SUBTITLE);
2884 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2885 pvr_set_channel (mpctx
->stream
, cmd
->args
[0].v
.s
);
2886 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2887 pvr_get_current_channelname (mpctx
->stream
),
2888 pvr_get_current_stationname (mpctx
->stream
));
2890 #endif /* CONFIG_PVR */
2894 case MP_CMD_DVB_SET_CHANNEL
:
2895 if (mpctx
->stream
->type
== STREAMTYPE_DVB
) {
2896 mpctx
->last_dvb_step
= 1;
2899 (mpctx
->stream
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
2900 mpctx
->eof
= mpctx
->dvbin_reopen
= 1;
2903 #endif /* CONFIG_DVBIN */
2905 case MP_CMD_TV_LAST_CHANNEL
:
2906 if (mpctx
->file_format
== DEMUXER_TYPE_TV
) {
2907 tv_last_channel((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2908 if (tv_channel_list
) {
2909 set_osd_msg(OSD_MSG_TV_CHANNEL
, 1, osd_duration
,
2910 MSGTR_OSDChannel
, tv_channel_current
->name
);
2911 //vo_osd_changed(OSDTYPE_SUBTITLE);
2915 else if (mpctx
->stream
&& mpctx
->stream
->type
== STREAMTYPE_PVR
) {
2916 pvr_set_lastchannel (mpctx
->stream
);
2917 set_osd_msg (OSD_MSG_TV_CHANNEL
, 1, osd_duration
, "%s: %s",
2918 pvr_get_current_channelname (mpctx
->stream
),
2919 pvr_get_current_stationname (mpctx
->stream
));
2921 #endif /* CONFIG_PVR */
2924 case MP_CMD_TV_STEP_NORM
:
2925 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2926 tv_step_norm((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2929 case MP_CMD_TV_STEP_CHANNEL_LIST
:
2930 if (mpctx
->file_format
== DEMUXER_TYPE_TV
)
2931 tv_step_chanlist((tvi_handle_t
*) (mpctx
->demuxer
->priv
));
2933 #endif /* CONFIG_TV */
2934 case MP_CMD_TV_TELETEXT_ADD_DEC
:
2936 if (mpctx
->demuxer
->teletext
)
2937 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_ADD_DEC
,
2938 &(cmd
->args
[0].v
.s
));
2941 case MP_CMD_TV_TELETEXT_GO_LINK
:
2943 if (mpctx
->demuxer
->teletext
)
2944 teletext_control(mpctx
->demuxer
->teletext
,TV_VBI_CONTROL_GO_LINK
,
2945 &(cmd
->args
[0].v
.i
));
2949 case MP_CMD_SUB_LOAD
:
2951 int n
= mpctx
->set_of_sub_size
;
2952 add_subtitles(cmd
->args
[0].v
.s
, sh_video
->fps
, 0);
2953 if (n
!= mpctx
->set_of_sub_size
) {
2954 if (mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] < 0)
2955 mpctx
->global_sub_indices
[SUB_SOURCE_SUBS
] =
2956 mpctx
->global_sub_size
;
2957 ++mpctx
->global_sub_size
;
2962 case MP_CMD_SUB_REMOVE
:
2964 int v
= cmd
->args
[0].v
.i
;
2966 remove_subtitle_range(mpctx
, 0, mpctx
->set_of_sub_size
);
2967 } else if (v
< mpctx
->set_of_sub_size
) {
2968 remove_subtitle_range(mpctx
, v
, 1);
2973 case MP_CMD_GET_SUB_VISIBILITY
:
2975 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
2976 "ANS_SUB_VISIBILITY=%d\n", sub_visibility
);
2980 case MP_CMD_SCREENSHOT
:
2981 if (vo_config_count
) {
2982 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "sending VFCTRL_SCREENSHOT!\n");
2984 ((vf_instance_t
*) sh_video
->vfilter
)->
2985 control(sh_video
->vfilter
, VFCTRL_SCREENSHOT
,
2987 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "failed (forgot -vf screenshot?)\n");
2991 case MP_CMD_VF_CHANGE_RECTANGLE
:
2994 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
2997 case MP_CMD_GET_TIME_LENGTH
:{
2998 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_LENGTH=%.2lf\n",
2999 demuxer_get_time_length(mpctx
->demuxer
));
3003 case MP_CMD_GET_FILENAME
:{
3004 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_FILENAME='%s'\n",
3005 get_metadata(META_NAME
));
3009 case MP_CMD_GET_VIDEO_CODEC
:{
3010 char *inf
= get_metadata(META_VIDEO_CODEC
);
3013 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_CODEC='%s'\n", inf
);
3018 case MP_CMD_GET_VIDEO_BITRATE
:{
3019 char *inf
= get_metadata(META_VIDEO_BITRATE
);
3022 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VIDEO_BITRATE='%s'\n", inf
);
3027 case MP_CMD_GET_VIDEO_RESOLUTION
:{
3028 char *inf
= get_metadata(META_VIDEO_RESOLUTION
);
3031 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,
3032 "ANS_VIDEO_RESOLUTION='%s'\n", inf
);
3037 case MP_CMD_GET_AUDIO_CODEC
:{
3038 char *inf
= get_metadata(META_AUDIO_CODEC
);
3041 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_CODEC='%s'\n", inf
);
3046 case MP_CMD_GET_AUDIO_BITRATE
:{
3047 char *inf
= get_metadata(META_AUDIO_BITRATE
);
3050 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_BITRATE='%s'\n", inf
);
3055 case MP_CMD_GET_AUDIO_SAMPLES
:{
3056 char *inf
= get_metadata(META_AUDIO_SAMPLES
);
3059 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_AUDIO_SAMPLES='%s'\n", inf
);
3064 case MP_CMD_GET_META_TITLE
:{
3065 char *inf
= get_metadata(META_INFO_TITLE
);
3068 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TITLE='%s'\n", inf
);
3073 case MP_CMD_GET_META_ARTIST
:{
3074 char *inf
= get_metadata(META_INFO_ARTIST
);
3077 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ARTIST='%s'\n", inf
);
3082 case MP_CMD_GET_META_ALBUM
:{
3083 char *inf
= get_metadata(META_INFO_ALBUM
);
3086 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_ALBUM='%s'\n", inf
);
3091 case MP_CMD_GET_META_YEAR
:{
3092 char *inf
= get_metadata(META_INFO_YEAR
);
3095 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_YEAR='%s'\n", inf
);
3100 case MP_CMD_GET_META_COMMENT
:{
3101 char *inf
= get_metadata(META_INFO_COMMENT
);
3104 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_COMMENT='%s'\n", inf
);
3109 case MP_CMD_GET_META_TRACK
:{
3110 char *inf
= get_metadata(META_INFO_TRACK
);
3113 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_TRACK='%s'\n", inf
);
3118 case MP_CMD_GET_META_GENRE
:{
3119 char *inf
= get_metadata(META_INFO_GENRE
);
3122 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_META_GENRE='%s'\n", inf
);
3127 case MP_CMD_GET_VO_FULLSCREEN
:
3128 if (mpctx
->video_out
&& vo_config_count
)
3129 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_VO_FULLSCREEN=%d\n", vo_fs
);
3132 case MP_CMD_GET_PERCENT_POS
:
3133 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_PERCENT_POSITION=%d\n",
3134 demuxer_get_percent_pos(mpctx
->demuxer
));
3137 case MP_CMD_GET_TIME_POS
:{
3140 pos
= sh_video
->pts
;
3141 else if (sh_audio
&& mpctx
->audio_out
)
3143 playing_audio_pts(sh_audio
, mpctx
->d_audio
,
3145 mp_msg(MSGT_GLOBAL
, MSGL_INFO
, "ANS_TIME_POSITION=%.1f\n", pos
);
3152 execl("/bin/sh", "sh", "-c", cmd
->args
[0].v
.s
, NULL
);
3158 case MP_CMD_KEYDOWN_EVENTS
:
3159 mplayer_put_key(cmd
->args
[0].v
.i
);
3162 case MP_CMD_SET_MOUSE_POS
:{
3163 int pointer_x
, pointer_y
;
3165 pointer_x
= cmd
->args
[0].v
.i
;
3166 pointer_y
= cmd
->args
[1].v
.i
;
3167 rescale_input_coordinates(pointer_x
, pointer_y
, &dx
, &dy
);
3168 #ifdef CONFIG_DVDNAV
3169 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
3170 && dx
> 0.0 && dy
> 0.0) {
3172 pointer_x
= (int) (dx
* (double) sh_video
->disp_w
);
3173 pointer_y
= (int) (dy
* (double) sh_video
->disp_h
);
3174 mp_dvdnav_update_mouse_pos(mpctx
->stream
,
3175 pointer_x
, pointer_y
, &button
);
3176 if (osd_level
> 1 && button
> 0)
3177 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3178 "Selected button number %d", button
);
3182 if (use_menu
&& dx
>= 0.0 && dy
>= 0.0)
3183 menu_update_mouse_pos(dx
, dy
);
3188 #ifdef CONFIG_DVDNAV
3189 case MP_CMD_DVDNAV
:{
3192 mp_command_type command
= 0;
3193 if (mpctx
->stream
->type
!= STREAMTYPE_DVDNAV
)
3196 for (i
= 0; mp_dvdnav_bindings
[i
].name
; i
++)
3197 if (cmd
->args
[0].v
.s
&&
3198 !strcasecmp (cmd
->args
[0].v
.s
,
3199 mp_dvdnav_bindings
[i
].name
))
3200 command
= mp_dvdnav_bindings
[i
].cmd
;
3202 mp_dvdnav_handle_input(mpctx
->stream
,command
,&button
);
3203 if (osd_level
> 1 && button
> 0)
3204 set_osd_msg(OSD_MSG_TEXT
, 1, osd_duration
,
3205 "Selected button number %d", button
);
3209 case MP_CMD_SWITCH_TITLE
:
3210 if (mpctx
->stream
->type
== STREAMTYPE_DVDNAV
)
3211 mp_dvdnav_switch_title(mpctx
->stream
, cmd
->args
[0].v
.i
);
3218 if ((use_gui
) && (cmd
->id
> MP_CMD_GUI_EVENTS
))
3219 guiGetEvent(guiIEvent
, (char *) cmd
->id
);
3222 mp_msg(MSGT_CPLAYER
, MSGL_V
,
3223 "Received unknown cmd %s\n", cmd
->name
);
3226 switch (cmd
->pausing
) {
3227 case 1: // "pausing"
3228 mpctx
->osd_function
= OSD_PAUSE
;
3230 case 3: // "pausing_toggle"
3231 mpctx
->was_paused
= !mpctx
->was_paused
;
3232 if (mpctx
->was_paused
)
3233 mpctx
->osd_function
= OSD_PAUSE
;
3234 else if (mpctx
->osd_function
== OSD_PAUSE
)
3235 mpctx
->osd_function
= OSD_PLAY
;
3237 case 2: // "pausing_keep"
3238 if (mpctx
->was_paused
)
3239 mpctx
->osd_function
= OSD_PAUSE
;