mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 12:41:05 +00:00
volume: Implement GstStreamVolume interface
This commit is contained in:
parent
6e23ea172f
commit
723b2baa5d
4 changed files with 43 additions and 4 deletions
|
@ -146,11 +146,17 @@ static void gst_volume_mixer_init (GstMixerClass * iface);
|
||||||
(GInterfaceInitFunc) gst_volume_mixer_init, \
|
(GInterfaceInitFunc) gst_volume_mixer_init, \
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL \
|
NULL \
|
||||||
|
}; \
|
||||||
|
static const GInterfaceInfo svol_info = { \
|
||||||
|
NULL, \
|
||||||
|
NULL, \
|
||||||
|
NULL \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, \
|
g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, \
|
||||||
&voliface_info); \
|
&voliface_info); \
|
||||||
g_type_add_interface_static (type, GST_TYPE_MIXER, &volmixer_info); \
|
g_type_add_interface_static (type, GST_TYPE_MIXER, &volmixer_info); \
|
||||||
|
g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info); \
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstVolume, gst_volume, GstAudioFilter,
|
GST_BOILERPLATE_FULL (GstVolume, gst_volume, GstAudioFilter,
|
||||||
|
@ -302,8 +308,7 @@ volume_update_volume (GstVolume * this, gfloat volume, gboolean mute)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_volume_interface_supported (GstImplementsInterface * iface, GType type)
|
gst_volume_interface_supported (GstImplementsInterface * iface, GType type)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (type == GST_TYPE_MIXER, FALSE);
|
return (type == GST_TYPE_MIXER || type == GST_TYPE_STREAM_VOLUME);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
#include <gst/interfaces/streamvolume.h>
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
#include <gst/audio/gstaudiofilter.h>
|
#include <gst/audio/gstaudiofilter.h>
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,8 @@ elements_textoverlay_LDADD = $(GST_BASE_LIBS) $(LDADD)
|
||||||
elements_textoverlay_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
|
elements_textoverlay_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
|
||||||
|
|
||||||
elements_volume_LDADD = \
|
elements_volume_LDADD = \
|
||||||
|
$(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-@GST_MAJORMINOR@.la \
|
||||||
|
$(GST_PLUGINS_BASE_LIBS) \
|
||||||
$(GST_CONTROLLER_LIBS) \
|
$(GST_CONTROLLER_LIBS) \
|
||||||
$(GST_BASE_LIBS) \
|
$(GST_BASE_LIBS) \
|
||||||
$(LDADD)
|
$(LDADD)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
#include <gst/controller/gstcontroller.h>
|
#include <gst/controller/gstcontroller.h>
|
||||||
|
#include <gst/interfaces/streamvolume.h>
|
||||||
|
|
||||||
/* For ease of programming we use globals to keep refs for our floating
|
/* For ease of programming we use globals to keep refs for our floating
|
||||||
* src and sink pads we create; otherwise we always have to do get_pad,
|
* src and sink pads we create; otherwise we always have to do get_pad,
|
||||||
|
@ -148,6 +149,35 @@ cleanup_volume (GstElement * volume)
|
||||||
gst_check_teardown_element (volume);
|
gst_check_teardown_element (volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (test_get_set)
|
||||||
|
{
|
||||||
|
GstElement *volume = gst_element_factory_make ("volume", NULL);
|
||||||
|
gdouble val;
|
||||||
|
|
||||||
|
fail_unless (volume != NULL);
|
||||||
|
g_object_get (G_OBJECT (volume), "volume", &val, NULL);
|
||||||
|
fail_unless (val == 1.0);
|
||||||
|
fail_unless (val == gst_stream_volume_get_volume (GST_STREAM_VOLUME (volume),
|
||||||
|
GST_STREAM_VOLUME_FORMAT_LINEAR));
|
||||||
|
|
||||||
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
||||||
|
g_object_get (G_OBJECT (volume), "volume", &val, NULL);
|
||||||
|
fail_unless (val == 0.5);
|
||||||
|
fail_unless (val == gst_stream_volume_get_volume (GST_STREAM_VOLUME (volume),
|
||||||
|
GST_STREAM_VOLUME_FORMAT_LINEAR));
|
||||||
|
|
||||||
|
gst_stream_volume_set_volume (GST_STREAM_VOLUME (volume),
|
||||||
|
GST_STREAM_VOLUME_FORMAT_LINEAR, 1.0);
|
||||||
|
g_object_get (G_OBJECT (volume), "volume", &val, NULL);
|
||||||
|
fail_unless (val == 1.0);
|
||||||
|
fail_unless (val == gst_stream_volume_get_volume (GST_STREAM_VOLUME (volume),
|
||||||
|
GST_STREAM_VOLUME_FORMAT_LINEAR));
|
||||||
|
|
||||||
|
gst_object_unref (volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_unity_s8)
|
GST_START_TEST (test_unity_s8)
|
||||||
{
|
{
|
||||||
GstElement *volume;
|
GstElement *volume;
|
||||||
|
@ -1459,6 +1489,7 @@ volume_suite (void)
|
||||||
TCase *tc_chain = tcase_create ("general");
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
suite_add_tcase (s, tc_chain);
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test (tc_chain, test_get_set);
|
||||||
tcase_add_test (tc_chain, test_unity_s8);
|
tcase_add_test (tc_chain, test_unity_s8);
|
||||||
tcase_add_test (tc_chain, test_half_s8);
|
tcase_add_test (tc_chain, test_half_s8);
|
||||||
tcase_add_test (tc_chain, test_double_s8);
|
tcase_add_test (tc_chain, test_double_s8);
|
||||||
|
|
Loading…
Reference in a new issue