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.
|
|
|
|
*/
|
|
|
|
|
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"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2003-02-10 20:32:32 +00:00
|
|
|
#include "gstregistrypool.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);
|
2003-01-17 18:48:17 +00:00
|
|
|
static void gst_scheduler_dispose (GObject *object);
|
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
|
|
|
{
|
2003-01-17 18:48:17 +00:00
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass*) klass;
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_scheduler_dispose);
|
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
|
|
|
}
|
|
|
|
|
2003-01-17 18:48:17 +00:00
|
|
|
static void
|
|
|
|
gst_scheduler_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GstScheduler *sched = GST_SCHEDULER (object);
|
|
|
|
|
2003-01-17 20:02:27 +00:00
|
|
|
/* thse lists should all be NULL */
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ( "scheduler %p dispose %p %p %p",
|
2003-01-17 20:02:27 +00:00
|
|
|
object,
|
|
|
|
sched->clock_providers,
|
|
|
|
sched->clock_receivers,
|
|
|
|
sched->schedulers);
|
|
|
|
|
2003-02-02 19:49:29 +00:00
|
|
|
gst_object_replace ((GstObject **)&sched->current_clock, NULL);
|
|
|
|
gst_object_replace ((GstObject **)&sched->clock, NULL);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->setup)
|
|
|
|
sclass->setup (sched);
|
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)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->reset)
|
|
|
|
sclass->reset (sched);
|
2001-12-19 19:22:53 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
/**
|
2003-01-09 14:15:37 +00:00
|
|
|
* gst_scheduler_pad_link:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2003-01-09 14:15:37 +00:00
|
|
|
* @srcpad: the srcpad to link
|
|
|
|
* @sinkpad: the sinkpad to link to
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
2003-01-09 14:15:37 +00:00
|
|
|
* Links the srcpad to the given sinkpad.
|
2001-12-04 22:12:50 +00:00
|
|
|
*/
|
|
|
|
void
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
|
2001-01-19 02:23:35 +00:00
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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));
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
if (sclass->pad_link)
|
|
|
|
sclass->pad_link (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
|
|
|
/**
|
2003-01-09 14:15:37 +00:00
|
|
|
* gst_scheduler_pad_unlink:
|
2002-01-19 06:29:40 +00:00
|
|
|
* @sched: the scheduler
|
2003-01-09 14:15:37 +00:00
|
|
|
* @srcpad: the srcpad to unlink
|
|
|
|
* @sinkpad: the sinkpad to unlink from
|
2001-12-04 22:12:50 +00:00
|
|
|
*
|
2003-01-09 14:15:37 +00:00
|
|
|
* Unlinks the srcpad from the given sinkpad.
|
2001-12-04 22:12:50 +00:00
|
|
|
*/
|
|
|
|
void
|
2003-01-09 14:15:37 +00:00
|
|
|
gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad)
|
2000-12-26 23:51:04 +00:00
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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));
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
2003-01-09 14:15:37 +00:00
|
|
|
if (sclass->pad_unlink)
|
|
|
|
sclass->pad_unlink (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-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->pad_select)
|
|
|
|
sclass->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
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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) {
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p",
|
2002-09-17 21:23:33 +00:00
|
|
|
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-11-27 20:47:39 +00:00
|
|
|
if (gst_element_provides_clock (element)) {
|
2002-03-30 17:05:03 +00:00
|
|
|
sched->clock_providers = g_list_prepend (sched->clock_providers, element);
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s", GST_ELEMENT_NAME (element));
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
2002-11-27 20:47:39 +00:00
|
|
|
if (gst_element_requires_clock (element)) {
|
2002-03-30 17:05:03 +00:00
|
|
|
sched->clock_receivers = g_list_prepend (sched->clock_receivers, element);
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_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
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->add_element)
|
|
|
|
sclass->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)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
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);
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->remove_element)
|
|
|
|
sclass->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
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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);
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler READY to PAUSED clock is %p (%s)", clock,
|
2002-05-08 20:40:48 +00:00
|
|
|
(clock ? GST_OBJECT_NAME (clock) : "nil"));
|
|
|
|
|
2003-03-28 17:36:22 +00:00
|
|
|
gst_scheduler_set_clock (sched, clock);
|
2002-03-30 17:05:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->state_transition)
|
|
|
|
return sclass->state_transition (sched, element, transition);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2002-09-17 21:23:33 +00:00
|
|
|
/**
|
2002-12-14 13:02:16 +00:00
|
|
|
* gst_scheduler_scheduling_change:
|
2002-09-17 21:23:33 +00:00
|
|
|
* @sched: the scheduler
|
2002-12-14 13:02:16 +00:00
|
|
|
* @element: the element that changed its scheduling strategy
|
2002-09-17 21:23:33 +00:00
|
|
|
*
|
2002-12-14 13:02:16 +00:00
|
|
|
* Tell the scheduler that an element changed its scheduling strategy.
|
|
|
|
* An element could, for example, change its loop function or changes
|
|
|
|
* from a loop based element to a chain based element.
|
2002-09-17 21:23:33 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2002-09-17 21:23:33 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->scheduling_change)
|
|
|
|
sclass->scheduling_change (sched, element);
|
2002-09-17 21:23:33 +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
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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));
|
2003-01-17 20:02:27 +00:00
|
|
|
g_return_if_fail (sched2->parent_sched == NULL);
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ("gstscheduler: %p add scheduler %p", sched, sched2);
|
2003-01-17 20:02:27 +00:00
|
|
|
|
|
|
|
gst_object_ref (GST_OBJECT (sched2));
|
|
|
|
gst_object_ref (GST_OBJECT (sched));
|
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;
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->add_scheduler)
|
|
|
|
sclass->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)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched2));
|
2003-01-17 20:02:27 +00:00
|
|
|
g_return_if_fail (sched2->parent_sched == sched);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ("gstscheduler: %p remove scheduler %p", sched, sched2);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->remove_scheduler)
|
|
|
|
sclass->remove_scheduler (sched, sched2);
|
2003-01-17 20:02:27 +00:00
|
|
|
|
|
|
|
sched->schedulers = g_list_remove (sched->schedulers, sched2);
|
|
|
|
sched2->parent_sched = NULL;
|
|
|
|
|
|
|
|
gst_object_unref (GST_OBJECT (sched2));
|
|
|
|
gst_object_unref (GST_OBJECT (sched));
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->lock_element)
|
|
|
|
sclass->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
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->unlock_element)
|
|
|
|
sclass->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)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->error)
|
|
|
|
sclass->error (sched, element);
|
2001-12-22 21:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2003-01-11 16:27:45 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the element should save its state, FALSE
|
|
|
|
* if the scheduler can perform this action itself.
|
2001-12-22 21:18:17 +00:00
|
|
|
*/
|
2003-01-11 16:27:45 +00:00
|
|
|
gboolean
|
2001-12-22 21:18:17 +00:00
|
|
|
gst_scheduler_yield (GstScheduler *sched, GstElement *element)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2003-01-11 16:27:45 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), TRUE);
|
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (element), TRUE);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->yield)
|
2003-01-11 16:27:45 +00:00
|
|
|
return sclass->yield (sched, element);
|
|
|
|
|
|
|
|
return TRUE;
|
2001-12-22 21:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
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
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->interrupt)
|
|
|
|
return sclass->interrupt (sched, element);
|
2001-12-27 00:47:41 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
|
2002-05-08 20:40:48 +00:00
|
|
|
(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 ();
|
|
|
|
}
|
|
|
|
}
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, sched, "scheduler selected clock %p (%s)", clock,
|
|
|
|
clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-");
|
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);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
2003-02-02 19:49:29 +00:00
|
|
|
gst_object_replace ((GstObject **)&sched->clock, (GstObject *)clock);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock,
|
2002-05-08 20:40:48 +00:00
|
|
|
(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;
|
|
|
|
|
2003-02-02 19:49:29 +00:00
|
|
|
gst_object_replace ((GstObject **)&sched->current_clock, (GstObject *)clock);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
|
|
|
while (receivers) {
|
|
|
|
GstElement *element = GST_ELEMENT (receivers->data);
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on element %s", clock,
|
2002-06-16 21:50:50 +00:00
|
|
|
(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);
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on scheduler %p", clock,
|
2002-06-16 21:50:50 +00:00
|
|
|
(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);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
2003-02-02 19:49:29 +00:00
|
|
|
gst_object_replace ((GstObject **)&sched->clock, NULL);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using automatic clock");
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
gst/gstclock.*: deprecate old interface and disable functions that aren't in use anymore.
Original commit message from CVS:
2004-01-13 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstclock.c: (gst_clock_class_init), (gst_clock_init),
(gst_clock_set_speed), (gst_clock_set_active),
(gst_clock_is_active), (gst_clock_reset),
(gst_clock_handle_discont):
* gst/gstclock.h:
deprecate old interface and disable functions that aren't in use
anymore.
* gst/gstelement.h:
* gst/gstelement.c: (gst_element_get_time), (gst_element_wait),
(gst_element_set_time), (gst_element_adjust_time):
add concept of "element time" and functions to get/set this time.
* gst/gstelement.c: (gst_element_change_state):
update element time correctly.
* gst/gstelement.c: (gst_element_get_compatible_pad_filtered):
This is a debug message, not a g_critical.
* gst/gstpad.c: (gst_pad_event_default):
handle discontinuous events right with element time.
* gst/gstscheduler.c: (gst_scheduler_state_transition):
update to clocking fixes.
set clocks on elements in READY=>PAUSED. The old behaviour caused
a wrong element time on the first element that started playing.
* gst/schedulers/gstbasicscheduler.c:
(gst_basic_scheduler_class_init):
* gst/schedulers/gstoptimalscheduler.c:
(gst_opt_scheduler_class_init):
remove code that just implements the default behaviour.
* gst/elements/gstfakesink.c: (gst_fakesink_chain):
update to use new clocking functions
* testsuite/clock/clock1.c: (gst_clock_debug), (main):
* testsuite/clock/clock2.c: (gst_clock_debug), (main):
update to test new element time.
* gst/autoplug/gstspideridentity.c: (gst_spider_identity_getcaps):
use _get_allowed_caps instead of _get_caps. This catches filtered
caps correctly.
* testsuite/debug/commandline.c:
update for new GST_DEBUG syntax.
* testsuite/threads/Makefile.am:
disable a test that only works sometimes.
2004-01-14 00:46:48 +00:00
|
|
|
GstClockReturn gst_clock_id_wait (GstClockID id,
|
|
|
|
GstClockTimeDiff *jitter);
|
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
|
2002-12-27 22:57:13 +00:00
|
|
|
* @id: the clockid to use
|
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-12-27 22:57:13 +00:00
|
|
|
* Wait till the clock reaches a specific time. The ClockID can
|
|
|
|
* be obtained from #gst_clock_new_single_shot_id.
|
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-12-27 22:57:13 +00:00
|
|
|
gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element,
|
|
|
|
GstClockID id, GstClockTimeDiff *jitter)
|
2002-03-30 17:05:03 +00:00
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
g_return_val_if_fail (GST_IS_SCHEDULER (sched), GST_CLOCK_ERROR);
|
2002-12-27 22:57:13 +00:00
|
|
|
g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->clock_wait)
|
2002-12-27 22:57:13 +00:00
|
|
|
return sclass->clock_wait (sched, element, id, jitter);
|
|
|
|
else
|
2002-11-02 13:54:34 +00:00
|
|
|
return gst_clock_id_wait (id, jitter);
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
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-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
2003-02-27 18:16:29 +00:00
|
|
|
gboolean res = FALSE;
|
2002-12-19 21:31:03 +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
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
2003-02-27 18:16:29 +00:00
|
|
|
if (sclass->iterate) {
|
|
|
|
res = sclass->iterate (sched);
|
|
|
|
}
|
2002-02-22 23:12:05 +00:00
|
|
|
|
2003-02-27 18:16:29 +00:00
|
|
|
return res;
|
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
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstSchedulerClass *sclass;
|
|
|
|
|
2001-12-22 21:18:17 +00:00
|
|
|
g_return_if_fail (GST_IS_SCHEDULER (sched));
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
sclass = GST_SCHEDULER_GET_CLASS (sched);
|
|
|
|
|
|
|
|
if (sclass->show)
|
|
|
|
sclass->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
|
|
|
|
2003-12-13 16:58:29 +00:00
|
|
|
if (!_default_name) {
|
|
|
|
if (g_getenv ("GST_SCHEDULER")) {
|
|
|
|
_default_name = g_strdup (g_getenv ("GST_SCHEDULER"));
|
|
|
|
} else {
|
|
|
|
_default_name = g_strdup (GST_SCHEDULER_DEFAULT_NAME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_assert (_default_name);
|
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
|
|
|
|
2003-01-17 18:59:44 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
factory = gst_scheduler_factory_find (name);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
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));
|
2003-01-18 14:11:36 +00:00
|
|
|
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2003-01-17 18:48:17 +00:00
|
|
|
else {
|
2001-12-04 22:12:50 +00:00
|
|
|
g_free (factory->longdesc);
|
2003-01-17 18:48:17 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
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
|
|
|
|
2003-01-17 18:59:44 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2001-07-15 13:04:38 +00:00
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_DEBUG ("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);
|
2003-01-17 18:48:17 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
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
|
|
|
{
|
2003-02-10 20:32:32 +00:00
|
|
|
GstScheduler *sched = 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);
|
2003-01-17 18:59:44 +00:00
|
|
|
g_return_val_if_fail (GST_IS_ELEMENT (parent), 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);
|
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
sched = GST_SCHEDULER (g_object_new (factory->type, NULL));
|
|
|
|
sched->parent = parent;
|
2002-05-04 18:59:24 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
GST_ELEMENT_SCHED (parent) = sched;
|
2002-05-04 18:59:24 +00:00
|
|
|
|
|
|
|
/* let's refcount the scheduler */
|
2003-02-10 20:32:32 +00:00
|
|
|
gst_object_ref (GST_OBJECT (sched));
|
|
|
|
gst_object_sink (GST_OBJECT (sched));
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
return sched;
|
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
|
|
|
{
|
2003-01-17 18:48:17 +00:00
|
|
|
g_free (_default_name);
|
2001-12-27 00:47:41 +00:00
|
|
|
|
|
|
|
_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;
|
|
|
|
}
|