mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
ges: Add a SourceClipAsset class
Cleaning up the way we use the default framerate for natural frame rate.
This commit is contained in:
parent
130140d059
commit
13325aabdd
8 changed files with 110 additions and 20 deletions
|
@ -199,22 +199,13 @@ ges_clip_asset_get_natural_framerate (GESClipAsset * self,
|
||||||
if (klass->get_natural_framerate)
|
if (klass->get_natural_framerate)
|
||||||
return klass->get_natural_framerate (self, framerate_n, framerate_d);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_clip_asset_get_frame_time:
|
* ges_clip_asset_get_frame_time:
|
||||||
* @self: The object for which to compute timestamp for specifed frame
|
* @self: The object for which to compute timestamp for specifed frame
|
||||||
* @frame_number: The frame number we want the timestamp for the frame number
|
* @frame_number: The frame number we want the internal time coordinate timestamp of
|
||||||
* inside the media scale of @self
|
|
||||||
*
|
*
|
||||||
* Converts the given frame number into a timestamp, using the "natural" frame
|
* Converts the given frame number into a timestamp, using the "natural" frame
|
||||||
* rate of the asset.
|
* 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
|
* 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.
|
* as, for example, the `in-point` or `max-duration` of a #GESClip.
|
||||||
*
|
*
|
||||||
* Returns: The timestamp corresponding to @frame_number in the element source
|
* Returns: The timestamp corresponding to @frame_number in the element source, given
|
||||||
* in the media scale, or #GST_CLOCK_TIME_NONE if the clip asset does not have a
|
* in internal time coordinates, or #GST_CLOCK_TIME_NONE if the clip asset does not have a
|
||||||
* natural frame rate.
|
* natural frame rate.
|
||||||
*/
|
*/
|
||||||
GstClockTime
|
GstClockTime
|
||||||
|
|
48
ges/ges-source-clip-asset.c
Normal file
48
ges/ges-source-clip-asset.c
Normal 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)
|
||||||
|
{
|
||||||
|
}
|
40
ges/ges-source-clip-asset.h
Normal file
40
ges/ges-source-clip-asset.h
Normal 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
|
|
@ -53,7 +53,15 @@ enum
|
||||||
PROP_0,
|
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
|
static void
|
||||||
ges_source_clip_get_property (GObject * object, guint property_id,
|
ges_source_clip_get_property (GObject * object, guint property_id,
|
||||||
|
|
|
@ -52,11 +52,11 @@
|
||||||
#define DEFAULT_VPATTERN GES_VIDEO_TEST_PATTERN_SMPTE
|
#define DEFAULT_VPATTERN GES_VIDEO_TEST_PATTERN_SMPTE
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GESTestClipAsset, ges_test_clip_asset, GES,
|
G_DECLARE_FINAL_TYPE (GESTestClipAsset, ges_test_clip_asset, GES,
|
||||||
TEST_CLIP_ASSET, GESClipAsset);
|
TEST_CLIP_ASSET, GESSourceClipAsset);
|
||||||
|
|
||||||
struct _GESTestClipAsset
|
struct _GESTestClipAsset
|
||||||
{
|
{
|
||||||
GESClipAsset parent;
|
GESSourceClipAsset parent;
|
||||||
|
|
||||||
gint natural_framerate_n;
|
gint natural_framerate_n;
|
||||||
gint natural_framerate_d;
|
gint natural_framerate_d;
|
||||||
|
@ -66,7 +66,8 @@ struct _GESTestClipAsset
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GES_TYPE_TEST_CLIP_ASSET (ges_test_clip_asset_get_type())
|
#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
|
static gboolean
|
||||||
_get_natural_framerate (GESClipAsset * asset, gint * framerate_n,
|
_get_natural_framerate (GESClipAsset * asset, gint * framerate_n,
|
||||||
|
|
|
@ -126,7 +126,7 @@ struct _GESUriSourceAssetPrivate
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GESUriClipAsset, ges_uri_clip_asset,
|
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));
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <ges/ges-types.h>
|
#include <ges/ges-types.h>
|
||||||
#include <ges/ges-asset.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>
|
#include <ges/ges-track-element-asset.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -34,7 +34,7 @@ GES_DECLARE_TYPE(UriClipAsset, uri_clip_asset, URI_CLIP_ASSET);
|
||||||
|
|
||||||
struct _GESUriClipAsset
|
struct _GESUriClipAsset
|
||||||
{
|
{
|
||||||
GESClipAsset parent;
|
GESSourceClipAsset parent;
|
||||||
|
|
||||||
/* <private> */
|
/* <private> */
|
||||||
GESUriClipAssetPrivate *priv;
|
GESUriClipAssetPrivate *priv;
|
||||||
|
@ -45,7 +45,7 @@ struct _GESUriClipAsset
|
||||||
|
|
||||||
struct _GESUriClipAssetClass
|
struct _GESUriClipAssetClass
|
||||||
{
|
{
|
||||||
GESClipAssetClass parent_class;
|
GESSourceClipAssetClass parent_class;
|
||||||
|
|
||||||
/* <private> */
|
/* <private> */
|
||||||
GstDiscoverer *discoverer; /* Unused */
|
GstDiscoverer *discoverer; /* Unused */
|
||||||
|
|
|
@ -7,6 +7,7 @@ ges_sources = files([
|
||||||
'ges-clip.c',
|
'ges-clip.c',
|
||||||
'ges-pipeline.c',
|
'ges-pipeline.c',
|
||||||
'ges-source-clip.c',
|
'ges-source-clip.c',
|
||||||
|
'ges-source-clip-asset.c',
|
||||||
'ges-base-effect-clip.c',
|
'ges-base-effect-clip.c',
|
||||||
'ges-effect-clip.c',
|
'ges-effect-clip.c',
|
||||||
'ges-uri-clip.c',
|
'ges-uri-clip.c',
|
||||||
|
@ -77,6 +78,7 @@ ges_headers = files([
|
||||||
'ges-clip.h',
|
'ges-clip.h',
|
||||||
'ges-pipeline.h',
|
'ges-pipeline.h',
|
||||||
'ges-source-clip.h',
|
'ges-source-clip.h',
|
||||||
|
'ges-source-clip-asset.h',
|
||||||
'ges-uri-clip.h',
|
'ges-uri-clip.h',
|
||||||
'ges-base-effect-clip.h',
|
'ges-base-effect-clip.h',
|
||||||
'ges-effect-clip.h',
|
'ges-effect-clip.h',
|
||||||
|
|
Loading…
Reference in a new issue