2009-08-04 15:13:11 +00:00
|
|
|
/* GStreamer Editing Services
|
2009-11-30 14:14:25 +00:00
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-08-04 15:13:11 +00:00
|
|
|
*/
|
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gespipeline
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESPipeline
|
2012-12-21 23:17:41 +00:00
|
|
|
* @short_description: Convenience GstPipeline for editing.
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
2013-07-01 14:27:54 +00:00
|
|
|
* #GESPipeline allows developers to view and render #GESTimeline
|
2009-09-10 16:40:51 +00:00
|
|
|
* in a simple fashion.
|
|
|
|
* Its usage is inspired by the 'playbin' element from gst-plugins-base.
|
2009-08-04 15:13:11 +00:00
|
|
|
*/
|
|
|
|
|
2010-07-15 14:58:22 +00:00
|
|
|
#include <gst/gst.h>
|
2013-03-30 13:35:45 +00:00
|
|
|
#include <gst/video/videooverlay.h>
|
2010-07-15 17:49:28 +00:00
|
|
|
#include <stdio.h>
|
2013-03-30 13:35:45 +00:00
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
#include "ges-internal.h"
|
2013-07-01 14:27:54 +00:00
|
|
|
#include "ges-pipeline.h"
|
2010-07-15 14:58:22 +00:00
|
|
|
#include "ges-screenshot.h"
|
2014-03-21 09:22:52 +00:00
|
|
|
#include "ges-audio-track.h"
|
|
|
|
#include "ges-video-track.h"
|
2009-09-10 16:40:51 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (ges_pipeline_debug);
|
|
|
|
#undef GST_CAT_DEFAULT
|
|
|
|
#define GST_CAT_DEFAULT ges_pipeline_debug
|
|
|
|
|
2014-02-17 11:34:04 +00:00
|
|
|
#define DEFAULT_TIMELINE_MODE GES_PIPELINE_MODE_PREVIEW
|
2009-12-04 09:49:32 +00:00
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
/* Structure corresponding to a timeline - sink link */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2010-04-20 10:57:53 +00:00
|
|
|
GESTrack *track;
|
2009-12-09 11:22:34 +00:00
|
|
|
GstElement *tee;
|
|
|
|
GstPad *srcpad; /* Timeline source pad */
|
2009-12-04 09:49:32 +00:00
|
|
|
GstPad *playsinkpad;
|
|
|
|
GstPad *encodebinpad;
|
2014-11-04 14:38:05 +00:00
|
|
|
|
|
|
|
guint query_position_id;
|
2009-09-08 17:45:08 +00:00
|
|
|
} OutputChain;
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
struct _GESPipelinePrivate
|
2010-11-28 15:40:15 +00:00
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GstElement *playsink;
|
|
|
|
GstElement *encodebin;
|
|
|
|
/* Note : urisink is only created when a URI has been provided */
|
|
|
|
GstElement *urisink;
|
|
|
|
|
|
|
|
GESPipelineFlags mode;
|
|
|
|
|
2013-05-29 18:05:52 +00:00
|
|
|
GMutex dyn_mutex;
|
2010-11-28 15:40:15 +00:00
|
|
|
GList *chains;
|
2015-06-10 15:54:20 +00:00
|
|
|
GList *not_rendered_tracks;
|
2010-11-28 15:40:15 +00:00
|
|
|
|
|
|
|
GstEncodingProfile *profile;
|
|
|
|
};
|
|
|
|
|
2011-11-11 16:29:20 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_AUDIO_SINK,
|
|
|
|
PROP_VIDEO_SINK,
|
2011-12-23 13:07:21 +00:00
|
|
|
PROP_TIMELINE,
|
|
|
|
PROP_MODE,
|
2014-11-25 18:13:02 +00:00
|
|
|
PROP_AUDIO_FILTER,
|
|
|
|
PROP_VIDEO_FILTER,
|
2011-11-11 16:29:20 +00:00
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *properties[PROP_LAST];
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
static GstStateChangeReturn ges_pipeline_change_state (GstElement *
|
2009-09-08 17:45:08 +00:00
|
|
|
element, GstStateChange transition);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
static OutputChain *get_output_chain_for_track (GESPipeline * self,
|
2010-04-20 10:57:53 +00:00
|
|
|
GESTrack * track);
|
2013-07-01 14:27:54 +00:00
|
|
|
static OutputChain *new_output_chain_for_track (GESPipeline * self,
|
2010-04-20 10:57:53 +00:00
|
|
|
GESTrack * track);
|
2014-10-21 08:59:43 +00:00
|
|
|
static void _link_track (GESPipeline * self, GESTrack * track);
|
|
|
|
static void _unlink_track (GESPipeline * self, GESTrack * track);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2013-03-30 13:35:45 +00:00
|
|
|
/****************************************************
|
|
|
|
* Video Overlay vmethods implementation *
|
|
|
|
****************************************************/
|
|
|
|
static void
|
|
|
|
_overlay_expose (GstVideoOverlay * overlay)
|
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *pipeline = GES_PIPELINE (overlay);
|
2013-03-30 13:35:45 +00:00
|
|
|
|
|
|
|
gst_video_overlay_expose (GST_VIDEO_OVERLAY (pipeline->priv->playsink));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_overlay_handle_events (GstVideoOverlay * overlay, gboolean handle_events)
|
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *pipeline = GES_PIPELINE (overlay);
|
2013-03-30 13:35:45 +00:00
|
|
|
|
|
|
|
gst_video_overlay_handle_events (GST_VIDEO_OVERLAY (pipeline->priv->playsink),
|
|
|
|
handle_events);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_overlay_set_render_rectangle (GstVideoOverlay * overlay, gint x,
|
|
|
|
gint y, gint width, gint height)
|
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *pipeline = GES_PIPELINE (overlay);
|
2013-03-30 13:35:45 +00:00
|
|
|
|
2015-07-01 15:28:52 +00:00
|
|
|
gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (pipeline->priv->
|
|
|
|
playsink), x, y, width, height);
|
2013-03-30 13:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_overlay_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
|
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *pipeline = GES_PIPELINE (overlay);
|
2013-03-30 13:35:45 +00:00
|
|
|
|
2015-07-01 15:28:52 +00:00
|
|
|
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (pipeline->
|
|
|
|
priv->playsink), handle);
|
2013-03-30 13:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
video_overlay_init (gpointer g_iface, gpointer g_iface_data)
|
|
|
|
{
|
|
|
|
GstVideoOverlayInterface *iface = (GstVideoOverlayInterface *) g_iface;
|
|
|
|
|
|
|
|
iface->expose = _overlay_expose;
|
|
|
|
iface->handle_events = _overlay_handle_events;
|
|
|
|
iface->set_render_rectangle = _overlay_set_render_rectangle;
|
|
|
|
iface->set_window_handle = _overlay_set_window_handle;
|
|
|
|
}
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GESPipeline, ges_pipeline,
|
2013-03-30 13:35:45 +00:00
|
|
|
GST_TYPE_PIPELINE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY, video_overlay_init));
|
|
|
|
|
2011-11-11 16:29:20 +00:00
|
|
|
static void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_get_property (GObject * object, guint property_id,
|
2011-11-11 16:29:20 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *self = GES_PIPELINE (object);
|
2011-11-11 16:29:20 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_AUDIO_SINK:
|
|
|
|
g_object_get_property (G_OBJECT (self->priv->playsink), "audio-sink",
|
2012-11-18 23:19:01 +00:00
|
|
|
value);
|
2011-11-11 16:29:20 +00:00
|
|
|
break;
|
|
|
|
case PROP_VIDEO_SINK:
|
|
|
|
g_object_get_property (G_OBJECT (self->priv->playsink), "video-sink",
|
2012-11-18 23:19:01 +00:00
|
|
|
value);
|
2011-11-11 16:29:20 +00:00
|
|
|
break;
|
2011-12-23 13:07:21 +00:00
|
|
|
case PROP_TIMELINE:
|
|
|
|
g_value_set_object (value, self->priv->timeline);
|
|
|
|
break;
|
|
|
|
case PROP_MODE:
|
|
|
|
g_value_set_flags (value, self->priv->mode);
|
|
|
|
break;
|
2014-11-25 18:13:02 +00:00
|
|
|
case PROP_AUDIO_FILTER:
|
|
|
|
g_object_get_property (G_OBJECT (self->priv->playsink), "audio-filter",
|
|
|
|
value);
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_FILTER:
|
|
|
|
g_object_get_property (G_OBJECT (self->priv->playsink), "video-filter",
|
|
|
|
value);
|
|
|
|
break;
|
2011-11-11 16:29:20 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_set_property (GObject * object, guint property_id,
|
2011-11-11 16:29:20 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *self = GES_PIPELINE (object);
|
2011-11-11 16:29:20 +00:00
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_AUDIO_SINK:
|
|
|
|
g_object_set_property (G_OBJECT (self->priv->playsink), "audio-sink",
|
2012-11-18 23:19:01 +00:00
|
|
|
value);
|
2011-11-11 16:29:20 +00:00
|
|
|
break;
|
|
|
|
case PROP_VIDEO_SINK:
|
|
|
|
g_object_set_property (G_OBJECT (self->priv->playsink), "video-sink",
|
2012-11-18 23:19:01 +00:00
|
|
|
value);
|
2011-11-11 16:29:20 +00:00
|
|
|
break;
|
2011-12-23 13:07:21 +00:00
|
|
|
case PROP_TIMELINE:
|
2014-02-04 09:45:58 +00:00
|
|
|
ges_pipeline_set_timeline (GES_PIPELINE (object),
|
2012-11-18 23:19:01 +00:00
|
|
|
g_value_get_object (value));
|
2011-12-23 13:07:21 +00:00
|
|
|
break;
|
|
|
|
case PROP_MODE:
|
2013-09-09 15:47:02 +00:00
|
|
|
ges_pipeline_set_mode (GES_PIPELINE (object), g_value_get_flags (value));
|
2011-12-23 13:07:21 +00:00
|
|
|
break;
|
2014-11-25 18:13:02 +00:00
|
|
|
case PROP_AUDIO_FILTER:
|
|
|
|
g_object_set (self->priv->playsink, "audio-filter",
|
|
|
|
GST_ELEMENT (g_value_get_object (value)), NULL);
|
|
|
|
break;
|
|
|
|
case PROP_VIDEO_FILTER:
|
|
|
|
g_object_set (self->priv->playsink, "video-filter",
|
|
|
|
GST_ELEMENT (g_value_get_object (value)), NULL);
|
|
|
|
break;
|
2011-11-11 16:29:20 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-28 17:36:55 +00:00
|
|
|
static void
|
2014-11-03 12:06:34 +00:00
|
|
|
_timeline_track_added_cb (GESTimeline * timeline, GESTrack * track,
|
|
|
|
GESPipeline * pipeline)
|
2014-10-28 17:36:55 +00:00
|
|
|
{
|
2015-07-01 15:28:52 +00:00
|
|
|
track_disable_last_gap (track,
|
|
|
|
! !(pipeline->priv->mode & (GES_PIPELINE_MODE_RENDER |
|
|
|
|
GES_PIPELINE_MODE_SMART_RENDER)));
|
2014-10-28 17:36:55 +00:00
|
|
|
_link_track (pipeline, track);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-11-03 12:06:34 +00:00
|
|
|
_timeline_track_removed_cb (GESTimeline * timeline, GESTrack * track,
|
|
|
|
GESPipeline * pipeline)
|
2014-10-28 17:36:55 +00:00
|
|
|
{
|
|
|
|
_unlink_track (pipeline, track);
|
|
|
|
}
|
|
|
|
|
2009-08-04 15:13:11 +00:00
|
|
|
static void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_dispose (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
GESPipeline *self = GES_PIPELINE (object);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (self->priv->playsink) {
|
2014-02-17 11:34:04 +00:00
|
|
|
if (self->priv->mode & (GES_PIPELINE_MODE_PREVIEW))
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_bin_remove (GST_BIN (object), self->priv->playsink);
|
2010-06-21 09:52:49 +00:00
|
|
|
else
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_object_unref (self->priv->playsink);
|
|
|
|
self->priv->playsink = NULL;
|
2009-09-08 17:45:08 +00:00
|
|
|
}
|
2010-06-21 09:52:49 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (self->priv->encodebin) {
|
2014-02-17 11:34:04 +00:00
|
|
|
if (self->priv->mode & (GES_PIPELINE_MODE_RENDER |
|
|
|
|
GES_PIPELINE_MODE_SMART_RENDER))
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_bin_remove (GST_BIN (object), self->priv->encodebin);
|
2010-06-21 09:52:49 +00:00
|
|
|
else
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_object_unref (self->priv->encodebin);
|
|
|
|
self->priv->encodebin = NULL;
|
2010-06-21 09:52:49 +00:00
|
|
|
}
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (self->priv->profile) {
|
2010-12-15 11:36:25 +00:00
|
|
|
gst_encoding_profile_unref (self->priv->profile);
|
2010-11-28 15:40:15 +00:00
|
|
|
self->priv->profile = NULL;
|
2010-06-21 09:53:30 +00:00
|
|
|
}
|
|
|
|
|
2014-10-28 17:36:55 +00:00
|
|
|
if (self->priv->timeline) {
|
|
|
|
g_signal_handlers_disconnect_by_func (self->priv->timeline,
|
|
|
|
_timeline_track_added_cb, self);
|
|
|
|
g_signal_handlers_disconnect_by_func (self->priv->timeline,
|
|
|
|
_timeline_track_removed_cb, self);
|
|
|
|
}
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
G_OBJECT_CLASS (ges_pipeline_parent_class)->dispose (object);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_class_init (GESPipelineClass * klass)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2009-09-08 17:45:08 +00:00
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GESPipelinePrivate));
|
2010-11-28 15:40:15 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (ges_pipeline_debug, "gespipeline",
|
|
|
|
GST_DEBUG_FG_YELLOW, "ges pipeline");
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
object_class->dispose = ges_pipeline_dispose;
|
|
|
|
object_class->get_property = ges_pipeline_get_property;
|
|
|
|
object_class->set_property = ges_pipeline_set_property;
|
2011-11-11 16:29:20 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* GESPipeline:audio-sink:
|
2011-11-11 16:29:20 +00:00
|
|
|
*
|
|
|
|
* Audio sink for the preview.
|
|
|
|
*/
|
|
|
|
properties[PROP_AUDIO_SINK] = g_param_spec_object ("audio-sink", "Audio Sink",
|
|
|
|
"Audio sink for the preview.",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* GESPipeline:video-sink:
|
2011-11-11 16:29:20 +00:00
|
|
|
*
|
|
|
|
* Video sink for the preview.
|
|
|
|
*/
|
|
|
|
properties[PROP_VIDEO_SINK] = g_param_spec_object ("video-sink", "Video Sink",
|
|
|
|
"Video sink for the preview.",
|
|
|
|
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2011-12-23 13:07:21 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* GESPipeline:timeline:
|
2011-12-23 13:07:21 +00:00
|
|
|
*
|
|
|
|
* Timeline to use in this pipeline. See also
|
2014-02-04 09:45:58 +00:00
|
|
|
* ges_pipeline_set_timeline() for more info.
|
2011-12-23 13:07:21 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_TIMELINE] = g_param_spec_object ("timeline", "Timeline",
|
|
|
|
"Timeline to use in this pipeline. See also "
|
2014-02-04 09:45:58 +00:00
|
|
|
"ges_pipeline_set_timeline() for more info.",
|
2011-12-23 13:07:21 +00:00
|
|
|
GES_TYPE_TIMELINE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* GESPipeline:mode:
|
2011-12-23 13:07:21 +00:00
|
|
|
*
|
2013-07-01 14:27:54 +00:00
|
|
|
* Pipeline mode. See ges_pipeline_set_mode() for more
|
2011-12-23 13:07:21 +00:00
|
|
|
* info.
|
|
|
|
*/
|
|
|
|
properties[PROP_MODE] = g_param_spec_flags ("mode", "Mode",
|
2013-07-01 14:27:54 +00:00
|
|
|
"Pipeline mode. See ges_pipeline_set_mode() for more info.",
|
2011-12-23 13:07:21 +00:00
|
|
|
GES_TYPE_PIPELINE_FLAGS, DEFAULT_TIMELINE_MODE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
2014-11-25 18:13:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GESPipeline::audio-filter
|
|
|
|
*
|
|
|
|
* The audio filter(s) to apply during playback right before the audio sink
|
|
|
|
*
|
|
|
|
* Since: 1.6.0
|
|
|
|
*/
|
|
|
|
properties[PROP_AUDIO_FILTER] =
|
|
|
|
g_param_spec_object ("audio-filter", "Audio filter",
|
|
|
|
"the audio filter(s) to apply, if possible", GST_TYPE_ELEMENT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GESPipeline::video-filter
|
|
|
|
*
|
|
|
|
* The video filter(s) to apply during playback right before the video sink
|
|
|
|
*
|
|
|
|
* Since: 1.6.0
|
|
|
|
*/
|
|
|
|
properties[PROP_VIDEO_FILTER] =
|
|
|
|
g_param_spec_object ("video-filter", "Video filter",
|
|
|
|
"the Video filter(s) to apply, if possible", GST_TYPE_ELEMENT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, PROP_LAST, properties);
|
2011-12-23 13:07:21 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
element_class->change_state = GST_DEBUG_FUNCPTR (ges_pipeline_change_state);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
/* TODO : Add state_change handlers
|
|
|
|
* Don't change state if we don't have a timeline */
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_init (GESPipeline * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2009-09-08 17:45:08 +00:00
|
|
|
GST_INFO_OBJECT (self, "Creating new 'playsink'");
|
2010-11-28 15:40:15 +00:00
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
2013-09-09 15:47:02 +00:00
|
|
|
GES_TYPE_PIPELINE, GESPipelinePrivate);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
self->priv->playsink =
|
|
|
|
gst_element_factory_make ("playsink", "internal-sinks");
|
|
|
|
self->priv->encodebin =
|
2009-12-04 09:49:32 +00:00
|
|
|
gst_element_factory_make ("encodebin", "internal-encodebin");
|
2013-09-16 16:30:33 +00:00
|
|
|
g_object_set (self->priv->encodebin, "avoid-reencoding", TRUE, NULL);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (G_UNLIKELY (self->priv->playsink == NULL))
|
2011-08-29 10:00:06 +00:00
|
|
|
goto no_playsink;
|
2010-11-28 15:40:15 +00:00
|
|
|
if (G_UNLIKELY (self->priv->encodebin == NULL))
|
2011-08-29 10:00:06 +00:00
|
|
|
goto no_encodebin;
|
2010-11-23 17:24:38 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_set_mode (self, DEFAULT_TIMELINE_MODE);
|
2011-08-29 10:00:06 +00:00
|
|
|
|
2011-08-30 14:40:03 +00:00
|
|
|
return;
|
|
|
|
|
2011-08-29 10:00:06 +00:00
|
|
|
no_playsink:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (self, "Can't create playsink instance !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
no_encodebin:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (self, "Can't create encodebin instance !");
|
|
|
|
return;
|
|
|
|
}
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_new:
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2013-07-01 14:27:54 +00:00
|
|
|
* Creates a new conveninence #GESPipeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer floating): the new #GESPipeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2013-07-01 14:27:54 +00:00
|
|
|
GESPipeline *
|
|
|
|
ges_pipeline_new (void)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2013-09-09 15:47:32 +00:00
|
|
|
return GES_PIPELINE (gst_element_factory_make ("gespipeline", NULL));
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-12-15 11:36:25 +00:00
|
|
|
#define TRACK_COMPATIBLE_PROFILE(tracktype, profile) \
|
|
|
|
( (GST_IS_ENCODING_AUDIO_PROFILE (profile) && (tracktype) == GES_TRACK_TYPE_AUDIO) || \
|
|
|
|
(GST_IS_ENCODING_VIDEO_PROFILE (profile) && (tracktype) == GES_TRACK_TYPE_VIDEO))
|
2010-04-20 11:26:00 +00:00
|
|
|
|
2014-06-05 00:16:01 +00:00
|
|
|
static gboolean
|
|
|
|
_track_is_compatible_with_profile (GESPipeline * self, GESTrack * track,
|
|
|
|
GstEncodingProfile * prof)
|
|
|
|
{
|
|
|
|
if (TRACK_COMPATIBLE_PROFILE (track->type, prof)) {
|
|
|
|
if (self->priv->mode == GES_PIPELINE_MODE_SMART_RENDER) {
|
|
|
|
GstCaps *ocaps, *rcaps;
|
|
|
|
|
|
|
|
GST_DEBUG ("Smart Render mode, setting input caps");
|
|
|
|
ocaps = gst_encoding_profile_get_input_caps (prof);
|
|
|
|
ocaps = gst_caps_make_writable (ocaps);
|
|
|
|
if (track->type == GES_TRACK_TYPE_AUDIO)
|
|
|
|
rcaps = gst_caps_new_empty_simple ("audio/x-raw");
|
|
|
|
else
|
|
|
|
rcaps = gst_caps_new_empty_simple ("video/x-raw");
|
|
|
|
gst_caps_append (ocaps, rcaps);
|
|
|
|
ges_track_set_caps (track, ocaps);
|
|
|
|
gst_caps_unref (ocaps);
|
|
|
|
} else {
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
|
|
|
/* Raw preview or rendering mode */
|
|
|
|
if (track->type == GES_TRACK_TYPE_VIDEO)
|
|
|
|
caps = gst_caps_new_empty_simple ("video/x-raw");
|
|
|
|
else if (track->type == GES_TRACK_TYPE_AUDIO)
|
|
|
|
caps = gst_caps_new_empty_simple ("audio/x-raw");
|
|
|
|
|
|
|
|
if (caps) {
|
|
|
|
ges_track_set_caps (track, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
static gboolean
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_update_caps (GESPipeline * self)
|
2010-04-20 11:26:00 +00:00
|
|
|
{
|
|
|
|
GList *ltrack, *tracks, *lstream;
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (!self->priv->profile)
|
2010-04-20 11:26:00 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
GST_DEBUG ("Updating track caps");
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
tracks = ges_timeline_get_tracks (self->priv->timeline);
|
2010-04-20 11:26:00 +00:00
|
|
|
|
|
|
|
/* Take each stream of the encoding profile and find a matching
|
|
|
|
* track to set the caps on */
|
|
|
|
for (ltrack = tracks; ltrack; ltrack = ltrack->next) {
|
|
|
|
GESTrack *track = (GESTrack *) ltrack->data;
|
2010-12-15 11:36:25 +00:00
|
|
|
GList *allstreams;
|
|
|
|
|
2014-06-05 00:16:01 +00:00
|
|
|
if (!GST_IS_ENCODING_CONTAINER_PROFILE (self->priv->profile)) {
|
|
|
|
if (_track_is_compatible_with_profile (self, track, self->priv->profile)) {
|
|
|
|
gst_object_unref (track);
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
} else {
|
|
|
|
gst_object_unref (track);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-15 11:36:25 +00:00
|
|
|
allstreams = (GList *)
|
|
|
|
gst_encoding_container_profile_get_profiles (
|
|
|
|
(GstEncodingContainerProfile *) self->priv->profile);
|
2010-04-20 11:26:00 +00:00
|
|
|
|
|
|
|
/* Find a matching stream setting */
|
2010-12-15 11:36:25 +00:00
|
|
|
for (lstream = allstreams; lstream; lstream = lstream->next) {
|
|
|
|
GstEncodingProfile *prof = (GstEncodingProfile *) lstream->data;
|
2014-06-05 00:16:01 +00:00
|
|
|
if (_track_is_compatible_with_profile (self, track, prof))
|
2010-04-20 11:26:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (track);
|
2010-04-20 11:26:00 +00:00
|
|
|
}
|
|
|
|
|
2014-06-05 00:16:01 +00:00
|
|
|
done:
|
2010-04-20 11:26:00 +00:00
|
|
|
if (tracks)
|
|
|
|
g_list_free (tracks);
|
|
|
|
|
|
|
|
GST_DEBUG ("Done updating caps");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
static void
|
|
|
|
_link_tracks (GESPipeline * pipeline)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (pipeline, "Linking tracks");
|
|
|
|
|
|
|
|
if (!pipeline->priv->timeline) {
|
|
|
|
GST_INFO_OBJECT (pipeline, "Not timeline set yet, doing nothing");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next)
|
|
|
|
_link_track (pipeline, tmp->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_unlink_tracks (GESPipeline * pipeline)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (pipeline, "Disconnecting all tracks");
|
|
|
|
if (!pipeline->priv->timeline) {
|
|
|
|
GST_INFO_OBJECT (pipeline, "Not timeline set yet, doing nothing");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next)
|
|
|
|
_unlink_track (pipeline, tmp->data);
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
static GstStateChangeReturn
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_change_state (GstElement * element, GstStateChange transition)
|
2009-09-08 17:45:08 +00:00
|
|
|
{
|
2013-07-01 14:27:54 +00:00
|
|
|
GESPipeline *self;
|
2009-09-08 17:45:08 +00:00
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
self = GES_PIPELINE (element);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2010-11-28 15:40:15 +00:00
|
|
|
if (G_UNLIKELY (self->priv->timeline == NULL)) {
|
2009-09-08 17:45:08 +00:00
|
|
|
GST_ERROR_OBJECT (element,
|
|
|
|
"No GESTimeline set on the pipeline, cannot play !");
|
|
|
|
ret = GST_STATE_CHANGE_FAILURE;
|
|
|
|
goto done;
|
|
|
|
}
|
2014-02-17 11:34:04 +00:00
|
|
|
if (self->priv->mode & (GES_PIPELINE_MODE_RENDER |
|
2018-04-20 20:36:55 +00:00
|
|
|
GES_PIPELINE_MODE_SMART_RENDER)) {
|
2010-04-20 11:26:00 +00:00
|
|
|
GST_DEBUG ("rendering => Updating pipeline caps");
|
2018-04-20 20:36:55 +00:00
|
|
|
/* Set caps on all tracks according to profile if present */
|
|
|
|
if (!ges_pipeline_update_caps (self)) {
|
|
|
|
GST_ERROR_OBJECT (element, "Error setting the caps for rendering");
|
|
|
|
ret = GST_STATE_CHANGE_FAILURE;
|
|
|
|
goto done;
|
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
}
|
2014-10-21 08:59:43 +00:00
|
|
|
_link_tracks (self);
|
2009-09-08 17:45:08 +00:00
|
|
|
break;
|
2015-06-10 15:54:20 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
for (tmp = self->priv->not_rendered_tracks; tmp; tmp = tmp->next)
|
|
|
|
gst_element_set_locked_state (tmp->data, FALSE);
|
|
|
|
}
|
|
|
|
break;
|
2017-08-19 14:42:57 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
|
|
{
|
|
|
|
GstElement *queue = gst_bin_get_by_name (GST_BIN (self->priv->playsink),
|
|
|
|
"vqueue");
|
|
|
|
|
|
|
|
if (queue) {
|
|
|
|
GST_INFO_OBJECT (self, "Setting playsink video queue max-size-time to"
|
|
|
|
" 2 seconds.");
|
|
|
|
g_object_set (G_OBJECT (queue), "max-size-buffers", 0,
|
|
|
|
"max-size-bytes", 0, "max-size-time", (gint64) 2 * GST_SECOND,
|
|
|
|
NULL);
|
|
|
|
gst_object_unref (queue);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-09-08 17:45:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret =
|
2013-07-01 14:27:54 +00:00
|
|
|
GST_ELEMENT_CLASS (ges_pipeline_parent_class)->change_state
|
2009-11-30 14:14:25 +00:00
|
|
|
(element, transition);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
2017-07-24 14:32:47 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_NULL:
|
2014-10-21 08:59:43 +00:00
|
|
|
_unlink_tracks (self);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-20 10:57:53 +00:00
|
|
|
static OutputChain *
|
2013-07-01 14:27:54 +00:00
|
|
|
new_output_chain_for_track (GESPipeline * self, GESTrack * track)
|
2010-04-20 10:57:53 +00:00
|
|
|
{
|
|
|
|
OutputChain *chain;
|
|
|
|
|
|
|
|
chain = g_new0 (OutputChain, 1);
|
|
|
|
chain->track = track;
|
|
|
|
|
|
|
|
return chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
static OutputChain *
|
2013-07-01 14:27:54 +00:00
|
|
|
get_output_chain_for_track (GESPipeline * self, GESTrack * track)
|
2010-04-20 10:57:53 +00:00
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
for (tmp = self->priv->chains; tmp; tmp = tmp->next) {
|
2010-04-20 10:57:53 +00:00
|
|
|
OutputChain *chain = (OutputChain *) tmp->data;
|
|
|
|
if (chain->track == track)
|
|
|
|
return chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-08-29 10:00:06 +00:00
|
|
|
/* Fetches a compatible pad on the target element which isn't already
|
2010-01-08 17:14:46 +00:00
|
|
|
* linked */
|
|
|
|
static GstPad *
|
2014-10-21 08:59:43 +00:00
|
|
|
get_compatible_unlinked_pad (GstElement * element, GESTrack * track)
|
2010-01-08 17:14:46 +00:00
|
|
|
{
|
|
|
|
GstPad *res = NULL;
|
|
|
|
GstIterator *pads;
|
|
|
|
gboolean done = FALSE;
|
2014-10-21 08:59:43 +00:00
|
|
|
const GstCaps *srccaps;
|
2011-10-11 07:51:35 +00:00
|
|
|
GValue paditem = { 0, };
|
2010-01-08 17:14:46 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
if (G_UNLIKELY (track == NULL))
|
|
|
|
goto no_track;
|
2011-08-29 10:00:06 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_DEBUG_OBJECT (element, " track %" GST_PTR_FORMAT, track);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
pads = gst_element_iterate_sink_pads (element);
|
|
|
|
srccaps = ges_track_get_caps (track);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
2017-07-24 14:34:48 +00:00
|
|
|
GST_DEBUG_OBJECT (track, "srccaps %" GST_PTR_FORMAT, srccaps);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
|
|
|
while (!done) {
|
2011-10-11 07:51:35 +00:00
|
|
|
switch (gst_iterator_next (pads, &paditem)) {
|
2010-01-08 17:14:46 +00:00
|
|
|
case GST_ITERATOR_OK:
|
|
|
|
{
|
2011-10-11 07:51:35 +00:00
|
|
|
GstPad *testpad = g_value_get_object (&paditem);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
2011-10-11 07:51:35 +00:00
|
|
|
if (!gst_pad_is_linked (testpad)) {
|
2011-12-30 16:15:07 +00:00
|
|
|
GstCaps *sinkcaps = gst_pad_query_caps (testpad, NULL);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
2017-07-24 14:34:48 +00:00
|
|
|
GST_DEBUG_OBJECT (track, "sinkccaps %" GST_PTR_FORMAT, sinkcaps);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
|
|
|
if (gst_caps_can_intersect (srccaps, sinkcaps)) {
|
2011-10-11 07:51:35 +00:00
|
|
|
res = gst_object_ref (testpad);
|
2010-01-08 17:14:46 +00:00
|
|
|
done = TRUE;
|
2011-10-11 07:51:35 +00:00
|
|
|
}
|
2010-01-08 17:14:46 +00:00
|
|
|
gst_caps_unref (sinkcaps);
|
|
|
|
}
|
2011-10-11 07:51:35 +00:00
|
|
|
g_value_reset (&paditem);
|
2010-01-08 17:14:46 +00:00
|
|
|
}
|
2010-03-13 15:05:37 +00:00
|
|
|
break;
|
2010-01-08 17:14:46 +00:00
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
case GST_ITERATOR_ERROR:
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_ITERATOR_RESYNC:
|
|
|
|
gst_iterator_resync (pads);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-10-11 07:51:35 +00:00
|
|
|
g_value_reset (&paditem);
|
2010-01-08 17:14:46 +00:00
|
|
|
gst_iterator_free (pads);
|
|
|
|
|
|
|
|
return res;
|
2011-08-29 10:00:06 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
no_track:
|
2011-08-29 10:00:06 +00:00
|
|
|
{
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_ERROR ("No track to check against");
|
2011-08-29 10:00:06 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-08 17:14:46 +00:00
|
|
|
}
|
|
|
|
|
2014-11-04 14:38:05 +00:00
|
|
|
static GstClockTime
|
|
|
|
_query_position_cb (GstElement * composition, GESPipeline * self)
|
|
|
|
{
|
|
|
|
gint64 position;
|
|
|
|
|
|
|
|
if (gst_element_query_position (GST_ELEMENT (self), GST_FORMAT_TIME,
|
|
|
|
&position))
|
|
|
|
return position;
|
|
|
|
|
|
|
|
return GST_CLOCK_TIME_NONE;
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
static void
|
2014-10-21 08:59:43 +00:00
|
|
|
_link_track (GESPipeline * self, GESTrack * track)
|
2009-09-08 17:45:08 +00:00
|
|
|
{
|
2014-10-21 08:59:43 +00:00
|
|
|
GstPad *pad;
|
2009-09-08 17:45:08 +00:00
|
|
|
OutputChain *chain;
|
|
|
|
GstPad *sinkpad;
|
2011-10-11 07:51:35 +00:00
|
|
|
GstCaps *caps;
|
2014-10-21 08:59:43 +00:00
|
|
|
GstPadLinkReturn lret;
|
2009-09-09 10:42:29 +00:00
|
|
|
gboolean reconfigured = FALSE;
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
pad = ges_timeline_get_pad_for_track (self->priv->timeline, track);
|
2011-12-30 16:15:07 +00:00
|
|
|
caps = gst_pad_query_caps (pad, NULL);
|
2011-10-11 07:51:35 +00:00
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "new pad %s:%s , caps:%" GST_PTR_FORMAT,
|
2011-10-11 07:51:35 +00:00
|
|
|
GST_DEBUG_PAD_NAME (pad), caps);
|
2009-12-04 09:49:32 +00:00
|
|
|
|
2011-10-11 07:51:35 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!track)) {
|
2009-09-08 17:45:08 +00:00
|
|
|
GST_WARNING_OBJECT (self, "Couldn't find coresponding track !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-09 11:22:34 +00:00
|
|
|
/* Don't connect track if it's not going to be used */
|
|
|
|
if (track->type == GES_TRACK_TYPE_VIDEO &&
|
2014-02-17 11:34:04 +00:00
|
|
|
!(self->priv->mode & GES_PIPELINE_MODE_PREVIEW_VIDEO) &&
|
|
|
|
!(self->priv->mode & GES_PIPELINE_MODE_RENDER) &&
|
|
|
|
!(self->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)) {
|
2009-12-09 11:22:34 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Video track... but we don't need it. Not linking");
|
2009-09-08 17:45:08 +00:00
|
|
|
}
|
2009-12-09 11:22:34 +00:00
|
|
|
if (track->type == GES_TRACK_TYPE_AUDIO &&
|
2014-02-17 11:34:04 +00:00
|
|
|
!(self->priv->mode & GES_PIPELINE_MODE_PREVIEW_AUDIO) &&
|
|
|
|
!(self->priv->mode & GES_PIPELINE_MODE_RENDER) &&
|
|
|
|
!(self->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)) {
|
2009-12-09 11:22:34 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Audio track... but we don't need it. Not linking");
|
2009-09-08 17:45:08 +00:00
|
|
|
}
|
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
/* Get an existing chain or create it */
|
|
|
|
if (!(chain = get_output_chain_for_track (self, track)))
|
|
|
|
chain = new_output_chain_for_track (self, track);
|
2014-11-03 12:06:34 +00:00
|
|
|
|
2014-11-25 17:46:03 +00:00
|
|
|
if (chain->tee) {
|
2017-07-24 14:34:48 +00:00
|
|
|
GST_INFO_OBJECT (self, "Chain is already built (%" GST_PTR_FORMAT ")",
|
|
|
|
chain->encodebinpad ? chain->encodebinpad : chain->playsinkpad);
|
2014-11-25 17:46:03 +00:00
|
|
|
|
2014-11-03 12:06:34 +00:00
|
|
|
return;
|
2014-11-25 17:46:03 +00:00
|
|
|
}
|
2014-11-03 12:06:34 +00:00
|
|
|
|
2014-11-04 14:38:05 +00:00
|
|
|
chain->query_position_id =
|
|
|
|
g_signal_connect (ges_track_get_composition (track), "query-position",
|
|
|
|
G_CALLBACK (_query_position_cb), self);
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
chain->srcpad = pad;
|
2014-10-21 08:59:43 +00:00
|
|
|
gst_object_unref (pad);
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
/* Adding tee */
|
2014-11-25 17:46:03 +00:00
|
|
|
chain->tee = gst_element_factory_make ("tee", NULL);
|
|
|
|
gst_bin_add (GST_BIN_CAST (self), chain->tee);
|
|
|
|
gst_element_sync_state_with_parent (chain->tee);
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
/* Linking pad to tee */
|
2010-04-20 11:26:00 +00:00
|
|
|
sinkpad = gst_element_get_static_pad (chain->tee, "sink");
|
2014-10-21 08:59:43 +00:00
|
|
|
lret = gst_pad_link (pad, sinkpad);
|
|
|
|
if (lret != GST_PAD_LINK_OK) {
|
|
|
|
GST_ERROR_OBJECT (self, "Could not link the tee (%i)", lret);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (sinkpad);
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
/* Connect playsink */
|
2014-02-17 11:34:04 +00:00
|
|
|
if (self->priv->mode & GES_PIPELINE_MODE_PREVIEW) {
|
2009-12-09 11:22:34 +00:00
|
|
|
const gchar *sinkpad_name;
|
2010-06-21 09:54:01 +00:00
|
|
|
GstPad *tmppad;
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "Connecting to playsink");
|
|
|
|
|
|
|
|
switch (track->type) {
|
|
|
|
case GES_TRACK_TYPE_VIDEO:
|
|
|
|
sinkpad_name = "video_sink";
|
|
|
|
break;
|
|
|
|
case GES_TRACK_TYPE_AUDIO:
|
|
|
|
sinkpad_name = "audio_sink";
|
|
|
|
break;
|
|
|
|
case GES_TRACK_TYPE_TEXT:
|
|
|
|
sinkpad_name = "text_sink";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_WARNING_OBJECT (self, "Can't handle tracks of type %d yet",
|
|
|
|
track->type);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Request a sinkpad from playsink */
|
|
|
|
if (G_UNLIKELY (!(sinkpad =
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_element_get_request_pad (self->priv->playsink,
|
|
|
|
sinkpad_name)))) {
|
2010-04-20 11:26:00 +00:00
|
|
|
GST_ERROR_OBJECT (self, "Couldn't get a pad from the playsink !");
|
2009-12-09 11:22:34 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2012-04-18 14:34:01 +00:00
|
|
|
tmppad = gst_element_get_request_pad (chain->tee, "src_%u");
|
2010-07-14 11:29:23 +00:00
|
|
|
if (G_UNLIKELY (gst_pad_link_full (tmppad, sinkpad,
|
|
|
|
GST_PAD_LINK_CHECK_NOTHING) != GST_PAD_LINK_OK)) {
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_ERROR_OBJECT (self, "Couldn't link track pad to encodebin");
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (tmppad);
|
2009-12-09 11:22:34 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2015-09-24 04:40:27 +00:00
|
|
|
gst_object_unref (tmppad);
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Reconfiguring playsink");
|
|
|
|
|
|
|
|
/* reconfigure playsink */
|
2010-11-28 15:40:15 +00:00
|
|
|
g_signal_emit_by_name (self->priv->playsink, "reconfigure", &reconfigured);
|
2009-12-09 11:22:34 +00:00
|
|
|
GST_DEBUG ("'reconfigure' returned %d", reconfigured);
|
|
|
|
|
2010-06-21 09:54:01 +00:00
|
|
|
/* We still hold a reference on the sinkpad */
|
2009-12-09 11:22:34 +00:00
|
|
|
chain->playsinkpad = sinkpad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Connect to encodebin */
|
2015-07-01 15:28:52 +00:00
|
|
|
if (self->
|
|
|
|
priv->mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER))
|
|
|
|
{
|
2010-06-21 09:54:01 +00:00
|
|
|
GstPad *tmppad;
|
2009-12-09 11:22:34 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Connecting to encodebin");
|
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
if (!chain->encodebinpad) {
|
|
|
|
/* Check for unused static pads */
|
2014-10-21 08:59:43 +00:00
|
|
|
sinkpad = get_compatible_unlinked_pad (self->priv->encodebin, track);
|
2010-04-20 11:26:00 +00:00
|
|
|
|
|
|
|
if (sinkpad == NULL) {
|
2011-12-30 16:15:07 +00:00
|
|
|
GstCaps *caps = gst_pad_query_caps (pad, NULL);
|
2011-10-11 07:51:35 +00:00
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
/* If no compatible static pad is available, request a pad */
|
2010-11-28 15:40:15 +00:00
|
|
|
g_signal_emit_by_name (self->priv->encodebin, "request-pad", caps,
|
|
|
|
&sinkpad);
|
2011-10-11 07:51:35 +00:00
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
if (G_UNLIKELY (sinkpad == NULL)) {
|
2017-07-24 14:34:48 +00:00
|
|
|
GST_INFO_OBJECT (self, "Couldn't get a pad from encodebin for: %"
|
|
|
|
GST_PTR_FORMAT, caps);
|
|
|
|
gst_caps_unref (caps);
|
2015-06-10 15:54:20 +00:00
|
|
|
gst_element_set_locked_state (GST_ELEMENT (track), TRUE);
|
|
|
|
|
|
|
|
self->priv->not_rendered_tracks =
|
|
|
|
g_list_append (self->priv->not_rendered_tracks, track);
|
|
|
|
|
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2017-07-24 14:34:48 +00:00
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
2010-01-08 17:14:46 +00:00
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
chain->encodebinpad = sinkpad;
|
2017-07-24 14:34:48 +00:00
|
|
|
GST_INFO_OBJECT (track, "Linked to %" GST_PTR_FORMAT, sinkpad);
|
2009-12-09 11:22:34 +00:00
|
|
|
}
|
|
|
|
|
2012-04-18 14:34:01 +00:00
|
|
|
tmppad = gst_element_get_request_pad (chain->tee, "src_%u");
|
2014-10-21 08:59:43 +00:00
|
|
|
if (G_UNLIKELY (gst_pad_link_full (tmppad, chain->encodebinpad,
|
2010-07-14 11:29:23 +00:00
|
|
|
GST_PAD_LINK_CHECK_NOTHING) != GST_PAD_LINK_OK)) {
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_ERROR_OBJECT (self, "Couldn't link track pad to encodebin");
|
2009-12-09 11:22:34 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (tmppad);
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
}
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
/* If chain wasn't already present, insert it in list */
|
|
|
|
if (!get_output_chain_for_track (self, track))
|
2010-11-28 15:40:15 +00:00
|
|
|
self->priv->chains = g_list_append (self->priv->chains, chain);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("done");
|
2009-12-09 11:22:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
{
|
|
|
|
if (chain->tee) {
|
2015-06-10 15:54:20 +00:00
|
|
|
gst_element_set_state (chain->tee, GST_STATE_NULL);
|
2009-12-09 11:22:34 +00:00
|
|
|
gst_bin_remove (GST_BIN_CAST (self), chain->tee);
|
|
|
|
}
|
|
|
|
if (sinkpad)
|
|
|
|
gst_object_unref (sinkpad);
|
2015-06-10 15:54:20 +00:00
|
|
|
|
2009-12-09 11:22:34 +00:00
|
|
|
g_free (chain);
|
|
|
|
}
|
2009-09-08 17:45:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-10-21 08:59:43 +00:00
|
|
|
_unlink_track (GESPipeline * self, GESTrack * track)
|
2009-09-08 17:45:08 +00:00
|
|
|
{
|
2010-04-20 11:41:20 +00:00
|
|
|
OutputChain *chain;
|
2009-12-04 09:49:32 +00:00
|
|
|
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Unlinking removed %" GST_PTR_FORMAT, track);
|
2010-04-20 11:41:20 +00:00
|
|
|
|
|
|
|
if (G_UNLIKELY (!(chain = get_output_chain_for_track (self, track)))) {
|
2014-10-21 08:59:43 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "Track wasn't used");
|
2010-04-20 11:41:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlink encodebin */
|
|
|
|
if (chain->encodebinpad) {
|
2015-03-31 13:29:49 +00:00
|
|
|
GstPad *peer = gst_pad_get_peer (chain->encodebinpad);
|
2010-04-20 11:41:20 +00:00
|
|
|
gst_pad_unlink (peer, chain->encodebinpad);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (peer);
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_element_release_request_pad (self->priv->encodebin,
|
|
|
|
chain->encodebinpad);
|
2013-10-17 13:16:00 +00:00
|
|
|
gst_object_unref (chain->encodebinpad);
|
2010-04-20 11:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlink playsink */
|
|
|
|
if (chain->playsinkpad) {
|
2015-03-31 13:29:49 +00:00
|
|
|
GstPad *peer = gst_pad_get_peer (chain->playsinkpad);
|
2010-04-20 11:41:20 +00:00
|
|
|
gst_pad_unlink (peer, chain->playsinkpad);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (peer);
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_element_release_request_pad (self->priv->playsink, chain->playsinkpad);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (chain->playsinkpad);
|
2010-04-20 11:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_set_state (chain->tee, GST_STATE_NULL);
|
|
|
|
gst_bin_remove (GST_BIN (self), chain->tee);
|
2014-11-04 14:38:05 +00:00
|
|
|
if (chain->query_position_id) {
|
|
|
|
g_signal_handler_disconnect (ges_track_get_composition (track),
|
|
|
|
chain->query_position_id);
|
|
|
|
chain->query_position_id = 0;
|
|
|
|
}
|
2010-04-20 11:41:20 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
self->priv->chains = g_list_remove (self->priv->chains, chain);
|
2010-04-20 11:41:20 +00:00
|
|
|
g_free (chain);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("done");
|
|
|
|
}
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
2014-02-04 09:45:58 +00:00
|
|
|
* ges_pipeline_set_timeline:
|
2013-07-01 14:27:54 +00:00
|
|
|
* @pipeline: a #GESPipeline
|
2016-05-14 23:04:17 +00:00
|
|
|
* @timeline: (transfer full): the #GESTimeline to set on the @pipeline.
|
2009-09-16 10:37:45 +00:00
|
|
|
*
|
|
|
|
* Sets the timeline to use in this pipeline.
|
|
|
|
*
|
|
|
|
* The reference to the @timeline will be stolen by the @pipeline.
|
|
|
|
*
|
2017-04-02 21:03:18 +00:00
|
|
|
* Returns: %TRUE if the @timeline could be successfully set on the @pipeline,
|
|
|
|
* else %FALSE.
|
2009-09-16 10:37:45 +00:00
|
|
|
*/
|
2009-09-08 17:45:08 +00:00
|
|
|
gboolean
|
2014-02-04 09:45:58 +00:00
|
|
|
ges_pipeline_set_timeline (GESPipeline * pipeline, GESTimeline * timeline)
|
2009-09-08 17:45:08 +00:00
|
|
|
{
|
2014-10-21 08:59:43 +00:00
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (pipeline), FALSE);
|
2013-03-30 12:34:56 +00:00
|
|
|
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
|
2010-11-28 15:40:15 +00:00
|
|
|
g_return_val_if_fail (pipeline->priv->timeline == NULL, FALSE);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("pipeline:%p, timeline:%p", timeline, pipeline);
|
|
|
|
|
2009-12-09 11:22:34 +00:00
|
|
|
if (G_UNLIKELY (!gst_bin_add (GST_BIN_CAST (pipeline),
|
|
|
|
GST_ELEMENT (timeline)))) {
|
2009-09-08 17:45:08 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2010-11-28 15:40:15 +00:00
|
|
|
pipeline->priv->timeline = timeline;
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2014-10-28 17:36:55 +00:00
|
|
|
g_signal_connect (timeline, "track-added",
|
|
|
|
G_CALLBACK (_timeline_track_added_cb), pipeline);
|
|
|
|
g_signal_connect (timeline, "track-removed",
|
|
|
|
G_CALLBACK (_timeline_track_removed_cb), pipeline);
|
2013-04-09 03:02:14 +00:00
|
|
|
/* FIXME Check if we should rollback if we can't sync state */
|
|
|
|
gst_element_sync_state_with_parent (GST_ELEMENT (timeline));
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-12-04 09:49:32 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_set_render_settings:
|
|
|
|
* @pipeline: a #GESPipeline
|
2010-12-08 14:36:55 +00:00
|
|
|
* @output_uri: the URI to which the timeline will be rendered
|
2010-06-21 09:53:30 +00:00
|
|
|
* @profile: the #GstEncodingProfile to use to render the timeline.
|
2009-12-04 09:49:32 +00:00
|
|
|
*
|
|
|
|
* Specify where the pipeline shall be rendered and with what settings.
|
|
|
|
*
|
2010-06-21 09:53:30 +00:00
|
|
|
* A copy of @profile and @output_uri will be done internally, the caller can
|
|
|
|
* safely free those values afterwards.
|
|
|
|
*
|
2010-01-08 17:21:08 +00:00
|
|
|
* This method must be called before setting the pipeline mode to
|
2014-02-17 11:34:04 +00:00
|
|
|
* #GES_PIPELINE_MODE_RENDER
|
2010-01-08 17:21:08 +00:00
|
|
|
*
|
2009-12-04 09:49:32 +00:00
|
|
|
* Returns: %TRUE if the settings were aknowledged properly, else %FALSE
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_set_render_settings (GESPipeline * pipeline,
|
2012-07-20 11:11:56 +00:00
|
|
|
const gchar * output_uri, GstEncodingProfile * profile)
|
2009-12-04 09:49:32 +00:00
|
|
|
{
|
2012-06-25 08:32:36 +00:00
|
|
|
GError *err = NULL;
|
2013-07-22 01:41:13 +00:00
|
|
|
GstEncodingProfile *set_profile;
|
2012-06-25 08:32:36 +00:00
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (pipeline), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2014-03-14 17:48:44 +00:00
|
|
|
/* FIXME Properly handle multi track, for now GESPipeline
|
|
|
|
* only hanles single track per type, so we should just set the
|
|
|
|
* presence to 1.
|
|
|
|
*/
|
|
|
|
if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
|
|
|
|
const GList *tmpprofiles =
|
|
|
|
gst_encoding_container_profile_get_profiles
|
|
|
|
(GST_ENCODING_CONTAINER_PROFILE (profile));
|
2014-03-21 09:22:52 +00:00
|
|
|
GList *tmptrack, *tracks =
|
|
|
|
ges_timeline_get_tracks (pipeline->priv->timeline);
|
2014-03-14 17:48:44 +00:00
|
|
|
|
|
|
|
for (; tmpprofiles; tmpprofiles = tmpprofiles->next) {
|
2014-03-21 09:22:52 +00:00
|
|
|
for (tmptrack = tracks; tmptrack; tmptrack = tmptrack->next) {
|
|
|
|
if ((GST_IS_ENCODING_AUDIO_PROFILE (tmpprofiles->data) &&
|
|
|
|
GES_IS_AUDIO_TRACK (tmptrack->data)) ||
|
|
|
|
(GST_IS_ENCODING_VIDEO_PROFILE (tmpprofiles->data) &&
|
|
|
|
GES_IS_VIDEO_TRACK (tmptrack->data))) {
|
|
|
|
GST_DEBUG_OBJECT (pipeline, "Setting presence to 1!");
|
|
|
|
gst_encoding_profile_set_presence (tmpprofiles->data, 1);
|
2014-11-16 15:51:54 +00:00
|
|
|
gst_encoding_profile_set_allow_dynamic_output (tmpprofiles->data,
|
|
|
|
FALSE);
|
2014-03-21 09:22:52 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-14 17:48:44 +00:00
|
|
|
}
|
2014-03-21 09:22:52 +00:00
|
|
|
|
|
|
|
g_list_free_full (tracks, gst_object_unref);
|
2014-03-14 17:48:44 +00:00
|
|
|
}
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Clear previous URI sink if it existed */
|
|
|
|
/* FIXME : We should figure out if it was added to the pipeline,
|
|
|
|
* and if so, remove it. */
|
2010-11-28 15:40:15 +00:00
|
|
|
if (pipeline->priv->urisink) {
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (pipeline->priv->urisink);
|
2010-11-28 15:40:15 +00:00
|
|
|
pipeline->priv->urisink = NULL;
|
2009-12-04 09:49:32 +00:00
|
|
|
}
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
pipeline->priv->urisink =
|
2012-06-25 08:32:36 +00:00
|
|
|
gst_element_make_from_uri (GST_URI_SINK, output_uri, "urisink", &err);
|
2010-11-28 15:40:15 +00:00
|
|
|
if (G_UNLIKELY (pipeline->priv->urisink == NULL)) {
|
2012-06-25 08:32:36 +00:00
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't not create sink for URI %s: '%s'",
|
|
|
|
output_uri, ((err
|
|
|
|
&& err->message) ? err->message : "failed to create element"));
|
|
|
|
g_clear_error (&err);
|
2009-12-04 09:49:32 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (pipeline->priv->profile)
|
2010-12-15 11:36:25 +00:00
|
|
|
gst_encoding_profile_unref (pipeline->priv->profile);
|
2010-12-20 18:09:48 +00:00
|
|
|
g_object_set (pipeline->priv->encodebin, "avoid-reencoding",
|
2014-02-17 11:34:04 +00:00
|
|
|
!(!(pipeline->priv->mode & GES_PIPELINE_MODE_SMART_RENDER)), NULL);
|
2010-11-28 15:40:15 +00:00
|
|
|
g_object_set (pipeline->priv->encodebin, "profile", profile, NULL);
|
2013-07-22 01:41:13 +00:00
|
|
|
g_object_get (pipeline->priv->encodebin, "profile", &set_profile, NULL);
|
|
|
|
|
|
|
|
if (set_profile == NULL) {
|
|
|
|
GST_ERROR_OBJECT (pipeline, "Profile %" GST_PTR_FORMAT " could no be set",
|
|
|
|
profile);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We got a referencer when getting back the profile */
|
|
|
|
pipeline->priv->profile = profile;
|
2009-12-04 09:49:32 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-08-11 18:06:49 +00:00
|
|
|
/**
|
|
|
|
* ges_pipeline_get_mode:
|
|
|
|
* @pipeline: a #GESPipeline
|
|
|
|
*
|
|
|
|
* Returns: the #GESPipelineFlags currently in use.
|
|
|
|
**/
|
|
|
|
GESPipelineFlags
|
|
|
|
ges_pipeline_get_mode (GESPipeline * pipeline)
|
|
|
|
{
|
|
|
|
return pipeline->priv->mode;
|
|
|
|
}
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_set_mode:
|
|
|
|
* @pipeline: a #GESPipeline
|
2009-12-04 09:49:32 +00:00
|
|
|
* @mode: the #GESPipelineFlags to use
|
|
|
|
*
|
|
|
|
* switches the @pipeline to the specified @mode. The default mode when
|
2014-02-17 11:34:04 +00:00
|
|
|
* creating a #GESPipeline is #GES_PIPELINE_MODE_PREVIEW.
|
2009-12-04 09:49:32 +00:00
|
|
|
*
|
|
|
|
* Note: The @pipeline will be set to #GST_STATE_NULL during this call due to
|
2016-07-29 19:48:28 +00:00
|
|
|
* the internal changes that happen. The caller will therefore have to
|
2009-12-04 09:49:32 +00:00
|
|
|
* set the @pipeline to the requested state after calling this method.
|
2009-12-11 14:24:56 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the mode was properly set, else %FALSE.
|
2009-12-04 09:49:32 +00:00
|
|
|
**/
|
|
|
|
gboolean
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_set_mode (GESPipeline * pipeline, GESPipelineFlags mode)
|
2009-12-04 09:49:32 +00:00
|
|
|
{
|
2015-07-01 15:28:52 +00:00
|
|
|
|
|
|
|
GList *tmp;
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (pipeline), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2015-06-16 13:02:18 +00:00
|
|
|
GST_DEBUG_OBJECT (pipeline, "current mode : %d, mode : %d",
|
2010-11-28 15:40:15 +00:00
|
|
|
pipeline->priv->mode, mode);
|
2009-12-04 09:49:32 +00:00
|
|
|
|
|
|
|
/* fast-path, nothing to change */
|
2010-11-28 15:40:15 +00:00
|
|
|
if (mode == pipeline->priv->mode)
|
2009-12-04 09:49:32 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* FIXME: It would be nice if we are only (de)activating preview
|
|
|
|
* modes to not set the whole pipeline to NULL, but instead just
|
|
|
|
* do the proper (un)linking to playsink. */
|
|
|
|
|
|
|
|
/* Switch pipeline to NULL since we're changing the configuration */
|
|
|
|
gst_element_set_state (GST_ELEMENT_CAST (pipeline), GST_STATE_NULL);
|
|
|
|
|
2015-07-01 15:28:52 +00:00
|
|
|
|
|
|
|
if (pipeline->priv->timeline) {
|
|
|
|
gboolean disabled =
|
|
|
|
! !(mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER));
|
|
|
|
|
|
|
|
for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next)
|
|
|
|
track_disable_last_gap (GES_TRACK (tmp->data), disabled);
|
|
|
|
}
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
/* remove no-longer needed components */
|
2014-02-17 11:34:04 +00:00
|
|
|
if (pipeline->priv->mode & GES_PIPELINE_MODE_PREVIEW &&
|
|
|
|
!(mode & GES_PIPELINE_MODE_PREVIEW)) {
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Disable playsink */
|
|
|
|
GST_DEBUG ("Disabling playsink");
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (pipeline->priv->playsink);
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_bin_remove (GST_BIN_CAST (pipeline), pipeline->priv->playsink);
|
2009-12-04 09:49:32 +00:00
|
|
|
}
|
2010-11-28 15:40:15 +00:00
|
|
|
if ((pipeline->priv->mode &
|
2014-02-17 11:34:04 +00:00
|
|
|
(GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) &&
|
|
|
|
!(mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER))) {
|
2012-12-20 17:58:35 +00:00
|
|
|
GList *tmp;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next) {
|
|
|
|
GESTrackType type = GES_TRACK (tmp->data)->type;
|
|
|
|
|
|
|
|
if (type == GES_TRACK_TYPE_AUDIO)
|
|
|
|
caps = gst_caps_new_empty_simple ("audio/x-raw");
|
|
|
|
else if (type == GES_TRACK_TYPE_VIDEO)
|
|
|
|
caps = gst_caps_new_empty_simple ("video/x-raw");
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ges_track_set_caps (GES_TRACK (tmp->data), caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Disable render bin */
|
|
|
|
GST_DEBUG ("Disabling rendering bin");
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (pipeline->priv->encodebin);
|
|
|
|
gst_object_ref (pipeline->priv->urisink);
|
2009-12-04 09:49:32 +00:00
|
|
|
gst_bin_remove_many (GST_BIN_CAST (pipeline),
|
2010-11-28 15:40:15 +00:00
|
|
|
pipeline->priv->encodebin, pipeline->priv->urisink, NULL);
|
2009-12-04 09:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new elements */
|
2014-02-17 11:34:04 +00:00
|
|
|
if (!(pipeline->priv->mode & GES_PIPELINE_MODE_PREVIEW) &&
|
|
|
|
(mode & GES_PIPELINE_MODE_PREVIEW)) {
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Add playsink */
|
|
|
|
GST_DEBUG ("Adding playsink");
|
2010-11-28 15:40:15 +00:00
|
|
|
if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->playsink)) {
|
2009-12-04 09:49:32 +00:00
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't add playsink");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2010-11-28 15:40:15 +00:00
|
|
|
if (!(pipeline->priv->mode &
|
2014-02-17 11:34:04 +00:00
|
|
|
(GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) &&
|
|
|
|
(mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER))) {
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Adding render bin */
|
|
|
|
GST_DEBUG ("Adding render bin");
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
if (G_UNLIKELY (pipeline->priv->urisink == NULL)) {
|
2009-12-04 09:49:32 +00:00
|
|
|
GST_ERROR_OBJECT (pipeline, "Output URI not set !");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-11-28 15:40:15 +00:00
|
|
|
if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->encodebin)) {
|
2009-12-04 09:49:32 +00:00
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't add encodebin");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-11-28 15:40:15 +00:00
|
|
|
if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->urisink)) {
|
2009-12-04 09:49:32 +00:00
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't add URI sink");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-12-20 18:09:48 +00:00
|
|
|
g_object_set (pipeline->priv->encodebin, "avoid-reencoding",
|
2014-02-17 11:34:04 +00:00
|
|
|
!(!(mode & GES_PIPELINE_MODE_SMART_RENDER)), NULL);
|
2010-07-15 10:09:26 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
gst_element_link_pads_full (pipeline->priv->encodebin, "src",
|
|
|
|
pipeline->priv->urisink, "sink", GST_PAD_LINK_CHECK_NOTHING);
|
2009-12-04 09:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXUPS */
|
|
|
|
/* FIXME
|
|
|
|
* If we are rendering, set playsink to sync=False,
|
|
|
|
* If we are NOT rendering, set playsink to sync=TRUE */
|
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
pipeline->priv->mode = mode;
|
2009-12-09 14:03:30 +00:00
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-07-15 14:58:22 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_get_thumbnail:
|
|
|
|
* @self: a #GESPipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
|
2011-01-06 10:30:26 +00:00
|
|
|
* @caps: (transfer none): caps specifying current format. Use %GST_CAPS_ANY
|
|
|
|
* for native size.
|
2010-07-15 14:58:22 +00:00
|
|
|
*
|
2011-12-30 16:15:07 +00:00
|
|
|
* Returns a #GstSample with the currently playing image in the format specified by
|
|
|
|
* caps. The caller should free the sample with #gst_sample_unref when finished. If ANY
|
2010-07-15 14:58:22 +00:00
|
|
|
* caps are specified, the information will be returned in the whatever format
|
|
|
|
* is currently used by the sink. This information can be retrieve from caps
|
|
|
|
* associated with the buffer.
|
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer full) (nullable): a #GstSample or %NULL
|
2010-07-15 14:58:22 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
GstSample *
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_get_thumbnail (GESPipeline * self, GstCaps * caps)
|
2010-07-15 14:58:22 +00:00
|
|
|
{
|
|
|
|
GstElement *sink;
|
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (self), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2010-11-28 15:40:15 +00:00
|
|
|
sink = self->priv->playsink;
|
2011-12-30 16:15:07 +00:00
|
|
|
|
2010-07-15 14:58:22 +00:00
|
|
|
if (!sink) {
|
|
|
|
GST_WARNING ("thumbnailing can only be done if we have a playsink");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
return ges_play_sink_convert_frame (sink, caps);
|
2010-07-15 14:58:22 +00:00
|
|
|
}
|
|
|
|
|
2010-07-15 17:49:28 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_save_thumbnail:
|
|
|
|
* @self: a #GESPipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
|
2010-07-15 17:49:28 +00:00
|
|
|
* @width: the requested width or -1 for native size
|
|
|
|
* @height: the requested height or -1 for native size
|
|
|
|
* @format: a string specifying the desired mime type (for example,
|
|
|
|
* image/jpeg)
|
|
|
|
* @location: the path to save the thumbnail
|
2013-04-17 19:51:30 +00:00
|
|
|
* @error: (out) (allow-none) (transfer full): An error to be set in case
|
|
|
|
* something wrong happens or %NULL
|
2010-07-15 17:49:28 +00:00
|
|
|
*
|
2011-01-06 10:30:26 +00:00
|
|
|
* Saves the current frame to the specified @location.
|
2016-07-29 19:48:28 +00:00
|
|
|
*
|
2011-01-06 10:30:26 +00:00
|
|
|
* Returns: %TRUE if the thumbnail was properly save, else %FALSE.
|
2010-07-15 17:49:28 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_save_thumbnail (GESPipeline * self, int width, int
|
2013-04-17 19:51:30 +00:00
|
|
|
height, const gchar * format, const gchar * location, GError ** error)
|
2010-07-15 17:49:28 +00:00
|
|
|
{
|
2012-02-10 18:35:07 +00:00
|
|
|
GstMapInfo map_info;
|
2010-07-15 17:49:28 +00:00
|
|
|
GstBuffer *b;
|
2011-12-30 16:15:07 +00:00
|
|
|
GstSample *sample;
|
2010-07-15 17:49:28 +00:00
|
|
|
GstCaps *caps;
|
2010-07-16 15:29:05 +00:00
|
|
|
gboolean res = TRUE;
|
2010-07-15 17:49:28 +00:00
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (self), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2010-07-15 17:49:28 +00:00
|
|
|
caps = gst_caps_from_string (format);
|
|
|
|
|
|
|
|
if (width > 1)
|
2010-07-16 15:38:44 +00:00
|
|
|
gst_caps_set_simple (caps, "width", G_TYPE_INT, width, NULL);
|
2010-07-15 17:49:28 +00:00
|
|
|
|
|
|
|
if (height > 1)
|
2010-07-16 15:38:44 +00:00
|
|
|
gst_caps_set_simple (caps, "height", G_TYPE_INT, height, NULL);
|
2010-07-15 17:49:28 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
if (!(sample = ges_pipeline_get_thumbnail (self, caps))) {
|
2010-07-15 17:49:28 +00:00
|
|
|
gst_caps_unref (caps);
|
2013-04-17 19:48:05 +00:00
|
|
|
return FALSE;
|
2010-07-15 17:49:28 +00:00
|
|
|
}
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
b = gst_sample_get_buffer (sample);
|
2012-02-10 18:35:07 +00:00
|
|
|
if (gst_buffer_map (b, &map_info, GST_MAP_READ)) {
|
2012-02-10 18:43:51 +00:00
|
|
|
if (!g_file_set_contents (location, (const char *) map_info.data,
|
2013-04-17 19:51:30 +00:00
|
|
|
map_info.size, error)) {
|
2013-04-18 21:59:52 +00:00
|
|
|
GST_WARNING ("Could not save thumbnail: %s",
|
|
|
|
error ? (*error)->message : "");
|
2012-02-10 18:35:07 +00:00
|
|
|
res = FALSE;
|
|
|
|
}
|
2010-07-16 16:41:02 +00:00
|
|
|
}
|
2011-10-11 07:51:35 +00:00
|
|
|
|
2010-07-15 17:49:28 +00:00
|
|
|
gst_caps_unref (caps);
|
2012-02-10 18:35:07 +00:00
|
|
|
gst_buffer_unmap (b, &map_info);
|
2011-12-30 16:15:07 +00:00
|
|
|
gst_sample_unref (sample);
|
2011-10-11 07:51:35 +00:00
|
|
|
|
2010-07-16 15:29:05 +00:00
|
|
|
return res;
|
2010-07-15 17:49:28 +00:00
|
|
|
}
|
|
|
|
|
2010-07-15 14:58:22 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_get_thumbnail_rgb24:
|
|
|
|
* @self: a #GESPipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
|
2010-07-15 14:58:22 +00:00
|
|
|
* @width: the requested width or -1 for native size
|
|
|
|
* @height: the requested height or -1 for native size
|
|
|
|
*
|
2013-07-01 14:27:54 +00:00
|
|
|
* A convenience method for @ges_pipeline_get_thumbnail which
|
2010-07-15 14:58:22 +00:00
|
|
|
* returns a buffer in 24-bit RGB, optionally scaled to the specified width
|
|
|
|
* and height. If -1 is specified for either dimension, it will be left at
|
|
|
|
* native size. You can retreive this information from the caps associated
|
|
|
|
* with the buffer.
|
2016-05-14 23:04:17 +00:00
|
|
|
*
|
2011-12-30 16:15:07 +00:00
|
|
|
* The caller is responsible for unreffing the returned sample with
|
|
|
|
* #gst_sample_unref.
|
2010-07-15 14:58:22 +00:00
|
|
|
*
|
2016-05-14 23:04:17 +00:00
|
|
|
* Returns: (transfer full) (nullable): a #GstSample or %NULL
|
2010-07-15 14:58:22 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-30 16:15:07 +00:00
|
|
|
GstSample *
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_get_thumbnail_rgb24 (GESPipeline * self, gint width, gint height)
|
2010-07-15 14:58:22 +00:00
|
|
|
{
|
2011-12-30 16:15:07 +00:00
|
|
|
GstSample *ret;
|
2010-07-15 14:58:22 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (self), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2012-02-10 19:35:28 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING,
|
|
|
|
"RGB", NULL);
|
2010-07-15 14:58:22 +00:00
|
|
|
|
|
|
|
if (width != -1)
|
2010-07-16 15:38:44 +00:00
|
|
|
gst_caps_set_simple (caps, "width", G_TYPE_INT, (gint) width, NULL);
|
2010-07-15 14:58:22 +00:00
|
|
|
|
|
|
|
if (height != -1)
|
2010-07-16 15:38:44 +00:00
|
|
|
gst_caps_set_simple (caps, "height", G_TYPE_INT, (gint) height, NULL);
|
2010-07-15 14:58:22 +00:00
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
ret = ges_pipeline_get_thumbnail (self, caps);
|
2010-07-15 14:58:22 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
return ret;
|
|
|
|
}
|
2010-11-23 17:24:38 +00:00
|
|
|
|
2011-10-04 14:25:22 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_preview_get_video_sink:
|
|
|
|
* @self: a #GESPipeline
|
2011-10-04 14:25:22 +00:00
|
|
|
*
|
|
|
|
* Obtains a pointer to playsink's video sink element that is used for
|
2014-02-17 11:34:04 +00:00
|
|
|
* displaying video when the #GESPipeline is in %GES_PIPELINE_MODE_PREVIEW
|
2011-10-04 14:25:22 +00:00
|
|
|
*
|
2011-10-05 10:24:36 +00:00
|
|
|
* The caller is responsible for unreffing the returned element with
|
|
|
|
* #gst_object_unref.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a pointer to the playsink video sink #GstElement
|
2011-10-04 14:25:22 +00:00
|
|
|
*/
|
|
|
|
GstElement *
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_preview_get_video_sink (GESPipeline * self)
|
2011-10-04 14:25:22 +00:00
|
|
|
{
|
2011-11-11 16:09:34 +00:00
|
|
|
GstElement *sink = NULL;
|
2011-10-04 14:25:22 +00:00
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (self), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2011-10-04 14:25:22 +00:00
|
|
|
g_object_get (self->priv->playsink, "video-sink", &sink, NULL);
|
|
|
|
|
|
|
|
return sink;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_preview_set_video_sink:
|
|
|
|
* @self: a #GESPipeline in %GST_STATE_NULL
|
2011-10-05 10:24:36 +00:00
|
|
|
* @sink: (transfer none): a video sink #GstElement
|
2011-10-04 14:25:22 +00:00
|
|
|
*
|
|
|
|
* Sets playsink's video sink element that is used for displaying video when
|
2014-02-17 11:34:04 +00:00
|
|
|
* the #GESPipeline is in %GES_PIPELINE_MODE_PREVIEW
|
2011-10-04 14:25:22 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_preview_set_video_sink (GESPipeline * self, GstElement * sink)
|
2011-10-04 14:25:22 +00:00
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_if_fail (GES_IS_PIPELINE (self));
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2011-10-04 14:25:22 +00:00
|
|
|
g_object_set (self->priv->playsink, "video-sink", sink, NULL);
|
|
|
|
};
|
|
|
|
|
2011-11-07 14:08:34 +00:00
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_preview_get_audio_sink:
|
|
|
|
* @self: a #GESPipeline
|
2011-11-07 14:08:34 +00:00
|
|
|
*
|
|
|
|
* Obtains a pointer to playsink's audio sink element that is used for
|
2014-02-17 11:34:04 +00:00
|
|
|
* displaying audio when the #GESPipeline is in %GES_PIPELINE_MODE_PREVIEW
|
2011-11-07 14:08:34 +00:00
|
|
|
*
|
|
|
|
* The caller is responsible for unreffing the returned element with
|
|
|
|
* #gst_object_unref.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a pointer to the playsink audio sink #GstElement
|
|
|
|
*/
|
|
|
|
GstElement *
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_preview_get_audio_sink (GESPipeline * self)
|
2011-11-07 14:08:34 +00:00
|
|
|
{
|
2011-11-11 16:09:34 +00:00
|
|
|
GstElement *sink = NULL;
|
2011-11-07 14:08:34 +00:00
|
|
|
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_val_if_fail (GES_IS_PIPELINE (self), FALSE);
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2011-11-07 14:08:34 +00:00
|
|
|
g_object_get (self->priv->playsink, "audio-sink", &sink, NULL);
|
|
|
|
|
|
|
|
return sink;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-07-01 14:27:54 +00:00
|
|
|
* ges_pipeline_preview_set_audio_sink:
|
|
|
|
* @self: a #GESPipeline in %GST_STATE_NULL
|
2011-11-07 14:08:34 +00:00
|
|
|
* @sink: (transfer none): a audio sink #GstElement
|
|
|
|
*
|
|
|
|
* Sets playsink's audio sink element that is used for displaying audio when
|
2014-02-17 11:34:04 +00:00
|
|
|
* the #GESPipeline is in %GES_PIPELINE_MODE_PREVIEW
|
2011-11-07 14:08:34 +00:00
|
|
|
*/
|
|
|
|
void
|
2013-07-01 14:27:54 +00:00
|
|
|
ges_pipeline_preview_set_audio_sink (GESPipeline * self, GstElement * sink)
|
2011-11-07 14:08:34 +00:00
|
|
|
{
|
2013-09-09 15:47:02 +00:00
|
|
|
g_return_if_fail (GES_IS_PIPELINE (self));
|
2013-04-18 21:37:17 +00:00
|
|
|
|
2011-11-07 14:08:34 +00:00
|
|
|
g_object_set (self->priv->playsink, "audio-sink", sink, NULL);
|
|
|
|
};
|