2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_M_PROPERTY_H
|
|
|
|
#define MPLAYER_M_PROPERTY_H
|
2006-03-22 00:19:02 +00:00
|
|
|
|
2008-03-04 23:35:24 +00:00
|
|
|
#include "m_option.h"
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \defgroup Properties
|
|
|
|
///
|
|
|
|
/// Properties provide an interface to query and set the state of various
|
|
|
|
/// things in MPlayer. The API is based on the \ref Options API like the
|
|
|
|
/// \ref Config, but instead of using variables, properties use an ioctl like
|
|
|
|
/// function. The function is used to perform various actions like get and set
|
|
|
|
/// (see \ref PropertyActions).
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// \file
|
|
|
|
|
|
|
|
/// \defgroup PropertyActions Property actions
|
|
|
|
/// \ingroup Properties
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Get the current value.
|
|
|
|
/** \param arg Pointer to a variable of the right type.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_GET 0
|
|
|
|
|
|
|
|
/// Get a string representing the current value.
|
|
|
|
/** Set the variable to a newly allocated string or NULL.
|
|
|
|
* \param arg Pointer to a char* variable.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_PRINT 1
|
|
|
|
|
|
|
|
/// Set a new value.
|
|
|
|
/** The variable is updated to the value actually set.
|
|
|
|
* \param arg Pointer to a variable of the right type.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_SET 2
|
|
|
|
|
|
|
|
/// Set a new value from a string.
|
|
|
|
/** \param arg String containing the value.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_PARSE 3
|
|
|
|
|
|
|
|
/// Increment the current value.
|
|
|
|
/** The sign of the argument is also taken into account if applicable.
|
|
|
|
* \param arg Pointer to a variable of the right type or NULL.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_STEP_UP 4
|
|
|
|
|
|
|
|
/// Decrement the current value.
|
|
|
|
/** The sign of the argument is also taken into account if applicable.
|
|
|
|
* \param arg Pointer to a variable of the right type or NULL.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_STEP_DOWN 5
|
|
|
|
|
2007-05-29 21:49:39 +00:00
|
|
|
/// Get a string containg a parsable representation.
|
|
|
|
/** Set the variable to a newly allocated string or NULL.
|
|
|
|
* \param arg Pointer to a char* variable.
|
|
|
|
*/
|
|
|
|
#define M_PROPERTY_TO_STRING 6
|
|
|
|
|
|
|
|
/// Pass down an action to a sub-property.
|
|
|
|
#define M_PROPERTY_KEY_ACTION 7
|
|
|
|
|
|
|
|
/// Get a m_option describing the property.
|
|
|
|
#define M_PROPERTY_GET_TYPE 8
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
|
|
|
/// \defgroup PropertyActionsArg Property actions argument type
|
|
|
|
/// \ingroup Properties
|
|
|
|
/// \brief Types used as action argument.
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Argument for \ref M_PROPERTY_KEY_ACTION
|
|
|
|
typedef struct {
|
|
|
|
const char* key;
|
|
|
|
int action;
|
|
|
|
void* arg;
|
|
|
|
} m_property_action_t;
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
/// \defgroup PropertyActionsReturn Property actions return code
|
|
|
|
/// \ingroup Properties
|
|
|
|
/// \brief Return values for the control function.
|
|
|
|
///@{
|
|
|
|
|
|
|
|
/// Returned on success.
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_OK 1
|
2006-04-24 19:20:04 +00:00
|
|
|
|
|
|
|
/// Returned on error.
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_ERROR 0
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2006-04-25 18:48:53 +00:00
|
|
|
/// \brief Returned when the property can't be used, for example something about
|
2006-04-24 19:20:04 +00:00
|
|
|
/// the subs while playing audio only
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_UNAVAILABLE -1
|
2006-04-24 19:20:04 +00:00
|
|
|
|
|
|
|
/// Returned if the requested action is not implemented.
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_NOT_IMPLEMENTED -2
|
2006-04-24 19:20:04 +00:00
|
|
|
|
|
|
|
/// Returned when asking for a property that doesn't exist.
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_UNKNOWN -3
|
2006-04-24 19:20:04 +00:00
|
|
|
|
|
|
|
/// Returned when the action can't be done (like setting the volume when edl mute).
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_DISABLED -4
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
/// \ingroup Properties
|
|
|
|
/// \brief Property action callback.
|
2008-01-13 16:59:21 +00:00
|
|
|
typedef int(*m_property_ctrl_f)(const m_option_t* prop,int action,void* arg,void *ctx);
|
2006-03-22 00:19:02 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Do an action on a property.
|
2007-05-29 21:49:39 +00:00
|
|
|
/** \param prop_list The list of properties.
|
|
|
|
* \param prop The path of the property.
|
2006-04-24 19:20:04 +00:00
|
|
|
* \param action See \ref PropertyActions.
|
|
|
|
* \param arg Argument, usually a pointer to the data type used by the property.
|
|
|
|
* \return See \ref PropertyActionsReturn.
|
|
|
|
*/
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_do(const m_option_t* prop_list, const char* prop,
|
2007-05-29 21:49:39 +00:00
|
|
|
int action, void* arg, void *ctx);
|
2006-03-22 00:19:02 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Print a list of properties.
|
2008-01-13 16:59:21 +00:00
|
|
|
void m_properties_print_help_list(const m_option_t* list);
|
2006-03-22 16:35:17 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Expand a property string.
|
2006-04-25 18:48:53 +00:00
|
|
|
/** This function allows to print strings containing property values.
|
2006-04-24 19:20:04 +00:00
|
|
|
* ${NAME} is expanded to the value of property NAME or an empty
|
|
|
|
* string in case of error. $(NAME:STR) expand STR only if the property
|
|
|
|
* NAME is available.
|
2009-07-06 23:26:13 +00:00
|
|
|
*
|
2006-04-24 19:20:04 +00:00
|
|
|
* \param prop_list An array of \ref m_option describing the available
|
|
|
|
* properties.
|
|
|
|
* \param str The string to expand.
|
|
|
|
* \return The newly allocated expanded string.
|
|
|
|
*/
|
2008-01-13 16:59:21 +00:00
|
|
|
char* m_properties_expand_string(const m_option_t* prop_list,char* str, void *ctx);
|
2006-03-22 00:19:02 +00:00
|
|
|
|
2006-04-22 14:26:30 +00:00
|
|
|
// Helpers to use MPlayer's properties
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Do an action with an MPlayer property.
|
2007-02-21 00:49:24 +00:00
|
|
|
int mp_property_do(const char* name,int action, void* val, void *ctx);
|
2006-04-22 14:26:30 +00:00
|
|
|
|
2007-05-29 21:49:39 +00:00
|
|
|
/// Get the value of a property as a string suitable for display in an UI.
|
|
|
|
char* mp_property_print(const char *name, void* ctx);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// \defgroup PropertyImplHelper Property implementation helpers
|
|
|
|
/// \ingroup Properties
|
|
|
|
/// \brief Helper functions for common property types.
|
|
|
|
///@{
|
2006-04-22 14:26:30 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Clamp a value according to \ref m_option::min and \ref m_option::max.
|
2006-03-22 00:19:02 +00:00
|
|
|
#define M_PROPERTY_CLAMP(prop,val) do { \
|
|
|
|
if(((prop)->flags & M_OPT_MIN) && (val) < (prop)->min) \
|
|
|
|
(val) = (prop)->min; \
|
|
|
|
else if(((prop)->flags & M_OPT_MAX) && (val) > (prop)->max) \
|
|
|
|
(val) = (prop)->max; \
|
|
|
|
} while(0)
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Implement get.
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_int_ro(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,int var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Implement set, get and step up/down.
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_int_range(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,int* var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Same as m_property_int_range but cycle.
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_choice(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,int* var);
|
|
|
|
|
2008-10-01 17:05:18 +00:00
|
|
|
int m_property_flag_ro(const m_option_t* prop,int action,
|
|
|
|
void* arg,int var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Switch betwen min and max.
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_flag(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,int* var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Implement get, print.
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_float_ro(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,float var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Implement set, get and step up/down
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_float_range(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,float* var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// float with a print function which print the time in ms
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_delay(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,float* var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// Implement get, print
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_double_ro(const m_option_t* prop,int action,
|
2006-03-22 00:19:02 +00:00
|
|
|
void* arg,double var);
|
|
|
|
|
2007-05-31 12:42:02 +00:00
|
|
|
/// Implement print
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_time_ro(const m_option_t* prop,int action,
|
2007-05-31 12:42:02 +00:00
|
|
|
void* arg,double var);
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
/// get/print the string
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_string_ro(const m_option_t* prop,int action,void* arg, char* str);
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// get/print a bitrate
|
2008-01-13 16:59:21 +00:00
|
|
|
int m_property_bitrate(const m_option_t* prop,int action,void* arg,int rate);
|
2007-05-29 22:14:41 +00:00
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
///@}
|
2008-01-01 21:35:58 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_M_PROPERTY_H */
|