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"
|
2002-07-08 19:07:30 +00:00
|
|
|
#include "gstlog.h"
|
2002-05-08 20:40:48 +00:00
|
|
|
#include "gstregistry.h"
|
2000-12-26 23:51:04 +00:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2002-06-19 18:13:28 +00:00
|
|
|
/**
|
2002-06-27 23:55:27 +00:00
|
|
|
* gst_scheduler_get_preferred_stack:
|
2002-09-12 18:56:31 +00:00
|
|
|
* @sched: a #GstScheduler to query.
|
|
|
|
* @stack: the pointer to store the location of the preferred stack in.
|
|
|
|
* @size: the pointer to store the size of the preferred stack in.
|
2002-06-19 18:13:28 +00:00
|
|
|
*
|
2002-09-12 18:56:31 +00:00
|
|
|
* Gets the preferred stack location and size of this scheduler.
|
2002-06-19 18:13:28 +00:00
|
|
|
*
|
2002-06-27 23:55:27 +00:00
|
|
|
* Returns: TRUE if the scheduler suggested a preferred stacksize and location.
|
2002-06-19 18:13:28 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2002-06-27 23:55:27 +00:00
|
|
|
gst_scheduler_get_preferred_stack (GstScheduler *sched, gpointer *stack, gulong *size)
|
2002-06-19 18:13:28 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), FALSE);
|
|
|
|
|
2002-06-27 23:55:27 +00:00
|
|
|
if (CLASS (sched)->get_preferred_stack)
|
|
|
|
return CLASS (sched)->get_preferred_stack (sched, stack, size);
|
2002-06-19 18:13:28 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-12-19 19:22:53 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_reset:
|
2002-09-12 18:56:31 +00:00
|
|
|
* @sched: a #GstScheduler to reset.
|
2001-12-19 19:22:53 +00:00
|
|
|
*
|
2002-09-12 18:56:31 +00:00
|
|
|
* Reset the schedulers.
|
2001-12-19 19:22:53 +00:00
|
|
|
*/
|
|
|
|
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
|
2002-05-25 15:25:47 +00:00
|
|
|
* @element: the element to add to the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
2002-05-25 15:25:47 +00:00
|
|
|
* Add an element to the scheduler.
|
2001-12-04 22:12:50 +00:00
|
|
|
*/
|
|
|
|
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-09-13 23:02:54 +00:00
|
|
|
/* if it's already in this scheduler, don't bother doing anything */
|
2002-09-17 21:23:33 +00:00
|
|
|
if (GST_ELEMENT_SCHED (element) == sched) {
|
|
|
|
GST_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p",
|
|
|
|
GST_ELEMENT_NAME (element), sched);
|
2002-09-13 23:02:54 +00:00
|
|
|
return;
|
2002-09-17 21:23:33 +00:00
|
|
|
}
|
2002-09-13 23:02:54 +00:00
|
|
|
|
|
|
|
/* if it's not inside this scheduler, it has to be NULL */
|
|
|
|
g_assert (GST_ELEMENT_SCHED (element) == NULL);
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
if (element->getclockfunc) {
|
|
|
|
sched->clock_providers = g_list_prepend (sched->clock_providers, element);
|
2002-05-08 20:40:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "added clock provider %s", GST_ELEMENT_NAME (element));
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
if (element->setclockfunc) {
|
|
|
|
sched->clock_receivers = g_list_prepend (sched->clock_receivers, element);
|
2002-05-08 20:40:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_ELEMENT_NAME (element));
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
2002-09-13 23:02:54 +00:00
|
|
|
gst_element_set_scheduler (element, sched);
|
2002-09-12 20:52:03 +00:00
|
|
|
|
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:
|
2002-05-25 15:25:47 +00:00
|
|
|
* @sched: the scheduler
|
2002-03-31 14:04:50 +00:00
|
|
|
* @element: the element to remove
|
2002-03-30 17:05:03 +00:00
|
|
|
*
|
2002-05-25 15:25:47 +00:00
|
|
|
* Remove an element from the scheduler.
|
2002-03-30 17:05:03 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_remove_element (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
|
|
|
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);
|
2002-09-13 23:02:54 +00:00
|
|
|
|
|
|
|
gst_element_set_scheduler (element, NULL);
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler READY to PAUSED clock is %p (%s)", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"));
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
sched->current_clock = clock;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
{
|
2002-05-08 20:40:48 +00:00
|
|
|
GstClock *clock = gst_scheduler_get_clock (sched);
|
|
|
|
|
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler PAUSED to PLAYING clock is %p (%s)", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"));
|
|
|
|
|
|
|
|
sched->current_clock = clock;
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_scheduler_set_clock (sched, sched->current_clock);
|
2002-07-30 19:21:13 +00:00
|
|
|
if (sched->current_clock) {
|
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "enabling clock %p (%s)", sched->current_clock,
|
|
|
|
GST_OBJECT_NAME (sched->current_clock));
|
2002-04-23 14:58:51 +00:00
|
|
|
gst_clock_set_active (sched->current_clock, TRUE);
|
2002-07-30 19:21:13 +00:00
|
|
|
}
|
2002-03-30 17:05:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
2002-07-30 19:21:13 +00:00
|
|
|
if (sched->current_clock) {
|
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "disabling clock %p (%s)", sched->current_clock,
|
|
|
|
GST_OBJECT_NAME (sched->current_clock));
|
2002-04-23 14:58:51 +00:00
|
|
|
gst_clock_set_active (sched->current_clock, FALSE);
|
2002-07-30 19:21:13 +00:00
|
|
|
}
|
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-09-17 21:23:33 +00:00
|
|
|
/**
|
|
|
|
* gst_scheduler_state_transition:
|
|
|
|
* @sched: the scheduler
|
|
|
|
* @element: the element with the state transition
|
|
|
|
* @transition: the state transition
|
|
|
|
*
|
|
|
|
* Tell the scheduler that an element changed its state.
|
|
|
|
*
|
|
|
|
* Returns: a GstElementStateReturn indicating success or failure
|
|
|
|
* of the state transition.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
|
|
|
if (CLASS (sched)->scheduling_change)
|
|
|
|
CLASS (sched)->scheduling_change (sched, element);
|
|
|
|
}
|
|
|
|
|
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:
|
2002-05-25 15:25:47 +00:00
|
|
|
* @sched: the scheduler
|
2002-03-31 14:04:50 +00:00
|
|
|
* @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;
|
|
|
|
|
2002-06-08 23:45:53 +00:00
|
|
|
/* if we have a fixed clock, use that one */
|
2002-03-30 17:05:03 +00:00
|
|
|
if (GST_FLAG_IS_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK)) {
|
|
|
|
clock = sched->clock;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"));
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-05-08 20:40:48 +00:00
|
|
|
GList *schedulers = sched->schedulers;
|
2002-06-08 23:45:53 +00:00
|
|
|
GList *providers = sched->clock_providers;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-06-08 23:45:53 +00:00
|
|
|
/* try to get a clock from one of the schedulers we manage first */
|
2002-05-08 20:40:48 +00:00
|
|
|
while (schedulers) {
|
|
|
|
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
clock = gst_scheduler_get_clock (scheduler);
|
|
|
|
if (clock)
|
|
|
|
break;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
schedulers = g_list_next (schedulers);
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
2002-06-08 23:45:53 +00:00
|
|
|
/* still no clock, try to find one in the providers */
|
|
|
|
while (!clock && providers) {
|
|
|
|
clock = gst_element_get_clock (GST_ELEMENT (providers->data));
|
|
|
|
|
|
|
|
providers = g_list_next (providers);
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
2002-06-08 23:45:53 +00:00
|
|
|
/* still no clock, use a system clock */
|
2002-03-30 17:05:03 +00:00
|
|
|
if (!clock && sched->parent_sched == NULL) {
|
|
|
|
clock = gst_system_clock_obtain ();
|
|
|
|
}
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler selected clock %p (%s)", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"));
|
2002-03-30 17:05:03 +00:00
|
|
|
|
|
|
|
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-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"));
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2002-06-16 21:50:50 +00:00
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on element %s", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element));
|
2002-11-02 13:54:34 +00:00
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
gst_element_set_clock (element, clock);
|
|
|
|
receivers = g_list_next (receivers);
|
|
|
|
}
|
|
|
|
while (schedulers) {
|
|
|
|
GstScheduler *scheduler = GST_SCHEDULER (schedulers->data);
|
|
|
|
|
2002-06-16 21:50:50 +00:00
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on scheduler %p", clock,
|
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler);
|
2002-03-30 17:05:03 +00:00
|
|
|
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;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
GST_DEBUG (GST_CAT_CLOCK, "scheduler using automatic clock");
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-06-12 22:26:36 +00:00
|
|
|
* @jitter: the time difference between requested time and actual time
|
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
|
2002-05-26 21:54:27 +00:00
|
|
|
gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, GstClock *clock, GstClockTime time,
|
|
|
|
GstClockTimeDiff *jitter)
|
2002-03-30 17:05:03 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), GST_CLOCK_ERROR);
|
|
|
|
|
|
|
|
if (CLASS (sched)->clock_wait)
|
2002-05-26 21:54:27 +00:00
|
|
|
return CLASS (sched)->clock_wait (sched, element, clock, time, jitter);
|
2002-06-16 21:50:50 +00:00
|
|
|
else
|
2002-11-02 13:54:34 +00:00
|
|
|
{
|
|
|
|
GstClockID id = gst_clock_new_single_shot_id (clock, time);
|
|
|
|
|
|
|
|
return gst_clock_id_wait (id, jitter);
|
|
|
|
}
|
2002-03-30 17:05:03 +00:00
|
|
|
|
|
|
|
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
|
|
|
*
|
2002-05-25 15:25:47 +00:00
|
|
|
* Perform one iteration on the scheduler.
|
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
|
|
|
*
|
2002-05-25 15:25:47 +00:00
|
|
|
* Dump the state of the scheduler
|
2001-12-04 22:12:50 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
*
|
|
|
|
*/
|
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
|
|
|
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
|
|
|
|
2002-02-15 21:17:06 +00:00
|
|
|
if (!_default_name)
|
2002-09-12 19:23:41 +00:00
|
|
|
_default_name = g_strdup ("basicomega");
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
|
2001-12-04 22:12:50 +00:00
|
|
|
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-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
|
|
|
{
|
2002-05-08 20:40:48 +00:00
|
|
|
GstPluginFeature *feature;
|
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
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
feature = gst_registry_pool_find_feature (name, GST_TYPE_SCHEDULER_FACTORY);
|
|
|
|
if (feature)
|
|
|
|
return GST_SCHEDULER_FACTORY (feature);
|
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_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;
|
2002-08-11 19:33:47 +00:00
|
|
|
const gchar *default_name = gst_scheduler_factory_get_default_name ();
|
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
|
2002-08-11 19:33:47 +00:00
|
|
|
{
|
|
|
|
/* FIXME: do better error handling */
|
|
|
|
if (default_name == NULL)
|
|
|
|
g_error ("No default scheduler name - do you have a registry ?");
|
|
|
|
factory = gst_scheduler_factory_find (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;
|
|
|
|
}
|