Mercurial > mplayer.hg
annotate m_property.h @ 25961:354ad909efcf
add ffpcx decoder, works on my samples.
author | compn |
---|---|
date | Wed, 13 Feb 2008 21:36:27 +0000 |
parents | fc8d4bd1689a |
children | 4129c8cfa742 |
rev | line source |
---|---|
25553
6ac1ece1f9fe
Add multiple inclusion guards to all header files that lack them.
diego
parents:
23416
diff
changeset
|
1 #ifndef M_PROPERTY_H |
6ac1ece1f9fe
Add multiple inclusion guards to all header files that lack them.
diego
parents:
23416
diff
changeset
|
2 #define M_PROPERTY_H |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
3 |
18258 | 4 /// \defgroup Properties |
5 /// | |
6 /// Properties provide an interface to query and set the state of various | |
7 /// things in MPlayer. The API is based on the \ref Options API like the | |
8 /// \ref Config, but instead of using variables, properties use an ioctl like | |
9 /// function. The function is used to perform various actions like get and set | |
10 /// (see \ref PropertyActions). | |
11 ///@{ | |
12 | |
13 /// \file | |
14 | |
15 /// \defgroup PropertyActions Property actions | |
16 /// \ingroup Properties | |
17 ///@{ | |
18 | |
19 /// Get the current value. | |
20 /** \param arg Pointer to a variable of the right type. | |
21 */ | |
22 #define M_PROPERTY_GET 0 | |
23 | |
24 /// Get a string representing the current value. | |
25 /** Set the variable to a newly allocated string or NULL. | |
26 * \param arg Pointer to a char* variable. | |
27 */ | |
28 #define M_PROPERTY_PRINT 1 | |
29 | |
30 /// Set a new value. | |
31 /** The variable is updated to the value actually set. | |
32 * \param arg Pointer to a variable of the right type. | |
33 */ | |
34 #define M_PROPERTY_SET 2 | |
35 | |
36 /// Set a new value from a string. | |
37 /** \param arg String containing the value. | |
38 */ | |
39 #define M_PROPERTY_PARSE 3 | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
40 |
18258 | 41 /// Increment the current value. |
42 /** The sign of the argument is also taken into account if applicable. | |
43 * \param arg Pointer to a variable of the right type or NULL. | |
44 */ | |
45 #define M_PROPERTY_STEP_UP 4 | |
46 | |
47 /// Decrement the current value. | |
48 /** The sign of the argument is also taken into account if applicable. | |
49 * \param arg Pointer to a variable of the right type or NULL. | |
50 */ | |
51 #define M_PROPERTY_STEP_DOWN 5 | |
52 | |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
53 /// Get a string containg a parsable representation. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
54 /** Set the variable to a newly allocated string or NULL. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
55 * \param arg Pointer to a char* variable. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
56 */ |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
57 #define M_PROPERTY_TO_STRING 6 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
58 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
59 /// Pass down an action to a sub-property. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
60 #define M_PROPERTY_KEY_ACTION 7 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
61 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
62 /// Get a m_option describing the property. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
63 #define M_PROPERTY_GET_TYPE 8 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
64 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
65 ///@} |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
66 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
67 /// \defgroup PropertyActionsArg Property actions argument type |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
68 /// \ingroup Properties |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
69 /// \brief Types used as action argument. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
70 ///@{ |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
71 |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
72 /// Argument for \ref M_PROPERTY_KEY_ACTION |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
73 typedef struct { |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
74 const char* key; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
75 int action; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
76 void* arg; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
77 } m_property_action_t; |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
78 |
18258 | 79 ///@} |
80 | |
81 /// \defgroup PropertyActionsReturn Property actions return code | |
82 /// \ingroup Properties | |
83 /// \brief Return values for the control function. | |
84 ///@{ | |
85 | |
86 /// Returned on success. | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
87 #define M_PROPERTY_OK 1 |
18258 | 88 |
89 /// Returned on error. | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
90 #define M_PROPERTY_ERROR 0 |
18258 | 91 |
18283 | 92 /// \brief Returned when the property can't be used, for example something about |
18258 | 93 /// the subs while playing audio only |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
94 #define M_PROPERTY_UNAVAILABLE -1 |
18258 | 95 |
96 /// Returned if the requested action is not implemented. | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
97 #define M_PROPERTY_NOT_IMPLEMENTED -2 |
18258 | 98 |
99 /// Returned when asking for a property that doesn't exist. | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
100 #define M_PROPERTY_UNKNOWN -3 |
18258 | 101 |
102 /// Returned when the action can't be done (like setting the volume when edl mute). | |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
103 #define M_PROPERTY_DISABLED -4 |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
104 |
18258 | 105 ///@} |
106 | |
107 /// \ingroup Properties | |
108 /// \brief Property action callback. | |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
109 typedef int(*m_property_ctrl_f)(const m_option_t* prop,int action,void* arg,void *ctx); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
110 |
18258 | 111 /// Do an action on a property. |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
112 /** \param prop_list The list of properties. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
113 * \param prop The path of the property. |
18258 | 114 * \param action See \ref PropertyActions. |
115 * \param arg Argument, usually a pointer to the data type used by the property. | |
116 * \return See \ref PropertyActionsReturn. | |
117 */ | |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
118 int m_property_do(const m_option_t* prop_list, const char* prop, |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
119 int action, void* arg, void *ctx); |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
120 |
18258 | 121 /// Print a list of properties. |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
122 void m_properties_print_help_list(const m_option_t* list); |
17914
f9cb6fc1608a
Add an option to list the properties: -list-properties
albeu
parents:
17911
diff
changeset
|
123 |
18258 | 124 /// Expand a property string. |
18283 | 125 /** This function allows to print strings containing property values. |
18258 | 126 * ${NAME} is expanded to the value of property NAME or an empty |
127 * string in case of error. $(NAME:STR) expand STR only if the property | |
128 * NAME is available. | |
129 * | |
130 * \param prop_list An array of \ref m_option describing the available | |
131 * properties. | |
132 * \param str The string to expand. | |
133 * \return The newly allocated expanded string. | |
134 */ | |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
135 char* m_properties_expand_string(const 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
|
136 |
18189 | 137 // Helpers to use MPlayer's properties |
138 | |
18258 | 139 /// Do an action with an MPlayer property. |
22280
a5e5b0c45c03
Split command/property handling from mplayer.c to a new file command.c.
uau
parents:
19104
diff
changeset
|
140 int mp_property_do(const char* name,int action, void* val, void *ctx); |
18189 | 141 |
23393
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
142 /// Get the value of a property as a string suitable for display in an UI. |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
143 char* mp_property_print(const char *name, void* ctx); |
a5e55cb59bbc
Rework the property API to allow sub properties such as
albeu
parents:
22280
diff
changeset
|
144 |
18258 | 145 /// \defgroup PropertyImplHelper Property implementation helpers |
146 /// \ingroup Properties | |
147 /// \brief Helper functions for common property types. | |
148 ///@{ | |
18189 | 149 |
18258 | 150 /// Clamp a value according to \ref m_option::min and \ref m_option::max. |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
151 #define M_PROPERTY_CLAMP(prop,val) do { \ |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
152 if(((prop)->flags & M_OPT_MIN) && (val) < (prop)->min) \ |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
153 (val) = (prop)->min; \ |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
154 else if(((prop)->flags & M_OPT_MAX) && (val) > (prop)->max) \ |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
155 (val) = (prop)->max; \ |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
156 } while(0) |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
157 |
18258 | 158 /// Implement get. |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
159 int m_property_int_ro(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
160 void* arg,int var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
161 |
18258 | 162 /// Implement set, get and step up/down. |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
163 int m_property_int_range(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
164 void* arg,int* var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
165 |
18258 | 166 /// Same as m_property_int_range but cycle. |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
167 int m_property_choice(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
168 void* arg,int* var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
169 |
18258 | 170 /// Switch betwen min and max. |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
171 int m_property_flag(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
172 void* arg,int* var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
173 |
18258 | 174 /// Implement get, print. |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
175 int m_property_float_ro(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
176 void* arg,float var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
177 |
18258 | 178 /// Implement set, get and step up/down |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
179 int m_property_float_range(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
180 void* arg,float* var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
181 |
18258 | 182 /// float with a print function which print the time in ms |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
183 int m_property_delay(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
184 void* arg,float* var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
185 |
18258 | 186 /// Implement get, print |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
187 int m_property_double_ro(const m_option_t* prop,int action, |
17911
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
188 void* arg,double var); |
52f95509cd05
Add the new property API and implement a couple properties.
albeu
parents:
diff
changeset
|
189 |
23416
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23394
diff
changeset
|
190 /// Implement print |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
191 int m_property_time_ro(const m_option_t* prop,int action, |
23416
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23394
diff
changeset
|
192 void* arg,double var); |
ae4237717601
Move the time printing code out of the length property.
albeu
parents:
23394
diff
changeset
|
193 |
18258 | 194 /// get/print the string |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
195 int m_property_string_ro(const m_option_t* prop,int action,void* arg, char* str); |
18258 | 196 |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
197 /// get/print a bitrate |
25716
fc8d4bd1689a
All the m_property stuff works fine with constant m_option_t
reimar
parents:
25553
diff
changeset
|
198 int m_property_bitrate(const m_option_t* prop,int action,void* arg,int rate); |
23394
d4e8613ddc95
Make all the info available via the metadata API available via properties.
albeu
parents:
23393
diff
changeset
|
199 |
18258 | 200 ///@} |
201 | |
202 ///@} | |
25553
6ac1ece1f9fe
Add multiple inclusion guards to all header files that lack them.
diego
parents:
23416
diff
changeset
|
203 |
6ac1ece1f9fe
Add multiple inclusion guards to all header files that lack them.
diego
parents:
23416
diff
changeset
|
204 #endif /* M_PROPERTY_H */ |