capabilities -> formats

This commit is contained in:
Wim Taymans 2015-05-15 16:41:53 +02:00
parent 31cc37b6a5
commit d531634061
6 changed files with 40 additions and 29 deletions

View file

@ -53,6 +53,7 @@ typedef enum {
* @name: the name of the source * @name: the name of the source
* @properties: the properties of the source * @properties: the properties of the source
* @state: the current state of the source * @state: the current state of the source
* @formats: the supported formats
* *
* The source information * The source information
*/ */
@ -60,19 +61,19 @@ typedef struct {
const char *name; const char *name;
GVariant *properties; GVariant *properties;
PvSourceState state; PvSourceState state;
GVariant *capabilities; GBytes *formats;
} PvSourceInfo; } PvSourceInfo;
/** /**
* PvSourceInfoFlags: * PvSourceInfoFlags:
* @PV_SOURCE_INFO_FLAGS_NONE: no flags * @PV_SOURCE_INFO_FLAGS_NONE: no flags
* @PV_SOURCE_INFO_FLAGS_CAPABILITIES: include capabilities * @PV_SOURCE_INFO_FLAGS_FORMATS: include formats
* *
* Extra flags to pass to pv_context_get_source_info_list. * Extra flags to pass to pv_context_get_source_info_list.
*/ */
typedef enum { typedef enum {
PV_SOURCE_INFO_FLAGS_NONE = 0, PV_SOURCE_INFO_FLAGS_NONE = 0,
PV_SOURCE_INFO_FLAGS_CAPABILITIES = (1 << 0) PV_SOURCE_INFO_FLAGS_FORMATS = (1 << 0)
} PvSourceInfoFlags; } PvSourceInfoFlags;
typedef gboolean (*PvSourceInfoCallback) (PvContext *c, const PvSourceInfo *info, gpointer userdata); typedef gboolean (*PvSourceInfoCallback) (PvContext *c, const PvSourceInfo *info, gpointer userdata);

View file

@ -53,7 +53,7 @@
<method name='Disconnect'/> <method name='Disconnect'/>
<!-- CreateSourceOutput: <!-- CreateSourceOutput:
@source: the Source1 object path or / for default @source: the Source1 object path or / for default
@incaps: input capabilities @accepted_formats: the formats that can be accepted
@output: the SourceOutput1 object path @output: the SourceOutput1 object path
Create a new output for @source with given @incaps Create a new output for @source with given @incaps
@ -64,7 +64,7 @@
<arg type='o' name='output' direction='out'/> <arg type='o' name='output' direction='out'/>
</method> </method>
<!-- CreateSourceInput: <!-- CreateSourceInput:
@incaps: input capabilities @possible_formats: the formats that can be provided
@input: the SourceInput1 object path @input: the SourceInput1 object path
Create a new source and input object with given @incaps Create a new source and input object with given @incaps
@ -121,10 +121,9 @@
4 = the source is running 4 = the source is running
--> -->
<property name='State' type='u' access='read' /> <property name='State' type='u' access='read' />
<!-- Capabilities: <!-- PossibleFormats:
The capabilities of this source. This includes The all possible formats of this source.
supported data formats and transports.
--> -->
<property name='PossibleFormats' type='s' access='read' /> <property name='PossibleFormats' type='s' access='read' />
</interface> </interface>
@ -141,18 +140,21 @@
<property name='Client' type='o' access='read' /> <property name='Client' type='o' access='read' />
<!-- Source: the source of this source output --> <!-- Source: the source of this source output -->
<property name='Source' type='o' access='read' /> <property name='Source' type='o' access='read' />
<!-- Capabilities: capabilities of the source output --> <!-- PossibleFormats:
all possible formats of the source output. This is filtered
against the accepted_formats when creating the source output.
-->
<property name='PossibleFormats' type='s' access='read' /> <property name='PossibleFormats' type='s' access='read' />
<!-- Start: <!-- Start:
@incaps: input capabilities @requested_format: requested formats
@fd: output file descriptor @fd: output file descriptor
@outcaps: output capabilities @format: output format
Start the datatransfer of the source with @incaps. Start the datatransfer of the source with @requested_format.
The result is a file descriptor that can be used to get metadata The result is a file descriptor that can be used to get metadata
and media. @outcaps contains the final media format and transport and media. @format contains the final media format.
properties.
--> -->
<method name='Start'> <method name='Start'>
<arg type='s' name='requested_format' direction='in'/> <arg type='s' name='requested_format' direction='in'/>

View file

@ -139,7 +139,7 @@ v4l2_set_state (PvSource *source, PvSourceState state)
} }
static GBytes * static GBytes *
v4l2_get_capabilities (PvSource *source, GBytes *filter) v4l2_get_formats (PvSource *source, GBytes *filter)
{ {
GstCaps *caps, *cfilter; GstCaps *caps, *cfilter;
gchar *str; gchar *str;
@ -301,7 +301,7 @@ pv_v4l2_source_class_init (PvV4l2SourceClass * klass)
gobject_class->finalize = v4l2_source_finalize; gobject_class->finalize = v4l2_source_finalize;
source_class->get_capabilities = v4l2_get_capabilities; source_class->get_formats = v4l2_get_formats;
source_class->set_state = v4l2_set_state; source_class->set_state = v4l2_set_state;
source_class->create_source_output = v4l2_create_source_output; source_class->create_source_output = v4l2_create_source_output;
source_class->release_source_output = v4l2_release_source_output; source_class->release_source_output = v4l2_release_source_output;

View file

@ -139,7 +139,7 @@ client_set_state (PvSource *source, PvSourceState state)
} }
static GBytes * static GBytes *
client_get_capabilities (PvSource *source, GBytes *filter) client_get_formats (PvSource *source, GBytes *filter)
{ {
GstCaps *caps, *cfilter; GstCaps *caps, *cfilter;
gchar *str; gchar *str;
@ -311,7 +311,7 @@ pv_client_source_class_init (PvClientSourceClass * klass)
gobject_class->finalize = client_source_finalize; gobject_class->finalize = client_source_finalize;
source_class->get_capabilities = client_get_capabilities; source_class->get_formats = client_get_formats;
source_class->set_state = client_set_state; source_class->set_state = client_set_state;
source_class->create_source_output = client_create_source_output; source_class->create_source_output = client_create_source_output;
source_class->release_source_output = client_release_source_output; source_class->release_source_output = client_release_source_output;

View file

@ -187,11 +187,19 @@ pv_source_finalize (GObject * object)
G_OBJECT_CLASS (pv_source_parent_class)->finalize (object); G_OBJECT_CLASS (pv_source_parent_class)->finalize (object);
} }
static gboolean
default_set_state (PvSource *source, PvSourceState state)
{
pv_source_update_state (source, state);
return TRUE;
}
static PvSourceOutput * static PvSourceOutput *
default_create_source_output (PvSource *source, default_create_source_output (PvSource *source,
const gchar *client_path, const gchar *client_path,
GBytes *format_filter, GBytes *format_filter,
const gchar *prefix) const gchar *prefix,
GError **error)
{ {
PvSourcePrivate *priv = source->priv; PvSourcePrivate *priv = source->priv;
@ -272,6 +280,7 @@ pv_source_class_init (PvSourceClass * klass)
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
klass->set_state = default_set_state;
klass->create_source_output = default_create_source_output; klass->create_source_output = default_create_source_output;
klass->release_source_output = default_release_source_output; klass->release_source_output = default_release_source_output;
} }
@ -283,7 +292,7 @@ pv_source_init (PvSource * source)
} }
GBytes * GBytes *
pv_source_get_capabilities (PvSource *source, GBytes *filter) pv_source_get_formats (PvSource *source, GBytes *filter)
{ {
PvSourceClass *klass; PvSourceClass *klass;
GBytes *res; GBytes *res;
@ -292,8 +301,8 @@ pv_source_get_capabilities (PvSource *source, GBytes *filter)
klass = PV_SOURCE_GET_CLASS (source); klass = PV_SOURCE_GET_CLASS (source);
if (klass->get_capabilities) if (klass->get_formats)
res = klass->get_capabilities (source, filter); res = klass->get_formats (source, filter);
else else
res = NULL; res = NULL;
@ -329,8 +338,7 @@ pv_source_update_state (PvSource *source, PvSourceState state)
if (priv->state != state) { if (priv->state != state) {
priv->state = state; priv->state = state;
g_print ("source changed state %d\n", state); g_print ("source changed state %d\n", state);
if (priv->iface) pv_source1_set_state (priv->iface, state);
pv_source1_set_state (priv->iface, state);
g_object_notify (G_OBJECT (source), "state"); g_object_notify (G_OBJECT (source), "state");
} }
} }

View file

@ -54,7 +54,7 @@ struct _PvSource {
/** /**
* PvSourceClass: * PvSourceClass:
* @get_capabilities: called to get a list of supported formats from the source * @get_formats: called to get a list of supported formats from the source
* @set_state: called to change the current state of the source * @set_state: called to change the current state of the source
* @create_source_output: called to create a new source-output object * @create_source_output: called to create a new source-output object
* @release_source_output: called to release a source-output object * @release_source_output: called to release a source-output object
@ -64,7 +64,7 @@ struct _PvSource {
struct _PvSourceClass { struct _PvSourceClass {
GObjectClass parent_class; GObjectClass parent_class;
GBytes * (*get_capabilities) (PvSource *source, GBytes *filter); GBytes * (*get_formats) (PvSource *source, GBytes *filter);
gboolean (*set_state) (PvSource *source, PvSourceState); gboolean (*set_state) (PvSource *source, PvSourceState);
@ -82,7 +82,7 @@ GType pv_source_get_type (void);
const gchar * pv_source_get_object_path (PvSource *source); const gchar * pv_source_get_object_path (PvSource *source);
GBytes * pv_source_get_capabilities (PvSource *source, GBytes *filter); GBytes * pv_source_get_formats (PvSource *source, GBytes *filter);
gboolean pv_source_set_state (PvSource *source, PvSourceState state); gboolean pv_source_set_state (PvSource *source, PvSourceState state);
void pv_source_update_state (PvSource *source, PvSourceState state); void pv_source_update_state (PvSource *source, PvSourceState state);