*/
#include <gst/gst.h>
-#include "../cothreads.h"
GstElementDetails gst_autoplugcache_details = {
"AutoplugCache",
#include <gst/gstextratypes.h>
#include <gst/gstenumtypes.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
/* initialize GST */
void gst_init (int *argc, char **argv[]);
void gst_main (void);
void gst_main_quit (void);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#include <gst/gstlog.h>
#include "gstautoplug.h"
#include "gstregistry.h"
+#include "gstlog.h"
enum {
NEW_OBJECT,
#include <gst/gstelement.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
#define GST_TYPE_AUTOPLUG \
(gst_autoplug_get_type())
GstAutoplug* gst_autoplug_factory_create (GstAutoplugFactory *factory);
GstAutoplug* gst_autoplug_factory_make (const gchar *name);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#else /* GST_DISABLE_AUTOPLUG */
#include "gstevent.h"
#include "gstbin.h"
#include "gstxml.h"
+#include "gstlog.h"
#include "gstscheduler.h"
#include <gst/gstelement.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
extern GstElementDetails gst_bin_details;
extern GType _gst_bin_type;
void gst_bin_set_pre_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data);
void gst_bin_set_post_iterate_function (GstBin *bin, GstBinPrePostIterateFunction func, gpointer func_data);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+
+G_END_DECLS
#endif /* __GST_BIN_H__ */
#include "gstcaps.h"
#include "gsttype.h"
+#include "gstlog.h"
static GMemChunk *_gst_caps_chunk;
static GMutex *_gst_caps_chunk_lock;
#ifndef __GST_CAPS_H__
#define __GST_CAPS_H__
-#include <gst/gstconfig.h>
-
#include <gst/gstprops.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
typedef struct _GstCaps GstCaps;
GstCaps* gst_caps_load_thyself (xmlNodePtr parent);
#endif
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_CAPS_H__ */
#ifndef __GST_CLOCK_H__
#define __GST_CLOCK_H__
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
#include <gst/gstobject.h>
+G_BEGIN_DECLS
+
#define GST_TYPE_CLOCK \
(gst_clock_get_type())
#define GST_CLOCK(obj) \
void gst_clock_set_resolution (GstClock *clock, guint64 resolution);
guint64 gst_clock_get_resolution (GstClock *clock);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_CLOCK_H__ */
#define __GST_ELEMENT_H__
#include <gst/gstconfig.h>
-
#include <gst/gsttypes.h>
#include <gst/gstobject.h>
#include <gst/gstpad.h>
#include "gstelement.h"
#include "gstregistry.h"
+#include "gstlog.h"
static void gst_element_factory_class_init (GstElementFactoryClass *klass);
static void gst_element_factory_init (GstElementFactory *factory);
#ifndef __GST_EXTRA_TYPES_H__
#define __GST_EXTRA_TYPES_H__
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+G_BEGIN_DECLS
#define GST_TYPE_FILENAME (gst_extra_get_filename_type())
GType gst_extra_get_filename_type(void);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_EXTRA_TYPES_H__ */
#include "gst_private.h"
#include "gstobject.h"
+#include "gstlog.h"
/* Object signals and args */
enum {
g_object_ref (G_OBJECT (object));
return object;
}
-#define gst_object_ref gst_object_ref
/**
* gst_object_unref:
g_object_unref (G_OBJECT (object));
}
-#define gst_object_unref gst_object_unref
/**
* gst_object_sink:
gst_object_unref (object);
}
-/**
- * gst_object_ref:
- * @object: GstObject to reference
- *
- * Increments the refence count on the object.
- *
- * Returns: Apointer to the Object
- */
-#ifndef gst_object_ref
-GstObject*
-gst_object_ref (GstObject *object)
-{
- g_return_if_fail (object != NULL, NULL);
- g_return_if_fail (GST_IS_OBJECT (object), NULL);
-
-/* #ifdef HAVE_ATOMIC_H */
-/* g_return_if_fail (atomic_read (&(object->refcount)) > 0); */
-/* atomic_inc (&(object->refcount)) */
-/* #else */
- g_return_if_fail (object->refcount > 0);
- GST_LOCK (object);
-/* object->refcount++; */
- g_object_ref((GObject *)object);
- GST_UNLOCK (object);
-/* #endif */
-
- return object;
-}
-#endif /* gst_object_ref */
-
-/**
- * gst_object_unref:
- * @object: GstObject to unreference
- *
- * Decrements the refence count on the object. If reference count hits
- * zero, destroy the object.
- */
-#ifndef gst_object_unref
-void
-gst_object_unref (GstObject *object)
-{
- int reftest;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (GST_IS_OBJECT (object));
-
-#ifdef HAVE_ATOMIC_H
- g_return_if_fail (atomic_read (&(object->refcount)) > 0);
- reftest = atomic_dec_and_test (&(object->refcount))
-#else
- g_return_if_fail (object->refcount > 0);
- GST_LOCK (object);
- object->refcount--;
- reftest = (object->refcount == 0);
- GST_UNLOCK (object);
-#endif
-
- /* if we ended up with the refcount at zero */
- if (reftest) {
- /* get the count to 1 for gtk_object_destroy() */
-#ifdef HAVE_ATOMIC_H
- atomic_set (&(object->refcount),1);
-#else
- object->refcount = 1;
-#endif
- /* destroy it */
- gtk_object_destroy (G_OBJECT (object));
- /* drop the refcount back to zero */
-#ifdef HAVE_ATOMIC_H
- atomic_set (&(object->refcount),0);
-#else
- object->refcount = 0;
-#endif
- /* finalize the object */
- /* FIXME this is an evil hack that should be killed */
-/* FIXMEFIXMEFIXMEFIXME */
-/* gtk_object_finalize(G_OBJECT(object)); */
- }
-}
-#endif /* gst_object_unref */
-
/**
* gst_object_check_uniqueness:
* @list: a list of #GstObject to check through
#include <gst/gsttrace.h>
#include <gst/gsttypes.h>
-/* FIXME */
-#include "gstlog.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
extern GType _gst_object_type;
GObject object;
gchar *name;
- /* have to have a refcount for the object */
-#ifdef HAVE_ATOMIC_H
- atomic_t refcount;
-#else
- gint refcount;
-#endif
- /* locking for all sorts of things (like the refcount) */
+ /* locking for all sorts of things */
GMutex *lock;
/* this object's parent */
GstObject *parent;
#endif
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
+G_END_DECLS
#endif /* __GST_OBJECT_H__ */
#include "gstparse.h"
#include "gstinfo.h"
+#include "gstlog.h"
#include "parse/types.h"
typedef struct _gst_parse_delayed_pad gst_parse_delayed_pad;
#ifndef __GST_PARSE_H__
#define __GST_PARSE_H__
-#include <gst/gstpipeline.h>
+#include <gst/gstbin.h>
G_BEGIN_DECLS
#include "gst_private.h"
#include "gstpipeline.h"
+#include "gstlog.h"
#include "gstscheduler.h"
GstElementDetails gst_pipeline_details = {
#include <gst/gstbin.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
extern GstElementDetails gst_pipeline_details;
#define gst_pipeline_destroy(pipeline) gst_object_destroy(GST_OBJECT(pipeline))
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
+G_END_DECLS
#endif /* __GST_PIPELINE_H__ */
#include "gstplugin.h"
#include "gstversion.h"
#include "gstregistry.h"
+#include "gstlog.h"
#include "config.h"
static GModule *main_module;
#include <gst/gstconfig.h>
#include <gmodule.h>
-
#include <gst/gstpluginfeature.h>
+G_BEGIN_DECLS
+
GQuark gst_plugin_error_quark (void);
#define GST_PLUGIN_ERROR gst_plugin_error_quark ()
gboolean gst_plugin_load (const gchar *name);
gboolean gst_library_load (const gchar *name);
+G_END_DECLS
#endif /* __GST_PLUGIN_H__ */
#include "gstpluginfeature.h"
#include "gstplugin.h"
#include "gstregistry.h"
+#include "gstlog.h"
static void gst_plugin_feature_class_init (GstPluginFeatureClass *klass);
static void gst_plugin_feature_init (GstPluginFeature *feature);
-static GstObjectClass *parent_class = NULL;
+static GObjectClass *parent_class = NULL;
/* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
GType
#ifndef __GST_PLUGIN_FEATURE_H__
#define __GST_PLUGIN_FEATURE_H__
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+#include <glib-object.h>
-#include <gst/gstobject.h>
+G_BEGIN_DECLS
#define GST_TYPE_PLUGIN_FEATURE \
(gst_plugin_feature_get_type())
gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature *feature);
void gst_plugin_feature_unload_thyself (GstPluginFeature *feature);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_PLUGIN_FEATURE_H__ */
#include <glib-object.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
typedef struct _GstProps GstProps;
extern GType _gst_props_type;
#endif
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_PROPS_H__ */
#include "gstinfo.h"
#include "gstregistry.h"
+#include "gstlog.h"
+#include "gstmarshal.h"
#define CLASS(registry) GST_REGISTRY_CLASS (G_OBJECT_GET_CLASS (registry))
#include "gstsystemclock.h"
#include "gstscheduler.h"
+#include "gstlog.h"
#include "gstregistry.h"
static void gst_scheduler_class_init (GstSchedulerClass *klass);
#include <gst/gstelement.h>
#include <gst/gstbin.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+G_BEGIN_DECLS
#define GST_TYPE_SCHEDULER \
(gst_scheduler_get_type())
const gchar* gst_scheduler_factory_get_default_name (void);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_SCHEDULER_H__ */
#include <gst/gstclock.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
#define GST_TYPE_SYSTEM_CLOCK \
(gst_system_clock_get_type())
GstClock* gst_system_clock_obtain (void);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
+G_END_DECLS
#endif /* __GST_SYSTEM_CLOCK_H__ */
/* Thread signals and args */
enum {
+ SHUTDOWN,
/* FILL ME */
LAST_SIGNAL
};
enum {
ARG_0,
+ ARG_SCHEDPOLICY,
+ ARG_PRIORITY,
};
static void* gst_thread_main_loop (void *arg);
+#define GST_TYPE_THREAD_SCHEDPOLICY (gst_thread_schedpolicy_get_type())
+static GType
+gst_thread_schedpolicy_get_type(void) {
+ static GType thread_schedpolicy_type = 0;
+ static GEnumValue thread_schedpolicy[] = {
+ {SCHED_OTHER, "SCHED_OTHER", "Normal Scheduling"},
+ {SCHED_FIFO, "SCHED_FIFO", "FIFO Scheduling (requires root)"},
+ {SCHED_RR, "SCHED_RR", "Round-Robin Scheduling (requires root)"},
+ {0, NULL, NULL},
+ };
+ if (!thread_schedpolicy_type) {
+ thread_schedpolicy_type = g_enum_register_static("GstThreadSchedPolicy", thread_schedpolicy);
+ }
+ return thread_schedpolicy_type;
+}
+
static GstBinClass *parent_class = NULL;
-/* static guint gst_thread_signals[LAST_SIGNAL] = { 0 }; */
+static guint gst_thread_signals[LAST_SIGNAL] = { 0 };
GType
gst_thread_get_type(void) {
parent_class = g_type_class_ref (GST_TYPE_BIN);
+ g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_SCHEDPOLICY,
+ g_param_spec_enum("schedpolicy", "Scheduling Policy", "The scheduling policy of the thread",
+ GST_TYPE_THREAD_SCHEDPOLICY, SCHED_OTHER, G_PARAM_READWRITE));
+ g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_PRIORITY,
+ g_param_spec_int("priority", "Scheduling Priority", "The scheduling priority of the thread",
+ 0, 99, 0, G_PARAM_READWRITE));
+
+ gst_thread_signals[SHUTDOWN] =
+ g_signal_new ("shutdown", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstThreadClass, shutdown), NULL, NULL,
+ gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
gobject_class->dispose = gst_thread_dispose;
#ifndef GST_DISABLE_LOADSAVE
thread->ppid = getpid ();
thread->thread_id = -1;
+ thread->sched_policy = SCHED_OTHER;
+ thread->priority = 0;
}
static void
static void
gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
+ GstThread *thread;
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_THREAD (object));
+ thread = GST_THREAD (object);
+
switch (prop_id) {
+ case ARG_SCHEDPOLICY:
+ thread->sched_policy = g_value_get_enum (value);
+ break;
+ case ARG_PRIORITY:
+ thread->priority = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
static void
gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
+ GstThread *thread;
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_THREAD (object));
+ thread = GST_THREAD (object);
+
switch (prop_id) {
+ case ARG_SCHEDPOLICY:
+ g_value_set_enum (value, thread->sched_policy);
+ break;
+ case ARG_PRIORITY:
+ g_value_set_int (value, thread->priority);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
if (pthread_attr_init (&thread->attr) != 0)
g_warning ("pthread_attr_init returned an error !");
+
if (gst_scheduler_get_preferred_stack (GST_ELEMENT_SCHED (element), &thread->stack, &stacksize)) {
if (pthread_attr_setstack (&thread->attr, thread->stack, stacksize) != 0) {
g_warning ("pthread_attr_setstack failed");
thread = GST_THREAD (arg);
g_mutex_lock (thread->lock);
+ if (thread->sched_policy != SCHED_OTHER) {
+ struct sched_param sched_param;
+
+ memset (&sched_param, 0, sizeof (sched_param));
+ if (thread->priority == 0) {
+ thread->priority = sched_get_priority_max (thread->sched_policy);
+ }
+ sched_param.sched_priority = thread->priority;
+
+ if (sched_setscheduler (0, thread->sched_policy, &sched_param) != 0) {
+ GST_DEBUG (GST_CAT_THREAD, "not running with real-time priority");
+ }
+ }
+
gst_scheduler_setup (GST_ELEMENT_SCHED (thread));
GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING);
GST_INFO (GST_CAT_THREAD, "gstthread: thread \"%s\" is stopped",
GST_ELEMENT_NAME (thread));
+
+ g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0);
+
return NULL;
}
#include <gst/gstbin.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
extern GstElementDetails gst_thread_details;
typedef struct _GstThreadClass GstThreadClass;
struct _GstThread {
- GstBin bin;
-
- pthread_t thread_id; /* id of the thread, if any */
- pthread_attr_t attr; /* attributes for the stack space */
- void *stack; /* set with gst_scheduler_get_preferred_stack */
- gint pid; /* the pid of the thread */
- gint ppid; /* the pid of the thread's parent process */
- GMutex *lock; /* thread lock/condititon pair ... */
- GCond *cond; /* .... used to control the thread */
-
- gint transition; /* the current state transition */
+ GstBin bin;
+
+ pthread_t thread_id; /* id of the thread, if any */
+ pthread_attr_t attr; /* attributes for the stack space */
+ int sched_policy;
+ int priority;
+ void *stack; /* set with gst_scheduler_get_preferred_stack */
+ gint pid; /* the pid of the thread */
+ gint ppid; /* the pid of the thread's parent process */
+ GMutex *lock; /* thread lock/condititon pair ... */
+ GCond *cond; /* .... used to control the thread */
+
+ gint transition; /* the current state transition */
};
struct _GstThreadClass {
GstBinClass parent_class;
+
+ /* signals */
+ void (*shutdown) (GstThread *thread);
};
GType gst_thread_get_type (void);
GstElement* gst_thread_new (const gchar *name);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_THREAD_H__ */
#include <gst/gstobject.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+G_BEGIN_DECLS
#define GST_TYPE_TIME_CACHE (gst_time_cache_get_type ())
#define GST_TIME_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TIME_CACHE, GstTimeCache))
gboolean gst_time_cache_find_location (GstTimeCache *tc, guint64 location, gint64 *timestamp);
gboolean gst_time_cache_find_timestamp (GstTimeCache *tc, gint64 timestamp, guint64 *location);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_TIME_CACHE_H__ */
#include <glib.h>
+G_BEGIN_DECLS
typedef struct _GstTrace GstTrace;
typedef struct _GstTraceEntry GstTraceEntry;
#endif /* GST_DISABLE_TRACE */
+G_END_DECLS
+
#endif /* __GST_TRACE_H__ */
#include "gsttype.h"
#include "gstregistry.h"
+#include "gstobject.h"
+#include "gstlog.h"
/* global list of registered types */
#include <gst/gstcaps.h>
#include <gst/gstpluginfeature.h>
+G_BEGIN_DECLS
/* type of function used to check a stream for equality with type */
typedef GstCaps *(*GstTypeFindFunc) (GstBuffer *buf, gpointer priv);
/* get the list of registered types (returns list of GstType!) */
const GList* gst_type_get_list (void);
+G_END_DECLS
+
#endif /* __GST_TYPE_H__ */
#include "gsttype.h"
+#include "gstlog.h"
#include "gsttypefind.h"
/* #define GST_DEBUG_ENABLED */
#include <gst/gstelement.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
extern GstElementDetails gst_type_find_details;
GType gst_type_find_get_type (void);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* GST_DISABLE_TYPE_FIND */
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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.
+ */
+
#ifndef __GST_TYPES_H__
#define __GST_TYPES_H__
+#include <glib.h>
+
+G_BEGIN_DECLS
+
typedef struct _GstObject GstObject;
typedef struct _GstObjectClass GstObjectClass;
typedef struct _GstPad GstPad;
GST_RESULT_NOT_IMPL,
} GstResult;
-#endif
+G_END_DECLS
+
+#endif /* __GST_TYPES_H__ */
#define __GST_UTILS_H__
#include <glib.h>
-#include <gst/gstobject.h>
+#include <gst/gstelement.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
gboolean gst_util_has_arg (GObject *object, const gchar *argname,
GType arg_type);
void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad);
void gst_print_element_args (GString *buf, gint indent, GstElement *element);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __GST_UTILS_H__ */
#include "gst_private.h"
#include "gstxml.h"
+#include "gstlog.h"
#include "gstbin.h"
enum {
#include <gst/gstelement.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+G_BEGIN_DECLS
#define GST_TYPE_XML \
(gst_xml_get_type())
GstElement* gst_xml_make_element (xmlNodePtr cur, GstObject *parent);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#else /* GST_DISABLE_LOADSAVE */