2013-03-28 17:51:45 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) <2013> Thibault Saunier <thibault.saunier@collabora.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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION: gesvideotrack
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESVideoTrack
|
2013-03-28 17:51:45 +00:00
|
|
|
* @short_description: A standard GESTrack for raw video
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ges-video-track.h"
|
2013-05-30 04:04:47 +00:00
|
|
|
#include "ges-smart-video-mixer.h"
|
2013-03-28 17:51:45 +00:00
|
|
|
|
|
|
|
struct _GESVideoTrackPrivate
|
|
|
|
{
|
|
|
|
gpointer nothing;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GES_VIDEO_TRACK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GES_TYPE_VIDEO_TRACK, GESVideoTrackPrivate))
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GESVideoTrack, ges_video_track, GES_TYPE_TRACK);
|
|
|
|
|
2013-09-25 21:52:46 +00:00
|
|
|
static void
|
|
|
|
_sync_capsfilter_with_track (GESTrack * track, GstElement * capsfilter)
|
|
|
|
{
|
|
|
|
GstCaps *restriction, *caps;
|
|
|
|
gint fps_n, fps_d;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
g_object_get (track, "restriction-caps", &restriction, NULL);
|
2016-05-14 17:02:57 +00:00
|
|
|
if (restriction == NULL)
|
2013-09-25 21:52:46 +00:00
|
|
|
return;
|
2016-05-14 17:02:57 +00:00
|
|
|
|
|
|
|
if (gst_caps_get_size (restriction) == 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (restriction, 0);
|
|
|
|
if (!gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d))
|
|
|
|
goto done;
|
2013-09-25 21:52:46 +00:00
|
|
|
|
|
|
|
caps =
|
|
|
|
gst_caps_new_simple ("video/x-raw", "framerate", GST_TYPE_FRACTION, fps_n,
|
|
|
|
fps_d, NULL);
|
|
|
|
|
|
|
|
g_object_set (capsfilter, "caps", caps, NULL);
|
2015-10-01 09:28:38 +00:00
|
|
|
gst_caps_unref (caps);
|
2016-05-14 17:02:57 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
gst_caps_unref (restriction);
|
2013-09-25 21:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_track_restriction_changed_cb (GESTrack * track, GParamSpec * arg G_GNUC_UNUSED,
|
|
|
|
GstElement * capsfilter)
|
|
|
|
{
|
|
|
|
_sync_capsfilter_with_track (track, capsfilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_weak_notify_cb (GESTrack * track, GstElement * capsfilter)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (track,
|
|
|
|
(GCallback) _track_restriction_changed_cb, capsfilter);
|
|
|
|
}
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
static GstElement *
|
|
|
|
create_element_for_raw_video_gap (GESTrack * track)
|
|
|
|
{
|
2013-09-25 21:52:46 +00:00
|
|
|
GstElement *bin;
|
|
|
|
GstElement *capsfilter;
|
|
|
|
|
|
|
|
bin = gst_parse_bin_from_description
|
|
|
|
("videotestsrc pattern=2 name=src ! videorate ! capsfilter name=gapfilter caps=video/x-raw",
|
|
|
|
TRUE, NULL);
|
|
|
|
|
|
|
|
capsfilter = gst_bin_get_by_name (GST_BIN (bin), "gapfilter");
|
|
|
|
g_object_weak_ref (G_OBJECT (capsfilter), (GWeakNotify) _weak_notify_cb,
|
|
|
|
track);
|
|
|
|
g_signal_connect (track, "notify::restriction-caps",
|
|
|
|
(GCallback) _track_restriction_changed_cb, capsfilter);
|
|
|
|
|
|
|
|
_sync_capsfilter_with_track (track, capsfilter);
|
|
|
|
|
2013-10-17 13:16:00 +00:00
|
|
|
gst_object_unref (capsfilter);
|
|
|
|
|
2013-09-25 21:52:46 +00:00
|
|
|
return bin;
|
2013-03-28 17:51:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_video_track_init (GESVideoTrack * ges_video_track)
|
|
|
|
{
|
|
|
|
/* GESVideoTrackPrivate *priv = GES_VIDEO_TRACK_GET_PRIVATE (ges_video_track);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* TODO: Add initialization code here */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_video_track_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
/* TODO: Add deinitalization code here */
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (ges_video_track_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_video_track_class_init (GESVideoTrackClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
/* GESTrackClass *parent_class = GES_TRACK_CLASS (klass);
|
|
|
|
*/
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (GESVideoTrackPrivate));
|
|
|
|
|
|
|
|
object_class->finalize = ges_video_track_finalize;
|
2013-05-30 04:04:47 +00:00
|
|
|
|
|
|
|
GES_TRACK_CLASS (klass)->get_mixing_element = ges_smart_mixer_new;
|
2013-03-28 17:51:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_video_track_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GESVideoTrack of type #GES_TRACK_TYPE_VIDEO and with generic
|
|
|
|
* raw video caps ("video/x-raw");
|
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating): A new #GESTrack.
|
2013-03-28 17:51:45 +00:00
|
|
|
*/
|
|
|
|
GESVideoTrack *
|
|
|
|
ges_video_track_new (void)
|
|
|
|
{
|
|
|
|
GESVideoTrack *ret;
|
|
|
|
GstCaps *caps = gst_caps_new_empty_simple ("video/x-raw");
|
|
|
|
|
|
|
|
ret = g_object_new (GES_TYPE_VIDEO_TRACK, "track-type", GES_TRACK_TYPE_VIDEO,
|
|
|
|
"caps", caps, NULL);
|
|
|
|
|
|
|
|
ges_track_set_create_element_for_gap_func (GES_TRACK (ret),
|
|
|
|
create_element_for_raw_video_gap);
|
|
|
|
|
2014-10-26 20:30:53 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2013-03-28 17:51:45 +00:00
|
|
|
return ret;
|
|
|
|
}
|