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
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
#include "gstsystemclock.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
|
|
|
{
|
2002-03-30 17:05:03 +00:00
|
|
|
sched->clock_providers = NULL;
|
|
|
|
sched->clock_receivers = NULL;
|
|
|
|
sched->schedulers = NULL;
|
|
|
|
sched->state = GST_SCHEDULER_STATE_NONE;
|
|
|
|
sched->parent = NULL;
|
|
|
|
sched->parent_sched = NULL;
|
|
|
|
sched->clock = NULL;
|
2001-07-15 13:04:38 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 19:22:53 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_setup:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-19 19:22:53 +00:00
|
|
|
*
|
|
|
|
* 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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-19 19:22:53 +00:00
|
|
|
*
|
|
|
|
* 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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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
|
|
|
{
|
2002-02-22 23:12:05 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), NULL);
|
|
|
|
g_return_val_if_fail (padlist != NULL, NULL);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->pad_select)
|
|
|
|
CLASS (sched)->pad_select (sched, padlist);
|
2002-02-22 23:12:05 +00:00
|
|
|
|
|
|
|
return NULL;
|
2000-12-27 23:42:15 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_add_element:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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));
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (element->getclockfunc) {
|
|
|
|
sched->clock_providers = g_list_prepend (sched->clock_providers, element);
|
|
|
|
}
|
|
|
|
if (element->setclockfunc) {
|
|
|
|
sched->clock_receivers = g_list_prepend (sched->clock_receivers, 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
|
|
|
}
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_remove_element:
|
|
|
|
* @sched: the schedulerr
|
2002-03-31 14:04:50 +00:00
|
|
|
* @element: the element to remove
|
2002-03-30 17:05:03 +00:00
|
|
|
*
|
|
|
|
* Remove an element from the schedulerr.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_remove_element (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
|
|
|
GList *pads;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
|
|
|
sched->clock_providers = g_list_remove (sched->clock_providers, element);
|
|
|
|
sched->clock_receivers = g_list_remove (sched->clock_receivers, element);
|
|
|
|
|
|
|
|
if (CLASS (sched)->remove_element)
|
|
|
|
CLASS (sched)->remove_element (sched, element);
|
|
|
|
|
|
|
|
for (pads = element->pads; pads; pads = pads->next) {
|
|
|
|
GstPad *pad = GST_PAD (pads->data);
|
|
|
|
|
|
|
|
if (GST_IS_REAL_PAD (pad)) {
|
|
|
|
gst_pad_unset_sched (GST_PAD (pads->data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
2001-12-20 20:03:10 +00:00
|
|
|
* gst_scheduler_state_transition:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
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);
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (element == sched->parent && sched->parent_sched == NULL) {
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
|
|
|
{
|
|
|
|
GstClock *clock = gst_scheduler_get_clock (sched);
|
|
|
|
|
|
|
|
if (clock)
|
|
|
|
gst_clock_reset (clock);
|
|
|
|
|
|
|
|
sched->current_clock = clock;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
{
|
|
|
|
gst_scheduler_set_clock (sched, sched->current_clock);
|
|
|
|
if (sched->current_clock)
|
2002-04-23 14:58:51 +00:00
|
|
|
gst_clock_set_active (sched->current_clock, TRUE);
|
2002-03-30 17:05:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
if (sched->current_clock)
|
2002-04-23 14:58:51 +00:00
|
|
|
gst_clock_set_active (sched->current_clock, FALSE);
|
2002-03-30 17:05:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_add_scheduler:
|
2002-04-23 14:58:51 +00:00
|
|
|
* @sched: a #GstScheduler to add to
|
|
|
|
* @sched2: the #GstScheduler to add
|
2002-03-31 14:04:50 +00:00
|
|
|
*
|
2002-04-23 14:58:51 +00:00
|
|
|
* Notifies the scheduler that it has to monitor this scheduler.
|
2002-03-31 14:04:50 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
void
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2)
|
2001-10-21 18:00:31 +00:00
|
|
|
{
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
2002-03-30 17:05:03 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched2));
|
2001-12-22 21:18:17 +00:00
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
sched->schedulers = g_list_prepend (sched->schedulers, sched2);
|
|
|
|
sched2->parent_sched = sched;
|
|
|
|
|
|
|
|
if (CLASS (sched)->add_scheduler)
|
|
|
|
CLASS (sched)->add_scheduler (sched, sched2);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_remove_scheduler:
|
|
|
|
* @sched: the schedulerr
|
|
|
|
* @sched2: the scheduler to remove
|
|
|
|
*
|
|
|
|
a Notifies the scheduler that it can stop monitoring this scheduler.
|
|
|
|
*/
|
2002-03-30 17:05:03 +00:00
|
|
|
void
|
|
|
|
gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched2));
|
|
|
|
|
|
|
|
sched->schedulers = g_list_remove (sched->schedulers, sched2);
|
|
|
|
sched2->parent_sched = NULL;
|
|
|
|
|
|
|
|
if (CLASS (sched)->remove_scheduler)
|
|
|
|
CLASS (sched)->remove_scheduler (sched, sched2);
|
|
|
|
}
|
|
|
|
|
2001-12-09 13:17:54 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_lock_element:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-09 13:17:54 +00:00
|
|
|
* @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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-09 13:17:54 +00:00
|
|
|
* @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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-22 21:18:17 +00:00
|
|
|
* @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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-22 21:18:17 +00:00
|
|
|
* @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:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-22 21:18:17 +00:00
|
|
|
* @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
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_get_clock:
|
|
|
|
* @sched: the scheduler
|
|
|
|
*
|
|
|
|
* Get the current clock used by the scheduler
|
|
|
|
*
|
|
|
|
* Returns: a GstClock
|
|
|
|
*/
|
2002-03-30 17:05:03 +00:00
|
|
|
GstClock*
|
|
|
|
gst_scheduler_get_clock (GstScheduler *sched)
|
|
|
|
{
|
|
|
|
GstClock *clock = NULL;
|
|
|
|
|
|
|
|
if (GST_FLAG_IS_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK)) {
|
|
|
|
clock = sched->clock;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (sched->schedulers) {
|
|
|
|
GList *schedulers = sched->schedulers;
|
|
|
|
|
|
|
|
while (schedulers) {
|
|
|
|
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
|
|
|
|
|
|
|
|
clock = gst_scheduler_get_clock (scheduler);
|
|
|
|
if (clock)
|
|
|
|
break;
|
|
|
|
|
|
|
|
schedulers = g_list_next (schedulers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!clock && sched->clock_providers) {
|
|
|
|
clock = gst_element_get_clock (GST_ELEMENT (sched->clock_providers->data));
|
|
|
|
}
|
|
|
|
if (!clock && sched->parent_sched == NULL) {
|
|
|
|
clock = gst_system_clock_obtain ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return clock;
|
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_use_clock:
|
|
|
|
* @sched: the scheduler
|
|
|
|
* @clock: the clock to use
|
|
|
|
*
|
|
|
|
* Force the scheduler to use the given clock. The scheduler will
|
|
|
|
* always use the given clock even if new clock providers are added
|
|
|
|
* to this scheduler.
|
|
|
|
*/
|
2002-03-30 17:05:03 +00:00
|
|
|
void
|
|
|
|
gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock)
|
|
|
|
{
|
|
|
|
g_return_if_fail (sched != NULL);
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
|
|
|
GST_FLAG_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK);
|
|
|
|
sched->clock = clock;
|
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_set_clock:
|
|
|
|
* @sched: the scheduler
|
|
|
|
* @clock: the clock to set
|
|
|
|
*
|
|
|
|
* Set the clock for the scheduler. The clock will be distributed
|
|
|
|
* to all the elements managed by the scheduler.
|
|
|
|
*/
|
2002-03-30 17:05:03 +00:00
|
|
|
void
|
|
|
|
gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock)
|
|
|
|
{
|
|
|
|
GList *receivers;
|
|
|
|
GList *schedulers;
|
|
|
|
|
|
|
|
g_return_if_fail (sched != NULL);
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
|
|
|
receivers = sched->clock_receivers;
|
|
|
|
schedulers = sched->schedulers;
|
|
|
|
|
|
|
|
sched->current_clock = clock;
|
|
|
|
|
|
|
|
while (receivers) {
|
|
|
|
GstElement *element = GST_ELEMENT (receivers->data);
|
|
|
|
|
|
|
|
gst_element_set_clock (element, clock);
|
|
|
|
receivers = g_list_next (receivers);
|
|
|
|
}
|
|
|
|
while (schedulers) {
|
|
|
|
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
|
|
|
|
|
|
|
|
gst_scheduler_set_clock (scheduler, clock);
|
|
|
|
schedulers = g_list_next (schedulers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_auto_clock:
|
|
|
|
* @sched: the scheduler
|
|
|
|
*
|
|
|
|
* Let the scheduler select a clock automatically.
|
|
|
|
*/
|
2002-03-30 17:05:03 +00:00
|
|
|
void
|
|
|
|
gst_scheduler_auto_clock (GstScheduler *sched)
|
|
|
|
{
|
|
|
|
g_return_if_fail (sched != NULL);
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
|
|
|
GST_FLAG_UNSET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK);
|
|
|
|
sched->clock = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_scheduler_clock_wait:
|
|
|
|
* @sched: the scheduler
|
2002-03-31 14:04:50 +00:00
|
|
|
* @element: the element that wants to wait
|
|
|
|
* @clock: the clock to use
|
|
|
|
* @time: the time to wait for
|
2002-03-30 17:05:03 +00:00
|
|
|
*
|
2002-03-31 14:04:50 +00:00
|
|
|
* Wait till the clock reaches a specific time
|
2002-03-30 17:05:03 +00:00
|
|
|
*
|
2002-03-31 14:04:50 +00:00
|
|
|
* Returns: the status of the operation
|
2002-03-30 17:05:03 +00:00
|
|
|
*/
|
|
|
|
GstClockReturn
|
|
|
|
gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, GstClock *clock, GstClockTime time)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), GST_CLOCK_ERROR);
|
|
|
|
|
|
|
|
if (CLASS (sched)->clock_wait)
|
|
|
|
return CLASS (sched)->clock_wait (sched, element, clock, time);
|
|
|
|
|
|
|
|
return GST_CLOCK_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2001-12-04 22:12:50 +00:00
|
|
|
* gst_scheduler_iterate:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
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
|
|
|
{
|
2002-02-22 23:12:05 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
if (CLASS (sched)->iterate)
|
2002-02-22 23:12:05 +00:00
|
|
|
return CLASS (sched)->iterate (sched);
|
|
|
|
|
|
|
|
return FALSE;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_show:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
static void gst_scheduler_factory_class_init (GstSchedulerFactoryClass *klass);
|
|
|
|
static void gst_scheduler_factory_init (GstSchedulerFactory *factory);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2002-04-11 20:35:18 +00:00
|
|
|
static xmlNodePtr gst_scheduler_factory_save_thyself (GstObject *object, xmlNodePtr parent);
|
|
|
|
static void gst_scheduler_factory_restore_thyself (GstObject *object, xmlNodePtr parent);
|
2001-12-04 22:12:50 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
static GstPluginFeatureClass *factory_parent_class = NULL;
|
2002-04-11 20:35:18 +00:00
|
|
|
/* static guint gst_scheduler_factory_signals[LAST_SIGNAL] = { 0 }; */
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
GType
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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,
|
2002-04-11 20:35:18 +00:00
|
|
|
(GClassInitFunc) gst_scheduler_factory_class_init,
|
2001-12-04 22:12:50 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstSchedulerFactory),
|
|
|
|
0,
|
2002-04-11 20:35:18 +00:00
|
|
|
(GInstanceInitFunc) gst_scheduler_factory_init,
|
2001-12-04 22:12:50 +00:00
|
|
|
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
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
2002-04-11 20:35:18 +00:00
|
|
|
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_scheduler_factory_save_thyself);
|
|
|
|
gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_scheduler_factory_restore_thyself);
|
2001-12-04 22:12:50 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
_gst_schedulerfactories = NULL;
|
2002-02-15 21:17:06 +00:00
|
|
|
if (!_default_name)
|
|
|
|
_default_name = g_strdup ("basic");
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-14 22:16:47 +00:00
|
|
|
static void
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_new:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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*
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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);
|
2002-04-11 20:35:18 +00:00
|
|
|
factory = gst_scheduler_factory_find (name);
|
2001-12-04 22:12:50 +00:00
|
|
|
if (!factory) {
|
2002-04-11 20:35:18 +00:00
|
|
|
factory = GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, 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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_destroy:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_find:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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*
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
|
|
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (0,"gstscheduler: find \"%s\"", 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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_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
|
|
|
*/
|
2002-04-19 19:49:41 +00:00
|
|
|
const GList*
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_create:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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
|
2002-05-04 18:59:24 +00:00
|
|
|
* given schedulerfactory with the given parent. @parent will
|
|
|
|
* have its scheduler set to the returned #GstScheduler instance.
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
2002-05-04 18:59:24 +00:00
|
|
|
* Returns: A new #GstScheduler instance with a reference count of %1.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler*
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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);
|
2002-05-04 18:59:24 +00:00
|
|
|
g_return_val_if_fail (parent != 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;
|
2002-05-04 18:59:24 +00:00
|
|
|
|
|
|
|
GST_ELEMENT_SCHED (parent) = new;
|
|
|
|
|
|
|
|
/* let's refcount the scheduler */
|
|
|
|
gst_object_ref (GST_OBJECT (new));
|
|
|
|
gst_object_sink (GST_OBJECT (new));
|
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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_make:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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
|
2002-05-04 18:59:24 +00:00
|
|
|
* schedulerfactory with the given name and parent. @parent will
|
|
|
|
* have its scheduler set to the returned #GstScheduler instance.
|
|
|
|
* If %NULL is passed as @name, the default scheduler name will
|
|
|
|
* be used.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2002-05-04 18:59:24 +00:00
|
|
|
* Returns: A new #GstScheduler instance with a reference count of %1.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2001-12-04 22:12:50 +00:00
|
|
|
GstScheduler*
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
|
|
|
2002-05-04 18:59:24 +00:00
|
|
|
if (name)
|
|
|
|
factory = gst_scheduler_factory_find (name);
|
|
|
|
else
|
|
|
|
factory = gst_scheduler_factory_find (gst_scheduler_factory_get_default_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
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
return gst_scheduler_factory_create (factory, parent);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2002-01-01 15:58:51 +00:00
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_set_default_name:
|
2002-01-01 15:58:51 +00:00
|
|
|
* @name: the name of the factory used as a default
|
|
|
|
*
|
|
|
|
* Set the default schedulerfactory name.
|
|
|
|
*/
|
2001-12-27 00:47:41 +00:00
|
|
|
void
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_set_default_name (const gchar* name)
|
2001-12-27 00:47:41 +00:00
|
|
|
{
|
|
|
|
if (_default_name)
|
|
|
|
g_free (_default_name);
|
|
|
|
|
|
|
|
_default_name = g_strdup (name);
|
|
|
|
}
|
|
|
|
|
2002-01-01 15:58:51 +00:00
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_get_default_name:
|
2002-01-01 15:58:51 +00:00
|
|
|
*
|
|
|
|
* Get the default schedulerfactory name.
|
|
|
|
*
|
|
|
|
* Returns: the name of the default scheduler.
|
|
|
|
*/
|
2001-12-27 00:47:41 +00:00
|
|
|
const gchar*
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_get_default_name (void)
|
2001-12-27 00:47:41 +00:00
|
|
|
{
|
|
|
|
return _default_name;
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
static xmlNodePtr
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_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
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER_FACTORY (object), parent);
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
factory = GST_SCHEDULER_FACTORY (object);
|
2001-12-04 22:12:50 +00:00
|
|
|
|
|
|
|
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
|
|
|
/**
|
2002-04-11 20:35:18 +00:00
|
|
|
* gst_scheduler_factory_load_thyself:
|
2001-12-04 22:12:50 +00:00
|
|
|
* @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
|
2002-04-11 20:35:18 +00:00
|
|
|
gst_scheduler_factory_restore_thyself (GstObject *object, xmlNodePtr parent)
|
2001-05-25 21:00:07 +00:00
|
|
|
{
|
2002-04-11 20:35:18 +00:00
|
|
|
GstSchedulerFactory *factory = GST_SCHEDULER_FACTORY (object);
|
2001-12-04 22:12:50 +00:00
|
|
|
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 */
|