Mercurial > mplayer.hg
annotate m_property.c @ 24091:e7df91814c0f
Minor code cleanup
Move timed hiding of OSD progress bar to the same place where OSD
messages are timed out.
author | uau |
---|---|
date | Tue, 21 Aug 2007 00:24:13 +0000 |
parents | ae4237717601 |
children | 3086b6d39052 |
rev | line source |
---|---|
18258 | 1 |
2 /// \file | |
3 /// \ingroup Properties | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
4 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
5 #include "config.h" |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
6 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
7 #include <stdlib.h> |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
8 #include <stdio.h> |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
9 #include <string.h> |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
10 #include <inttypes.h> |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
11 #include <unistd.h> |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
12 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
13 #include "m_option.h" |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
14 #include "m_property.h" |
17914
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
15 #include "mp_msg.h" |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
16 #include "help_mp.h" |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
17 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
18 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5)) |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
19 |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
20 static int do_action(m_option_t* prop_list, const char* name, |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
21 int action, void* arg, void *ctx) { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
22 const char* sep; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
23 m_option_t* prop; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
24 m_property_action_t ka; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
25 int r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
26 if((sep = strchr(name,'/')) && sep[1]) { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
27 int len = sep-name; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
28 char base[len+1]; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
29 memcpy(base,name,len); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
30 base[len] = 0; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
31 prop = m_option_list_find(prop_list, base); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
32 ka.key = sep+1; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
33 ka.action = action; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
34 ka.arg = arg; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
35 action = M_PROPERTY_KEY_ACTION; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
36 arg = &ka; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
37 } else |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
38 prop = m_option_list_find(prop_list, name); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
39 if(!prop) return M_PROPERTY_UNKNOWN; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
40 r = ((m_property_ctrl_f)prop->p)(prop,action,arg,ctx); |
23395
0ff039835f0f
Fix fallback on the default GET_TYPE for unvailable/disabled
albeu
parents:
23394
diff
changeset
|
41 if(action == M_PROPERTY_GET_TYPE && r < 0) { |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
42 if(!arg) return M_PROPERTY_ERROR; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
43 *(m_option_t**)arg = prop; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
44 return M_PROPERTY_OK; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
45 } |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
46 return r; |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
47 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
48 |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
49 int m_property_do(m_option_t* prop_list, const char* name, |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
50 int action, void* arg, void *ctx) { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
51 m_option_t* opt; |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
52 void* val; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
53 char* str; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
54 int r; |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
55 |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
56 switch(action) { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
57 case M_PROPERTY_PRINT: |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
58 if((r = do_action(prop_list,name,M_PROPERTY_PRINT,arg,ctx)) >= 0) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
59 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
60 // fallback on the default print for this type |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
61 case M_PROPERTY_TO_STRING: |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
62 if((r = do_action(prop_list,name,M_PROPERTY_TO_STRING,arg,ctx)) != |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
63 M_PROPERTY_NOT_IMPLEMENTED) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
64 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
65 // fallback on the options API. Get the type, value and print. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
66 if((r = do_action(prop_list,name,M_PROPERTY_GET_TYPE,&opt,ctx)) <= 0) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
67 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
68 val = calloc(1,opt->type->size); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
69 if((r = do_action(prop_list,name,M_PROPERTY_GET,val,ctx)) <= 0) { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
70 free(val); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
71 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
72 } |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
73 if(!arg) return M_PROPERTY_ERROR; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
74 str = m_option_print(opt,val); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
75 free(val); |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
76 *(char**)arg = str == (char*)-1 ? NULL : str; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
77 return str != (char*)-1; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
78 case M_PROPERTY_PARSE: |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
79 // try the property own parsing func |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
80 if((r = do_action(prop_list,name,M_PROPERTY_PARSE,arg,ctx)) != |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
81 M_PROPERTY_NOT_IMPLEMENTED) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
82 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
83 // fallback on the options API, get the type and parse. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
84 if((r = do_action(prop_list,name,M_PROPERTY_GET_TYPE,&opt,ctx)) <= 0) |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
85 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
86 if(!arg) return M_PROPERTY_ERROR; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
87 val = calloc(1,opt->type->size); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
88 if((r = m_option_parse(opt,opt->name,arg,val,M_CONFIG_FILE)) <= 0) { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
89 free(val); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
90 return r; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
91 } |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
92 r = do_action(prop_list,name,M_PROPERTY_SET,val,ctx); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
93 m_option_free(opt,val); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
94 free(val); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
95 return r; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
96 } |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
97 return do_action(prop_list,name,action,arg,ctx); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
98 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
99 |
22280
a5e5b0c45c03
Split command/property handling from mplayer.c to a new file command.c.
uau
parents:
18258
diff
changeset
|
100 char* m_properties_expand_string(m_option_t* prop_list,char* str, void *ctx) { |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
101 int l,fr=0,pos=0,size=strlen(str)+512; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
102 char *p = NULL,*e,*ret = malloc(size), num_val; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
103 int skip = 0, lvl = 0, skip_lvl = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
104 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
105 while(str[0]) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
106 if(str[0] == '\\') { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
107 int sl = 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
108 switch(str[1]) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
109 case 'e': |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
110 p = "\x1b", l = 1; break; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
111 case 'n': |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
112 p = "\n", l = 1; break; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
113 case 'r': |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
114 p = "\r", l = 1; break; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
115 case 't': |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
116 p = "\t", l = 1; break; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
117 case 'x': |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
118 if(str[2]) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
119 char num[3] = { str[2], str[3], 0 }; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
120 char* end = num; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
121 num_val = strtol(num,&end,16); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
122 sl = end-num; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
123 l = 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
124 p = &num_val; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
125 } else |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
126 l = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
127 break; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
128 default: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
129 p = str+1, l = 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
130 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
131 str+=1+sl; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
132 } else if(lvl > 0 && str[0] == ')') { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
133 if(skip && lvl <= skip_lvl) skip = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
134 lvl--, str++, l = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
135 } else if(str[0] == '$' && str[1] == '{' && (e = strchr(str+2,'}'))) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
136 int pl = e-str-2; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
137 char pname[pl+1]; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
138 memcpy(pname,str+2,pl); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
139 pname[pl] = 0; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
140 if(m_property_do(prop_list, pname, |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
141 M_PROPERTY_PRINT, &p, ctx) >= 0 && p) |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
142 l = strlen(p), fr = 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
143 else |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
144 l = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
145 str = e+1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
146 } else if(str[0] == '?' && str[1] == '(' && (e = strchr(str+2,':'))) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
147 int pl = e-str-2; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
148 char pname[pl+1]; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
149 lvl++; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
150 if(!skip) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
151 memcpy(pname,str+2,pl); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
152 pname[pl] = 0; |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
153 if(m_property_do(prop_list,pname,M_PROPERTY_GET,NULL,ctx) < 0) |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
154 skip = 1, skip_lvl = lvl; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
155 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
156 str = e+1, l = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
157 } else |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
158 p = str, l = 1, str++; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
159 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
160 if(skip || l <= 0) continue; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
161 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
162 if(pos+l+1 > size) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
163 size = pos+l+512; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
164 ret = realloc(ret,size); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
165 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
166 memcpy(ret+pos,p,l); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
167 pos += l; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
168 if(fr) free(p), fr = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
169 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
170 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
171 ret[pos] = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
172 return ret; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
173 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
174 |
17914
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
175 void m_properties_print_help_list(m_option_t* list) { |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
176 char min[50],max[50]; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
177 int i,count = 0; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
178 |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
179 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_PropertyListHeader); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
180 for(i = 0 ; list[i].name ; i++) { |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
181 m_option_t* opt = &list[i]; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
182 if(opt->flags & M_OPT_MIN) |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
183 sprintf(min,"%-8.0f",opt->min); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
184 else |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
185 strcpy(min,"No"); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
186 if(opt->flags & M_OPT_MAX) |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
187 sprintf(max,"%-8.0f",opt->max); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
188 else |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
189 strcpy(max,"No"); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
190 mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %-20.20s %-15.15s %-10.10s %-10.10s\n", |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
191 opt->name, |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
192 opt->type->name, |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
193 min, |
17927 | 194 max); |
17914
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
195 count++; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
196 } |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
197 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalProperties, count); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
198 } |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
199 |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
200 // Some generic property implementations |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
201 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
202 int m_property_int_ro(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
203 void* arg,int var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
204 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
205 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
206 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
207 *(int*)arg = var; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
208 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
209 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
210 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
211 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
212 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
213 int m_property_int_range(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
214 void* arg,int* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
215 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
216 case M_PROPERTY_SET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
217 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
218 M_PROPERTY_CLAMP(prop,*(int*)arg); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
219 *var = *(int*)arg; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
220 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
221 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
222 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
223 *var += (arg ? *(int*)arg : 1) * |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
224 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
225 M_PROPERTY_CLAMP(prop,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
226 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
227 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
228 return m_property_int_ro(prop,action,arg,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
229 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
230 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
231 int m_property_choice(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
232 void* arg,int* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
233 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
234 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
235 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
236 *var += action == M_PROPERTY_STEP_UP ? 1 : prop->max; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
237 *var %= (int)prop->max+1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
238 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
239 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
240 return m_property_int_range(prop,action,arg,var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
241 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
242 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
243 int m_property_flag(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
244 void* arg,int* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
245 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
246 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
247 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
248 *var = *var == prop->min ? prop->max : prop->min; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
249 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
250 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
251 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
252 *(char**)arg = strdup((*var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
253 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
254 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
255 return m_property_int_range(prop,action,arg,var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
256 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
257 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
258 int m_property_float_ro(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
259 void* arg,float var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
260 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
261 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
262 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
263 *(float*)arg = var; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
264 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
265 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
266 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
267 *(char**)arg = malloc(20); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
268 sprintf(*(char**)arg,"%.2f",var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
269 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
270 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
271 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
272 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
273 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
274 int m_property_float_range(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
275 void* arg,float* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
276 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
277 case M_PROPERTY_SET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
278 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
279 M_PROPERTY_CLAMP(prop,*(float*)arg); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
280 *var = *(float*)arg; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
281 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
282 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
283 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
284 *var += (arg ? *(float*)arg : 0.1) * |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
285 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
286 M_PROPERTY_CLAMP(prop,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
287 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
288 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
289 return m_property_float_ro(prop,action,arg,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
290 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
291 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
292 int m_property_delay(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
293 void* arg,float* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
294 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
295 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
296 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
297 *(char**)arg = malloc(20); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
298 sprintf(*(char**)arg,"%d ms",ROUND((*var)*1000)); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
299 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
300 default: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
301 return m_property_float_range(prop,action,arg,var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
302 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
303 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
304 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
305 int m_property_double_ro(m_option_t* prop,int action, |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
306 void* arg,double var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
307 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
308 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
309 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
310 *(double*)arg = var; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
311 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
312 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
313 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
314 *(char**)arg = malloc(20); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
315 sprintf(*(char**)arg,"%.2f",var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
316 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
317 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
318 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
319 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
320 |
23416
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
321 int m_property_time_ro(m_option_t* prop,int action, |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
322 void* arg,double var) { |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
323 switch(action) { |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
324 case M_PROPERTY_PRINT: |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
325 if (!arg) |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
326 return M_PROPERTY_ERROR; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
327 else { |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
328 int h, m, s = var; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
329 h = s / 3600; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
330 s -= h * 3600; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
331 m = s / 60; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
332 s -= m * 60; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
333 *(char **) arg = malloc(20); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
334 if (h > 0) |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
335 sprintf(*(char **) arg, "%d:%02d:%02d", h, m, s); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
336 else if (m > 0) |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
337 sprintf(*(char **) arg, "%d:%02d", m, s); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
338 else |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
339 sprintf(*(char **) arg, "%d", s); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
340 return M_PROPERTY_OK; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
341 } |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
342 } |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
343 return m_property_double_ro(prop,action,arg,var); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
344 } |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
345 |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
346 int m_property_string_ro(m_option_t* prop,int action,void* arg,char* str) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
347 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
348 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
349 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
350 *(char**)arg = str; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
351 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
352 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
353 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
354 *(char**)arg = str ? strdup(str) : NULL; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
355 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
356 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
357 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
358 } |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
359 |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
360 int m_property_bitrate(m_option_t* prop,int action,void* arg,int rate) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
361 switch(action) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
362 case M_PROPERTY_PRINT: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
363 if (!arg) |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
364 return M_PROPERTY_ERROR; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
365 *(char**)arg = malloc (16); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
366 sprintf(*(char**)arg, "%d kbps", rate*8/1000); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
367 return M_PROPERTY_OK; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
368 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
369 return m_property_int_ro(prop, action, arg, rate); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
370 } |