2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
2001-12-04 22:12:50 +00:00
|
|
|
* 2000 Wim Taymans <wim.taymans@chello.be>
|
2000-12-28 22:12:02 +00:00
|
|
|
*
|
|
|
|
* gstscheduler.c: Default scheduling code for most cases
|
2000-12-26 23:51:04 +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.
|
|
|
|
*/
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
#define CLASS(obj) GST_SCHEDULER_CLASS (G_OBJECT_GET_CLASS (obj))
|
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2000-12-26 23:51:04 +00:00
|
|
|
|
|
|
|
#include "gstscheduler.h"
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static void gst_scheduler_class_init (GstSchedulerClass *klass);
|
|
|
|
static void gst_scheduler_init (GstScheduler *sched);
|
2000-12-26 23:51:04 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
2000-12-26 23:51:04 +00:00
|
|
|
|
2001-12-27 00:47:41 +00:00
|
|
|
static gchar *_default_name = NULL;
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
GType
|
|
|
|
gst_scheduler_get_type (void)
|
2000-12-26 23:51:04 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
static GType _gst_scheduler_type = 0;
|
2000-12-26 23:51:04 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!_gst_scheduler_type) {
|
|
|
|
static const GTypeInfo scheduler_info = {
|
|
|
|
sizeof (GstSchedulerClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_scheduler_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstScheduler),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_scheduler_init,
|
|
|
|
NULL
|
|
|
|
};
|
2000-12-26 23:51:04 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
_gst_scheduler_type = g_type_register_static (GST_TYPE_OBJECT, "GstScheduler",
|
|
|
|
&scheduler_info, G_TYPE_FLAG_ABSTRACT);
|
|
|
|
}
|
|
|
|
return _gst_scheduler_type;
|
2000-12-26 23:51:04 +00:00
|
|
|
}
|
2001-01-20 03:10:44 +00:00
|
|
|
|
2000-12-26 23:51:04 +00:00
|
|
|
static void
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_scheduler_class_init (GstSchedulerClass *klass)
|
2000-12-26 23:51:04 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
2000-12-26 23:51:04 +00:00
|
|
|
}
|
|
|
|
|
2001-07-15 13:04:38 +00:00
|
|
|
static void
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_scheduler_init (GstScheduler *sched)
|
2001-07-15 13:04:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-12-19 19:22:53 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_setup:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
*
|
|
|
|
* Prepare the scheduler.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_setup (GstScheduler *sched)
|
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2001-12-19 19:22:53 +00:00
|
|
|
if (CLASS (sched)->setup)
|
|
|
|
CLASS (sched)->setup (sched);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_scheduler_reset:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
*
|
|
|
|
* Reset the scheduler
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_reset (GstScheduler *sched)
|
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2001-12-19 19:22:53 +00:00
|
|
|
if (CLASS (sched)->reset)
|
|
|
|
CLASS (sched)->reset (sched);
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_pad_connect:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @srcpad: the srcpad to connect
|
|
|
|
* @sinkpad: the sinkpad to connect to
|
|
|
|
*
|
|
|
|
* Connect the srcpad to the given sinkpad.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_pad_connect (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
|
2001-01-19 02:23:35 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_PAD (srcpad));
|
|
|
|
g_return_if_fail (GST_IS_PAD (sinkpad));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->pad_connect)
|
|
|
|
CLASS (sched)->pad_connect (sched, srcpad, sinkpad);
|
2000-12-26 23:51:04 +00:00
|
|
|
}
|
2001-01-20 03:10:44 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_pad_disconnect:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @srcpad: the srcpad to disconnect
|
|
|
|
* @sinkpad: the sinkpad to disconnect from
|
|
|
|
*
|
|
|
|
* Disconnect the srcpad to the given sinkpad.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_pad_disconnect (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
|
2000-12-26 23:51:04 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_PAD (srcpad));
|
|
|
|
g_return_if_fail (GST_IS_PAD (sinkpad));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->pad_disconnect)
|
|
|
|
CLASS (sched)->pad_disconnect (sched, srcpad, sinkpad);
|
2000-12-26 23:51:04 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_pad_select:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @padlist: the padlist to select on
|
|
|
|
*
|
|
|
|
* register the given padlist for a select operation.
|
|
|
|
*
|
|
|
|
* Returns: the pad which received a buffer.
|
|
|
|
*/
|
|
|
|
GstPad *
|
|
|
|
gst_scheduler_pad_select (GstScheduler *sched, GList *padlist)
|
2001-01-20 03:10:44 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (padlist != NULL);
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->pad_select)
|
|
|
|
CLASS (sched)->pad_select (sched, padlist);
|
2000-12-27 23:42:15 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_add_element:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element to add to the schedulerr
|
|
|
|
*
|
|
|
|
* Add an element to the schedulerr.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_add_element (GstScheduler *sched, GstElement *element)
|
2001-01-20 03:10:44 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->add_element)
|
|
|
|
CLASS (sched)->add_element (sched, element);
|
2001-01-20 03:10:44 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
2001-12-20 20:03:10 +00:00
|
|
|
* gst_scheduler_state_transition:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @sched: the schedulerr
|
2001-12-20 20:03:10 +00:00
|
|
|
* @element: the element with the state transition
|
|
|
|
* @transition: the state transition
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
2001-12-20 20:03:10 +00:00
|
|
|
* Tell the scheduler that an element changed its state.
|
2001-12-28 20:20:26 +00:00
|
|
|
*
|
|
|
|
* Returns: a GstElementStateReturn indicating success or failure
|
|
|
|
* of the state transition.
|
2001-12-04 22:12:50 +00:00
|
|
|
*/
|
2001-12-22 21:18:17 +00:00
|
|
|
GstElementStateReturn
|
2001-12-20 20:03:10 +00:00
|
|
|
gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), GST_STATE_FAILURE);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
|
|
|
|
|
2001-12-20 20:03:10 +00:00
|
|
|
if (CLASS (sched)->state_transition)
|
2001-12-22 21:18:17 +00:00
|
|
|
return CLASS (sched)->state_transition (sched, element, transition);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_remove_element:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element to remove
|
|
|
|
*
|
|
|
|
* Remove an element from the schedulerr.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_remove_element (GstScheduler *sched, GstElement *element)
|
2001-10-21 18:00:31 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->remove_element)
|
|
|
|
CLASS (sched)->remove_element (sched, element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-09 13:17:54 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_lock_element:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element to lock
|
|
|
|
*
|
|
|
|
* Acquire a lock on the given element in the given scheduler.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_scheduler_lock_element (GstScheduler *sched, GstElement *element)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->lock_element)
|
|
|
|
CLASS (sched)->lock_element (sched, element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-09 13:17:54 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_unlock_element:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element to unlock
|
|
|
|
*
|
|
|
|
* Release the lock on the given element in the given scheduler.
|
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
|
|
|
gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->unlock_element)
|
|
|
|
CLASS (sched)->unlock_element (sched, element);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_error:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element with the error
|
|
|
|
*
|
|
|
|
* Tell the scheduler an element was in error
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_error (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
|
|
|
if (CLASS (sched)->error)
|
|
|
|
CLASS (sched)->error (sched, element);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_scheduler_yield:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element requesting a yield
|
|
|
|
*
|
|
|
|
* Tell the scheduler to schedule another element.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_yield (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
|
|
|
if (CLASS (sched)->yield)
|
|
|
|
CLASS (sched)->yield (sched, element);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_scheduler_interrupt:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @element: the element requesting an interrupt
|
|
|
|
*
|
|
|
|
* Tell the scheduler to interrupt execution of this element.
|
2001-12-27 00:47:41 +00:00
|
|
|
*
|
2001-12-28 20:20:26 +00:00
|
|
|
* Returns: TRUE if the element should return NULL from the chain/get
|
2001-12-27 00:47:41 +00:00
|
|
|
* function.
|
2001-12-22 21:18:17 +00:00
|
|
|
*/
|
2001-12-27 00:47:41 +00:00
|
|
|
gboolean
|
2001-12-22 21:18:17 +00:00
|
|
|
gst_scheduler_interrupt (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
2001-12-27 00:47:41 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
|
|
|
if (CLASS (sched)->interrupt)
|
2001-12-27 00:47:41 +00:00
|
|
|
return CLASS (sched)->interrupt (sched, element);
|
|
|
|
|
|
|
|
return FALSE;
|
2001-12-22 21:18:17 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_scheduler_iterate:
|
|
|
|
* @sched: the schedulerr
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Perform one iteration on the schedulerr.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Returns: a boolean indicating something usefull has happened.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
gboolean
|
|
|
|
gst_scheduler_iterate (GstScheduler *sched)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->iterate)
|
|
|
|
CLASS (sched)->iterate (sched);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_show:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
*
|
|
|
|
* Dump the state of the schedulerr
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_show (GstScheduler *sched)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->show)
|
|
|
|
CLASS (sched)->show (sched);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/*
|
|
|
|
* Factory stuff starts here
|
|
|
|
*
|
|
|
|
*/
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static GList* _gst_schedulerfactories;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static void gst_schedulerfactory_class_init (GstSchedulerFactoryClass *klass);
|
|
|
|
static void gst_schedulerfactory_init (GstSchedulerFactory *factory);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
static xmlNodePtr gst_schedulerfactory_save_thyself (GstObject *object, xmlNodePtr parent);
|
|
|
|
static void gst_schedulerfactory_restore_thyself (GstObject *object, xmlNodePtr parent);
|
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static GstPluginFeatureClass *factory_parent_class = NULL;
|
2001-12-14 22:59:21 +00:00
|
|
|
/* static guint gst_schedulerfactory_signals[LAST_SIGNAL] = { 0 }; */
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
GType
|
|
|
|
gst_schedulerfactory_get_type (void)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
static GType schedulerfactory_type = 0;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!schedulerfactory_type) {
|
|
|
|
static const GTypeInfo schedulerfactory_info = {
|
|
|
|
sizeof (GstSchedulerFactoryClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_schedulerfactory_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstSchedulerFactory),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_schedulerfactory_init,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
|
|
|
|
"GstSchedulerFactory", &schedulerfactory_info, 0);
|
|
|
|
}
|
|
|
|
return schedulerfactory_type;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-14 22:16:47 +00:00
|
|
|
static void
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_schedulerfactory_class_init (GstSchedulerFactoryClass *klass)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstObjectClass *gstobject_class;
|
|
|
|
GstPluginFeatureClass *gstpluginfeature_class;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
gobject_class = (GObjectClass*)klass;
|
|
|
|
gstobject_class = (GstObjectClass*)klass;
|
|
|
|
gstpluginfeature_class = (GstPluginFeatureClass*) klass;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_schedulerfactory_save_thyself);
|
|
|
|
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_schedulerfactory_restore_thyself);
|
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
_gst_schedulerfactories = NULL;
|
2001-12-27 00:47:41 +00:00
|
|
|
_default_name = g_strdup ("basic");
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-14 22:16:47 +00:00
|
|
|
static void
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_schedulerfactory_init (GstSchedulerFactory *factory)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
_gst_schedulerfactories = g_list_prepend (_gst_schedulerfactories, factory);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_new:
|
|
|
|
* @name: name of schedulerfactory to create
|
|
|
|
* @longdesc: long description of schedulerfactory to create
|
|
|
|
* @type: the gtk type of the GstScheduler element of this factory
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Create a new schedulerfactory with the given parameters
|
|
|
|
*
|
|
|
|
* Returns: a new #GstSchedulerFactory.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstSchedulerFactory*
|
|
|
|
gst_schedulerfactory_new (const gchar *name, const gchar *longdesc, GType type)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GstSchedulerFactory *factory;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
factory = gst_schedulerfactory_find (name);
|
|
|
|
if (!factory) {
|
|
|
|
factory = GST_SCHEDULERFACTORY (g_object_new (GST_TYPE_SCHEDULERFACTORY, NULL));
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_object_set_name (GST_OBJECT (factory), name);
|
|
|
|
if (factory->longdesc)
|
|
|
|
g_free (factory->longdesc);
|
|
|
|
factory->longdesc = g_strdup (longdesc);
|
|
|
|
factory->type = type;
|
2000-12-26 23:51:04 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
return factory;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_destroy:
|
|
|
|
* @factory: factory to destroy
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Removes the scheduler from the global list.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-05-25 21:00:07 +00:00
|
|
|
void
|
2001-12-04 22:12:50 +00:00
|
|
|
gst_schedulerfactory_destroy (GstSchedulerFactory *factory)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_if_fail (factory != NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
_gst_schedulerfactories = g_list_remove (_gst_schedulerfactories, factory);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* we don't free the struct bacause someone might have a handle to it.. */
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_find:
|
|
|
|
* @name: name of schedulerfactory to find
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Search for an schedulerfactory of the given name.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Returns: #GstSchedulerFactory if found, NULL otherwise
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstSchedulerFactory*
|
|
|
|
gst_schedulerfactory_find (const gchar *name)
|
2001-07-15 13:04:38 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GList *walk;
|
|
|
|
GstSchedulerFactory *factory;
|
2001-08-10 17:34:59 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
2001-07-15 13:04:38 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
GST_DEBUG (0,"gstscheduler: find \"%s\"\n", name);
|
2001-07-15 13:04:38 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
walk = _gst_schedulerfactories;
|
|
|
|
while (walk) {
|
|
|
|
factory = (GstSchedulerFactory *)(walk->data);
|
|
|
|
if (!strcmp (name, GST_OBJECT_NAME (factory)))
|
|
|
|
return factory;
|
|
|
|
walk = g_list_next (walk);
|
2001-07-15 13:04:38 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
return NULL;
|
2001-07-15 13:04:38 +00:00
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_get_list:
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Get the global list of schedulerfactories.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Returns: GList of type #GstSchedulerFactory
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GList*
|
|
|
|
gst_schedulerfactory_get_list (void)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
return _gst_schedulerfactories;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_create:
|
|
|
|
* @factory: the factory used to create the instance
|
2001-12-09 13:17:54 +00:00
|
|
|
* @parent: the parent element of this scheduler
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Create a new #GstScheduler instance from the
|
2001-12-09 13:17:54 +00:00
|
|
|
* given schedulerfactory with the given parent.
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
|
|
|
* Returns: A new #GstScheduler instance.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler*
|
|
|
|
gst_schedulerfactory_create (GstSchedulerFactory *factory, GstElement *parent)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler *new = NULL;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_val_if_fail (factory != NULL, NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
|
|
|
|
g_return_val_if_fail (factory->type != 0, NULL);
|
|
|
|
|
|
|
|
new = GST_SCHEDULER (g_object_new (factory->type, NULL));
|
|
|
|
new->parent = parent;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
|
|
|
|
return new;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_make:
|
|
|
|
* @name: the name of the factory used to create the instance
|
2001-12-09 13:17:54 +00:00
|
|
|
* @parent: the parent element of this scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
|
|
|
* Create a new #GstScheduler instance from the
|
2001-12-09 13:17:54 +00:00
|
|
|
* schedulerfactory with the given name and parent.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Returns: A new #GstScheduler instance.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler*
|
|
|
|
gst_schedulerfactory_make (const gchar *name, GstElement *parent)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GstSchedulerFactory *factory;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
factory = gst_schedulerfactory_find (name);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (factory == NULL)
|
|
|
|
return NULL;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
return gst_schedulerfactory_create (factory, parent);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-27 00:47:41 +00:00
|
|
|
void
|
|
|
|
gst_schedulerfactory_set_default_name (const gchar* name)
|
|
|
|
{
|
|
|
|
if (_default_name)
|
|
|
|
g_free (_default_name);
|
|
|
|
|
|
|
|
_default_name = g_strdup (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar*
|
|
|
|
gst_schedulerfactory_get_default_name (void)
|
|
|
|
{
|
|
|
|
return _default_name;
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
static xmlNodePtr
|
|
|
|
gst_schedulerfactory_save_thyself (GstObject *object, xmlNodePtr parent)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GstSchedulerFactory *factory;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULERFACTORY (object), parent);
|
|
|
|
|
|
|
|
factory = GST_SCHEDULERFACTORY (object);
|
|
|
|
|
|
|
|
if (GST_OBJECT_CLASS (factory_parent_class)->save_thyself) {
|
|
|
|
GST_OBJECT_CLASS (factory_parent_class)->save_thyself (object, parent);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
xmlNewChild (parent, NULL, "longdesc", factory->longdesc);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
return parent;
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_schedulerfactory_load_thyself:
|
|
|
|
* @parent: the parent XML node pointer
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2001-12-04 22:12:50 +00:00
|
|
|
* Load an schedulerfactory from the given XML parent node.
|
|
|
|
*
|
|
|
|
* Returns: A new factory based on the XML node.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
static void
|
|
|
|
gst_schedulerfactory_restore_thyself (GstObject *object, xmlNodePtr parent)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2001-12-04 22:12:50 +00:00
|
|
|
GstSchedulerFactory *factory = GST_SCHEDULERFACTORY (object);
|
|
|
|
xmlNodePtr children = parent->xmlChildrenNode;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (GST_OBJECT_CLASS (factory_parent_class)->restore_thyself) {
|
|
|
|
GST_OBJECT_CLASS (factory_parent_class)->restore_thyself (object, parent);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
while (children) {
|
|
|
|
if (!strcmp(children->name, "name")) {
|
|
|
|
gst_object_set_name (GST_OBJECT (factory), xmlNodeGetContent (children));
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!strcmp(children->name, "longdesc")) {
|
|
|
|
factory->longdesc = xmlNodeGetContent (children);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
children = children->next;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|