@ -43,6 +43,9 @@
* @ }
*/
# include "libavutil/log.h"
# include "libavutil/opt.h"
# include "libavutil/dict.h"
# include "libavformat/avformat.h"
/**
@ -227,6 +230,131 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
enum AVDevToAppMessageType type ,
void * data , size_t data_size ) ;
/**
* Following API allows user to probe device capabilities ( supported codecs ,
* pixel formats , sample formats , resolutions , channel counts , etc ) .
* It is build on top op AVOption API .
* Queried capabilities allows to set up converters of video or audio
* parameters that fit to the device .
*
* List of capablities that can be queried :
* - Capabilities valid for both audio and video devices :
* - codec : supported audio / video codecs .
* type : AV_OPT_TYPE_INT ( AVCodecID value )
* - Capabilities valid for audio devices :
* - sample_format : supported sample formats .
* type : AV_OPT_TYPE_INT ( AVSampleFormat value )
* - sample_rate : supported sample rates .
* type : AV_OPT_TYPE_INT
* - channels : supported number of channels .
* type : AV_OPT_TYPE_INT
* - channel_layout : supported channel layouts .
* type : AV_OPT_TYPE_INT64
* - Capabilities valid for video devices :
* - pixel_format : supported pixel formats .
* type : AV_OPT_TYPE_INT ( AVPixelFormat value )
* - window_size : supported window sizes ( describes size of the window size presented to the user ) .
* type : AV_OPT_TYPE_IMAGE_SIZE
* - frame_size : supported frame sizes ( describes size of provided video frames ) .
* type : AV_OPT_TYPE_IMAGE_SIZE
* - fps : supported fps values
* type : AV_OPT_TYPE_RATIONAL
*
* Value of the capability may be set by user using av_opt_set ( ) function
* and AVDeviceCapabilitiesQuery object . Following queries will
* limit results to the values matching already set capabilities .
* For example , setting a codec may impact number of formats or fps values
* returned during next query . Setting invalid value may limit results to zero .
*
* Example of the usage basing on opengl output device :
*
* @ code
* AVFormatContext * oc = NULL ;
* AVDeviceCapabilitiesQuery * caps = NULL ;
* AVOptionRanges * ranges ;
* int ret ;
*
* if ( ( ret = avformat_alloc_output_context2 ( & oc , NULL , " opengl " , NULL ) ) < 0 )
* goto fail ;
* if ( avdevice_capabilities_create ( & caps , oc , NULL ) < 0 )
* goto fail ;
*
* //query codecs
* if ( av_opt_query_ranges ( & ranges , caps , " codec " , AV_OPT_MULTI_COMPONENT_RANGE ) ) < 0 )
* goto fail ;
* //pick codec here and set it
* av_opt_set ( caps , " codec " , AV_CODEC_ID_RAWVIDEO , 0 ) ;
*
* //query format
* if ( av_opt_query_ranges ( & ranges , caps , " pixel_format " , AV_OPT_MULTI_COMPONENT_RANGE ) ) < 0 )
* goto fail ;
* //pick format here and set it
* av_opt_set ( caps , " pixel_format " , AV_PIX_FMT_YUV420P , 0 ) ;
*
* //query and set more capabilities
*
* fail :
* //clean up code
* avdevice_capabilities_free ( & query , oc ) ;
* avformat_free_context ( oc ) ;
* @ endcode
*/
/**
* Structure describes device capabilites .
*
* It is used by devices in conjuntion with av_device_capabilities AVOption table
* to implement capabilities probing API based on AVOption API . Should not be used directly .
*/
typedef struct AVDeviceCapabilitiesQuery {
const AVClass * class ;
AVFormatContext * device_context ;
enum AVCodecID codec ;
enum AVSampleFormat sample_format ;
enum AVPixelFormat pixel_format ;
int sample_rate ;
int channels ;
int64_t channel_layout ;
int window_width ;
int window_height ;
int frame_width ;
int frame_height ;
AVRational fps ;
} AVDeviceCapabilitiesQuery ;
/**
* AVOption table used by devices to implement device capabilites API . Should not be used by a user .
*/
extern const AVOption av_device_capabilities [ ] ;
/**
* Initialize capabilities probing API based on AVOption API .
*
* avdevice_capabilities_free ( ) must be called when query capabilities API is
* not used anymore .
*
* @ param [ out ] caps Device capabilities data . Pointer to a NULL pointer must be passed .
* @ param s Context of the device .
* @ param device_options An AVDictionary filled with device - private options .
* On return this parameter will be destroyed and replaced with a dict
* containing options that were not found . May be NULL .
* The same options must be passed later to avformat_write_header ( ) for output
* devices or avformat_open_input ( ) for input devices , or at any other place
* that affects device - private options .
*
* @ return > = 0 on success , negative otherwise .
*/
int avdevice_capabilities_create ( AVDeviceCapabilitiesQuery * * caps , AVFormatContext * s ,
AVDictionary * * device_options ) ;
/**
* Free resources created by avdevice_capabilities_create ( )
*
* @ param caps Device capabilities data to be freed .
* @ param s Context of the device .
*/
void avdevice_capabilities_free ( AVDeviceCapabilitiesQuery * * caps , AVFormatContext * s ) ;
/**
* Structure describes basic parameters of the device .
*/