mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
inter: Add channel property
This commit is contained in:
parent
e2abd5c833
commit
4eb4602746
9 changed files with 96 additions and 29 deletions
|
@ -45,8 +45,6 @@ plugin_init (GstPlugin * plugin)
|
||||||
gst_element_register (plugin, "intervideosink", GST_RANK_NONE,
|
gst_element_register (plugin, "intervideosink", GST_RANK_NONE,
|
||||||
GST_TYPE_INTER_VIDEO_SINK);
|
GST_TYPE_INTER_VIDEO_SINK);
|
||||||
|
|
||||||
gst_inter_surface_init ();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,8 @@ static gboolean gst_inter_audio_sink_unlock_stop (GstBaseSink * sink);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0
|
PROP_0,
|
||||||
|
PROP_CHANNEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pad templates */
|
/* pad templates */
|
||||||
|
@ -150,6 +151,10 @@ gst_inter_audio_sink_class_init (GstInterAudioSinkClass * klass)
|
||||||
base_sink_class->unlock_stop =
|
base_sink_class->unlock_stop =
|
||||||
GST_DEBUG_FUNCPTR (gst_inter_audio_sink_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
|
static void
|
||||||
|
|
|
@ -79,7 +79,8 @@ gst_inter_audio_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0
|
PROP_0,
|
||||||
|
PROP_CHANNEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pad templates */
|
/* pad templates */
|
||||||
|
@ -158,6 +159,10 @@ gst_inter_audio_src_class_init (GstInterAudioSrcClass * klass)
|
||||||
base_src_class->prepare_seek_segment =
|
base_src_class->prepare_seek_segment =
|
||||||
GST_DEBUG_FUNCPTR (gst_inter_audio_src_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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,22 +21,43 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "gstintersurface.h"
|
#include "gstintersurface.h"
|
||||||
|
|
||||||
static GstInterSurface *surface;
|
static GList *list;
|
||||||
|
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||||
|
|
||||||
|
|
||||||
GstInterSurface *
|
GstInterSurface *
|
||||||
gst_inter_surface_get (const char *name)
|
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
|
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 ();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ typedef struct _GstInterSurface GstInterSurface;
|
||||||
struct _GstInterSurface
|
struct _GstInterSurface
|
||||||
{
|
{
|
||||||
GMutex *mutex;
|
GMutex *mutex;
|
||||||
|
char *name;
|
||||||
|
|
||||||
/* video */
|
/* video */
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
|
@ -51,7 +52,7 @@ struct _GstInterSurface
|
||||||
|
|
||||||
|
|
||||||
GstInterSurface * gst_inter_surface_get (const char *name);
|
GstInterSurface * gst_inter_surface_get (const char *name);
|
||||||
void gst_inter_surface_init (void);
|
void gst_inter_surface_unref (GstInterSurface *surface);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -76,7 +76,8 @@ static gboolean gst_inter_video_sink_unlock_stop (GstBaseSink * sink);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0
|
PROP_0,
|
||||||
|
PROP_CHANNEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pad templates */
|
/* pad templates */
|
||||||
|
@ -144,6 +145,10 @@ gst_inter_video_sink_class_init (GstInterVideoSinkClass * klass)
|
||||||
base_sink_class->unlock_stop =
|
base_sink_class->unlock_stop =
|
||||||
GST_DEBUG_FUNCPTR (gst_inter_video_sink_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
|
static void
|
||||||
|
@ -151,15 +156,25 @@ gst_inter_video_sink_init (GstInterVideoSink * intervideosink,
|
||||||
GstInterVideoSinkClass * intervideosink_class)
|
GstInterVideoSinkClass * intervideosink_class)
|
||||||
{
|
{
|
||||||
intervideosink->surface = gst_inter_surface_get ("default");
|
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
|
void
|
||||||
gst_inter_video_sink_set_property (GObject * object, guint property_id,
|
gst_inter_video_sink_set_property (GObject * object, guint property_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
/* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
|
GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_CHANNEL:
|
||||||
|
g_free (intervideosink->channel);
|
||||||
|
intervideosink->channel = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -170,9 +185,12 @@ void
|
||||||
gst_inter_video_sink_get_property (GObject * object, guint property_id,
|
gst_inter_video_sink_get_property (GObject * object, guint property_id,
|
||||||
GValue * value, GParamSpec * pspec)
|
GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
/* GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object); */
|
GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_CHANNEL:
|
||||||
|
g_value_set_string (value, intervideosink->channel);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -192,9 +210,10 @@ gst_inter_video_sink_dispose (GObject * object)
|
||||||
void
|
void
|
||||||
gst_inter_video_sink_finalize (GObject * object)
|
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 */
|
/* clean up object here */
|
||||||
|
g_free (intervideosink->channel);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -248,6 +267,9 @@ gst_inter_video_sink_get_times (GstBaseSink * sink, GstBuffer * buffer,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_inter_video_sink_start (GstBaseSink * sink)
|
gst_inter_video_sink_start (GstBaseSink * sink)
|
||||||
{
|
{
|
||||||
|
GstInterVideoSink *intervideosink = GST_INTER_VIDEO_SINK (sink);
|
||||||
|
|
||||||
|
intervideosink->surface = gst_inter_surface_get (intervideosink->channel);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -264,6 +286,9 @@ gst_inter_video_sink_stop (GstBaseSink * sink)
|
||||||
intervideosink->surface->video_buffer = NULL;
|
intervideosink->surface->video_buffer = NULL;
|
||||||
g_mutex_unlock (intervideosink->surface->mutex);
|
g_mutex_unlock (intervideosink->surface->mutex);
|
||||||
|
|
||||||
|
gst_inter_surface_unref (intervideosink->surface);
|
||||||
|
intervideosink->surface = NULL;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ struct _GstInterVideoSink
|
||||||
GstBaseSink base_intervideosink;
|
GstBaseSink base_intervideosink;
|
||||||
|
|
||||||
GstInterSurface *surface;
|
GstInterSurface *surface;
|
||||||
|
char *channel;
|
||||||
|
|
||||||
int fps_n;
|
int fps_n;
|
||||||
int fps_d;
|
int fps_d;
|
||||||
|
|
|
@ -80,7 +80,8 @@ gst_inter_video_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0
|
PROP_0,
|
||||||
|
PROP_CHANNEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pad templates */
|
/* pad templates */
|
||||||
|
@ -156,6 +157,10 @@ gst_inter_video_src_class_init (GstInterVideoSrcClass * klass)
|
||||||
base_src_class->prepare_seek_segment =
|
base_src_class->prepare_seek_segment =
|
||||||
GST_DEBUG_FUNCPTR (gst_inter_video_src_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_format (GST_BASE_SRC (intervideosrc), GST_FORMAT_TIME);
|
||||||
gst_base_src_set_live (GST_BASE_SRC (intervideosrc), TRUE);
|
gst_base_src_set_live (GST_BASE_SRC (intervideosrc), TRUE);
|
||||||
|
|
||||||
intervideosrc->surface = gst_inter_surface_get ("default");
|
intervideosrc->channel = g_strdup ("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_inter_video_src_set_property (GObject * object, guint property_id,
|
gst_inter_video_src_set_property (GObject * object, guint property_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
/* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
|
GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_CHANNEL:
|
||||||
|
g_free (intervideosrc->channel);
|
||||||
|
intervideosrc->channel = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -186,9 +195,12 @@ void
|
||||||
gst_inter_video_src_get_property (GObject * object, guint property_id,
|
gst_inter_video_src_get_property (GObject * object, guint property_id,
|
||||||
GValue * value, GParamSpec * pspec)
|
GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
/* GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object); */
|
GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_CHANNEL:
|
||||||
|
g_value_set_string (value, intervideosrc->channel);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -208,9 +220,10 @@ gst_inter_video_src_dispose (GObject * object)
|
||||||
void
|
void
|
||||||
gst_inter_video_src_finalize (GObject * object)
|
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 */
|
/* clean up object here */
|
||||||
|
g_free (intervideosrc->channel);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -279,6 +292,8 @@ gst_inter_video_src_start (GstBaseSrc * src)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (intervideosrc, "start");
|
GST_DEBUG_OBJECT (intervideosrc, "start");
|
||||||
|
|
||||||
|
intervideosrc->surface = gst_inter_surface_get (intervideosrc->channel);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,6 +304,9 @@ gst_inter_video_src_stop (GstBaseSrc * src)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (intervideosrc, "stop");
|
GST_DEBUG_OBJECT (intervideosrc, "stop");
|
||||||
|
|
||||||
|
gst_inter_surface_unref (intervideosrc->surface);
|
||||||
|
intervideosrc->surface = NULL;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,15 +409,6 @@ gst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,
|
||||||
intervideosrc->width) *
|
intervideosrc->width) *
|
||||||
gst_video_format_get_component_height (intervideosrc->format, 1,
|
gst_video_format_get_component_height (intervideosrc->format, 1,
|
||||||
intervideosrc->height));
|
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);
|
buffer = gst_buffer_make_metadata_writable (buffer);
|
||||||
|
|
|
@ -41,6 +41,8 @@ struct _GstInterVideoSrc
|
||||||
|
|
||||||
GstInterSurface *surface;
|
GstInterSurface *surface;
|
||||||
|
|
||||||
|
char *channel;
|
||||||
|
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
int fps_n;
|
int fps_n;
|
||||||
int fps_d;
|
int fps_d;
|
||||||
|
|
Loading…
Reference in a new issue