Mercurial > mplayer.hg
annotate m_property.c @ 25588:0f344d22ee48
Fix compilation due to conflicting type declaration:
qtx/list.c:22: error: conflicting types for 'OSErr'
qtx/qtxsdk/components.h:15: error: previous declaration of 'OSErr' was here
author | diego |
---|---|
date | Sun, 06 Jan 2008 11:45:47 +0000 |
parents | 26a839637972 |
children | fc8d4bd1689a |
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 lvl++; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
148 if(!skip) { |
25501
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
149 int is_not = str[2] == '!'; |
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
150 int pl = e - str - (is_not ? 3 : 2); |
25460
3086b6d39052
Move two variable to the scope where they are indeed used.
ulion
parents:
23416
diff
changeset
|
151 char pname[pl+1]; |
25501
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
152 memcpy(pname, str + (is_not ? 3 : 2), pl); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
153 pname[pl] = 0; |
25501
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
154 if(m_property_do(prop_list,pname,M_PROPERTY_GET,NULL,ctx) < 0) { |
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
155 if (!is_not) |
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
156 skip = 1, skip_lvl = lvl; |
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
157 } |
26a839637972
Support ?(!NAME:TEXT) format for expanding string by property.
ulion
parents:
25460
diff
changeset
|
158 else if (is_not) |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
159 skip = 1, skip_lvl = lvl; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
160 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
161 str = e+1, l = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
162 } else |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
163 p = str, l = 1, str++; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
164 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
165 if(skip || l <= 0) continue; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
166 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
167 if(pos+l+1 > size) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
168 size = pos+l+512; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
169 ret = realloc(ret,size); |
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 memcpy(ret+pos,p,l); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
172 pos += l; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
173 if(fr) free(p), fr = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
174 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
175 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
176 ret[pos] = 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
177 return ret; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
178 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
179 |
17914
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
180 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
|
181 char min[50],max[50]; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
182 int i,count = 0; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
183 |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
184 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_PropertyListHeader); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
185 for(i = 0 ; list[i].name ; i++) { |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
186 m_option_t* opt = &list[i]; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
187 if(opt->flags & M_OPT_MIN) |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
188 sprintf(min,"%-8.0f",opt->min); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
189 else |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
190 strcpy(min,"No"); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
191 if(opt->flags & M_OPT_MAX) |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
192 sprintf(max,"%-8.0f",opt->max); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
193 else |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
194 strcpy(max,"No"); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
195 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
|
196 opt->name, |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
197 opt->type->name, |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
198 min, |
17927 | 199 max); |
17914
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
200 count++; |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
201 } |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
202 mp_msg(MSGT_CFGPARSER, MSGL_INFO, MSGTR_TotalProperties, count); |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
203 } |
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
204 |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
205 // Some generic property implementations |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
206 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
207 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
|
208 void* arg,int var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
209 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
210 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
211 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
212 *(int*)arg = var; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
213 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
214 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
215 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
216 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
217 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
218 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
|
219 void* arg,int* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
220 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
221 case M_PROPERTY_SET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
222 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
223 M_PROPERTY_CLAMP(prop,*(int*)arg); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
224 *var = *(int*)arg; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
225 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
226 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
227 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
228 *var += (arg ? *(int*)arg : 1) * |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
229 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
230 M_PROPERTY_CLAMP(prop,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
231 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
232 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
233 return m_property_int_ro(prop,action,arg,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
234 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
235 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
236 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
|
237 void* arg,int* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
238 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
239 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
240 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
241 *var += action == M_PROPERTY_STEP_UP ? 1 : prop->max; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
242 *var %= (int)prop->max+1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
243 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
244 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
245 return m_property_int_range(prop,action,arg,var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
246 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
247 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
248 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
|
249 void* arg,int* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
250 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
251 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
252 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
253 *var = *var == prop->min ? prop->max : prop->min; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
254 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
255 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
256 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
257 *(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
|
258 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
259 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
260 return m_property_int_range(prop,action,arg,var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
261 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
262 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
263 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
|
264 void* arg,float var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
265 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
266 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
267 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
268 *(float*)arg = 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 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
271 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
272 *(char**)arg = malloc(20); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
273 sprintf(*(char**)arg,"%.2f",var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
274 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
275 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
276 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
277 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
278 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
279 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
|
280 void* arg,float* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
281 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
282 case M_PROPERTY_SET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
283 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
284 M_PROPERTY_CLAMP(prop,*(float*)arg); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
285 *var = *(float*)arg; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
286 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
287 case M_PROPERTY_STEP_UP: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
288 case M_PROPERTY_STEP_DOWN: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
289 *var += (arg ? *(float*)arg : 0.1) * |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
290 (action == M_PROPERTY_STEP_DOWN ? -1 : 1); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
291 M_PROPERTY_CLAMP(prop,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
292 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
293 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
294 return m_property_float_ro(prop,action,arg,*var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
295 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
296 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
297 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
|
298 void* arg,float* var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
299 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
300 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
301 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
302 *(char**)arg = malloc(20); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
303 sprintf(*(char**)arg,"%d ms",ROUND((*var)*1000)); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
304 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
305 default: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
306 return m_property_float_range(prop,action,arg,var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
307 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
308 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
309 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
310 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
|
311 void* arg,double var) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
312 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
313 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
314 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
315 *(double*)arg = 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 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
318 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
319 *(char**)arg = malloc(20); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
320 sprintf(*(char**)arg,"%.2f",var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
321 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
322 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
323 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
324 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
325 |
23416
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
326 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
|
327 void* arg,double var) { |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
328 switch(action) { |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
329 case M_PROPERTY_PRINT: |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
330 if (!arg) |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
331 return M_PROPERTY_ERROR; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
332 else { |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
333 int h, m, s = var; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
334 h = s / 3600; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
335 s -= h * 3600; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
336 m = s / 60; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
337 s -= m * 60; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
338 *(char **) arg = malloc(20); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
339 if (h > 0) |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
340 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
|
341 else if (m > 0) |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
342 sprintf(*(char **) arg, "%d:%02d", m, s); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
343 else |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
344 sprintf(*(char **) arg, "%d", s); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
345 return M_PROPERTY_OK; |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
346 } |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
347 } |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
348 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
|
349 } |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23395
diff
changeset
|
350 |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
351 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
|
352 switch(action) { |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
353 case M_PROPERTY_GET: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
354 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
355 *(char**)arg = str; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
356 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
357 case M_PROPERTY_PRINT: |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
358 if(!arg) return 0; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
359 *(char**)arg = str ? strdup(str) : NULL; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
360 return 1; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
361 } |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
362 return M_PROPERTY_NOT_IMPLEMENTED; |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
363 } |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
364 |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
365 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
|
366 switch(action) { |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
367 case M_PROPERTY_PRINT: |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
368 if (!arg) |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
369 return M_PROPERTY_ERROR; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
370 *(char**)arg = malloc (16); |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
371 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
|
372 return M_PROPERTY_OK; |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
373 } |
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
374 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
|
375 } |