omxaudiosink: Implements OpenMAX based audio sinks

Provides omxanalogaudiosink and omxhdmiaudiosink elements on
the Raspberry PI.

- omxanalogaudiosink is capable to render raw mono or stereo audio
through the jack output.
- omxhdmiaudiosink is capable to render raw audio up to 8 channels
and transmit ac3/dts(IEC 61937) through the HDMI output.
- sinks provide a clock derived from rendered samples
- sinks support the GstStreamVolume interface by implementing
the volume and mute properties.

https://bugzilla.gnome.org/show_bug.cgi?id=728962
This commit is contained in:
Josep Torra 2014-04-04 14:11:58 +02:00
parent 893587f69c
commit b3eb4d897d
9 changed files with 1611 additions and 2 deletions

View file

@ -80,3 +80,23 @@ in-port-index=200
out-port-index=201
hacks=no-component-role
[omxanalogaudiosink]
type-name=GstOMXAnalogAudioSink
core-name=/opt/vc/lib/libopenmaxil.so
component-name=OMX.broadcom.audio_render
rank=256
in-port-index=100
out-port-index=101
hacks=no-component-role
sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,41400,48000,88200,96000,176400,192000},channels=(int)[1,2]
[omxhdmiaudiosink]
type-name=GstOMXHdmiAudioSink
core-name=/opt/vc/lib/libopenmaxil.so
component-name=OMX.broadcom.audio_render
rank=257
in-port-index=100
out-port-index=101
hacks=no-component-role
sink-template-caps=audio/x-raw,format=(string){S16LE,S32LE},layout=(string)interleaved,rate=(int){8000,11025,16000,22050,24000,32000,41400,48000,88200,96000,176400,192000},channels=(int)[1,8];audio/x-ac3,framed=(boolean)true;audio/x-dts,framed=(boolean)true,block-size=(int){512,1024,2048}

View file

@ -28,7 +28,10 @@ libgstomx_la_SOURCES = \
gstomxmpeg4videoenc.c \
gstomxh264enc.c \
gstomxh263enc.c \
gstomxaacenc.c
gstomxaacenc.c \
gstomxaudiosink.c \
gstomxanalogaudiosink.c \
gstomxhdmiaudiosink.c
noinst_HEADERS = \
gstomx.h \
@ -47,7 +50,10 @@ noinst_HEADERS = \
gstomxmpeg4videoenc.h \
gstomxh264enc.h \
gstomxh263enc.h \
gstomxaacenc.h
gstomxaacenc.h \
gstomxaudiosink.h \
gstomxanalogaudiosink.h \
gstomxhdmiaudiosink.h
if !HAVE_EXTERNAL_OMX
OMX_INCLUDEPATH = -I$(abs_srcdir)/openmax

View file

@ -40,6 +40,8 @@
#include "gstomxh264enc.h"
#include "gstomxh263enc.h"
#include "gstomxaacenc.h"
#include "gstomxanalogaudiosink.h"
#include "gstomxhdmiaudiosink.h"
GST_DEBUG_CATEGORY (gstomx_debug);
#define GST_CAT_DEFAULT gstomx_debug
@ -2246,6 +2248,7 @@ done:
typedef GType (*GGetTypeFunction) (void);
static const GGetTypeFunction types[] = {
gst_omx_analog_audio_sink_get_type, gst_omx_hdmi_audio_sink_get_type,
gst_omx_mpeg2_video_dec_get_type, gst_omx_mpeg4_video_dec_get_type,
gst_omx_h264_dec_get_type, gst_omx_h263_dec_get_type,
gst_omx_wmv_dec_get_type, gst_omx_mpeg4_video_enc_get_type,
@ -2266,6 +2269,7 @@ struct TypeOffest
};
static const struct TypeOffest base_types[] = {
{gst_omx_audio_sink_get_type, G_STRUCT_OFFSET (GstOMXAudioSinkClass, cdata)},
{gst_omx_video_dec_get_type, G_STRUCT_OFFSET (GstOMXVideoDecClass, cdata)},
{gst_omx_video_enc_get_type, G_STRUCT_OFFSET (GstOMXVideoEncClass, cdata)},
{gst_omx_audio_enc_get_type, G_STRUCT_OFFSET (GstOMXAudioEncClass, cdata)},

View file

@ -0,0 +1,64 @@
/*
* Copyright (C) 2014, Fluendo, S.A.
* Copyright (C) 2014, Metrological Media Innovations B.V.
* Author: Josep Torra <josep@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "gstomxanalogaudiosink.h"
GST_DEBUG_CATEGORY_STATIC (gst_omx_analog_audio_sink_debug_category);
#define GST_CAT_DEFAULT gst_omx_analog_audio_sink_debug_category
/* class initialization */
#define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_omx_analog_audio_sink_debug_category, \
"omxanalogaudiosink", 0, "debug category for gst-omx analog audio sink");
G_DEFINE_TYPE_WITH_CODE (GstOMXAnalogAudioSink, gst_omx_analog_audio_sink,
GST_TYPE_OMX_AUDIO_SINK, DEBUG_INIT);
static void
gst_omx_analog_audio_sink_class_init (GstOMXAnalogAudioSinkClass * klass)
{
GstOMXAudioSinkClass *audiosink_class = GST_OMX_AUDIO_SINK_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
audiosink_class->cdata.default_sink_template_caps = "audio/x-raw, "
"format = (string) " GST_AUDIO_FORMATS_ALL ", "
"layout = (string) interleaved, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ] ";
audiosink_class->destination = "local";
gst_element_class_set_static_metadata (element_class,
"OpenMAX Analog Audio Sink",
"Sink/Audio", "Output analog audio", "Josep Torra <josep@fluendo.com>");
gst_omx_set_default_role (&audiosink_class->cdata, "audio_render.local");
}
static void
gst_omx_analog_audio_sink_init (GstOMXAnalogAudioSink * self)
{
}

View file

@ -0,0 +1,61 @@
/*
* Copyright (C) 2014, Fluendo, S.A.
* Copyright (C) 2014, Metrological Media Innovations B.V.
* Author: Josep Torra <josep@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __GST_OMX_ANALOG_AUDIO_SINK_H__
#define __GST_OMX_ANALOG_AUDIO_SINK_H__
#include <gst/gst.h>
#include "gstomxaudiosink.h"
G_BEGIN_DECLS
#define GST_TYPE_OMX_ANALOG_AUDIO_SINK \
(gst_omx_analog_audio_sink_get_type())
#define GST_OMX_ANALOG_AUDIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_ANALOG_AUDIO_SINK,GstOMXAnalogAudioSink))
#define GST_OMX_ANALOG_AUDIO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_ANALOG_AUDIO_SINK,GstOMXAnalogAudioSinkClass))
#define GST_OMX_ANALOG_AUDIO_SINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_ANALOG_AUDIO_SINK,GstOMXAnalogAudioSinkClass))
#define GST_IS_OMX_ANALOG_AUDIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_ANALOG_AUDIO_SINK))
#define GST_IS_OMX_ANALOG_AUDIO_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_ANALOG_AUDIO_SINK))
typedef struct _GstOMXAnalogAudioSink GstOMXAnalogAudioSink;
typedef struct _GstOMXAnalogAudioSinkClass GstOMXAnalogAudioSinkClass;
struct _GstOMXAnalogAudioSink
{
GstOMXAudioSink parent;
};
struct _GstOMXAnalogAudioSinkClass
{
GstOMXAudioSinkClass parent_class;
};
GType gst_omx_analog_audio_sink_get_type (void);
G_END_DECLS
#endif /* __GST_OMX_ANALOG_AUDIO_SINK_H__ */

1224
omx/gstomxaudiosink.c Normal file

File diff suppressed because it is too large Load diff

103
omx/gstomxaudiosink.h Normal file
View file

@ -0,0 +1,103 @@
/*
* Copyright (C) 2014, Fluendo, S.A.
* Copyright (C) 2014, Metrological Media Innovations B.V.
* Author: Josep Torra <josep@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __GST_OMX_AUDIO_SINK_H__
#define __GST_OMX_AUDIO_SINK_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include "gstomx.h"
G_BEGIN_DECLS
#define GST_TYPE_OMX_AUDIO_SINK \
(gst_omx_audio_sink_get_type())
#define GST_OMX_AUDIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_AUDIO_SINK,GstOMXAudioSink))
#define GST_OMX_AUDIO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_AUDIO_SINK,GstOMXAudioSinkClass))
#define GST_OMX_AUDIO_SINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_AUDIO_SINK,GstOMXAudioSinkClass))
#define GST_IS_OMX_AUDIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_AUDIO_SINK))
#define GST_IS_OMX_AUDIO_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_AUDIO_SINK))
#define GST_OMX_AUDIO_SINK_CAST(obj) ((GstOMXAudioSink *) (obj))
#define GST_OMX_AUDIO_SINK_GET_LOCK(obj) (&GST_OMX_AUDIO_SINK_CAST (obj)->lock)
#define GST_OMX_AUDIO_SINK_LOCK(obj) (g_mutex_lock (GST_OMX_AUDIO_SINK_GET_LOCK (obj)))
#define GST_OMX_AUDIO_SINK_UNLOCK(obj) (g_mutex_unlock (GST_OMX_AUDIO_SINK_GET_LOCK (obj)))
#define PASSTHROUGH_CAPS \
"audio/x-ac3, framed = (boolean) true;" \
"audio/x-eac3, framed = (boolean) true; " \
"audio/x-dts, framed = (boolean) true, " \
"block-size = (int) { 512, 1024, 2048 }; " \
"audio/mpeg, mpegversion = (int) 1, " \
"mpegaudioversion = (int) [ 1, 2 ], parsed = (boolean) true;"
typedef struct _GstOMXAudioSink GstOMXAudioSink;
typedef struct _GstOMXAudioSinkClass GstOMXAudioSinkClass;
struct _GstOMXAudioSink
{
GstAudioSink parent;
/* < protected > */
GstOMXComponent *comp;
GstOMXPort *in_port, *out_port;
gboolean mute;
gdouble volume;
gboolean iec61937;
guint endianness;
guint rate;
guint channels;
guint width;
gboolean is_signed;
gboolean is_float;
guint buffer_size;
guint samples;
GMutex lock;
};
struct _GstOMXAudioSinkClass
{
GstAudioSinkClass parent_class;
GstOMXClassData cdata;
const gchar * destination;
};
GType gst_omx_audio_sink_get_type (void);
G_END_DECLS
#endif /* __GST_OMX_AUDIO_SINK_H__ */

66
omx/gstomxhdmiaudiosink.c Normal file
View file

@ -0,0 +1,66 @@
/*
* Copyright (C) 2014, Fluendo, S.A.
* Copyright (C) 2014, Metrological Media Innovations B.V.
* Author: Josep Torra <josep@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include "gstomxhdmiaudiosink.h"
GST_DEBUG_CATEGORY_STATIC (gst_omx_hdmi_audio_sink_debug_category);
#define GST_CAT_DEFAULT gst_omx_hdmi_audio_sink_debug_category
/* class initialization */
#define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_omx_hdmi_audio_sink_debug_category, \
"omxhdmiaudiosink", 0, "debug category for gst-omx hdmi audio sink");
G_DEFINE_TYPE_WITH_CODE (GstOMXHdmiAudioSink, gst_omx_hdmi_audio_sink,
GST_TYPE_OMX_AUDIO_SINK, DEBUG_INIT);
static void
gst_omx_hdmi_audio_sink_class_init (GstOMXHdmiAudioSinkClass * klass)
{
GstOMXAudioSinkClass *audiosink_class = GST_OMX_AUDIO_SINK_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
audiosink_class->cdata.default_sink_template_caps = "audio/x-raw, "
"format = (string) " GST_AUDIO_FORMATS_ALL ", "
"layout = (string) interleaved, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; "
PASSTHROUGH_CAPS;
audiosink_class->destination = "hdmi";
gst_element_class_set_static_metadata (element_class,
"OpenMAX HDMI Audio Sink",
"Sink/Audio",
"Output audio through HDMI", "Josep Torra <josep@fluendo.com>");
gst_omx_set_default_role (&audiosink_class->cdata, "audio_render.hdmi");
}
static void
gst_omx_hdmi_audio_sink_init (GstOMXHdmiAudioSink * self)
{
}

61
omx/gstomxhdmiaudiosink.h Normal file
View file

@ -0,0 +1,61 @@
/*
* Copyright (C) 2014, Fluendo, S.A.
* Copyright (C) 2014, Metrological Media Innovations B.V.
* Author: Josep Torra <josep@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __GST_OMX_HDMI_AUDIO_SINK_H__
#define __GST_OMX_HDMI_AUDIO_SINK_H__
#include <gst/gst.h>
#include "gstomxaudiosink.h"
G_BEGIN_DECLS
#define GST_TYPE_OMX_HDMI_AUDIO_SINK \
(gst_omx_hdmi_audio_sink_get_type())
#define GST_OMX_HDMI_AUDIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_HDMI_AUDIO_SINK,GstOMXHdmiAudioSink))
#define GST_OMX_HDMI_AUDIO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_HDMI_AUDIO_SINK,GstOMXHdmiAudioSinkClass))
#define GST_OMX_HDMI_AUDIO_SINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_HDMI_AUDIO_SINK,GstOMXHdmiAudioSinkClass))
#define GST_IS_OMX_HDMI_AUDIO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_HDMI_AUDIO_SINK))
#define GST_IS_OMX_HDMI_AUDIO_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_HDMI_AUDIO_SINK))
typedef struct _GstOMXHdmiAudioSink GstOMXHdmiAudioSink;
typedef struct _GstOMXHdmiAudioSinkClass GstOMXHdmiAudioSinkClass;
struct _GstOMXHdmiAudioSink
{
GstOMXAudioSink parent;
};
struct _GstOMXHdmiAudioSinkClass
{
GstOMXAudioSinkClass parent_class;
};
GType gst_omx_hdmi_audio_sink_get_type (void);
G_END_DECLS
#endif /* __GST_OMX_HDMI_AUDIO_SINK_H__ */