gst_element_register (plugin, "intervideosink", GST_RANK_NONE,
GST_TYPE_INTER_VIDEO_SINK);
- gst_inter_surface_init ();
-
return TRUE;
}
enum
{
- PROP_0
+ PROP_0,
+ PROP_CHANNEL
};
/* pad templates */
base_sink_class->unlock_stop =
GST_DEBUG_FUNCPTR (gst_inter_audio_sink_unlock_stop);
+ g_object_class_install_property (gobject_class, PROP_CHANNEL,
+ g_param_spec_string ("channel", "Channel",
+ "Channel name to match inter src and sink elements",
+ "default", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
enum
{
- PROP_0
+ PROP_0,
+ PROP_CHANNEL
};
/* pad templates */
base_src_class->prepare_seek_segment =
GST_DEBUG_FUNCPTR (gst_inter_audio_src_prepare_seek_segment);
+ g_object_class_install_property (gobject_class, PROP_CHANNEL,
+ g_param_spec_string ("channel", "Channel",
+ "Channel name to match inter src and sink elements",
+ "default", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
#include "config.h"
#endif
+#include <string.h>
+
#include "gstintersurface.h"
-static GstInterSurface *surface;
+static GList *list;
+static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
GstInterSurface *
gst_inter_surface_get (const char *name)
{
- return surface;
+ GList *g;
+ GstInterSurface *surface;
-}
+ g_static_mutex_lock (&mutex);
+
+ for (g = list; g; g = g_list_next (g)) {
+ surface = (GstInterSurface *) g->data;
+ if (strcmp (name, surface->name) == 0) {
+ g_static_mutex_unlock (&mutex);
+ return surface;
+ }
+ }
-void
-gst_inter_surface_init (void)
-{
surface = g_malloc0 (sizeof (GstInterSurface));
+ surface->name = g_strdup (name);
surface->mutex = g_mutex_new ();
surface->audio_adapter = gst_adapter_new ();
+
+ list = g_list_append (list, surface);
+ g_static_mutex_unlock (&mutex);
+
+ return surface;
+}
+
+void
+gst_inter_surface_unref (GstInterSurface * surface)
+{
+
}
struct _GstInterSurface
{
GMutex *mutex;
+ char *name;
/* video */
GstVideoFormat format;
GstInterSurface * gst_inter_surface_get (const char *name);
-void gst_inter_surface_init (void);
+void gst_inter_surface_unref (GstInterSurface *surface);
G_END_DECLS
enum
{
- PROP_0
+ PROP_0,
+ PROP_CHANNEL
};
/* pad templates */
base_sink_class->unlock_stop =
GST_DEBUG_FUNCPTR (gst_inter_video_sink_unlock_stop);
+ g_object_class_install_property (gobject_class, PROP_CHANNEL,
+ g_param_spec_string ("channel", "Channel",
+ "Channel name to match inter src and sink elements",
+ "default", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
GstInterVideoSinkClass * intervideosink_class)
{
intervideosink->surface = gst_inter_surface_get ("default");
+
+ intervideosink->sinkpad =
+ gst_pad_new_from_static_template (&gst_inter_video_sink_sink_template,
+ "sink");
+
+ intervideosink->channel = g_strdup ("default");
}
void
gst_inter_video_sink_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
- /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object);
switch (property_id) {
+ case PROP_CHANNEL:
+ g_free (intervideosink->channel);
+ intervideosink->channel = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
gst_inter_video_sink_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
- /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object);
switch (property_id) {
+ case PROP_CHANNEL:
+ g_value_set_string (value, intervideosink->channel);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
void
gst_inter_video_sink_finalize (GObject * object)
{
- /* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object);
/* clean up object here */
+ g_free (intervideosink->channel);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
gst_inter_video_sink_start (GstBaseSink * sink)
{
+ GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink);
+
+ intervideosink->surface = gst_inter_surface_get (intervideosink->channel);
return TRUE;
}
intervideosink->surface->video_buffer = NULL;
g_mutex_unlock (intervideosink->surface->mutex);
+ gst_inter_surface_unref (intervideosink->surface);
+ intervideosink->surface = NULL;
+
return TRUE;
}
GstBaseSink base_intervideosink;
GstInterSurface *surface;
+ char *channel;
int fps_n;
int fps_d;
enum
{
- PROP_0
+ PROP_0,
+ PROP_CHANNEL
};
/* pad templates */
base_src_class->prepare_seek_segment =
GST_DEBUG_FUNCPTR (gst_inter_video_src_prepare_seek_segment);
+ g_object_class_install_property (gobject_class, PROP_CHANNEL,
+ g_param_spec_string ("channel", "Channel",
+ "Channel name to match inter src and sink elements",
+ "default", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
gst_base_src_set_format (GST_BASE_SRC (intervideosrc), GST_FORMAT_TIME);
gst_base_src_set_live (GST_BASE_SRC (intervideosrc), TRUE);
- intervideosrc->surface = gst_inter_surface_get ("default");
+ intervideosrc->channel = g_strdup ("default");
}
void
gst_inter_video_src_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
- /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object);
switch (property_id) {
+ case PROP_CHANNEL:
+ g_free (intervideosrc->channel);
+ intervideosrc->channel = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
gst_inter_video_src_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
- /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object);
switch (property_id) {
+ case PROP_CHANNEL:
+ g_value_set_string (value, intervideosrc->channel);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
void
gst_inter_video_src_finalize (GObject * object)
{
- /* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
+ GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object);
/* clean up object here */
+ g_free (intervideosrc->channel);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GST_DEBUG_OBJECT (intervideosrc, "start");
+ intervideosrc->surface = gst_inter_surface_get (intervideosrc->channel);
+
return TRUE;
}
GST_DEBUG_OBJECT (intervideosrc, "stop");
+ gst_inter_surface_unref (intervideosrc->surface);
+ intervideosrc->surface = NULL;
+
return TRUE;
}
intervideosrc->width) *
gst_video_format_get_component_height (intervideosrc->format, 1,
intervideosrc->height));
-
-#if 0
- {
- int i;
- for (i = 0; i < 10000; i++) {
- data[i] = g_random_int () & 0xff;
- }
- }
-#endif
}
buffer = gst_buffer_make_metadata_writable (buffer);
GstInterSurface *surface;
+ char *channel;
+
GstVideoFormat format;
int fps_n;
int fps_d;