/* GObject VMethods */
+static gboolean
+_get_natural_framerate (GESTimelineElement * self, gint * framerate_n,
+ gint * framerate_d)
+{
+ if (self->parent)
+ return ges_timeline_element_get_natural_framerate (self->parent,
+ framerate_n, framerate_d);
+
+ return FALSE;
+}
+
static void
ges_audio_uri_source_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
ges_audio_uri_source_class_init (GESAudioUriSourceClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_CLASS (klass);
object_class->get_property = ges_audio_uri_source_get_property;
g_param_spec_string ("uri", "URI", "uri of the resource",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ element_class->get_natural_framerate = _get_natural_framerate;
+
source_class->create_source = ges_audio_uri_source_create_source;
}
#endif
#include "ges-clip-asset.h"
+#include "ges-source-clip.h"
+#include "ges-internal.h"
#define GES_CLIP_ASSET_GET_PRIVATE(o)\
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GES_TYPE_CLIP_ASSET, \
return self->priv->supportedformats;
}
+
+/**
+ * ges_clip_asset_get_natural_framerate:
+ * @self: The object from which to retrieve the natural framerate
+ * @framerate_n: The framerate numerator
+ * @framerate_d: The framerate denominator
+ *
+ * Result: %TRUE if @self has a natural framerate %FALSE otherwise
+ */
+gboolean
+ges_clip_asset_get_natural_framerate (GESClipAsset * self,
+ gint * framerate_n, gint * framerate_d)
+{
+ GESClipAssetClass *klass;
+ g_return_val_if_fail (GES_IS_CLIP_ASSET (self), FALSE);
+ g_return_val_if_fail (framerate_n && framerate_d, FALSE);
+
+ klass = GES_CLIP_ASSET_GET_CLASS (self);
+
+ *framerate_n = 0;
+ *framerate_d = -1;
+
+ if (klass->get_natural_framerate)
+ return klass->get_natural_framerate (self, framerate_n, framerate_d);
+
+ if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (self)),
+ GES_TYPE_SOURCE_CLIP)) {
+ *framerate_n = DEFAULT_FRAMERATE_N;
+ *framerate_d = DEFAULT_FRAMERATE_D;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
{
GESAssetClass parent;
- gpointer _ges_reserved[GES_PADDING];
+ gboolean (*get_natural_framerate) (GESClipAsset *self, gint *framerate_n, gint *framerate_d);
+
+ gpointer _ges_reserved[GES_PADDING - 1];
};
GES_API
GESTrackType supportedformats);
GES_API
GESTrackType ges_clip_asset_get_supported_formats (GESClipAsset *self);
+GES_API
+gboolean ges_clip_asset_get_natural_framerate (GESClipAsset* self, gint* framerate_n, gint* framerate_d);
G_END_DECLS
return ges_layer_get_priority (clip->priv->layer);
}
+static gboolean
+_get_natural_framerate (GESTimelineElement * self, gint * framerate_n,
+ gint * framerate_d)
+{
+ GESAsset *asset = ges_extractable_get_asset (GES_EXTRACTABLE (self));
+
+ if (!asset) {
+ GST_WARNING_OBJECT (self, "No asset set?");
+
+ return FALSE;
+ }
+
+ return ges_clip_asset_get_natural_framerate (GES_CLIP_ASSET (asset),
+ framerate_n, framerate_d);
+}
+
/****************************************************
* *
* GESContainer virtual methods implementation *
element_class->deep_copy = _deep_copy;
element_class->lookup_child = _lookup_child;
element_class->get_layer_priority = _get_layer_priority;
+ element_class->get_natural_framerate = _get_natural_framerate;
container_class->add_child = _add_child;
container_class->remove_child = _remove_child;
g_slice_free (ChildPropHandler, handler);
}
+static gboolean
+_get_natural_framerate (GESTimelineElement * self, gint * framerate_n,
+ gint * framerate_d)
+{
+ GST_INFO_OBJECT (self, "No natural framerate");
+
+ return FALSE;
+}
+
static void
ges_timeline_element_init (GESTimelineElement * self)
{
ges_timeline_element_get_children_properties;
klass->lookup_child = _lookup_child;
klass->set_child_property = _set_child_property;
+ klass->get_natural_framerate = _get_natural_framerate;
}
static void
}
return FALSE;
}
+
+/**
+ * ges_timeline_element_get_natural_framerate:
+ * @self: The #GESTimelineElement to get "natural" framerate from
+ * @framerate_n: (out): The framerate numerator
+ * @framerate_d: (out): The framerate denominator
+ *
+ * Get the "natural" framerate of @self. This is to say, for example
+ * for a #GESVideoUriSource the framerate of the source.
+ *
+ * Note that a #GESAudioSource may also have a natural framerate if it derives
+ * from the same #GESSourceClip asset as a #GESVideoSource, and its value will
+ * be that of the video source. For example, if the uri of a #GESUriClip points
+ * to a file that contains both a video and audio stream, then the corresponding
+ * #GESAudioUriSource will share the natural framerate of the corresponding
+ * #GESVideoUriSource.
+ *
+ * Returns: Whether @self has a natural framerate or not, @framerate_n
+ * and @framerate_d will be set to, respectively, 0 and -1 if it is
+ * not the case.
+ *
+ * Since: 1.18
+ */
+gboolean
+ges_timeline_element_get_natural_framerate (GESTimelineElement * self,
+ gint * framerate_n, gint * framerate_d)
+{
+ GESTimelineElementClass *klass;
+
+ g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), FALSE);
+ g_return_val_if_fail (framerate_n && framerate_d, FALSE);
+
+ klass = GES_TIMELINE_ELEMENT_GET_CLASS (self);
+
+ *framerate_n = 0;
+ *framerate_d = -1;
+ return klass->get_natural_framerate (self, framerate_n, framerate_d);
+}
guint32 (*get_layer_priority) (GESTimelineElement *self);
/*< private > */
+ gboolean (*get_natural_framerate) (GESTimelineElement * self, gint *framerate_n, gint *framerate_d);
/* Padding for API extension */
- gpointer _ges_reserved[GES_PADDING_LARGE - 4];
+ gpointer _ges_reserved[GES_PADDING_LARGE - 5];
};
GES_API
GstClockTime paste_position);
GES_API
GESTrackType ges_timeline_element_get_track_types (GESTimelineElement * self);
+GES_API
+gboolean ges_timeline_element_get_natural_framerate (GESTimelineElement *self,
+ gint *framerate_n,
+ gint *framerate_d);
GES_API
guint32 ges_timeline_element_get_layer_priority (GESTimelineElement * self);
return asset->priv->type;
}
+
+/**
+ * ges_track_element_asset_get_natural_framerate:
+ * @self: A #GESAsset
+ * @framerate_n: The framerate numerator
+ * @framerate_d: The framerate denominator
+ *
+ * Result: %TRUE if @self has a natural framerate %FALSE otherwise
+ */
+gboolean
+ges_track_element_asset_get_natural_framerate (GESTrackElementAsset * self,
+ gint * framerate_n, gint * framerate_d)
+{
+ GESTrackElementAssetClass *klass;
+
+ g_return_val_if_fail (GES_IS_TRACK_ELEMENT_ASSET (self), FALSE);
+ g_return_val_if_fail (framerate_n && framerate_d, FALSE);
+
+ klass = GES_TRACK_ELEMENT_ASSET_GET_CLASS (self);
+
+ *framerate_n = 0;
+ *framerate_d = -1;
+
+ if (klass->get_natural_framerate)
+ return klass->get_natural_framerate (self, framerate_n, framerate_d);
+
+ return FALSE;
+}
{
GESAssetClass parent_class;
- gpointer _ges_reserved[GES_PADDING];
+ gboolean (*get_natural_framerate) (GESTrackElementAsset *self, gint *framerate_n, gint *framerate_d);
+
+ gpointer _ges_reserved[GES_PADDING - 1];
};
GES_API
const GESTrackType ges_track_element_asset_get_track_type (GESTrackElementAsset *asset);
GES_API
void ges_track_element_asset_set_track_type (GESTrackElementAsset * asset, GESTrackType type);
+GES_API
+gboolean ges_track_element_asset_get_natural_framerate (GESTrackElementAsset *self,
+ gint *framerate_n,
+ gint *framerate_d);
G_END_DECLS
return ges_timeline_element_get_layer_priority (element->parent);
}
+static gboolean
+_get_natural_framerate (GESTimelineElement * self, gint * framerate_n,
+ gint * framerate_d)
+{
+ GESAsset *asset = ges_extractable_get_asset (GES_EXTRACTABLE (self));
+
+ /* FIXME: asset should **never** be NULL */
+ if (asset &&
+ ges_track_element_asset_get_natural_framerate (GES_TRACK_ELEMENT_ASSET
+ (asset), framerate_n, framerate_d))
+ return TRUE;
+
+ if (self->parent)
+ return ges_timeline_element_get_natural_framerate (self->parent,
+ framerate_n, framerate_d);
+
+ return FALSE;
+}
+
static void
ges_track_element_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
element_class->get_track_types = _get_track_types;
element_class->deep_copy = ges_track_element_copy_properties;
element_class->get_layer_priority = _get_layer_priority;
+ element_class->get_natural_framerate = _get_natural_framerate;
klass->create_gnl_object = ges_track_element_create_gnl_object_func;
klass->lookup_child = _lookup_child;
return FALSE;
}
+static gboolean
+ges_uri_source_asset_get_natural_framerate (GESTrackElementAsset * asset,
+ gint * framerate_n, gint * framerate_d)
+{
+ GESUriSourceAssetPrivate *priv = GES_URI_SOURCE_ASSET (asset)->priv;
+
+ if (!GST_IS_DISCOVERER_VIDEO_INFO (priv->sinfo))
+ return FALSE;
+
+ *framerate_d =
+ gst_discoverer_video_info_get_framerate_denom (GST_DISCOVERER_VIDEO_INFO
+ (priv->sinfo));
+ *framerate_n =
+ gst_discoverer_video_info_get_framerate_num (GST_DISCOVERER_VIDEO_INFO
+ (priv->sinfo));
+
+ if ((*framerate_n == 0 && *framerate_d == 1) || *framerate_d == 0
+ || *framerate_d == G_MAXINT) {
+ GST_INFO_OBJECT (asset, "No framerate information about the file.");
+
+ *framerate_n = 0;
+ *framerate_d = -1;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+_get_natural_framerate (GESClipAsset * self, gint * framerate_n,
+ gint * framerate_d)
+{
+ GList *tmp;
+
+ for (tmp = (GList *)
+ ges_uri_clip_asset_get_stream_assets (GES_URI_CLIP_ASSET (self)); tmp;
+ tmp = tmp->next) {
+
+ if (ges_track_element_asset_get_natural_framerate (tmp->data, framerate_n,
+ framerate_d))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
_asset_proxied (GESAsset * self, const gchar * new_uri)
{
GES_ASSET_CLASS (klass)->request_id_update = _request_id_update;
GES_ASSET_CLASS (klass)->inform_proxy = _asset_proxied;
+ GES_CLIP_ASSET_CLASS (klass)->get_natural_framerate = _get_natural_framerate;
+
klass->discovered = discoverer_discovered_cb;
object_class->dispose = ges_uri_source_asset_dispose;
GES_ASSET_CLASS (klass)->extract = _extract;
+ GES_TRACK_ELEMENT_ASSET_CLASS (klass)->get_natural_framerate =
+ ges_uri_source_asset_get_natural_framerate;
}
static void
return FALSE;
}
-gboolean
-ges_video_uri_source_get_natural_size (GESVideoSource * source, gint * width,
- gint * height)
+static GstDiscovererVideoInfo *
+_get_video_stream_info (GESVideoUriSource * self)
{
- const GstTagList *tags = NULL;
- gchar *rotation_info = NULL;
- gint videoflip_method, rotate_angle;
GstDiscovererStreamInfo *info;
- GESAsset *asset = ges_extractable_get_asset (GES_EXTRACTABLE (source));
+ GESAsset *asset = ges_extractable_get_asset (GES_EXTRACTABLE (self));
if (!asset) {
- GST_DEBUG_OBJECT (source, "No asset set yet");
- return FALSE;
+ GST_DEBUG_OBJECT (self, "No asset set yet");
+ return NULL;
}
info = ges_uri_source_asset_get_stream_info (GES_URI_SOURCE_ASSET (asset));
if (!GST_IS_DISCOVERER_VIDEO_INFO (info)) {
- GST_ERROR_OBJECT (source, "Doesn't have a video info (%" GST_PTR_FORMAT
+ GST_ERROR_OBJECT (self, "Doesn't have a video info (%" GST_PTR_FORMAT
")", info);
- return FALSE;
+ return NULL;
}
- *width =
- gst_discoverer_video_info_get_width (GST_DISCOVERER_VIDEO_INFO (info));
- *height =
- gst_discoverer_video_info_get_height (GST_DISCOVERER_VIDEO_INFO (info));
+ return GST_DISCOVERER_VIDEO_INFO (info);
+}
+
+
+gboolean
+ges_video_uri_source_get_natural_size (GESVideoSource * source, gint * width,
+ gint * height)
+{
+ const GstTagList *tags = NULL;
+ gchar *rotation_info = NULL;
+ gint videoflip_method, rotate_angle;
+ GstDiscovererVideoInfo *info =
+ _get_video_stream_info (GES_VIDEO_URI_SOURCE (source));
+
+ if (!info)
+ return FALSE;
+ *width = gst_discoverer_video_info_get_width (info);
+ *height = gst_discoverer_video_info_get_height (info);
if (!ges_timeline_element_lookup_child (GES_TIMELINE_ELEMENT (source),
"GstVideoFlip::video-direction", NULL, NULL))
goto done;