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