vf_uspp: drop this filter
[mplayer.git] / m_property.h
blob1e377f8dc26482c9e97a35a26f310c068622048d
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_M_PROPERTY_H
20 #define MPLAYER_M_PROPERTY_H
22 #include "m_option.h"
24 /// \defgroup Properties
25 ///
26 /// Properties provide an interface to query and set the state of various
27 /// things in MPlayer. The API is based on the \ref Options API like the
28 /// \ref Config, but instead of using variables, properties use an ioctl like
29 /// function. The function is used to perform various actions like get and set
30 /// (see \ref PropertyActions).
31 ///@{
33 /// \file
35 /// \defgroup PropertyActions Property actions
36 /// \ingroup Properties
37 ///@{
39 /// Get the current value.
40 /** \param arg Pointer to a variable of the right type.
42 #define M_PROPERTY_GET 0
44 /// Get a string representing the current value.
45 /** Set the variable to a newly allocated string or NULL.
46 * \param arg Pointer to a char* variable.
48 #define M_PROPERTY_PRINT 1
50 /// Set a new value.
51 /** The variable is updated to the value actually set.
52 * \param arg Pointer to a variable of the right type.
54 #define M_PROPERTY_SET 2
56 /// Set a new value from a string.
57 /** \param arg String containing the value.
59 #define M_PROPERTY_PARSE 3
62 * \param arg Pointer to a variable of the right type or NULL.
64 #define M_PROPERTY_STEP 4
66 /// Get a string containg a parsable representation.
67 /** Set the variable to a newly allocated string or NULL.
68 * \param arg Pointer to a char* variable.
70 #define M_PROPERTY_TO_STRING 6
72 /// Pass down an action to a sub-property.
73 #define M_PROPERTY_KEY_ACTION 7
75 /// Get a m_option describing the property.
76 #define M_PROPERTY_GET_TYPE 8
78 ///@}
80 /// \defgroup PropertyActionsArg Property actions argument type
81 /// \ingroup Properties
82 /// \brief Types used as action argument.
83 ///@{
85 /// Argument for \ref M_PROPERTY_KEY_ACTION
86 typedef struct {
87 const char* key;
88 int action;
89 void* arg;
90 } m_property_action_t;
92 ///@}
94 /// \defgroup PropertyActionsReturn Property actions return code
95 /// \ingroup Properties
96 /// \brief Return values for the control function.
97 ///@{
99 /// Returned on success.
100 #define M_PROPERTY_OK 1
102 /// Returned on error.
103 #define M_PROPERTY_ERROR 0
105 /// \brief Returned when the property can't be used, for example something about
106 /// the subs while playing audio only
107 #define M_PROPERTY_UNAVAILABLE -1
109 /// Returned if the requested action is not implemented.
110 #define M_PROPERTY_NOT_IMPLEMENTED -2
112 /// Returned when asking for a property that doesn't exist.
113 #define M_PROPERTY_UNKNOWN -3
115 /// Returned when the action can't be done (like setting the volume when edl mute).
116 #define M_PROPERTY_DISABLED -4
118 ///@}
120 /// \ingroup Properties
121 /// \brief Property action callback.
122 typedef int(*m_property_ctrl_f)(const m_option_t* prop,int action,void* arg,void *ctx);
124 /// Do an action on a property.
125 /** \param prop_list The list of properties.
126 * \param prop The path of the property.
127 * \param action See \ref PropertyActions.
128 * \param arg Argument, usually a pointer to the data type used by the property.
129 * \return See \ref PropertyActionsReturn.
131 int m_property_do(const m_option_t* prop_list, const char* prop,
132 int action, void* arg, void *ctx);
134 /// Print a list of properties.
135 void m_properties_print_help_list(const m_option_t* list);
137 /// Expand a property string.
138 /** This function allows to print strings containing property values.
139 * ${NAME} is expanded to the value of property NAME or an empty
140 * string in case of error. $(NAME:STR) expand STR only if the property
141 * NAME is available.
143 * \param prop_list An array of \ref m_option describing the available
144 * properties.
145 * \param str The string to expand.
146 * \return The newly allocated expanded string.
148 char* m_properties_expand_string(const m_option_t* prop_list,char* str, void *ctx);
150 // Helpers to use MPlayer's properties
152 /// Do an action with an MPlayer property.
153 int mp_property_do(const char* name,int action, void* val, void *ctx);
155 /// Get the value of a property as a string suitable for display in an UI.
156 char* mp_property_print(const char *name, void* ctx);
158 /// \defgroup PropertyImplHelper Property implementation helpers
159 /// \ingroup Properties
160 /// \brief Helper functions for common property types.
161 ///@{
163 /// Clamp a value according to \ref m_option::min and \ref m_option::max.
164 #define M_PROPERTY_CLAMP(prop,val) do { \
165 if(((prop)->flags & M_OPT_MIN) && (val) < (prop)->min) \
166 (val) = (prop)->min; \
167 else if(((prop)->flags & M_OPT_MAX) && (val) > (prop)->max) \
168 (val) = (prop)->max; \
169 } while(0)
171 /// Implement get.
172 int m_property_int_ro(const m_option_t* prop,int action,
173 void* arg,int var);
175 /// Implement set, get and step up/down.
176 int m_property_int_range(const m_option_t* prop,int action,
177 void* arg,int* var);
179 /// Same as m_property_int_range but cycle.
180 int m_property_choice(const m_option_t* prop,int action,
181 void* arg,int* var);
183 int m_property_flag_ro(const m_option_t* prop,int action,
184 void* arg,int var);
186 /// Switch betwen min and max.
187 int m_property_flag(const m_option_t* prop,int action,
188 void* arg,int* var);
190 /// Implement get, print.
191 int m_property_float_ro(const m_option_t* prop,int action,
192 void* arg,float var);
194 /// Implement set, get and step up/down
195 int m_property_float_range(const m_option_t* prop,int action,
196 void* arg,float* var);
198 /// float with a print function which print the time in ms
199 int m_property_delay(const m_option_t* prop,int action,
200 void* arg,float* var);
202 /// Implement get, print
203 int m_property_double_ro(const m_option_t* prop,int action,
204 void* arg,double var);
206 /// Implement print
207 int m_property_time_ro(const m_option_t* prop,int action,
208 void* arg,double var);
210 /// get/print the string
211 int m_property_string_ro(const m_option_t* prop,int action,void* arg, char* str);
213 /// get/print a bitrate
214 int m_property_bitrate(const m_option_t* prop,int action,void* arg,int rate);
216 ///@}
218 ///@}
220 #endif /* MPLAYER_M_PROPERTY_H */