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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2009-09-10 16:40:51 +00:00
|
|
|
/**
|
|
|
|
* SECTION:ges-timeline-pipeline
|
|
|
|
* @short_description: Convenience #GstPipeline for editing.
|
2009-08-04 15:13:11 +00:00
|
|
|
*
|
2009-09-10 16:40:51 +00:00
|
|
|
* #GESTimelinePipeline allows developers to view and render #GESTimeline
|
|
|
|
* 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>
|
2010-07-15 17:49:28 +00:00
|
|
|
#include <stdio.h>
|
2009-09-10 16:40:51 +00:00
|
|
|
#include "ges-internal.h"
|
|
|
|
#include "ges-timeline-pipeline.h"
|
2010-07-15 14:58:22 +00:00
|
|
|
#include "ges-screenshot.h"
|
2009-09-10 16:40:51 +00:00
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
#define DEFAULT_TIMELINE_MODE TIMELINE_MODE_PREVIEW
|
|
|
|
|
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;
|
2009-09-08 17:45:08 +00:00
|
|
|
} OutputChain;
|
|
|
|
|
2009-08-06 15:38:43 +00:00
|
|
|
G_DEFINE_TYPE (GESTimelinePipeline, ges_timeline_pipeline, GST_TYPE_PIPELINE);
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
static GstStateChangeReturn ges_timeline_pipeline_change_state (GstElement *
|
|
|
|
element, GstStateChange transition);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
2010-04-20 10:57:53 +00:00
|
|
|
static OutputChain *get_output_chain_for_track (GESTimelinePipeline * self,
|
|
|
|
GESTrack * track);
|
|
|
|
static OutputChain *new_output_chain_for_track (GESTimelinePipeline * self,
|
|
|
|
GESTrack * track);
|
2009-08-04 15:13:11 +00:00
|
|
|
|
|
|
|
static void
|
2010-06-21 09:52:01 +00:00
|
|
|
ges_timeline_pipeline_dispose (GObject * object)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2009-09-08 17:45:08 +00:00
|
|
|
GESTimelinePipeline *self = GES_TIMELINE_PIPELINE (object);
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
if (self->playsink) {
|
2010-05-20 10:29:30 +00:00
|
|
|
if (self->mode & (TIMELINE_MODE_PREVIEW))
|
|
|
|
gst_bin_remove (GST_BIN (object), self->playsink);
|
2010-06-21 09:52:49 +00:00
|
|
|
else
|
|
|
|
gst_object_unref (self->playsink);
|
2009-12-04 09:49:32 +00:00
|
|
|
self->playsink = NULL;
|
2009-09-08 17:45:08 +00:00
|
|
|
}
|
2010-06-21 09:52:49 +00:00
|
|
|
|
|
|
|
if (self->encodebin) {
|
|
|
|
if (self->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
|
|
|
|
gst_bin_remove (GST_BIN (object), self->encodebin);
|
|
|
|
else
|
|
|
|
gst_object_unref (self->encodebin);
|
|
|
|
self->encodebin = NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-21 09:53:30 +00:00
|
|
|
if (self->profile) {
|
|
|
|
gst_encoding_profile_free (self->profile);
|
|
|
|
self->profile = NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-21 09:52:01 +00:00
|
|
|
G_OBJECT_CLASS (ges_timeline_pipeline_parent_class)->dispose (object);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_pipeline_class_init (GESTimelinePipelineClass * 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
|
|
|
|
2010-06-21 09:52:01 +00:00
|
|
|
object_class->dispose = ges_timeline_pipeline_dispose;
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
element_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (ges_timeline_pipeline_change_state);
|
|
|
|
|
|
|
|
/* 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
|
2009-08-04 15:16:31 +00:00
|
|
|
ges_timeline_pipeline_init (GESTimelinePipeline * self)
|
2009-08-04 15:13:11 +00:00
|
|
|
{
|
2009-09-08 17:45:08 +00:00
|
|
|
GST_INFO_OBJECT (self, "Creating new 'playsink'");
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
self->playsink = gst_element_factory_make ("playsink", "internal-sinks");
|
|
|
|
self->encodebin =
|
|
|
|
gst_element_factory_make ("encodebin", "internal-encodebin");
|
2010-05-07 11:30:07 +00:00
|
|
|
/* Limit encodebin buffering to 1 buffer since we know the various
|
|
|
|
* stream fed to it are decoupled already */
|
2010-05-10 10:44:56 +00:00
|
|
|
g_object_set (self->encodebin, "queue-buffers-max", (guint32) 1,
|
2010-07-15 10:09:26 +00:00
|
|
|
"queue-bytes-max", (guint32) 0, "queue-time-max", (guint64) 0,
|
|
|
|
"use-smartencoder", TRUE, NULL);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
if (G_UNLIKELY (self->playsink == NULL))
|
2009-09-08 17:45:08 +00:00
|
|
|
GST_ERROR_OBJECT (self, "Can't create playsink instance !");
|
2009-12-04 09:49:32 +00:00
|
|
|
if (G_UNLIKELY (self->encodebin == NULL))
|
|
|
|
GST_ERROR_OBJECT (self, "Can't create encodebin instance !");
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
ges_timeline_pipeline_set_mode (self, DEFAULT_TIMELINE_MODE);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_new:
|
|
|
|
*
|
|
|
|
* Creates a new conveninence #GESTimelinePipeline.
|
|
|
|
*
|
|
|
|
* Returns: the new #GESTimelinePipeline.
|
|
|
|
*/
|
2009-08-04 15:16:31 +00:00
|
|
|
GESTimelinePipeline *
|
2009-08-04 15:13:11 +00:00
|
|
|
ges_timeline_pipeline_new (void)
|
|
|
|
{
|
2009-09-07 13:46:44 +00:00
|
|
|
return g_object_new (GES_TYPE_TIMELINE_PIPELINE, NULL);
|
2009-08-04 15:13:11 +00:00
|
|
|
}
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
#define TRACK_COMPATIBLE_PROFILE(tracktype, proftype) \
|
|
|
|
(((proftype) == GST_ENCODING_PROFILE_AUDIO && (tracktype) == GES_TRACK_TYPE_AUDIO) || \
|
|
|
|
((proftype) == GST_ENCODING_PROFILE_VIDEO && (tracktype) == GES_TRACK_TYPE_VIDEO) || \
|
|
|
|
((proftype) == GST_ENCODING_PROFILE_TEXT && (tracktype) == GES_TRACK_TYPE_TEXT))
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ges_timeline_pipeline_update_caps (GESTimelinePipeline * self)
|
|
|
|
{
|
|
|
|
GList *ltrack, *tracks, *lstream;
|
|
|
|
|
|
|
|
if (!self->profile)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
GST_DEBUG ("Updating track caps");
|
|
|
|
|
|
|
|
tracks = ges_timeline_get_tracks (self->timeline);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Find a matching stream setting */
|
|
|
|
for (lstream = self->profile->encodingprofiles; lstream;
|
|
|
|
lstream = lstream->next) {
|
|
|
|
GstStreamEncodingProfile *prof =
|
|
|
|
(GstStreamEncodingProfile *) lstream->data;
|
|
|
|
|
|
|
|
if (TRACK_COMPATIBLE_PROFILE (track->type, prof->type)) {
|
|
|
|
if (self->mode == TIMELINE_MODE_SMART_RENDER) {
|
|
|
|
GstCaps *ocaps, *rcaps;
|
|
|
|
|
|
|
|
GST_DEBUG ("Smart Render mode, setting output caps");
|
|
|
|
ocaps = gst_stream_encoding_profile_get_output_caps (prof);
|
|
|
|
if (track->type == GES_TRACK_TYPE_AUDIO)
|
|
|
|
rcaps = gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
|
|
|
|
else
|
|
|
|
rcaps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb");
|
|
|
|
gst_caps_append (ocaps, rcaps);
|
|
|
|
ges_track_set_caps (track, ocaps);
|
|
|
|
} else {
|
2010-06-28 15:08:08 +00:00
|
|
|
GstCaps *caps = NULL;
|
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
/* Raw preview or rendering mode */
|
|
|
|
if (track->type == GES_TRACK_TYPE_VIDEO)
|
2010-06-28 15:08:08 +00:00
|
|
|
caps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb");
|
2010-04-20 11:26:00 +00:00
|
|
|
else if (track->type == GES_TRACK_TYPE_AUDIO)
|
2010-06-28 15:08:08 +00:00
|
|
|
gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
|
|
|
|
|
|
|
|
if (caps) {
|
|
|
|
ges_track_set_caps (track, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (track);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tracks)
|
|
|
|
g_list_free (tracks);
|
|
|
|
|
|
|
|
GST_DEBUG ("Done updating caps");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
ges_timeline_pipeline_change_state (GstElement * element,
|
|
|
|
GstStateChange transition)
|
|
|
|
{
|
|
|
|
GESTimelinePipeline *self;
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
|
|
|
self = GES_TIMELINE_PIPELINE (element);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
|
|
if (G_UNLIKELY (self->timeline == NULL)) {
|
|
|
|
GST_ERROR_OBJECT (element,
|
|
|
|
"No GESTimeline set on the pipeline, cannot play !");
|
|
|
|
ret = GST_STATE_CHANGE_FAILURE;
|
|
|
|
goto done;
|
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
if (self->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
|
|
|
|
GST_DEBUG ("rendering => Updating pipeline caps");
|
|
|
|
if (!ges_timeline_pipeline_update_caps (self)) {
|
|
|
|
GST_ERROR_OBJECT (element, "Error setting the caps for rendering");
|
|
|
|
ret = GST_STATE_CHANGE_FAILURE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/* Set caps on all tracks according to profile if present */
|
|
|
|
/* FIXME : Add a new SMART_RENDER mode to avoid decoding */
|
2009-09-08 17:45:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret =
|
2009-11-30 14:14:25 +00:00
|
|
|
GST_ELEMENT_CLASS (ges_timeline_pipeline_parent_class)->change_state
|
|
|
|
(element, transition);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-20 10:57:53 +00:00
|
|
|
static OutputChain *
|
|
|
|
new_output_chain_for_track (GESTimelinePipeline * self, GESTrack * track)
|
|
|
|
{
|
|
|
|
OutputChain *chain;
|
|
|
|
|
|
|
|
chain = g_new0 (OutputChain, 1);
|
|
|
|
chain->track = track;
|
|
|
|
|
|
|
|
return chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
static OutputChain *
|
|
|
|
get_output_chain_for_track (GESTimelinePipeline * self, GESTrack * track)
|
|
|
|
{
|
|
|
|
GList *tmp;
|
|
|
|
|
|
|
|
for (tmp = self->chains; tmp; tmp = tmp->next) {
|
|
|
|
OutputChain *chain = (OutputChain *) tmp->data;
|
|
|
|
if (chain->track == track)
|
|
|
|
return chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-08 17:14:46 +00:00
|
|
|
/* Fetches a ocmpatible pad on the target element which isn't already
|
|
|
|
* linked */
|
|
|
|
static GstPad *
|
|
|
|
get_compatible_unlinked_pad (GstElement * element, GstPad * pad)
|
|
|
|
{
|
|
|
|
GstPad *res = NULL;
|
|
|
|
GstIterator *pads;
|
|
|
|
gboolean done = FALSE;
|
|
|
|
GstCaps *srccaps;
|
|
|
|
|
|
|
|
GST_DEBUG ("element : %s, pad %s:%s",
|
|
|
|
GST_ELEMENT_NAME (element), GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
|
|
|
if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
|
|
|
|
pads = gst_element_iterate_sink_pads (element);
|
|
|
|
else
|
|
|
|
pads = gst_element_iterate_src_pads (element);
|
2010-06-28 15:08:08 +00:00
|
|
|
srccaps = gst_pad_get_caps_reffed (pad);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("srccaps %" GST_PTR_FORMAT, srccaps);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
gpointer padptr;
|
|
|
|
|
|
|
|
switch (gst_iterator_next (pads, &padptr)) {
|
|
|
|
case GST_ITERATOR_OK:
|
|
|
|
{
|
|
|
|
GstPad *testpad = (GstPad *) padptr;
|
|
|
|
|
|
|
|
if (gst_pad_is_linked (testpad)) {
|
|
|
|
gst_object_unref (testpad);
|
|
|
|
} else {
|
2010-06-28 15:08:08 +00:00
|
|
|
GstCaps *sinkcaps = gst_pad_get_caps_reffed (testpad);
|
2010-01-08 17:14:46 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("sinkccaps %" GST_PTR_FORMAT, sinkcaps);
|
|
|
|
|
|
|
|
if (gst_caps_can_intersect (srccaps, sinkcaps)) {
|
|
|
|
res = testpad;
|
|
|
|
done = TRUE;
|
|
|
|
} else
|
|
|
|
gst_object_unref (testpad);
|
|
|
|
gst_caps_unref (sinkcaps);
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_iterator_free (pads);
|
|
|
|
gst_caps_unref (srccaps);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
static void
|
|
|
|
pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
|
|
|
|
{
|
|
|
|
OutputChain *chain;
|
|
|
|
GESTrack *track;
|
|
|
|
GstPad *sinkpad;
|
2009-09-09 10:42:29 +00:00
|
|
|
gboolean reconfigured = FALSE;
|
2009-09-08 17:45:08 +00:00
|
|
|
|
2010-04-20 11:26:00 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "new pad %s:%s , caps:%" GST_PTR_FORMAT,
|
|
|
|
GST_DEBUG_PAD_NAME (pad), GST_PAD_CAPS (pad));
|
2009-12-04 09:49:32 +00:00
|
|
|
|
2009-09-08 17:45:08 +00:00
|
|
|
if (G_UNLIKELY (!(track =
|
|
|
|
ges_timeline_get_track_for_pad (self->timeline, pad)))) {
|
|
|
|
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 &&
|
|
|
|
!(self->mode & TIMELINE_MODE_PREVIEW_VIDEO) &&
|
2010-04-20 11:26:00 +00:00
|
|
|
!(self->mode & TIMELINE_MODE_RENDER) &&
|
|
|
|
!(self->mode & TIMELINE_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 &&
|
|
|
|
!(self->mode & TIMELINE_MODE_PREVIEW_AUDIO) &&
|
2010-04-20 11:26:00 +00:00
|
|
|
!(self->mode & TIMELINE_MODE_RENDER) &&
|
|
|
|
!(self->mode & TIMELINE_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);
|
2009-09-08 17:45:08 +00:00
|
|
|
chain->srcpad = pad;
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
/* Adding tee */
|
|
|
|
chain->tee = gst_element_factory_make ("tee", NULL);
|
|
|
|
gst_bin_add (GST_BIN_CAST (self), chain->tee);
|
2009-12-11 14:17:25 +00:00
|
|
|
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");
|
2010-07-14 11:29:23 +00:00
|
|
|
gst_pad_link_full (pad, sinkpad, GST_PAD_LINK_CHECK_NOTHING);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (sinkpad);
|
2009-12-09 11:22:34 +00:00
|
|
|
|
|
|
|
/* Connect playsink */
|
|
|
|
if (self->mode & TIMELINE_MODE_PREVIEW) {
|
|
|
|
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 =
|
|
|
|
gst_element_get_request_pad (self->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;
|
|
|
|
}
|
|
|
|
|
2010-06-21 09:54:01 +00:00
|
|
|
tmppad = gst_element_get_request_pad (chain->tee, "src%d");
|
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)) {
|
2010-04-20 11:26:00 +00:00
|
|
|
GST_ERROR_OBJECT (self, "Couldn't link track pad to playsink");
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (tmppad);
|
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
|
|
|
|
|
|
|
GST_DEBUG ("Reconfiguring playsink");
|
|
|
|
|
|
|
|
/* reconfigure playsink */
|
|
|
|
g_signal_emit_by_name (self->playsink, "reconfigure", &reconfigured);
|
|
|
|
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 */
|
2010-04-20 11:26:00 +00:00
|
|
|
if (self->mode & (TIMELINE_MODE_RENDER | TIMELINE_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 */
|
|
|
|
sinkpad = get_compatible_unlinked_pad (self->encodebin, pad);
|
|
|
|
|
|
|
|
if (sinkpad == NULL) {
|
2010-06-28 15:08:08 +00:00
|
|
|
GstCaps *caps = gst_pad_get_caps_reffed (pad);
|
2010-04-20 11:26:00 +00:00
|
|
|
/* If no compatible static pad is available, request a pad */
|
2010-06-28 15:08:08 +00:00
|
|
|
g_signal_emit_by_name (self->encodebin, "request-pad", caps, &sinkpad);
|
|
|
|
gst_caps_unref (caps);
|
2010-04-20 11:26:00 +00:00
|
|
|
if (G_UNLIKELY (sinkpad == NULL)) {
|
|
|
|
GST_ERROR_OBJECT (self, "Couldn't get a pad from encodebin !");
|
|
|
|
goto error;
|
|
|
|
}
|
2010-01-08 17:14:46 +00:00
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
chain->encodebinpad = sinkpad;
|
2009-12-09 11:22:34 +00:00
|
|
|
}
|
|
|
|
|
2010-06-21 09:54:01 +00:00
|
|
|
tmppad = gst_element_get_request_pad (chain->tee, "src%d");
|
2010-07-14 11:29:23 +00:00
|
|
|
if (G_UNLIKELY (gst_pad_link_full (tmppad,
|
|
|
|
chain->encodebinpad,
|
|
|
|
GST_PAD_LINK_CHECK_NOTHING) != GST_PAD_LINK_OK)) {
|
2009-12-09 11:22:34 +00:00
|
|
|
GST_WARNING_OBJECT (self, "Couldn't link track pad to playsink");
|
|
|
|
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))
|
|
|
|
self->chains = g_list_append (self->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) {
|
|
|
|
gst_bin_remove (GST_BIN_CAST (self), chain->tee);
|
|
|
|
}
|
|
|
|
if (sinkpad)
|
|
|
|
gst_object_unref (sinkpad);
|
|
|
|
g_free (chain);
|
|
|
|
}
|
2009-09-08 17:45:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pad_removed_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
|
|
|
|
{
|
2010-04-20 11:41:20 +00:00
|
|
|
OutputChain *chain;
|
|
|
|
GESTrack *track;
|
|
|
|
GstPad *peer;
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "pad removed %s:%s", GST_DEBUG_PAD_NAME (pad));
|
|
|
|
|
2010-04-20 11:41:20 +00:00
|
|
|
if (G_UNLIKELY (!(track =
|
|
|
|
ges_timeline_get_track_for_pad (self->timeline, pad)))) {
|
|
|
|
GST_WARNING_OBJECT (self, "Couldn't find coresponding track !");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!(chain = get_output_chain_for_track (self, track)))) {
|
|
|
|
GST_DEBUG_OBJECT (self, "Pad wasn't used");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlink encodebin */
|
|
|
|
if (chain->encodebinpad) {
|
|
|
|
peer = gst_pad_get_peer (chain->encodebinpad);
|
|
|
|
gst_pad_unlink (peer, chain->encodebinpad);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (peer);
|
2010-04-20 11:41:20 +00:00
|
|
|
gst_element_release_request_pad (self->encodebin, chain->encodebinpad);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlink playsink */
|
|
|
|
if (chain->playsinkpad) {
|
|
|
|
peer = gst_pad_get_peer (chain->playsinkpad);
|
|
|
|
gst_pad_unlink (peer, chain->playsinkpad);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (peer);
|
2010-04-20 11:41:20 +00:00
|
|
|
gst_element_release_request_pad (self->playsink, chain->playsinkpad);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (chain->playsinkpad);
|
2010-04-20 11:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlike/remove tee */
|
|
|
|
peer = gst_element_get_static_pad (chain->tee, "sink");
|
|
|
|
gst_pad_unlink (pad, peer);
|
2010-06-21 09:54:01 +00:00
|
|
|
gst_object_unref (peer);
|
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);
|
|
|
|
|
|
|
|
self->chains = g_list_remove (self->chains, chain);
|
|
|
|
g_free (chain);
|
2009-09-08 17:45:08 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("done");
|
|
|
|
}
|
|
|
|
|
2009-09-16 10:37:45 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_add_timeline:
|
|
|
|
* @pipeline: a #GESTimelinePipeline
|
|
|
|
* @timeline: the #GESTimeline to set on the @pipeline.
|
|
|
|
*
|
|
|
|
* Sets the timeline to use in this pipeline.
|
|
|
|
*
|
|
|
|
* The reference to the @timeline will be stolen by the @pipeline.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the @timeline could be successfully set on the @pipeline,
|
|
|
|
* else FALSE.
|
|
|
|
*/
|
2009-09-08 17:45:08 +00:00
|
|
|
gboolean
|
|
|
|
ges_timeline_pipeline_add_timeline (GESTimelinePipeline * pipeline,
|
|
|
|
GESTimeline * timeline)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (pipeline->timeline == NULL, FALSE);
|
|
|
|
g_return_val_if_fail (timeline != NULL, FALSE);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
pipeline->timeline = timeline;
|
|
|
|
|
|
|
|
/* Connect to pipeline */
|
|
|
|
g_signal_connect (timeline, "pad-added", (GCallback) pad_added_cb, pipeline);
|
|
|
|
g_signal_connect (timeline, "pad-removed", (GCallback) pad_removed_cb,
|
|
|
|
pipeline);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-12-04 09:49:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_set_render_settings:
|
|
|
|
* @pipeline: a #GESTimelinePipeline
|
|
|
|
* @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
|
|
|
|
* #TIMELINE_MODE_RENDER
|
|
|
|
*
|
2009-12-04 09:49:32 +00:00
|
|
|
* Returns: %TRUE if the settings were aknowledged properly, else %FALSE
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
ges_timeline_pipeline_set_render_settings (GESTimelinePipeline * pipeline,
|
|
|
|
gchar * output_uri, GstEncodingProfile * profile)
|
|
|
|
{
|
|
|
|
/* Clear previous URI sink if it existed */
|
|
|
|
/* FIXME : We should figure out if it was added to the pipeline,
|
|
|
|
* and if so, remove it. */
|
|
|
|
if (pipeline->urisink) {
|
|
|
|
g_object_unref (pipeline->urisink);
|
|
|
|
pipeline->urisink = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pipeline->urisink =
|
|
|
|
gst_element_make_from_uri (GST_URI_SINK, output_uri, "urisink");
|
|
|
|
if (G_UNLIKELY (pipeline->urisink == NULL)) {
|
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't not create sink for URI %s",
|
|
|
|
output_uri);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-06-21 09:53:30 +00:00
|
|
|
if (pipeline->profile)
|
|
|
|
gst_encoding_profile_free (pipeline->profile);
|
2010-07-15 10:09:26 +00:00
|
|
|
g_object_set (pipeline->encodebin, "use-smartencoder",
|
|
|
|
!(!(pipeline->mode & TIMELINE_MODE_SMART_RENDER)), NULL);
|
2009-12-04 09:49:32 +00:00
|
|
|
g_object_set (pipeline->encodebin, "profile", profile, NULL);
|
2010-06-21 09:53:30 +00:00
|
|
|
pipeline->profile = gst_encoding_profile_copy (profile);
|
2009-12-04 09:49:32 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_set_mode:
|
|
|
|
* @pipeline: a #GESTimelinePipeline
|
|
|
|
* @mode: the #GESPipelineFlags to use
|
|
|
|
*
|
|
|
|
* switches the @pipeline to the specified @mode. The default mode when
|
|
|
|
* creating a #GESTimelinePipeline is #TIMELINE_MODE_PREVIEW.
|
|
|
|
*
|
|
|
|
* Note: The @pipeline will be set to #GST_STATE_NULL during this call due to
|
|
|
|
* the internal changes that happen. The caller will therefore have to
|
|
|
|
* 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
|
|
|
|
ges_timeline_pipeline_set_mode (GESTimelinePipeline * pipeline,
|
|
|
|
GESPipelineFlags mode)
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (pipeline, "current mode : %d, mode : %d", pipeline->mode,
|
|
|
|
mode);
|
|
|
|
|
|
|
|
/* fast-path, nothing to change */
|
|
|
|
if (mode == pipeline->mode)
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* remove no-longer needed components */
|
|
|
|
if (pipeline->mode & TIMELINE_MODE_PREVIEW && !(mode & TIMELINE_MODE_PREVIEW)) {
|
|
|
|
/* Disable playsink */
|
|
|
|
GST_DEBUG ("Disabling playsink");
|
|
|
|
g_object_ref (pipeline->playsink);
|
|
|
|
gst_bin_remove (GST_BIN_CAST (pipeline), pipeline->playsink);
|
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
if ((pipeline->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) &&
|
|
|
|
!(mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))) {
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Disable render bin */
|
|
|
|
GST_DEBUG ("Disabling rendering bin");
|
|
|
|
g_object_ref (pipeline->encodebin);
|
|
|
|
g_object_ref (pipeline->urisink);
|
|
|
|
gst_bin_remove_many (GST_BIN_CAST (pipeline),
|
|
|
|
pipeline->encodebin, pipeline->urisink, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new elements */
|
|
|
|
if (!(pipeline->mode & TIMELINE_MODE_PREVIEW) &&
|
|
|
|
(mode & TIMELINE_MODE_PREVIEW)) {
|
|
|
|
/* Add playsink */
|
|
|
|
GST_DEBUG ("Adding playsink");
|
|
|
|
|
|
|
|
if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->playsink)) {
|
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't add playsink");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2010-04-20 11:26:00 +00:00
|
|
|
if (!(pipeline->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) &&
|
|
|
|
(mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))) {
|
2009-12-04 09:49:32 +00:00
|
|
|
/* Adding render bin */
|
|
|
|
GST_DEBUG ("Adding render bin");
|
|
|
|
|
|
|
|
if (G_UNLIKELY (pipeline->urisink == NULL)) {
|
|
|
|
GST_ERROR_OBJECT (pipeline, "Output URI not set !");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->encodebin)) {
|
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't add encodebin");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->urisink)) {
|
|
|
|
GST_ERROR_OBJECT (pipeline, "Couldn't add URI sink");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-07-15 10:09:26 +00:00
|
|
|
g_object_set (pipeline->encodebin, "use-smartencoder",
|
|
|
|
!(!(mode & TIMELINE_MODE_SMART_RENDER)), NULL);
|
|
|
|
|
2010-07-14 11:29:23 +00:00
|
|
|
gst_element_link_pads_full (pipeline->encodebin, "src", pipeline->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 */
|
|
|
|
|
2009-12-09 14:03:30 +00:00
|
|
|
pipeline->mode = mode;
|
|
|
|
|
2009-12-04 09:49:32 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-07-15 14:58:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_get_thumbnail
|
|
|
|
* @self: a #GESTimelinePipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
|
|
|
|
* @caps: caps specifying current format. Use %GST_CAPS_ANY for native size.
|
|
|
|
*
|
|
|
|
* Returns a #GstBuffer with the currently playing in the format specified by
|
|
|
|
* caps. The caller should unref the #gst_buffer_unref when finished. If %ANY
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Returns: a #GstBuffer or %NULL
|
|
|
|
*/
|
|
|
|
|
|
|
|
GstBuffer *
|
2010-07-15 17:49:28 +00:00
|
|
|
ges_timeline_pipeline_get_thumbnail_buffer (GESTimelinePipeline * self,
|
|
|
|
GstCaps * caps)
|
2010-07-15 14:58:22 +00:00
|
|
|
{
|
|
|
|
GstElement *sink;
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
sink = self->playsink;
|
|
|
|
if (!sink) {
|
|
|
|
GST_WARNING ("thumbnailing can only be done if we have a playsink");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME (merge into core): this should be replaced with the "convert-frame"
|
|
|
|
* action */
|
|
|
|
buf = gst_play_sink_convert_frame (sink, caps);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-07-15 17:49:28 +00:00
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_save_thumbnail
|
|
|
|
* @self: a #GESTimelinePipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* A convenience method for ges_timeline_pipeline_get_thumbnail_raw which
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The caller is responsible for unreffing the returned buffer with
|
|
|
|
* #gst_buffer_unref.
|
|
|
|
*
|
|
|
|
* Returns: a #GstBuffer or %NULL
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
ges_timeline_pipeline_save_thumbnail (GESTimelinePipeline * self, int width, int
|
|
|
|
height, gchar * format, gchar * location)
|
|
|
|
{
|
|
|
|
GstBuffer *b;
|
|
|
|
FILE *fp;
|
|
|
|
GstCaps *caps;
|
2010-07-16 15:29:05 +00:00
|
|
|
gboolean res = TRUE;
|
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
|
|
|
|
|
|
|
if (!(b = ges_timeline_pipeline_get_thumbnail_buffer (self, caps))) {
|
|
|
|
gst_caps_unref (caps);
|
2010-07-16 15:29:05 +00:00
|
|
|
return res;
|
2010-07-15 17:49:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fp = fopen (location, "w+");
|
2010-07-16 16:41:02 +00:00
|
|
|
if (!fwrite (GST_BUFFER_DATA (b), GST_BUFFER_SIZE (b), 1, fp) || ferror (fp)) {
|
2010-07-16 15:29:05 +00:00
|
|
|
res = FALSE;
|
2010-07-16 16:41:02 +00:00
|
|
|
}
|
2010-07-15 17:49:28 +00:00
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
gst_buffer_unref (b);
|
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
|
|
|
/**
|
|
|
|
* ges_timeline_pipeline_get_thumbnail_rgb24
|
|
|
|
* @self: a #GESTimelinePipeline in %GST_STATE_PLAYING or %GST_STATE_PAUSED
|
|
|
|
* @width: the requested width or -1 for native size
|
|
|
|
* @height: the requested height or -1 for native size
|
|
|
|
*
|
|
|
|
* A convenience method for ges_timeline_pipeline_get_thumbnail_raw which
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The caller is responsible for unreffing the returned buffer with
|
|
|
|
* #gst_buffer_unref.
|
|
|
|
*
|
|
|
|
* Returns: a #GstBuffer or %NULL
|
|
|
|
*/
|
|
|
|
|
|
|
|
GstBuffer *
|
|
|
|
ges_timeline_pipeline_get_thumbnail_rgb24 (GESTimelinePipeline * self,
|
|
|
|
gint width, gint height)
|
|
|
|
{
|
|
|
|
GstBuffer *ret;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
caps = gst_caps_from_string ("video/x-raw-rgb,bpp=(int)24," "depth=(int)24");
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-07-15 17:49:28 +00:00
|
|
|
ret = ges_timeline_pipeline_get_thumbnail_buffer (self, caps);
|
2010-07-15 14:58:22 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
return ret;
|
|
|
|
}
|