inter: Add channel property

This commit is contained in:
David Schleef 2012-01-22 15:49:12 -08:00
parent e2abd5c833
commit 4eb4602746
9 changed files with 96 additions and 29 deletions

View file

@ -45,8 +45,6 @@ plugin_init (GstPlugin * plugin)
gst_element_register (plugin, "intervideosink", GST_RANK_NONE,
GST_TYPE_INTER_VIDEO_SINK);
gst_inter_surface_init ();
return TRUE;
}

View file

@ -77,7 +77,8 @@ static gboolean gst_inter_audio_sink_unlock_stop (GstBaseSink * sink);
enum
{
PROP_0
PROP_0,
PROP_CHANNEL
};
/* pad templates */
@ -150,6 +151,10 @@ gst_inter_audio_sink_class_init (GstInterAudioSinkClass * klass)
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

View file

@ -79,7 +79,8 @@ gst_inter_audio_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
enum
{
PROP_0
PROP_0,
PROP_CHANNEL
};
/* pad templates */
@ -158,6 +159,10 @@ gst_inter_audio_src_class_init (GstInterAudioSrcClass * klass)
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));
}

View file

@ -21,22 +21,43 @@
#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;
}
}
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_init (void)
gst_inter_surface_unref (GstInterSurface * surface)
{
surface = g_malloc0 (sizeof (GstInterSurface));
surface->mutex = g_mutex_new ();
surface->audio_adapter = gst_adapter_new ();
}

View file

@ -30,6 +30,7 @@ typedef struct _GstInterSurface GstInterSurface;
struct _GstInterSurface
{
GMutex *mutex;
char *name;
/* video */
GstVideoFormat format;
@ -51,7 +52,7 @@ struct _GstInterSurface
GstInterSurface * gst_inter_surface_get (const char *name);
void gst_inter_surface_init (void);
void gst_inter_surface_unref (GstInterSurface *surface);
G_END_DECLS

View file

@ -76,7 +76,8 @@ static gboolean gst_inter_video_sink_unlock_stop (GstBaseSink * sink);
enum
{
PROP_0
PROP_0,
PROP_CHANNEL
};
/* pad templates */
@ -144,6 +145,10 @@ gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass)
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
@ -151,15 +156,25 @@ gst_inter_video_sink_init (GstInterVideoSink * intervideosink,
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;
@ -170,9 +185,12 @@ void
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;
@ -192,9 +210,10 @@ gst_inter_video_sink_dispose (GObject * object)
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);
}
@ -248,6 +267,9 @@ gst_inter_video_sink_get_times (GstBaseSink * sink, GstBuffer * buffer,
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;
}
@ -264,6 +286,9 @@ gst_inter_video_sink_stop (GstBaseSink * sink)
intervideosink->surface->video_buffer = NULL;
g_mutex_unlock (intervideosink->surface->mutex);
gst_inter_surface_unref (intervideosink->surface);
intervideosink->surface = NULL;
return TRUE;
}

View file

@ -39,6 +39,7 @@ struct _GstInterVideoSink
GstBaseSink base_intervideosink;
GstInterSurface *surface;
char *channel;
int fps_n;
int fps_d;

View file

@ -80,7 +80,8 @@ gst_inter_video_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
enum
{
PROP_0
PROP_0,
PROP_CHANNEL
};
/* pad templates */
@ -156,6 +157,10 @@ gst_inter_video_src_class_init (GstInterVideoSrcClass * klass)
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));
}
@ -166,16 +171,20 @@ gst_inter_video_src_init (GstInterVideoSrc * intervideosrc,
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;
@ -186,9 +195,12 @@ void
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;
@ -208,9 +220,10 @@ gst_inter_video_src_dispose (GObject * object)
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);
}
@ -279,6 +292,8 @@ gst_inter_video_src_start (GstBaseSrc * src)
GST_DEBUG_OBJECT (intervideosrc, "start");
intervideosrc->surface = gst_inter_surface_get (intervideosrc->channel);
return TRUE;
}
@ -289,6 +304,9 @@ gst_inter_video_src_stop (GstBaseSrc * src)
GST_DEBUG_OBJECT (intervideosrc, "stop");
gst_inter_surface_unref (intervideosrc->surface);
intervideosrc->surface = NULL;
return TRUE;
}
@ -391,15 +409,6 @@ gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
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);

View file

@ -41,6 +41,8 @@ struct _GstInterVideoSrc
GstInterSurface *surface;
char *channel;
GstVideoFormat format;
int fps_n;
int fps_d;