annotate command.c.tmp @ 22478:3501ae650b23

Add alternative way to create command.c to svn history, created by Rathann. Having this in the repository history probably won't have much more than symbolic value but shouldn't hurt either beyond bloating history size.
author uau
date Fri, 09 Mar 2007 12:30:14 +0000
parents
children a99ddf2ece25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22478
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1 #include <inttypes.h>
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2 #include <stdlib.h>
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
3 #include "config.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
4
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
5 #include <unistd.h>
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
6
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
7 #include "help_mp.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
8
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
9 #include "m_option.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
10 #include "m_property.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
11
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
12 #include "libvo/video_out.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
13
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
14 #include "libvo/sub.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
15
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
16 #include "libao2/audio_out.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
17
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
18 #include "spudec.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
19 #include "vobsub.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
20
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
21 #ifdef HAVE_NEW_GUI
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
22 #include "Gui/interface.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
23 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
24
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
25 #include "input/input.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
26
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
27 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
28
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
29 #ifdef USE_TV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
30 #include "stream/tv.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
31 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
32 #ifdef USE_RADIO
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
33 #include "stream/stream_radio.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
34 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
35
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
36 #ifdef HAS_DVBIN_SUPPORT
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
37 #include "stream/dvbin.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
38 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
39 #include "playtree.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
40
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
41 #include "stream/stream.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
42 #include "libmpdemux/demuxer.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
43 #include "libmpdemux/stheader.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
44 #include "libmpdemux/matroska.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
45
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
46 #ifdef USE_DVDREAD
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
47 #include "stream/stream_dvd.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
48 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
49
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
50 #ifdef USE_DVDNAV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
51 #include "stream/stream_dvdnav.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
52 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
53
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
54 #include "libmpcodecs/dec_video.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
55 #include "libmpcodecs/mp_image.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
56 #include "libmpcodecs/vf.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
57 #include "libmpcodecs/vd.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
58 #ifdef USE_ASS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
59 #include "libass/ass.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
60 #include "libass/ass_mp.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
61 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
62 #include "mpcommon.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
63 #include "metadata.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
64 #include "mixer.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
65
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
66 #include "mplayer.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
67
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
68 #include "mp_core.h"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
69
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
70 static int sub_source(MPContext * mpctx)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
71 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
72 int source = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
73 int top = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
74 int i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
75 for (i = 0; i < SUB_SOURCES; i++) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
76 int j = mpctx->global_sub_indices[i];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
77 if ((j >= 0) && (j > top) && (mpctx->global_sub_pos >= j)) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
78 source = i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
79 top = j;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
80 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
81 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
82 return source;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
83 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
84
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
85 /**
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
86 * \brief Log the currently displayed subtitle to a file
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
87 *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
88 * Logs the current or last displayed subtitle together with filename
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
89 * and time information to ~/.mplayer/subtitle_log
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
90 *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
91 * Intended purpose is to allow convenient marking of bogus subtitles
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
92 * which need to be fixed while watching the movie.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
93 */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
94
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
95 static void log_sub(void){
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
96 char *fname;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
97 FILE *f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
98 int i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
99
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
100 if (subdata == NULL || vo_sub_last == NULL) return;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
101 fname = get_path("subtitle_log");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
102 f = fopen(fname, "a");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
103 if (!f) return;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
104 fprintf(f, "----------------------------------------------------------\n");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
105 if (subdata->sub_uses_time) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
106 fprintf(f, "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", filename,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
107 vo_sub_last->start/360000, (vo_sub_last->start/6000)%60,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
108 (vo_sub_last->start/100)%60, vo_sub_last->start%100,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
109 vo_sub_last->end/360000, (vo_sub_last->end/6000)%60,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
110 (vo_sub_last->end/100)%60, vo_sub_last->end%100);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
111 } else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
112 fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start, vo_sub_last->end);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
113 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
114 for (i = 0; i < vo_sub_last->lines; i++) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
115 fprintf(f, "%s\n", vo_sub_last->text[i]);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
116 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
117 fclose(f);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
118 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
119
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
120
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
121 /// \defgroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
122 ///@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
123
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
124 /// \defgroup GeneralProperties General properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
125 /// \ingroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
126 ///@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
127
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
128 /// OSD level (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
129 static int mp_property_osdlevel(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
130 return m_property_choice(prop,action,arg,&osd_level);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
131 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
132
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
133 /// Playback speed (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
134 static int mp_property_playback_speed(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
135 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
136 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
137 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
138 M_PROPERTY_CLAMP(prop,*(float*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
139 playback_speed = *(float*)arg;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
140 build_afilter_chain(mpctx->sh_audio, &ao_data);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
141 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
142 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
143 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
144 playback_speed += (arg ? *(float*)arg : 0.1) *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
145 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
146 M_PROPERTY_CLAMP(prop,playback_speed);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
147 build_afilter_chain(mpctx->sh_audio, &ao_data);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
148 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
149 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
150 return m_property_float_range(prop,action,arg,&playback_speed);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
151 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
152
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
153 /// filename with path (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
154 static int mp_property_path(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
155 return m_property_string_ro(prop,action,arg,filename);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
156 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
157
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
158 /// filename without path (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
159 static int mp_property_filename(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
160 char* f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
161 if(!filename) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
162 if(((f = strrchr(filename,'/')) || (f = strrchr(filename,'\\'))) && f[1])
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
163 f++;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
164 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
165 f = filename;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
166 return m_property_string_ro(prop,action,arg,f);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
167 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
168
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
169 /// Demuxer name (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
170 static int mp_property_demuxer(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
171 if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
172 return m_property_string_ro(prop, action, arg, (char *) mpctx->demuxer->desc->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
173 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
174
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
175 /// Position in the stream (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
176 static int mp_property_stream_pos(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
177 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
178 if (!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
179 switch (action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
180 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
181 *(off_t *) arg = stream_tell(mpctx->demuxer->stream);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
182 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
183 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
184 M_PROPERTY_CLAMP(prop,*(off_t*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
185 stream_seek(mpctx->demuxer->stream, *(off_t *) arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
186 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
187 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
188 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
189 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
190
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
191 /// Stream start offset (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
192 static int mp_property_stream_start(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
193 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
194 switch (action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
195 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
196 *(off_t *) arg = mpctx->demuxer->stream->start_pos;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
197 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
198 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
199 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
200 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
201
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
202 /// Stream end offset (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
203 static int mp_property_stream_end(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
204 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
205 switch (action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
206 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
207 *(off_t *) arg = mpctx->demuxer->stream->end_pos;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
208 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
209 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
210 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
211 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
212
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
213 /// Stream length (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
214 static int mp_property_stream_length(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
215 if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
216 switch (action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
217 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
218 *(off_t *) arg = mpctx->demuxer->stream->end_pos - mpctx->demuxer->stream->start_pos;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
219 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
220 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
221 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
222 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
223
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
224 /// Media length in seconds (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
225 static int mp_property_length(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
226 double len;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
227
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
228 if (!mpctx->demuxer ||
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
229 !(int) (len = demuxer_get_time_length(mpctx->demuxer)))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
230 return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
231
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
232 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
233 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
234 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
235 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
236 int h, m, s = len;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
237 h = s/3600;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
238 s -= h*3600;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
239 m = s/60;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
240 s -= m*60;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
241 *(char**)arg = malloc(20);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
242 if(h > 0) sprintf(*(char**)arg,"%d:%02d:%02d",h,m,s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
243 else if(m > 0) sprintf(*(char**)arg,"%d:%02d",m,s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
244 else sprintf(*(char**)arg,"%d",s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
245 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
246 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
247 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
248 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
249 return m_property_double_ro(prop,action,arg,len);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
250 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
251
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
252 ///@}
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
253
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
254 /// \defgroup AudioProperties Audio properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
255 /// \ingroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
256 ///@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
257
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
258 /// Volume (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
259 static int mp_property_volume(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
260
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
261 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
262
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
263 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
264 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
265 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
266 mixer_getbothvolume(&mpctx->mixer, arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
267 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
268 case M_PROPERTY_PRINT:{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
269 float vol;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
270 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
271 mixer_getbothvolume(&mpctx->mixer, &vol);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
272 return m_property_float_range(prop,action,arg,&vol);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
273 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
274 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
275 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
276 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
277 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
278 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
279 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
280 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
281
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
282 if (mpctx->edl_muted) return M_PROPERTY_DISABLED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
283 mpctx->user_muted = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
284
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
285 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
286 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
287 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
288 M_PROPERTY_CLAMP(prop,*(float*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
289 mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
290 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
291 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
292 if(arg && *(float*)arg <= 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
293 mixer_decvolume(&mpctx->mixer);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
294 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
295 mixer_incvolume(&mpctx->mixer);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
296 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
297 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
298 if(arg && *(float*)arg <= 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
299 mixer_incvolume(&mpctx->mixer);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
300 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
301 mixer_decvolume(&mpctx->mixer);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
302 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
303 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
304 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
305 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
306
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
307 /// Mute (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
308 static int mp_property_mute(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
309
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
310 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
311
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
312 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
313 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
314 if (mpctx->edl_muted) return M_PROPERTY_DISABLED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
315 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
316 if ((!!*(int *) arg) != mpctx->mixer.muted)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
317 mixer_mute(&mpctx->mixer);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
318 mpctx->user_muted = mpctx->mixer.muted;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
319 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
320 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
321 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
322 if (mpctx->edl_muted) return M_PROPERTY_DISABLED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
323 mixer_mute(&mpctx->mixer);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
324 mpctx->user_muted = mpctx->mixer.muted;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
325 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
326 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
327 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
328 if (mpctx->edl_muted) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
329 *(char**)arg = strdup(MSGTR_EnabledEdl);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
330 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
331 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
332 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
333 return m_property_flag(prop, action, arg, &mpctx->mixer.muted);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
334
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
335 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
336 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
337
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
338 /// Audio delay (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
339 static int mp_property_audio_delay(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
340 if (!(mpctx->sh_audio && mpctx->sh_video)) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
341 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
342 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
343 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
344 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
345 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
346 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
347 float delay = audio_delay;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
348 m_property_delay(prop,action,arg,&audio_delay);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
349 if (mpctx->sh_audio) mpctx->sh_audio->delay -= audio_delay - delay;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
350 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
351 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
352 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
353 return m_property_delay(prop,action,arg,&audio_delay);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
354 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
355 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
356
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
357 /// Audio codec tag (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
358 static int mp_property_audio_format(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
359 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
360 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
361 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
362
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
363 /// Audio bitrate (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
364 static int mp_property_audio_bitrate(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
365 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
366 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->i_bps);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
367 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
368
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
369 /// Samplerate (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
370 static int mp_property_samplerate(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
371 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
372 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->samplerate);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
373 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
374
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
375 /// Number of channels (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
376 static int mp_property_channels(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
377 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
378 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
379 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
380 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
381 switch (mpctx->sh_audio->channels) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
382 case 1: *(char**)arg = strdup("mono"); break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
383 case 2: *(char**)arg = strdup("stereo"); break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
384 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
385 *(char**)arg = malloc(32);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
386 sprintf(*(char **) arg, "%d channels", mpctx->sh_audio->channels);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
387 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
388 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
389 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
390 return m_property_int_ro(prop, action, arg, mpctx->sh_audio->channels);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
391 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
392
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
393 /// Selected audio id (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
394 static int mp_property_audio(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
395 int current_id = -1, tmp;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
396
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
397 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
398 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
399 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
400 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
401 *(int*)arg = audio_id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
402 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
403 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
404 if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
405 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
406
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
407 if (audio_id < 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
408 *(char**)arg = strdup(MSGTR_Disabled);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
409 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
410 char lang[40] = MSGTR_Unknown;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
411 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
412 demux_mkv_get_audio_lang(mpctx->demuxer, audio_id, lang, 9);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
413 #ifdef USE_DVDREAD
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
414 else if (mpctx->stream->type == STREAMTYPE_DVD) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
415 int code = dvd_lang_from_aid(mpctx->stream, audio_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
416 if (code) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
417 lang[0] = code >> 8;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
418 lang[1] = code;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
419 lang[2] = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
420 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
421 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
422 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
423
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
424 #ifdef USE_DVDNAV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
425 else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
426 dvdnav_lang_from_aid(mpctx->stream, audio_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
427 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
428 *(char**)arg = malloc(64);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
429 snprintf(*(char**)arg, 64, "(%d) %s", audio_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
430 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
431 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
432
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
433 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
434 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
435 if(action==M_PROPERTY_SET && arg)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
436 tmp = *((int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
437 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
438 tmp = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
439 current_id = mpctx->demuxer->audio->id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
440 audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
441 if (audio_id == -2 || (audio_id > -1 && mpctx->demuxer->audio->id != current_id && current_id != -2))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
442 uninit_player(INITED_AO | INITED_ACODEC);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
443 if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
444 sh_audio_t *sh2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
445 sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
446 if(sh2) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
447 sh2->ds = mpctx->demuxer->audio;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
448 mpctx->sh_audio = sh2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
449 reinit_audio_chain();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
450 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
451 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
452 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
453 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
454 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
455 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
456 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
457
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
458 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
459
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
460 /// Selected video id (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
461 static int mp_property_video(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
462 int current_id = -1, tmp;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
463
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
464 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
465 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
466 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
467 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
468 *(int*)arg = video_id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
469 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
470 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
471 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
472 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
473
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
474 if (video_id < 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
475 *(char**)arg = strdup(MSGTR_Disabled);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
476 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
477 char lang[40] = MSGTR_Unknown;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
478 *(char**)arg = malloc(64);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
479 snprintf(*(char**)arg, 64, "(%d) %s", video_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
480 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
481 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
482
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
483 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
484 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
485 current_id = mpctx->demuxer->video->id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
486 if(action==M_PROPERTY_SET && arg)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
487 tmp = *((int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
488 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
489 tmp = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
490 video_id = demuxer_switch_video(mpctx->demuxer, tmp);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
491 if (video_id == -2 || (video_id > -1 && mpctx->demuxer->video->id != current_id && current_id != -2))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
492 uninit_player(INITED_VCODEC | (fixed_vo && video_id != -2 ? 0 : INITED_VO));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
493 if (video_id > -1 && mpctx->demuxer->video->id != current_id) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
494 sh_video_t *sh2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
495 sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
496 if(sh2) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
497 sh2->ds = mpctx->demuxer->video;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
498 mpctx->sh_video = sh2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
499 reinit_video_chain();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
500 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
501 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
502 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
503 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
504
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
505 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
506 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
507 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
508 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
509
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
510 static int mp_property_program(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
511 demux_program_t prog;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
512
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
513 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
514 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
515 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
516 if(action==M_PROPERTY_SET && arg)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
517 prog.progid = *((int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
518 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
519 prog.progid = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
520 if (demux_control(mpctx->demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) == DEMUXER_CTRL_NOTIMPL)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
521 return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
522
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
523 mp_property_do("switch_audio", M_PROPERTY_SET, &prog.aid, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
524 mp_property_do("switch_video", M_PROPERTY_SET, &prog.vid, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
525 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
526
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
527 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
528 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
529 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
530 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
531
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
532 ///@}
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
533
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
534 /// \defgroup VideoProperties Video properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
535 /// \ingroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
536 ///@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
537
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
538 /// Fullscreen state (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
539 static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
540
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
541 if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
542
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
543 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
544 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
545 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
546 M_PROPERTY_CLAMP(prop,*(int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
547 if(vo_fs == !!*(int*)arg) return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
548 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
549 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
550 #ifdef HAVE_NEW_GUI
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
551 if(use_gui) guiGetEvent(guiIEvent,(char*)MP_CMD_GUI_FULLSCREEN);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
552 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
553 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
554 if (vo_config_count) mpctx->video_out->control(VOCTRL_FULLSCREEN, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
555 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
556 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
557 return m_property_flag(prop,action,arg,&vo_fs);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
558 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
559 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
560
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
561 static int mp_property_deinterlace(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
562 int deinterlace;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
563 vf_instance_t *vf;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
564 if (!mpctx->sh_video || !mpctx->sh_video->vfilter) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
565 vf = mpctx->sh_video->vfilter;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
566 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
567 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
568 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
569 vf->control(vf, VFCTRL_GET_DEINTERLACE, arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
570 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
571 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
572 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
573 M_PROPERTY_CLAMP(prop,*(int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
574 vf->control(vf, VFCTRL_SET_DEINTERLACE, arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
575 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
576 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
577 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
578 vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
579 deinterlace = !deinterlace;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
580 vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
581 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
582 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
583 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
584 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
585
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
586 /// Panscan (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
587 static int mp_property_panscan(m_option_t * prop, int action, void *arg, MPContext * mpctx)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
588 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
589
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
590 if (!mpctx->video_out || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
591 return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
592
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
593 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
594 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
595 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
596 M_PROPERTY_CLAMP(prop,*(float*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
597 vo_panscan = *(float*)arg;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
598 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
599 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
600 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
601 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
602 vo_panscan += (arg ? *(float*)arg : 0.1) *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
603 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
604 if(vo_panscan > 1) vo_panscan = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
605 else if(vo_panscan < 0) vo_panscan = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
606 mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
607 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
608 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
609 return m_property_float_range(prop,action,arg,&vo_panscan);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
610 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
611 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
612
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
613 /// Helper to set vo flags.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
614 /** \ingroup PropertyImplHelper
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
615 */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
616 static int mp_property_vo_flag(m_option_t* prop,int action,void* arg,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
617 int vo_ctrl, int *vo_var, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
618
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
619 if (!mpctx->video_out) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
620
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
621 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
622 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
623 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
624 M_PROPERTY_CLAMP(prop,*(int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
625 if(*vo_var == !!*(int*)arg) return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
626 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
627 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
628 if (vo_config_count) mpctx->video_out->control(vo_ctrl, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
629 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
630 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
631 return m_property_flag(prop,action,arg,vo_var);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
632 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
633 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
634
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
635 /// Window always on top (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
636 static int mp_property_ontop(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
637 return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
638 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
639
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
640 /// Display in the root window (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
641 static int mp_property_rootwin(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
642 return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN, &vo_rootwin, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
643 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
644
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
645 /// Show window borders (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
646 static int mp_property_border(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
647 return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, &vo_border, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
648 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
649
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
650 /// Framedropping state (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
651 static int mp_property_framedropping(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
652
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
653 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
654
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
655 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
656 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
657 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
658 *(char**)arg = strdup(frame_dropping == 1 ? MSGTR_Enabled :
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
659 (frame_dropping == 2 ? MSGTR_HardFrameDrop : MSGTR_Disabled));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
660 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
661 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
662 return m_property_choice(prop,action,arg,&frame_dropping);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
663 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
664 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
665
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
666 /// Color settings, try to use vf/vo then fall back on TV. (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
667 static int mp_property_gamma(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
668 int* gamma = prop->priv, r;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
669
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
670 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
671
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
672 if(gamma[0] == 1000) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
673 gamma[0] = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
674 get_video_colors(mpctx->sh_video, prop->name, gamma);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
675 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
676
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
677 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
678 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
679 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
680 M_PROPERTY_CLAMP(prop,*(int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
681 *gamma = *(int*)arg;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
682 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
683 if(r <= 0) break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
684 return r;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
685 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
686 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
687 r = get_video_colors(mpctx->sh_video, prop->name, arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
688 if(r <= 0) break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
689 return r;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
690 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
691 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
692 *gamma += (arg ? *(int*)arg : 1) *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
693 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
694 M_PROPERTY_CLAMP(prop,*gamma);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
695 r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
696 if(r <= 0) break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
697 return r;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
698 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
699 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
700 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
701
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
702 #ifdef USE_TV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
703 if (mpctx->demuxer->type == DEMUXER_TYPE_TV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
704 int l = strlen(prop->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
705 char tv_prop[3+l+1];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
706 sprintf(tv_prop,"tv_%s",prop->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
707 return mp_property_do(tv_prop, action, arg, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
708 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
709 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
710
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
711 return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
712 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
713
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
714 /// VSync (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
715 static int mp_property_vsync(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
716 return m_property_flag(prop,action,arg,&vo_vsync);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
717 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
718
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
719 /// Video codec tag (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
720 static int mp_property_video_format(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
721 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
722 return m_property_int_ro(prop, action, arg, mpctx->sh_video->format);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
723 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
724
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
725 /// Video bitrate (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
726 static int mp_property_video_bitrate(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
727 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
728 return m_property_int_ro(prop, action, arg, mpctx->sh_video->i_bps);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
729 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
730
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
731 /// Video display width (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
732 static int mp_property_width(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
733 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
734 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
735 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
736
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
737 /// Video display height (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
738 static int mp_property_height(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
739 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
740 return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
741 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
742
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
743 /// Video fps (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
744 static int mp_property_fps(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
745 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
746 return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
747 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
748
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
749 /// Video aspect (RO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
750 static int mp_property_aspect(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
751 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
752 return m_property_float_ro(prop, action, arg, mpctx->sh_video->aspect);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
753 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
754
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
755 ///@}
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
756
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
757 /// \defgroup SubProprties Subtitles properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
758 /// \ingroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
759 ///@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
760
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
761 /// Text subtitle position (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
762 static int mp_property_sub_pos(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
763 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
764
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
765 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
766 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
767 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
768 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
769 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
770 vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
771 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
772 return m_property_int_range(prop,action,arg,&sub_pos);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
773 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
774 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
775
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
776 /// Selected subtitles (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
777 static int mp_property_sub(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
778 demux_stream_t *const d_sub = mpctx->d_sub;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
779 const int global_sub_size = mpctx->global_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
780 int source = -1, reset_spu = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
781 char* sub_name;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
782
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
783 if(global_sub_size <= 0) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
784
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
785 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
786 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
787 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
788 *(int *) arg = mpctx->global_sub_pos;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
789 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
790 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
791 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
792 *(char**)arg = malloc(64);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
793 (*(char**)arg)[63] = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
794 sub_name = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
795 if(subdata)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
796 sub_name = subdata->filename;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
797 #ifdef USE_ASS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
798 if (ass_track && ass_track->name)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
799 sub_name = ass_track->name;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
800 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
801 if(sub_name) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
802 char *tmp,*tmp2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
803 tmp = sub_name;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
804 if ((tmp2 = strrchr(tmp, '/')))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
805 tmp = tmp2+1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
806
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
807 snprintf(*(char**)arg, 63, "(%d) %s%s",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
808 mpctx->set_of_sub_pos + 1,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
809 strlen(tmp) < 20 ? "" : "...",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
810 strlen(tmp) < 20 ? tmp : tmp+strlen(tmp)-19);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
811 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
812 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
813 #ifdef USE_DVDNAV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
814 if (mpctx->stream->type == STREAMTYPE_DVDNAV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
815 if(vo_spudec && dvdsub_id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
816 unsigned char lang[3];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
817 if (dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
818 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
819 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
820 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
821 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
822 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
823 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
824
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
825 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA && dvdsub_id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
826 char lang[40] = MSGTR_Unknown;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
827 demux_mkv_get_sub_lang(mpctx->demuxer, dvdsub_id, lang, 9);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
828 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
829 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
830 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
831 #ifdef HAVE_OGGVORBIS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
832 if (mpctx->demuxer->type == DEMUXER_TYPE_OGG && d_sub && dvdsub_id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
833 char *lang = demux_ogg_sub_lang(mpctx->demuxer, dvdsub_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
834 if (!lang) lang = MSGTR_Unknown;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
835 snprintf(*(char**)arg, 63, "(%d) %s",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
836 dvdsub_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
837 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
838 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
839 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
840 if (vo_vobsub && vobsub_id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
841 const char *language = MSGTR_Unknown;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
842 language = vobsub_get_id(vo_vobsub, (unsigned int) vobsub_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
843 snprintf(*(char**)arg, 63, "(%d) %s",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
844 vobsub_id, language ? language : MSGTR_Unknown);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
845 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
846 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
847 #ifdef USE_DVDREAD
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
848 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD && dvdsub_id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
849 char lang[3];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
850 int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
851 lang[0] = code >> 8;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
852 lang[1] = code;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
853 lang[2] = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
854 snprintf(*(char**)arg, 63, "(%d) %s",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
855 dvdsub_id, lang);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
856 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
857 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
858 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
859 if (dvdsub_id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
860 snprintf(*(char**)arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
861 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
862 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
863 snprintf(*(char**)arg, 63, MSGTR_Disabled);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
864 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
865
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
866 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
867 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
868 if(*(int*)arg < -1) *(int*)arg = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
869 else if(*(int*)arg >= global_sub_size) *(int*)arg = global_sub_size-1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
870 mpctx->global_sub_pos = *(int *) arg;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
871 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
872 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
873 mpctx->global_sub_pos += 2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
874 mpctx->global_sub_pos = (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
875 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
876 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
877 mpctx->global_sub_pos += global_sub_size + 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
878 mpctx->global_sub_pos = (mpctx->global_sub_pos % (global_sub_size + 1)) - 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
879 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
880 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
881 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
882 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
883
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
884 if (mpctx->global_sub_pos >= 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
885 source = sub_source(mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
886
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
887 mp_msg(MSGT_CPLAYER, MSGL_DBG3,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
888 "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
889 global_sub_size,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
890 mpctx->global_sub_indices[SUB_SOURCE_VOBSUB],
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
891 mpctx->global_sub_indices[SUB_SOURCE_SUBS],
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
892 mpctx->global_sub_indices[SUB_SOURCE_DEMUX],
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
893 mpctx->global_sub_pos, source);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
894
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
895 mpctx->set_of_sub_pos = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
896 subdata = NULL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
897 vo_sub_last = vo_sub = NULL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
898
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
899 vobsub_id = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
900 dvdsub_id = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
901 if (d_sub) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
902 if (d_sub->id > -2) reset_spu = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
903 d_sub->id = -2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
904 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
905 #ifdef USE_ASS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
906 ass_track = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
907 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
908
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
909 if (source == SUB_SOURCE_VOBSUB) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
910 vobsub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_VOBSUB];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
911 } else if (source == SUB_SOURCE_SUBS) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
912 mpctx->set_of_sub_pos = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
913 #ifdef USE_ASS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
914 if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos])
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
915 ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
916 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
917 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
918 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
919 subdata = mpctx->set_of_subtitles[mpctx->set_of_sub_pos];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
920 vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
921 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
922 } else if (source == SUB_SOURCE_DEMUX) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
923 dvdsub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
924 if (d_sub) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
925 #ifdef USE_DVDREAD
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
926 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
927 d_sub->id = dvdsub_id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
928 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
929 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
930
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
931 #ifdef USE_DVDNAV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
932 if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVDNAV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
933 d_sub->id = dvdsub_id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
934 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
935 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
936 if (mpctx->stream->type != STREAMTYPE_DVD && mpctx->stream->type != STREAMTYPE_DVDNAV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
937 int i = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
938 for (d_sub->id = 0; d_sub->id < MAX_S_STREAMS; d_sub->id++) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
939 if (mpctx->demuxer->s_streams[d_sub->id]) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
940 if (i == dvdsub_id) break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
941 i++;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
942 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
943 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
944 d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
945 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
946 if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
947 d_sub->id = demux_mkv_change_subs(mpctx->demuxer, dvdsub_id);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
948 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
949 if (d_sub->sh && d_sub->id >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
950 sh_sub_t *sh = d_sub->sh;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
951 if (sh->type == 'v')
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
952 init_vo_spudec();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
953 #ifdef USE_ASS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
954 else if (ass_enabled && sh->type == 'a')
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
955 ass_track = sh->ass_track;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
956 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
957 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
958 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
959 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
960 #ifdef USE_DVDREAD
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
961 if (vo_spudec && (mpctx->stream->type == STREAMTYPE_DVD || mpctx->stream->type == STREAMTYPE_DVDNAV) && dvdsub_id < 0 && reset_spu) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
962 dvdsub_id = -2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
963 d_sub->id = dvdsub_id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
964 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
965 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
966 update_subtitles(mpctx->sh_video, d_sub, 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
967
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
968 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
969 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
970
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
971 /// Subtitle delay (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
972 static int mp_property_sub_delay(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
973 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
974 return m_property_delay(prop,action,arg,&sub_delay);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
975 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
976
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
977 /// Alignment of text subtitles (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
978 static int mp_property_sub_alignment(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
979 char* name[] = { MSGTR_Top, MSGTR_Center, MSGTR_Bottom };
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
980
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
981 if (!mpctx->sh_video || mpctx->global_sub_pos < 0 || sub_source(mpctx) != SUB_SOURCE_SUBS)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
982 return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
983
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
984 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
985 case M_PROPERTY_PRINT:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
986 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
987 M_PROPERTY_CLAMP(prop,sub_alignment);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
988 *(char**)arg = strdup(name[sub_alignment]);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
989 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
990 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
991 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
992 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
993 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
994 vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
995 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
996 return m_property_choice(prop,action,arg,&sub_alignment);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
997 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
998 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
999
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1000 /// Subtitle visibility (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1001 static int mp_property_sub_visibility(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1002 if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1003
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1004 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1005 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1006 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1007 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1008 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1009 vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1010 if(vo_spudec) vo_osd_changed(OSDTYPE_SPU);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1011 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1012 return m_property_flag(prop,action,arg,&sub_visibility);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1013 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1014 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1015
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1016 /// Show only forced subtitles (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1017 static int mp_property_sub_forced_only(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1018 if(!vo_spudec) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1019
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1020 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1021 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1022 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1023 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1024 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1025 m_property_flag(prop,action,arg,&forced_subs_only);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1026 spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1027 return M_PROPERTY_OK;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1028 default:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1029 return m_property_flag(prop,action,arg,&forced_subs_only);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1030 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1031
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1032 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1033
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1034 ///@}
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1035
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1036 /// \defgroup TVProperties TV properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1037 /// \ingroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1038 ///@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1039
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1040 #ifdef USE_TV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1041
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1042 /// TV color settings (RW)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1043 static int mp_property_tv_color(m_option_t * prop, int action, void *arg, MPContext * mpctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1044 int r,val;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1045 tvi_handle_t *tvh = mpctx->demuxer->priv;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1046 if (mpctx->demuxer->type != DEMUXER_TYPE_TV || !tvh) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1047
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1048 switch(action) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1049 case M_PROPERTY_SET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1050 if(!arg) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1051 M_PROPERTY_CLAMP(prop,*(int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1052 return tv_set_color_options(tvh,(int)prop->priv,*(int*)arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1053 case M_PROPERTY_GET:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1054 return tv_get_color_options(tvh,(int)prop->priv,arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1055 case M_PROPERTY_STEP_UP:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1056 case M_PROPERTY_STEP_DOWN:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1057 if((r = tv_get_color_options(tvh,(int)prop->priv,&val)) >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1058 if(!r) return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1059 val += (arg ? *(int*)arg : 1) *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1060 (action == M_PROPERTY_STEP_DOWN ? -1 : 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1061 M_PROPERTY_CLAMP(prop,val);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1062 return tv_set_color_options(tvh,(int)prop->priv,val);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1063 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1064 return M_PROPERTY_ERROR;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1065 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1066 return M_PROPERTY_NOT_IMPLEMENTED;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1067 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1068
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1069 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1070
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1071 ///@}
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1072
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1073 /// All properties available in MPlayer.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1074 /** \ingroup Properties
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1075 */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1076 static m_option_t mp_properties[] = {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1077 // General
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1078 { "osdlevel", mp_property_osdlevel, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1079 M_OPT_RANGE, 0, 3, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1080 { "speed", mp_property_playback_speed, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1081 M_OPT_RANGE, 0.01, 100.0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1082 { "filename", mp_property_filename, CONF_TYPE_STRING,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1083 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1084 { "path", mp_property_path, CONF_TYPE_STRING,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1085 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1086 { "demuxer", mp_property_demuxer, CONF_TYPE_STRING,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1087 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1088 { "stream_pos", mp_property_stream_pos, CONF_TYPE_POSITION,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1089 M_OPT_MIN, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1090 { "stream_start", mp_property_stream_start, CONF_TYPE_POSITION,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1091 M_OPT_MIN, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1092 { "stream_end", mp_property_stream_end, CONF_TYPE_POSITION,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1093 M_OPT_MIN, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1094 { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1095 M_OPT_MIN, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1096 { "length", mp_property_length, CONF_TYPE_DOUBLE,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1097 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1098
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1099 // Audio
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1100 { "volume", mp_property_volume, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1101 M_OPT_RANGE, 0, 100, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1102 { "mute", mp_property_mute, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1103 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1104 { "audio_delay", mp_property_audio_delay, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1105 M_OPT_RANGE, -100, 100, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1106 { "audio_format", mp_property_audio_format, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1107 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1108 { "audio_bitrate", mp_property_audio_bitrate, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1109 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1110 { "samplerate", mp_property_samplerate, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1111 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1112 { "channels", mp_property_channels, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1113 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1114 { "switch_audio", mp_property_audio, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1115 CONF_RANGE, -2, MAX_A_STREAMS-1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1116
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1117 // Video
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1118 { "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1119 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1120 { "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1121 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1122 { "ontop", mp_property_ontop, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1123 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1124 { "rootwin", mp_property_rootwin, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1125 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1126 { "border", mp_property_border, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1127 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1128 { "framedropping", mp_property_framedropping, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1129 M_OPT_RANGE, 0, 2, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1130 { "gamma", mp_property_gamma, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1131 M_OPT_RANGE, -100, 100, &vo_gamma_gamma },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1132 { "brightness", mp_property_gamma, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1133 M_OPT_RANGE, -100, 100, &vo_gamma_brightness },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1134 { "contrast", mp_property_gamma, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1135 M_OPT_RANGE, -100, 100, &vo_gamma_contrast },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1136 { "saturation", mp_property_gamma, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1137 M_OPT_RANGE, -100, 100, &vo_gamma_saturation },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1138 { "hue", mp_property_gamma, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1139 M_OPT_RANGE, -100, 100, &vo_gamma_hue },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1140 { "panscan", mp_property_panscan, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1141 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1142 { "vsync", mp_property_vsync, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1143 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1144 { "video_format", mp_property_video_format, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1145 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1146 { "video_bitrate", mp_property_video_bitrate, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1147 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1148 { "width", mp_property_width, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1149 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1150 { "height", mp_property_height, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1151 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1152 { "fps", mp_property_fps, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1153 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1154 { "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1155 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1156 { "switch_video", mp_property_video, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1157 CONF_RANGE, -2, MAX_V_STREAMS-1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1158 { "switch_program", mp_property_program, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1159 CONF_RANGE, -1, 65535, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1160
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1161 // Subs
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1162 { "sub", mp_property_sub, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1163 M_OPT_MIN, -1, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1164 { "sub_delay", mp_property_sub_delay, CONF_TYPE_FLOAT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1165 0, 0, 0, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1166 { "sub_pos", mp_property_sub_pos, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1167 M_OPT_RANGE, 0, 100, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1168 { "sub_alignment", mp_property_sub_alignment, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1169 M_OPT_RANGE, 0, 2, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1170 { "sub_visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1171 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1172 { "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1173 M_OPT_RANGE, 0, 1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1174
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1175 #ifdef USE_TV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1176 { "tv_brightness", mp_property_tv_color, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1177 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_BRIGHTNESS },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1178 { "tv_contrast", mp_property_tv_color, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1179 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_CONTRAST },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1180 { "tv_saturation", mp_property_tv_color, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1181 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_SATURATION },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1182 { "tv_hue", mp_property_tv_color, CONF_TYPE_INT,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1183 M_OPT_RANGE, -100, 100, (void*)TV_COLOR_HUE },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1184 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1185
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1186 { NULL, NULL, NULL, 0, 0, 0, NULL }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1187 };
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1188
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1189 m_option_t* mp_property_find(const char* name) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1190 return m_option_list_find(mp_properties,name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1191 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1192
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1193 int mp_property_do(const char *name, int action, void *val, void *ctx) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1194 m_option_t* p = mp_property_find(name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1195 if(!p) return M_PROPERTY_UNAVAILABLE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1196 return m_property_do(p, action, val, ctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1197 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1198
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1199 char *property_expand_string(MPContext * mpctx, char *str) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1200 return m_properties_expand_string(mp_properties, str, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1201 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1202
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1203 void property_print_help(void) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1204 m_properties_print_help_list(mp_properties);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1205 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1206
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1207
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1208 ///@}
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1209 // Properties group
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1210
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1211
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1212 /**
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1213 * \defgroup Command2Property Command to property bridge
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1214 *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1215 * It is used to handle most commands that just set a property
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1216 * and optionally display something on the OSD.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1217 * Two kinds of commands are handled: adjust or toggle.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1218 *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1219 * Adjust commands take 1 or 2 parameters: <value> <abs>
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1220 * If <abs> is non-zero the property is set to the given value
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1221 * otherwise it is adjusted.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1222 *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1223 * Toggle commands take 0 or 1 parameters. With no parameter
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1224 * or a value less than the property minimum it just steps the
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1225 * property to its next value. Otherwise it sets it to the given
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1226 * value.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1227 *
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1228 *@{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1229 */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1230
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1231 /// List of the commands that can be handled by setting a property.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1232 static struct {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1233 /// property name
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1234 const char* name;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1235 /// cmd id
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1236 int cmd;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1237 /// set/adjust or toggle command
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1238 int toggle;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1239 /// progressbar type
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1240 int osd_progbar;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1241 /// osd msg id if it must be shared
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1242 int osd_id;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1243 /// osd msg template
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1244 const char* osd_msg;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1245 } set_prop_cmd[] = {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1246 // audio
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1247 { "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1248 { "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1249 { "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1250 { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1251 // video
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1252 { "fullscreen", MP_CMD_VO_FULLSCREEN, 1, 0, -1, NULL },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1253 { "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, MSGTR_Panscan },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1254 { "ontop", MP_CMD_VO_ONTOP, 1, 0, -1, MSGTR_OnTopStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1255 { "rootwin", MP_CMD_VO_ROOTWIN, 1, 0, -1, MSGTR_RootwinStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1256 { "border", MP_CMD_VO_BORDER, 1, 0, -1, MSGTR_BorderStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1257 { "framedropping", MP_CMD_FRAMEDROPPING, 1, 0, -1, MSGTR_FramedroppingStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1258 { "gamma", MP_CMD_GAMMA, 0, OSD_BRIGHTNESS, -1, MSGTR_Gamma },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1259 { "brightness", MP_CMD_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1260 { "contrast", MP_CMD_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1261 { "saturation", MP_CMD_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1262 { "hue", MP_CMD_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1263 { "vsync", MP_CMD_SWITCH_VSYNC, 1, 0, -1, MSGTR_VSyncStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1264 // subs
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1265 { "sub", MP_CMD_SUB_SELECT, 1, 0, -1, MSGTR_SubSelectStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1266 { "sub_pos", MP_CMD_SUB_POS, 0, 0, -1, MSGTR_SubPosStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1267 { "sub_alignment", MP_CMD_SUB_ALIGNMENT, 1, 0, -1, MSGTR_SubAlignStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1268 { "sub_delay", MP_CMD_SUB_DELAY, 0, 0, OSD_MSG_SUB_DELAY, MSGTR_SubDelayStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1269 { "sub_visibility", MP_CMD_SUB_VISIBILITY, 1, 0, -1, MSGTR_SubVisibleStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1270 { "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1, 0, -1, MSGTR_SubForcedOnlyStatus },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1271 #ifdef USE_TV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1272 { "tv_brightness", MP_CMD_TV_SET_BRIGHTNESS, 0, OSD_BRIGHTNESS, -1, MSGTR_Brightness },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1273 { "tv_hue", MP_CMD_TV_SET_HUE, 0, OSD_HUE, -1, MSGTR_Hue },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1274 { "tv_saturation", MP_CMD_TV_SET_SATURATION, 0, OSD_SATURATION, -1, MSGTR_Saturation },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1275 { "tv_contrast", MP_CMD_TV_SET_CONTRAST, 0, OSD_CONTRAST, -1, MSGTR_Contrast },
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1276 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1277 { NULL, 0, 0, 0, -1, NULL }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1278 };
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1279
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1280
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1281 /// Handle commands that set a property.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1282 static int set_property_command(MPContext * mpctx, mp_cmd_t * cmd) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1283 int i,r;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1284 m_option_t* prop;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1285
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1286 // look for the command
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1287 for(i = 0 ; set_prop_cmd[i].name ; i++)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1288 if(set_prop_cmd[i].cmd == cmd->id) break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1289 if(!set_prop_cmd[i].name) return 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1290
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1291 // get the property
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1292 prop = mp_property_find(set_prop_cmd[i].name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1293 if(!prop) return 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1294
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1295 // toggle command
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1296 if(set_prop_cmd[i].toggle) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1297 // set to value
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1298 if(cmd->nargs > 0 && cmd->args[0].v.i >= prop->min)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1299 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v.i, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1300 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1301 r = m_property_do(prop, M_PROPERTY_STEP_UP, NULL, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1302 } else if(cmd->args[1].v.i) //set
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1303 r = m_property_do(prop, M_PROPERTY_SET, &cmd->args[0].v, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1304 else // adjust
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1305 r = m_property_do(prop, M_PROPERTY_STEP_UP, &cmd->args[0].v, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1306
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1307 if(r <= 0) return 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1308
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1309 if(set_prop_cmd[i].osd_progbar) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1310 if(prop->type == CONF_TYPE_INT) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1311 if (m_property_do(prop, M_PROPERTY_GET, &r, mpctx) > 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1312 set_osd_bar(set_prop_cmd[i].osd_progbar,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1313 set_prop_cmd[i].osd_msg,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1314 prop->min,prop->max,r);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1315 } else if(prop->type == CONF_TYPE_FLOAT) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1316 float f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1317 if (m_property_do(prop, M_PROPERTY_GET, &f, mpctx) > 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1318 set_osd_bar(set_prop_cmd[i].osd_progbar,set_prop_cmd[i].osd_msg,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1319 prop->min,prop->max,f);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1320 } else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1321 mp_msg(MSGT_CPLAYER,MSGL_ERR, "Property use an unsupported type.\n");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1322 return 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1323 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1324
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1325 if(set_prop_cmd[i].osd_msg) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1326 char *val = m_property_print(prop, mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1327 if(val) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1328 set_osd_msg(set_prop_cmd[i].osd_id >= 0 ? set_prop_cmd[i].osd_id :
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1329 OSD_MSG_PROPERTY+i,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1330 set_prop_cmd[i].osd_msg,val);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1331 free(val);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1332 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1333 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1334 return 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1335 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1336
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1337 static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1338 //remove the borders, if any, and rescale to the range [0,1],[0,1]
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1339 if(vo_fs) { //we are in full-screen mode
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1340 if(vo_screenwidth > vo_dwidth) //there are borders along the x axis
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1341 ix -= (vo_screenwidth - vo_dwidth) / 2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1342 if(vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1343 iy -= (vo_screenheight - vo_dheight) / 2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1344
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1345 if(ix < 0 || ix > vo_dwidth) {*dx = *dy = -1.0; return; } //we are on one of the borders
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1346 if(iy < 0 || iy > vo_dheight) {*dx = *dy = -1.0; return; } //we are on one of the borders
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1347 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1348
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1349 *dx = (double) ix / (double) vo_dwidth;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1350 *dy = (double) iy / (double) vo_dheight;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1351
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1352 mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1353 *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, vo_dheight, vo_fs);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1354 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1355
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1356 int run_command(MPContext * mpctx, mp_cmd_t * cmd)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1357 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1358 sh_audio_t * const sh_audio = mpctx->sh_audio;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1359 sh_video_t * const sh_video = mpctx->sh_video;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1360 int brk_cmd = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1361 if (!set_property_command(mpctx, cmd))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1362 switch(cmd->id) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1363 case MP_CMD_SEEK : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1364 float v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1365 int abs;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1366 if(sh_video)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1367 mpctx->osd_show_percentage = sh_video->fps;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1368 v = cmd->args[0].v.f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1369 abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1370 if(abs==2) { /* Absolute seek to a specific timestamp in seconds */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1371 abs_seek_pos = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1372 if(sh_video)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1373 mpctx->osd_function = (v > sh_video->pts) ? OSD_FFW : OSD_REW;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1374 rel_seek_secs = v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1375 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1376 else if(abs) { /* Absolute seek by percentage */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1377 abs_seek_pos = 3;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1378 if(sh_video)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1379 mpctx->osd_function = OSD_FFW; // Direction isn't set correctly
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1380 rel_seek_secs = v/100.0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1381 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1382 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1383 rel_seek_secs+= v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1384 mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1385 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1386 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1387 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1388 case MP_CMD_SET_PROPERTY: {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1389 m_option_t* prop = mp_property_find(cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1390 if(!prop) mp_msg(MSGT_CPLAYER,MSGL_WARN,"Unknown property: '%s'\n",cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1391 else if (m_property_parse(prop, cmd->args[1].v.s, mpctx) <= 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1392 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to set property '%s' to '%s'.\n",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1393 cmd->args[0].v.s,cmd->args[1].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1394
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1395 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1396 case MP_CMD_STEP_PROPERTY: {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1397 m_option_t* prop = mp_property_find(cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1398 float arg = cmd->args[1].v.f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1399 if(!prop) mp_msg(MSGT_CPLAYER,MSGL_WARN, "Unknown property: '%s'\n",cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1400 else if (m_property_do(prop, M_PROPERTY_STEP_UP, arg ? &arg : NULL, mpctx) <= 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1401 mp_msg(MSGT_CPLAYER,MSGL_WARN, "Failed to increment property '%s' by %f.\n",cmd->args[0].v.s, arg);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1402 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1403
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1404 case MP_CMD_GET_PROPERTY: {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1405 m_option_t* prop;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1406 void* val;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1407 char* tmp;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1408 prop = mp_property_find(cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1409 if(!prop) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1410 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Unknown property: '%s'\n",cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1411 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1412 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1413 /* Use m_option_print directly to get easily parseable values. */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1414 val = calloc(1,prop->type->size);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1415 if (m_property_do(prop, M_PROPERTY_GET, val, mpctx) <= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1416 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to get value of property '%s'.\n",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1417 cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1418 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1419 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1420 tmp = m_option_print(prop, val);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1421 if(!tmp || tmp == (char*)-1) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1422 mp_msg(MSGT_CPLAYER,MSGL_WARN,"Failed to print value of property '%s'.\n",
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1423 cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1424 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1425 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1426 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_%s=%s\n",cmd->args[0].v.s,tmp);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1427 free(tmp);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1428 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1429 case MP_CMD_EDL_MARK:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1430 if( edl_fd ) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1431 float v = sh_video ? sh_video->pts :
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1432 playing_audio_pts(sh_audio, mpctx->d_audio, mpctx->audio_out);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1433
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1434 if (mpctx->begin_skip == MP_NOPTS_VALUE)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1435 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1436 mpctx->begin_skip = v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1437 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutStartSkip);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1438 }else{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1439 if (mpctx->begin_skip > v)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1440 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1441 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdloutBadStop);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1442 }else{
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1443 fprintf(edl_fd, "%f %f %d\n", mpctx->begin_skip, v, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1444 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdloutEndSkip);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1445 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1446 mpctx->begin_skip = MP_NOPTS_VALUE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1447 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1448 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1449 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1450 case MP_CMD_SWITCH_RATIO : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1451 if (cmd->nargs == 0 || cmd->args[0].v.f == -1)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1452 movie_aspect = (float) sh_video->disp_w / sh_video->disp_h;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1453 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1454 movie_aspect = cmd->args[0].v.f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1455 mpcodecs_config_vo (sh_video, sh_video->disp_w, sh_video->disp_h, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1456 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1457 case MP_CMD_SPEED_INCR : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1458 float v = cmd->args[0].v.f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1459 playback_speed += v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1460 build_afilter_chain(sh_audio, &ao_data);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1461 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1462 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1463 case MP_CMD_SPEED_MULT : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1464 float v = cmd->args[0].v.f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1465 playback_speed *= v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1466 build_afilter_chain(sh_audio, &ao_data);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1467 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1468 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1469 case MP_CMD_SPEED_SET : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1470 float v = cmd->args[0].v.f;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1471 playback_speed = v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1472 build_afilter_chain(sh_audio, &ao_data);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1473 set_osd_msg(OSD_MSG_SPEED,1,osd_duration,MSGTR_OSDSpeed, playback_speed);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1474 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1475 case MP_CMD_FRAME_STEP :
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1476 case MP_CMD_PAUSE : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1477 cmd->pausing = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1478 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1479 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1480 case MP_CMD_FILE_FILTER : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1481 file_filter = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1482 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1483 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1484 case MP_CMD_QUIT : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1485 exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1486 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1487 case MP_CMD_PLAY_TREE_STEP : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1488 int n = cmd->args[0].v.i == 0 ? 1 : cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1489 int force = cmd->args[1].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1490
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1491 #ifdef HAVE_NEW_GUI
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1492 if (use_gui) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1493 int i=0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1494 if (n>0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1495 for (i=0;i<n;i++)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1496 mplNext();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1497 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1498 for (i=0;i<-1*n;i++)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1499 mplPrev();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1500 } else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1501 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1502 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1503 if (!force && mpctx->playtree_iter) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1504 play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1505
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1506 if(play_tree_iter_step(i,n,0) == PLAY_TREE_ITER_ENTRY)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1507 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1508 play_tree_iter_free(i);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1509 } else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1510 mpctx->eof = (n > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1511 if (mpctx->eof)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1512 mpctx->play_tree_step = n;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1513 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1514 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1515 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1516 case MP_CMD_PLAY_TREE_UP_STEP : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1517 int n = cmd->args[0].v.i > 0 ? 1 : -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1518 int force = cmd->args[1].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1519
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1520 if (!force && mpctx->playtree_iter) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1521 play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1522 if(play_tree_iter_up_step(i,n,0) == PLAY_TREE_ITER_ENTRY)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1523 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1524 play_tree_iter_free(i);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1525 } else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1526 mpctx->eof = (n > 0) ? PT_UP_NEXT : PT_UP_PREV;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1527 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1528 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1529 case MP_CMD_PLAY_ALT_SRC_STEP : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1530 if (mpctx->playtree_iter && mpctx->playtree_iter->num_files > 1) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1531 int v = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1532 if (v > 0 && mpctx->playtree_iter->file < mpctx->playtree_iter->num_files)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1533 mpctx->eof = PT_NEXT_SRC;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1534 else if (v < 0 && mpctx->playtree_iter->file > 1)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1535 mpctx->eof = PT_PREV_SRC;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1536 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1537 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1538 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1539 case MP_CMD_SUB_STEP : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1540 if (sh_video) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1541 int movement = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1542 step_sub(subdata, sh_video->pts, movement);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1543 #ifdef USE_ASS
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1544 if (ass_track)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1545 sub_delay += ass_step_sub(ass_track, (sh_video->pts + sub_delay) * 1000 + .5, movement) / 1000.;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1546 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1547 set_osd_msg(OSD_MSG_SUB_DELAY,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1548 MSGTR_OSDSubDelay, ROUND(sub_delay*1000));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1549 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1550 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1551 case MP_CMD_SUB_LOG : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1552 log_sub();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1553 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1554 case MP_CMD_OSD : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1555 int v = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1556 int max = (term_osd && !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1557 if(osd_level > max) osd_level = max;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1558 if(v < 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1559 osd_level=(osd_level+1)%(max+1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1560 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1561 osd_level= v > max ? max : v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1562 /* Show OSD state when disabled, but not when an explicit
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1563 argument is given to the OSD command, i.e. in slave mode. */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1564 if (v == -1 && osd_level <= 1)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1565 set_osd_msg(OSD_MSG_OSD_STATUS,0,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1566 MSGTR_OSDosd, osd_level ? MSGTR_OSDenabled : MSGTR_OSDdisabled);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1567 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1568 rm_osd_msg(OSD_MSG_OSD_STATUS);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1569 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1570 case MP_CMD_OSD_SHOW_TEXT : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1571 set_osd_msg(OSD_MSG_TEXT,cmd->args[2].v.i,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1572 (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1573 "%-.63s",cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1574 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1575 case MP_CMD_OSD_SHOW_PROPERTY_TEXT : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1576 char *txt = m_properties_expand_string(mp_properties,cmd->args[0].v.s,mpctx);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1577 /* if no argument supplied take default osd_duration, else <arg> ms. */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1578 if(txt) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1579 set_osd_msg(OSD_MSG_TEXT,cmd->args[2].v.i,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1580 (cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1581 "%-.63s",txt);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1582 free(txt);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1583 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1584 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1585 case MP_CMD_LOADFILE : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1586 play_tree_t* e = play_tree_new();
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1587 play_tree_add_file(e,cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1588
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1589 if (cmd->args[1].v.i) // append
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1590 play_tree_append_entry(mpctx->playtree, e);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1591 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1592 // Go back to the starting point.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1593 while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1594 /* NOP */;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1595 play_tree_free_list(mpctx->playtree->child, 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1596 play_tree_set_child(mpctx->playtree, e);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1597 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1598 mpctx->eof = PT_NEXT_SRC;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1599 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1600 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1601 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1602 case MP_CMD_LOADLIST : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1603 play_tree_t* e = parse_playlist_file(cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1604 if(!e)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1605 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_PlaylistLoadUnable,cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1606 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1607 if (cmd->args[1].v.i) // append
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1608 play_tree_append_entry(mpctx->playtree, e);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1609 else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1610 // Go back to the starting point.
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1611 while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1612 /* NOP */;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1613 play_tree_free_list(mpctx->playtree->child, 1);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1614 play_tree_set_child(mpctx->playtree, e);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1615 play_tree_iter_step(mpctx->playtree_iter, 0, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1616 mpctx->eof = PT_NEXT_SRC;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1617 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1618 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1619 brk_cmd = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1620 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1621 #ifdef USE_RADIO
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1622 case MP_CMD_RADIO_STEP_CHANNEL : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1623 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1624 int v = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1625 if(v > 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1626 radio_step_channel(mpctx->demuxer->stream, RADIO_CHANNEL_HIGHER);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1627 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1628 radio_step_channel(mpctx->demuxer->stream, RADIO_CHANNEL_LOWER);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1629 if (radio_get_channel_name(mpctx->demuxer->stream)) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1630 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1631 MSGTR_OSDChannel, radio_get_channel_name(mpctx->demuxer->stream));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1632 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1633 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1634 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1635 case MP_CMD_RADIO_SET_CHANNEL : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1636 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1637 radio_set_channel(mpctx->demuxer->stream, cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1638 if (radio_get_channel_name(mpctx->demuxer->stream)) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1639 set_osd_msg(OSD_MSG_RADIO_CHANNEL,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1640 MSGTR_OSDChannel, radio_get_channel_name(mpctx->demuxer->stream));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1641 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1642 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1643 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1644 case MP_CMD_RADIO_SET_FREQ : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1645 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1646 radio_set_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1647 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1648 case MP_CMD_RADIO_STEP_FREQ :
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1649 if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1650 radio_step_freq(mpctx->demuxer->stream, cmd->args[0].v.f);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1651 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1652 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1653 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1654 #ifdef USE_TV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1655 case MP_CMD_TV_SET_FREQ : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1656 if (mpctx->file_format == DEMUXER_TYPE_TV)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1657 tv_set_freq((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.f * 16.0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1658 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1659 case MP_CMD_TV_SET_NORM : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1660 if (mpctx->file_format == DEMUXER_TYPE_TV)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1661 tv_set_norm((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1662 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1663 case MP_CMD_TV_STEP_CHANNEL : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1664 if (mpctx->file_format == DEMUXER_TYPE_TV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1665 int v = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1666 if(v > 0){
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1667 tv_step_channel((tvi_handle_t *) (mpctx->demuxer->priv), TV_CHANNEL_HIGHER);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1668 } else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1669 tv_step_channel((tvi_handle_t *) (mpctx->demuxer->priv), TV_CHANNEL_LOWER);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1670 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1671 if (tv_channel_list) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1672 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1673 MSGTR_OSDChannel, tv_channel_current->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1674 //vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1675 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1676 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1677 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1678 #ifdef HAS_DVBIN_SUPPORT
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1679 if ((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1680 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1681 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1682 if(priv->is_on)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1683 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1684 int dir;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1685 int v = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1686
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1687 mpctx->last_dvb_step = v;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1688 if(v > 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1689 dir = DVB_CHANNEL_HIGHER;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1690 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1691 dir = DVB_CHANNEL_LOWER;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1692
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1693
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1694 if(dvb_step_channel(priv, dir))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1695 mpctx->eof = mpctx->dvbin_reopen = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1696 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1697 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1698 #endif /* HAS_DVBIN_SUPPORT */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1699 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1700 case MP_CMD_TV_SET_CHANNEL : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1701 if (mpctx->file_format == DEMUXER_TYPE_TV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1702 tv_set_channel((tvi_handle_t *) (mpctx->demuxer->priv), cmd->args[0].v.s);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1703 if (tv_channel_list) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1704 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1705 MSGTR_OSDChannel, tv_channel_current->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1706 //vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1707 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1708 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1709 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1710 #ifdef HAS_DVBIN_SUPPORT
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1711 case MP_CMD_DVB_SET_CHANNEL:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1712 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1713 if ((mpctx->stream->type == STREAMTYPE_DVB) && mpctx->stream->priv)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1714 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1715 dvb_priv_t *priv = (dvb_priv_t *) mpctx->stream->priv;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1716 if(priv->is_on)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1717 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1718 if(priv->list->current <= cmd->args[0].v.i)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1719 mpctx->last_dvb_step = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1720 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1721 mpctx->last_dvb_step = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1722
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1723 if(dvb_set_channel(priv, cmd->args[1].v.i, cmd->args[0].v.i))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1724 mpctx->eof = mpctx->dvbin_reopen = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1725 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1726 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1727 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1728 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1729 #endif /* HAS_DVBIN_SUPPORT */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1730 case MP_CMD_TV_LAST_CHANNEL : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1731 if (mpctx->file_format == DEMUXER_TYPE_TV) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1732 tv_last_channel((tvi_handle_t *) (mpctx->demuxer->priv));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1733 if (tv_channel_list) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1734 set_osd_msg(OSD_MSG_TV_CHANNEL,1,osd_duration,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1735 MSGTR_OSDChannel, tv_channel_current->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1736 //vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1737 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1738 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1739 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1740 case MP_CMD_TV_STEP_NORM : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1741 if (mpctx->file_format == DEMUXER_TYPE_TV)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1742 tv_step_norm((tvi_handle_t *) (mpctx->demuxer->priv));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1743 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1744 case MP_CMD_TV_STEP_CHANNEL_LIST : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1745 if (mpctx->file_format == DEMUXER_TYPE_TV)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1746 tv_step_chanlist((tvi_handle_t *) (mpctx->demuxer->priv));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1747 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1748 #endif /* USE_TV */
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1749 case MP_CMD_SUB_LOAD:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1750 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1751 if (sh_video) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1752 int n = mpctx->set_of_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1753 add_subtitles(cmd->args[0].v.s, sh_video->fps, 0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1754 if (n != mpctx->set_of_sub_size) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1755 if (mpctx->global_sub_indices[SUB_SOURCE_SUBS] < 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1756 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = mpctx->global_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1757 ++mpctx->global_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1758 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1759 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1760 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1761 case MP_CMD_SUB_REMOVE:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1762 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1763 if (sh_video) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1764 int v = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1765 sub_data *subd;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1766 if (v < 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1767 for (v = 0; v < mpctx->set_of_sub_size; ++v) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1768 subd = mpctx->set_of_subtitles[v];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1769 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1770 filename_recode(subd->filename));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1771 sub_free(subd);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1772 mpctx->set_of_subtitles[v] = NULL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1773 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1774 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1775 mpctx->global_sub_size -= mpctx->set_of_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1776 mpctx->set_of_sub_size = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1777 if (mpctx->set_of_sub_pos >= 0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1778 mpctx->global_sub_pos = -2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1779 vo_sub_last = vo_sub = NULL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1780 vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1781 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1782 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1783 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1784 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1785 else if (v < mpctx->set_of_sub_size) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1786 subd = mpctx->set_of_subtitles[v];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1787 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1788 filename_recode(subd->filename));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1789 sub_free(subd);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1790 if (mpctx->set_of_sub_pos == v) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1791 mpctx->global_sub_pos = -2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1792 vo_sub_last = vo_sub = NULL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1793 vo_osd_changed(OSDTYPE_SUBTITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1794 vo_update_osd(sh_video->disp_w, sh_video->disp_h);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1795 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1796 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1797 else if (mpctx->set_of_sub_pos > v) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1798 --mpctx->set_of_sub_pos;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1799 --mpctx->global_sub_pos;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1800 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1801 while (++v < mpctx->set_of_sub_size)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1802 mpctx->set_of_subtitles[v - 1] = mpctx->set_of_subtitles[v];
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1803 --mpctx->set_of_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1804 --mpctx->global_sub_size;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1805 if (mpctx->set_of_sub_size <= 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1806 mpctx->global_sub_indices[SUB_SOURCE_SUBS] = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1807 mpctx->set_of_subtitles[mpctx->set_of_sub_size] = NULL;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1808 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1809 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1810 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1811 case MP_CMD_GET_SUB_VISIBILITY:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1812 {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1813 if (sh_video) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1814 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_SUB_VISIBILITY=%d\n", sub_visibility);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1815 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1816 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1817 case MP_CMD_SCREENSHOT :
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1818 if(vo_config_count){
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1819 mp_msg(MSGT_CPLAYER,MSGL_INFO,"sending VFCTRL_SCREENSHOT!\n");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1820 if(CONTROL_OK!=((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SCREENSHOT, &cmd->args[0].v.i))
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1821 mpctx->video_out->control(VOCTRL_SCREENSHOT, NULL);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1822 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1823 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1824 case MP_CMD_VF_CHANGE_RECTANGLE:
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1825 set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1826 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1827
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1828 case MP_CMD_GET_TIME_LENGTH : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1829 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2lf\n", demuxer_get_time_length(mpctx->demuxer));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1830 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1831
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1832 case MP_CMD_GET_FILENAME : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1833 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_FILENAME='%s'\n", get_metadata (META_NAME));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1834 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1835
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1836 case MP_CMD_GET_VIDEO_CODEC : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1837 char *inf = get_metadata (META_VIDEO_CODEC);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1838 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1839 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_CODEC='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1840 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1841 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1842
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1843 case MP_CMD_GET_VIDEO_BITRATE : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1844 char *inf = get_metadata (META_VIDEO_BITRATE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1845 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1846 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_BITRATE='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1847 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1848 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1849
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1850 case MP_CMD_GET_VIDEO_RESOLUTION : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1851 char *inf = get_metadata (META_VIDEO_RESOLUTION);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1852 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1853 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VIDEO_RESOLUTION='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1854 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1855 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1856
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1857 case MP_CMD_GET_AUDIO_CODEC : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1858 char *inf = get_metadata (META_AUDIO_CODEC);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1859 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1860 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_CODEC='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1861 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1862 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1863
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1864 case MP_CMD_GET_AUDIO_BITRATE : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1865 char *inf = get_metadata (META_AUDIO_BITRATE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1866 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1867 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_BITRATE='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1868 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1869 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1870
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1871 case MP_CMD_GET_AUDIO_SAMPLES : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1872 char *inf = get_metadata (META_AUDIO_SAMPLES);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1873 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1874 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_AUDIO_SAMPLES='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1875 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1876 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1877
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1878 case MP_CMD_GET_META_TITLE : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1879 char *inf = get_metadata (META_INFO_TITLE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1880 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1881 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_TITLE='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1882 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1883 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1884
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1885 case MP_CMD_GET_META_ARTIST : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1886 char *inf = get_metadata (META_INFO_ARTIST);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1887 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1888 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_ARTIST='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1889 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1890 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1891
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1892 case MP_CMD_GET_META_ALBUM : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1893 char *inf = get_metadata (META_INFO_ALBUM);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1894 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1895 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_ALBUM='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1896 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1897 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1898
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1899 case MP_CMD_GET_META_YEAR : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1900 char *inf = get_metadata (META_INFO_YEAR);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1901 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1902 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_YEAR='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1903 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1904 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1905
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1906 case MP_CMD_GET_META_COMMENT : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1907 char *inf = get_metadata (META_INFO_COMMENT);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1908 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1909 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_COMMENT='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1910 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1911 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1912
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1913 case MP_CMD_GET_META_TRACK : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1914 char *inf = get_metadata (META_INFO_TRACK);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1915 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1916 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_TRACK='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1917 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1918 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1919
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1920 case MP_CMD_GET_META_GENRE : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1921 char *inf = get_metadata (META_INFO_GENRE);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1922 if (!inf) inf = strdup ("");
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1923 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_META_GENRE='%s'\n", inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1924 free (inf);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1925 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1926
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1927 case MP_CMD_GET_VO_FULLSCREEN : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1928 if (mpctx->video_out && vo_config_count)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1929 mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_VO_FULLSCREEN=%d\n", vo_fs);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1930 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1931
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1932 case MP_CMD_GET_PERCENT_POS : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1933 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n", demuxer_get_percent_pos(mpctx->demuxer));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1934 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1935 case MP_CMD_GET_TIME_POS : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1936 float pos = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1937 if (sh_video)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1938 pos = sh_video->pts;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1939 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1940 if (sh_audio && mpctx->audio_out)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1941 pos = playing_audio_pts(sh_audio, mpctx->d_audio, mpctx->audio_out);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1942 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1943 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1944 case MP_CMD_RUN : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1945 #ifndef __MINGW32__
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1946 if(!fork()) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1947 execl("/bin/sh","sh","-c",cmd->args[0].v.s,NULL);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1948 exit(0);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1949 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1950 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1951 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1952 case MP_CMD_KEYDOWN_EVENTS : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1953 mplayer_put_key(cmd->args[0].v.i);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1954 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1955 case MP_CMD_SEEK_CHAPTER : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1956 int seek = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1957 int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1958 int chap;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1959 float next_pts = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1960 int num_chapters;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1961 char *chapter_name;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1962
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1963 rel_seek_secs = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1964 abs_seek_pos = 0;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1965 chap = demuxer_seek_chapter(mpctx->demuxer, seek, abs, &next_pts, &num_chapters, &chapter_name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1966 if(chap != -1) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1967 if(next_pts > -1.0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1968 abs_seek_pos = 1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1969 rel_seek_secs = next_pts;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1970 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1971 if(chapter_name) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1972 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter,
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1973 chap+1, chapter_name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1974 free(chapter_name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1975 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1976 } else {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1977 if (seek > 0)
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1978 rel_seek_secs = 1000000000.;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1979 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1980 set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter, 0, MSGTR_Unknown);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1981 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1982 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1983 } break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1984 case MP_CMD_SET_MOUSE_POS: {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1985 int button = -1, pointer_x, pointer_y;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1986 double dx, dy;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1987 pointer_x = cmd->args[0].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1988 pointer_y = cmd->args[1].v.i;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1989 rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1990 #ifdef USE_DVDNAV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1991 if (mpctx->stream->type == STREAMTYPE_DVDNAV && dx > 0.0 && dy > 0.0) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1992 pointer_x = (int) (dx * (double) sh_video->disp_w);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1993 pointer_y = (int) (dy * (double) sh_video->disp_h);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1994 mp_dvdnav_update_mouse_pos(mpctx->stream, pointer_x, pointer_y, &button);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1995 if(button>0) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Selected button number %d", button);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1996 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1997 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1998 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
1999 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2000 #ifdef USE_DVDNAV
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2001 case MP_CMD_DVDNAV: {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2002 int button = -1;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2003 if (mpctx->stream->type != STREAMTYPE_DVDNAV) break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2004
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2005 if (mp_dvdnav_handle_input (mpctx->stream, cmd->args[0].v.i, &button)) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2006 uninit_player(INITED_ALL-(INITED_STREAM|INITED_INPUT|(fixed_vo ? INITED_VO : 0)));
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2007 brk_cmd = 2;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2008 } else if(button>0) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, "Selected button number %d", button);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2009 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2010 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2011 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2012 default : {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2013 #ifdef HAVE_NEW_GUI
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2014 if ( ( use_gui )&&( cmd->id > MP_CMD_GUI_EVENTS ) ) guiGetEvent( guiIEvent,(char *)cmd->id );
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2015 else
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2016 #endif
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2017 mp_msg(MSGT_CPLAYER, MSGL_V, "Received unknown cmd %s\n",cmd->name);
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2018 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2019 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2020 switch (cmd->pausing) {
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2021 case 1: // "pausing"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2022 mpctx->osd_function = OSD_PAUSE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2023 break;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2024 case 3: // "pausing_toggle"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2025 mpctx->was_paused = !mpctx->was_paused;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2026 // fall through
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2027 case 2: // "pausing_keep"
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2028 if (mpctx->was_paused) mpctx->osd_function = OSD_PAUSE;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2029 }
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2030 return brk_cmd;
3501ae650b23 Add alternative way to create command.c to svn history,
uau
parents:
diff changeset
2031 }