diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2011-11-09 20:09:01 +0100 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2011-11-10 23:20:32 +0200 |
commit | f8abc7e7340bc0307232298583d12590186f8434 (patch) | |
tree | 6f5e9683d379492cbc62690ecd4f62f31f29287f /gst/audiovisualizers/gstspacescope.c | |
parent | 02de08aaaa9f860a16279eb5e036cece2ce828b1 (diff) | |
download | gstreamer-plugins-bad-f8abc7e7340bc0307232298583d12590186f8434.tar.gz |
audiovisualizer: port to 0.11
Diffstat (limited to 'gst/audiovisualizers/gstspacescope.c')
-rw-r--r-- | gst/audiovisualizers/gstspacescope.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/gst/audiovisualizers/gstspacescope.c b/gst/audiovisualizers/gstspacescope.c index fe8169dc4..85621f619 100644 --- a/gst/audiovisualizers/gstspacescope.c +++ b/gst/audiovisualizers/gstspacescope.c @@ -41,14 +41,20 @@ static GstStaticPadTemplate gst_space_scope_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN) +#if G_BYTE_ORDER == G_BIG_ENDIAN + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("xRGB")) +#else + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("BGRx")) +#endif ); static GstStaticPadTemplate gst_space_scope_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS) + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_AUDIO_NE (S16) ", " + "rate = (int) [ 8000, 96000 ], " "channels = (int) 2") ); @@ -59,13 +65,14 @@ static gboolean gst_space_scope_render (GstBaseAudioVisualizer * scope, GstBuffer * audio, GstBuffer * video); -GST_BOILERPLATE (GstSpaceScope, gst_space_scope, GstBaseAudioVisualizer, - GST_TYPE_BASE_AUDIO_VISUALIZER); +G_DEFINE_TYPE (GstSpaceScope, gst_space_scope, GST_TYPE_BASE_AUDIO_VISUALIZER); static void -gst_space_scope_base_init (gpointer g_class) +gst_space_scope_class_init (GstSpaceScopeClass * g_class) { - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + GstElementClass *element_class = (GstElementClass *) g_class; + GstBaseAudioVisualizerClass *scope_class = + (GstBaseAudioVisualizerClass *) g_class; gst_element_class_set_details_simple (element_class, "Stereo visualizer", "Visualization", @@ -75,19 +82,12 @@ gst_space_scope_base_init (gpointer g_class) gst_static_pad_template_get (&gst_space_scope_src_template)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_space_scope_sink_template)); -} - -static void -gst_space_scope_class_init (GstSpaceScopeClass * g_class) -{ - GstBaseAudioVisualizerClass *scope_class = - (GstBaseAudioVisualizerClass *) g_class; scope_class->render = GST_DEBUG_FUNCPTR (gst_space_scope_render); } static void -gst_space_scope_init (GstSpaceScope * scope, GstSpaceScopeClass * g_class) +gst_space_scope_init (GstSpaceScope * scope) { /* do nothing */ } @@ -96,15 +96,17 @@ static gboolean gst_space_scope_render (GstBaseAudioVisualizer * scope, GstBuffer * audio, GstBuffer * video) { - guint32 *vdata = (guint32 *) GST_BUFFER_DATA (video); - gint16 *adata = (gint16 *) GST_BUFFER_DATA (audio); + gsize asize; + guint32 *vdata = + (guint32 *) gst_buffer_map (video, NULL, NULL, GST_MAP_WRITE); + gint16 *adata = (gint16 *) gst_buffer_map (audio, &asize, NULL, GST_MAP_READ); guint i, s, x, y, off, ox, oy; guint num_samples; gfloat dx, dy; guint w = scope->width; /* draw dots 1st channel x, 2nd channel y */ - num_samples = GST_BUFFER_SIZE (audio) / (scope->channels * sizeof (gint16)); + num_samples = asize / (scope->channels * sizeof (gint16)); dx = scope->width / 65536.0; ox = scope->width / 2; dy = scope->height / 65536.0; @@ -116,6 +118,8 @@ gst_space_scope_render (GstBaseAudioVisualizer * scope, GstBuffer * audio, off = (y * w) + x; vdata[off] = 0x00FFFFFF; } + gst_buffer_unmap (video, vdata, -1); + gst_buffer_unmap (audio, adata, -1); return TRUE; } |