ges: Add a SourceClipAsset class

Cleaning up the way we use the default framerate for natural
frame rate.
This commit is contained in:
Thibault Saunier 2020-03-17 11:53:47 -03:00
parent 130140d059
commit 13325aabdd
8 changed files with 110 additions and 20 deletions

View file

@ -199,22 +199,13 @@ ges_clip_asset_get_natural_framerate (GESClipAsset * self,
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;
}
/**
* ges_clip_asset_get_frame_time:
* @self: The object for which to compute timestamp for specifed frame
* @frame_number: The frame number we want the timestamp for the frame number
* inside the media scale of @self
* @frame_number: The frame number we want the internal time coordinate timestamp of
*
* Converts the given frame number into a timestamp, using the "natural" frame
* rate of the asset.
@ -222,8 +213,8 @@ ges_clip_asset_get_natural_framerate (GESClipAsset * self,
* You can use this to reference a specific frame in a media file and use this
* as, for example, the `in-point` or `max-duration` of a #GESClip.
*
* Returns: The timestamp corresponding to @frame_number in the element source
* in the media scale, or #GST_CLOCK_TIME_NONE if the clip asset does not have a
* Returns: The timestamp corresponding to @frame_number in the element source, given
* in internal time coordinates, or #GST_CLOCK_TIME_NONE if the clip asset does not have a
* natural frame rate.
*/
GstClockTime

View file

@ -0,0 +1,48 @@
/* GStreamer Editing Services
* Copyright (C) 2020 Igalia S.L
* Author: 2020 Thibault Saunier <tsaunier@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ges-source-clip-asset.h"
#include "ges-internal.h"
G_DEFINE_TYPE (GESSourceClipAsset, ges_source_clip_asset, GES_TYPE_CLIP_ASSET);
static gboolean
get_natural_framerate (GESClipAsset * self, gint * framerate_n,
gint * framerate_d)
{
*framerate_n = DEFAULT_FRAMERATE_N;
*framerate_d = DEFAULT_FRAMERATE_D;
return TRUE;
}
static void
ges_source_clip_asset_class_init (GESSourceClipAssetClass * klass)
{
GES_CLIP_ASSET_CLASS (klass)->get_natural_framerate = get_natural_framerate;
}
static void
ges_source_clip_asset_init (GESSourceClipAsset * self)
{
}

View file

@ -0,0 +1,40 @@
/* GStreamer Editing Services
* Copyright (C) 2020 Igalia S.L
* Author: 2020 Thibault Saunier <tsaunier@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <ges/ges-clip-asset.h>
G_BEGIN_DECLS
#define GES_TYPE_SOURCE_CLIP_ASSET ges_source_clip_asset_get_type ()
GES_API
G_DECLARE_DERIVABLE_TYPE(GESSourceClipAsset, ges_source_clip_asset, GES,
SOURCE_CLIP_ASSET, GESClipAsset);
struct _GESSourceClipAssetClass
{
GESClipAssetClass parent_class;
/* FIXME 2.0: Add some padding, meanwhile that would break ABI */
};
G_END_DECLS

View file

@ -53,7 +53,15 @@ enum
PROP_0,
};
G_DEFINE_TYPE_WITH_PRIVATE (GESSourceClip, ges_source_clip, GES_TYPE_CLIP);
static void
extractable_interface_init (GESExtractableInterface * iface)
{
iface->asset_type = GES_TYPE_SOURCE_CLIP_ASSET;
}
G_DEFINE_TYPE_WITH_CODE (GESSourceClip, ges_source_clip,
GES_TYPE_CLIP, G_ADD_PRIVATE (GESSourceClip)
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, extractable_interface_init));
static void
ges_source_clip_get_property (GObject * object, guint property_id,

View file

@ -52,11 +52,11 @@
#define DEFAULT_VPATTERN GES_VIDEO_TEST_PATTERN_SMPTE
G_DECLARE_FINAL_TYPE (GESTestClipAsset, ges_test_clip_asset, GES,
TEST_CLIP_ASSET, GESClipAsset);
TEST_CLIP_ASSET, GESSourceClipAsset);
struct _GESTestClipAsset
{
GESClipAsset parent;
GESSourceClipAsset parent;
gint natural_framerate_n;
gint natural_framerate_d;
@ -66,7 +66,8 @@ struct _GESTestClipAsset
};
#define GES_TYPE_TEST_CLIP_ASSET (ges_test_clip_asset_get_type())
G_DEFINE_TYPE (GESTestClipAsset, ges_test_clip_asset, GES_TYPE_CLIP_ASSET);
G_DEFINE_TYPE (GESTestClipAsset, ges_test_clip_asset,
GES_TYPE_SOURCE_CLIP_ASSET);
static gboolean
_get_natural_framerate (GESClipAsset * asset, gint * framerate_n,

View file

@ -126,7 +126,7 @@ struct _GESUriSourceAssetPrivate
};
G_DEFINE_TYPE_WITH_CODE (GESUriClipAsset, ges_uri_clip_asset,
GES_TYPE_CLIP_ASSET, G_ADD_PRIVATE (GESUriClipAsset)
GES_TYPE_SOURCE_CLIP_ASSET, G_ADD_PRIVATE (GESUriClipAsset)
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init));
static void

View file

@ -25,7 +25,7 @@
#include <gio/gio.h>
#include <ges/ges-types.h>
#include <ges/ges-asset.h>
#include <ges/ges-clip-asset.h>
#include <ges/ges-source-clip-asset.h>
#include <ges/ges-track-element-asset.h>
G_BEGIN_DECLS
@ -34,7 +34,7 @@ GES_DECLARE_TYPE(UriClipAsset, uri_clip_asset, URI_CLIP_ASSET);
struct _GESUriClipAsset
{
GESClipAsset parent;
GESSourceClipAsset parent;
/* <private> */
GESUriClipAssetPrivate *priv;
@ -45,7 +45,7 @@ struct _GESUriClipAsset
struct _GESUriClipAssetClass
{
GESClipAssetClass parent_class;
GESSourceClipAssetClass parent_class;
/* <private> */
GstDiscoverer *discoverer; /* Unused */

View file

@ -7,6 +7,7 @@ ges_sources = files([
'ges-clip.c',
'ges-pipeline.c',
'ges-source-clip.c',
'ges-source-clip-asset.c',
'ges-base-effect-clip.c',
'ges-effect-clip.c',
'ges-uri-clip.c',
@ -77,6 +78,7 @@ ges_headers = files([
'ges-clip.h',
'ges-pipeline.h',
'ges-source-clip.h',
'ges-source-clip-asset.h',
'ges-uri-clip.h',
'ges-base-effect-clip.h',
'ges-effect-clip.h',