mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
openal: improved port to 1.0
https://bugzilla.gnome.org/show_bug.cgi?id=698013
This commit is contained in:
parent
16ed8840ea
commit
30d7908df2
6 changed files with 1172 additions and 782 deletions
|
@ -346,7 +346,7 @@ GST_PLUGINS_NONPORTED=" cdxaparse \
|
|||
linsys vcd \
|
||||
apexsink cdaudio dc1394 directfb \
|
||||
gsettings \
|
||||
musepack nas openal sdl sndfile timidity \
|
||||
musepack nas sdl sndfile timidity \
|
||||
directdraw direct3d9 acm wininet \
|
||||
xvid lv2 teletextdec sndio osx_video quicktime"
|
||||
AC_SUBST(GST_PLUGINS_NONPORTED)
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* GStreamer openal plugin
|
||||
*
|
||||
* Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
|
||||
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
||||
* Copyright (C) 2009-2010 Chris Robinson <chris.kcat@gmail.com>
|
||||
* Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -24,18 +26,21 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/gst-i18n-plugin.h>
|
||||
|
||||
#include "gstopenalsink.h"
|
||||
#include "gstopenalsrc.h"
|
||||
|
||||
#include <gst/gst-i18n-plugin.h>
|
||||
|
||||
GST_DEBUG_CATEGORY (openal_debug);
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
if (!gst_element_register (plugin, "openalsink", GST_RANK_SECONDARY,
|
||||
GST_TYPE_OPENAL_SINK) ||
|
||||
!gst_element_register (plugin, "openalsrc", GST_RANK_SECONDARY,
|
||||
GST_TYPE_OPENAL_SINK))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_element_register (plugin, "openalsrc", GST_RANK_SECONDARY,
|
||||
GST_TYPE_OPENAL_SRC))
|
||||
return FALSE;
|
||||
|
||||
|
@ -44,12 +49,14 @@ plugin_init (GstPlugin * plugin)
|
|||
LOCALEDIR);
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
#endif /* ENABLE_NLS */
|
||||
#endif
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (openal_debug, "openal", 0, "openal plugins");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
openal,
|
||||
"OpenAL support for GStreamer",
|
||||
"OpenAL plugin library",
|
||||
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* GStreamer
|
||||
*
|
||||
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
|
||||
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
* Copyright (C) 2009-2010 Chris Robinson <chris.kcat@gmail.com>
|
||||
*
|
||||
* Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
|
@ -24,8 +26,7 @@
|
|||
#define __GST_OPENALSINK_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/gstaudiosink.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <al.h>
|
||||
|
@ -43,7 +44,8 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_OPENAL_SINK (gst_openal_sink_get_type())
|
||||
#define GST_TYPE_OPENAL_SINK \
|
||||
(gst_openal_sink_get_type())
|
||||
#define GST_OPENAL_SINK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENAL_SINK,GstOpenALSink))
|
||||
#define GST_OPENAL_SINK_CLASS(klass) \
|
||||
|
@ -52,6 +54,8 @@ G_BEGIN_DECLS
|
|||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENAL_SINK))
|
||||
#define GST_IS_OPENAL_SINK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENAL_SINK))
|
||||
#define GST_OPENAL_SINK_CAST(obj) \
|
||||
((GstOpenALSink*)obj)
|
||||
|
||||
#if 1
|
||||
#define GST_ALC_ERROR(Device) ("ALC error: %s", alcGetString((Device), alcGetError((Device))))
|
||||
|
@ -62,61 +66,51 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstOpenALSink GstOpenALSink;
|
||||
typedef struct _GstOpenALSinkClass GstOpenALSinkClass;
|
||||
|
||||
#define GST_OPENAL_SINK_CAST(obj) ((GstOpenALSink*)obj)
|
||||
#define GST_OPENAL_SINK_GET_LOCK(obj) (GST_OPENAL_SINK_CAST(obj)->openal_lock)
|
||||
#define GST_OPENAL_SINK_GET_LOCK(obj) (&GST_OPENAL_SINK_CAST(obj)->openal_lock)
|
||||
#define GST_OPENAL_SINK_LOCK(obj) (g_mutex_lock(GST_OPENAL_SINK_GET_LOCK(obj)))
|
||||
#define GST_OPENAL_SINK_UNLOCK(obj) (g_mutex_unlock(GST_OPENAL_SINK_GET_LOCK(obj)))
|
||||
|
||||
struct _GstOpenALSink {
|
||||
GstAudioSink sink;
|
||||
struct _GstOpenALSink
|
||||
{
|
||||
GstAudioSink sink;
|
||||
|
||||
gchar *devname;
|
||||
gchar *device_name;
|
||||
|
||||
/* When set, we don't own device */
|
||||
ALCdevice *custom_dev;
|
||||
/* When set, we don't own device or context */
|
||||
ALCcontext *custom_ctx;
|
||||
/* When set, we don't own sID */
|
||||
ALuint custom_sID;
|
||||
ALCdevice *default_device;
|
||||
/* When set, device is not owned */
|
||||
ALCdevice *user_device;
|
||||
|
||||
ALCdevice *device;
|
||||
ALCcontext *context;
|
||||
ALuint sID;
|
||||
ALCcontext *default_context;
|
||||
/* When set, device or context is not owned */
|
||||
ALCcontext *user_context;
|
||||
|
||||
ALuint bID_idx;
|
||||
ALuint bID_count;
|
||||
ALuint *bIDs;
|
||||
ALuint bID_length;
|
||||
ALuint default_source;
|
||||
/* When set, source is not owned */
|
||||
ALuint user_source;
|
||||
|
||||
ALenum format;
|
||||
ALuint srate;
|
||||
ALuint bytes_per_sample;
|
||||
ALuint buffer_idx;
|
||||
ALuint buffer_count;
|
||||
ALuint *buffers;
|
||||
ALuint buffer_length;
|
||||
|
||||
ALboolean write_reset;
|
||||
ALenum format;
|
||||
ALuint rate;
|
||||
ALuint channels;
|
||||
ALuint bytes_per_sample;
|
||||
|
||||
GstCaps *probed_caps;
|
||||
ALboolean write_reset;
|
||||
|
||||
GMutex *openal_lock;
|
||||
GstCaps *probed_caps;
|
||||
|
||||
GMutex openal_lock;
|
||||
};
|
||||
|
||||
struct _GstOpenALSinkClass {
|
||||
GstAudioSinkClass parent_class;
|
||||
struct _GstOpenALSinkClass
|
||||
{
|
||||
GstAudioSinkClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_openal_sink_get_type(void);
|
||||
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
#define GST_S16_NE GST_S16_LE
|
||||
#define GST_FLOAT32_NE GST_FLOAT32_LE
|
||||
#define GST_FLOAT64_NE GST_FLOAT64_LE
|
||||
#else
|
||||
#define GST_S16_NE GST_S16_BE
|
||||
#define GST_FLOAT32_NE GST_FLOAT32_BE
|
||||
#define GST_FLOAT64_NE GST_FLOAT64_BE
|
||||
#endif
|
||||
|
||||
#define OPENAL_MIN_RATE 8000
|
||||
#define OPENAL_MAX_RATE 192000
|
||||
GType gst_openal_sink_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/*
|
||||
* GStreamer
|
||||
*
|
||||
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
|
||||
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
* Copyright (C) 2008 Victor Lin <bornstub@gmail.com>
|
||||
* Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -27,6 +29,8 @@
|
|||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
|
@ -45,51 +49,63 @@
|
|||
|
||||
/**
|
||||
* SECTION:element-openalsrc
|
||||
* @short_description: record sound from your sound card using OpenAL
|
||||
* @see_also: openalsink
|
||||
* @short_description: capture raw audio samples through OpenAL
|
||||
*
|
||||
* This element captures raw audio samples through OpenAL.
|
||||
*
|
||||
* <refsect2>
|
||||
* <para>
|
||||
* This element lets you record sound using the OpenAL
|
||||
* </para>
|
||||
* <title>Example pipelines</title>
|
||||
* <para>
|
||||
* <programlisting>
|
||||
* gst-launch -v openalsrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=mymusic.ogg
|
||||
* </programlisting>
|
||||
* will record sound from your sound card using OpenAL and encode it to an Ogg/Vorbis file
|
||||
* </para>
|
||||
* |[
|
||||
* gst-launch -v openalsrc ! audioconvert ! wavenc ! filesink location=stream.wav
|
||||
* ]| * will capture sound through OpenAL and encode it to a wav file.
|
||||
* |[
|
||||
* gst-launch openalsrc ! "audio/x-raw,format=S16LE,rate=44100" ! audioconvert ! volume volume=0.25 ! openalsink
|
||||
* ]| will capture and play audio through OpenAL.
|
||||
* </refsect2>
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEV:
|
||||
* To get better timing/delay information you may also be interested in this:
|
||||
* http://kcat.strangesoft.net/openal-extensions/SOFT_source_latency.txt
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/gsterror.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (openal_debug);
|
||||
#define GST_CAT_DEFAULT openal_debug
|
||||
|
||||
#include "gstopenalsrc.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (openalsrc_debug);
|
||||
static void gst_openal_src_dispose (GObject * object);
|
||||
static void gst_openal_src_finalize (GObject * object);
|
||||
static void gst_openal_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_openal_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static GstCaps *gst_openal_src_getcaps (GstBaseSrc * basesrc, GstCaps * filter);
|
||||
static gboolean gst_openal_src_open (GstAudioSrc * audiosrc);
|
||||
static gboolean gst_openal_src_prepare (GstAudioSrc * audiosrc,
|
||||
GstAudioRingBufferSpec * spec);
|
||||
static gboolean gst_openal_src_unprepare (GstAudioSrc * audiosrc);
|
||||
static gboolean gst_openal_src_close (GstAudioSrc * audiosrc);
|
||||
static guint gst_openal_src_read (GstAudioSrc * audiosrc, gpointer data,
|
||||
guint length, GstClockTime * timestamp);
|
||||
static guint gst_openal_src_delay (GstAudioSrc * audiosrc);
|
||||
static void gst_openal_src_reset (GstAudioSrc * audiosrc);
|
||||
|
||||
#define GST_CAT_DEFAULT openalsrc_debug
|
||||
#define OPENAL_DEFAULT_DEVICE_NAME NULL
|
||||
#define OPENAL_DEFAULT_DEVICE NULL
|
||||
|
||||
#define DEFAULT_DEVICE NULL
|
||||
#define DEFAULT_DEVICE_NAME NULL
|
||||
#define OPENAL_MIN_RATE 8000
|
||||
#define OPENAL_MAX_RATE 192000
|
||||
|
||||
/**
|
||||
Filter signals and args
|
||||
**/
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Properties
|
||||
**/
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -97,116 +113,137 @@ enum
|
|||
PROP_DEVICE_NAME
|
||||
};
|
||||
|
||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
static GstStaticPadTemplate openalsrc_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"signed = (boolean) TRUE, "
|
||||
"width = (int) 16, "
|
||||
"depth = (int) 16, "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
|
||||
"audio/x-raw-int, "
|
||||
"signed = (boolean) TRUE, "
|
||||
"width = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
||||
GST_STATIC_CAPS (
|
||||
/* These caps do not work on my card */
|
||||
// "audio/x-adpcm, " "layout = (string) ima, "
|
||||
// "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
|
||||
// "audio/x-alaw, " "rate = (int) [ 1, MAX ], "
|
||||
// "channels = (int) 1; "
|
||||
// "audio/x-mulaw, " "rate = (int) [ 1, MAX ], "
|
||||
// "channels = (int) 1; "
|
||||
// "audio/x-raw, " "format = (string) " GST_AUDIO_NE (F64) ", "
|
||||
// "rate = (int) [ 1, MAX ], " "channels = (int) 1; "
|
||||
// "audio/x-raw, " "format = (string) " GST_AUDIO_NE (F32) ", "
|
||||
// "rate = (int) [ 1, MAX ], " "channels = (int) 1; "
|
||||
"audio/x-raw, " "format = (string) " GST_AUDIO_NE (S16) ", "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) 1; "
|
||||
/* These caps work wrongly on my card */
|
||||
// "audio/x-raw, " "format = (string) " GST_AUDIO_NE (U16) ", "
|
||||
// "rate = (int) [ 1, MAX ], " "channels = (int) 1; "
|
||||
// "audio/x-raw, " "format = (string) " G_STRINGIFY (S8) ", "
|
||||
// "rate = (int) [ 1, MAX ], " "channels = (int) 1"));
|
||||
"audio/x-raw, " "format = (string) " G_STRINGIFY (U8) ", "
|
||||
"rate = (int) [ 1, MAX ], " "channels = (int) 1")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (GstOpenalSrc, gst_openal_src, GstAudioSrc, GST_TYPE_AUDIO_SRC);
|
||||
static inline ALenum
|
||||
checkALError (const char *fname, unsigned int fline)
|
||||
{
|
||||
ALenum err = alGetError ();
|
||||
if (err != AL_NO_ERROR)
|
||||
g_warning ("%s:%u: context error: %s", fname, fline, alGetString (err));
|
||||
return err;
|
||||
}
|
||||
|
||||
static void gst_openal_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_openal_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static gboolean gst_openal_src_open (GstAudioSrc * src);
|
||||
static gboolean
|
||||
gst_openal_src_prepare (GstAudioSrc * src, GstRingBufferSpec * spec);
|
||||
static gboolean gst_openal_src_unprepare (GstAudioSrc * src);
|
||||
static gboolean gst_openal_src_close (GstAudioSrc * src);
|
||||
static guint
|
||||
gst_openal_src_read (GstAudioSrc * src, gpointer data, guint length);
|
||||
static guint gst_openal_src_delay (GstAudioSrc * src);
|
||||
static void gst_openal_src_reset (GstAudioSrc * src);
|
||||
#define checkALError() checkALError(__FILE__, __LINE__)
|
||||
|
||||
static void gst_openal_src_finalize (GObject * object);
|
||||
G_DEFINE_TYPE (GstOpenalSrc, gst_openal_src, GST_TYPE_AUDIO_SRC);
|
||||
|
||||
static void
|
||||
gst_openal_src_base_init (gpointer gclass)
|
||||
gst_openal_src_dispose (GObject * object)
|
||||
{
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (object);
|
||||
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
||||
if (openalsrc->probed_caps)
|
||||
gst_caps_unref (openalsrc->probed_caps);
|
||||
openalsrc->probed_caps = NULL;
|
||||
|
||||
gst_element_class_set_static_metadata (element_class, "OpenAL src",
|
||||
"Source/Audio",
|
||||
"OpenAL source capture audio from device",
|
||||
"Victor Lin <bornstub@gmail.com>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_factory)
|
||||
);
|
||||
G_OBJECT_CLASS (gst_openal_src_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_openal_src_class_init (GstOpenalSrcClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstAudioSrcClass *gstaudio_src_class;
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||
GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass;
|
||||
GstAudioSrcClass *gstaudiosrc_class = (GstAudioSrcClass *) (klass);
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (klass);
|
||||
gstaudio_src_class = GST_AUDIO_SRC_CLASS (klass);
|
||||
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_openal_src_dispose);
|
||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_openal_src_finalize);
|
||||
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_openal_src_set_property);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_openal_src_get_property);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (openalsrc_debug, "openalsrc",
|
||||
0, "OpenAL source capture audio from device");
|
||||
gst_openal_src_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gobject_class->set_property = gst_openal_src_set_property;
|
||||
gobject_class->get_property = gst_openal_src_get_property;
|
||||
gobject_class->finalize = gst_openal_src_finalize;
|
||||
gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_openal_src_getcaps);
|
||||
|
||||
gstaudio_src_class->open = GST_DEBUG_FUNCPTR (gst_openal_src_open);
|
||||
gstaudio_src_class->prepare = GST_DEBUG_FUNCPTR (gst_openal_src_prepare);
|
||||
gstaudio_src_class->unprepare = GST_DEBUG_FUNCPTR (gst_openal_src_unprepare);
|
||||
gstaudio_src_class->close = GST_DEBUG_FUNCPTR (gst_openal_src_close);
|
||||
gstaudio_src_class->read = GST_DEBUG_FUNCPTR (gst_openal_src_read);
|
||||
gstaudio_src_class->delay = GST_DEBUG_FUNCPTR (gst_openal_src_delay);
|
||||
gstaudio_src_class->reset = GST_DEBUG_FUNCPTR (gst_openal_src_reset);
|
||||
gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_openal_src_open);
|
||||
gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_openal_src_prepare);
|
||||
gstaudiosrc_class->unprepare = GST_DEBUG_FUNCPTR (gst_openal_src_unprepare);
|
||||
gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_openal_src_close);
|
||||
gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_openal_src_read);
|
||||
gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_openal_src_delay);
|
||||
gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_openal_src_reset);
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_DEVICE,
|
||||
g_param_spec_string ("device",
|
||||
"Device",
|
||||
"Specific capture device to open, NULL indicate default device",
|
||||
DEFAULT_DEVICE, G_PARAM_READWRITE)
|
||||
);
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE,
|
||||
g_param_spec_string ("device", "ALCdevice",
|
||||
"User device, default device if NULL", OPENAL_DEFAULT_DEVICE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_DEVICE_NAME,
|
||||
g_param_spec_string ("device-name",
|
||||
"Device name",
|
||||
"Readable name of device", DEFAULT_DEVICE_NAME, G_PARAM_READABLE)
|
||||
);
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
|
||||
g_param_spec_string ("device-name", "Device name",
|
||||
"Human-readable name of the device", OPENAL_DEFAULT_DEVICE_NAME,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gst_element_class_set_static_metadata (gstelement_class,
|
||||
"OpenAL Audio Source", "Source/Audio", "Input audio through OpenAL",
|
||||
"Juan Manuel Borges Caño <juanmabcmail@gmail.com>");
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&openalsrc_factory));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_openal_src_init (GstOpenalSrc * osrc, GstOpenalSrcClass * gclass)
|
||||
gst_openal_src_init (GstOpenalSrc * openalsrc)
|
||||
{
|
||||
osrc->deviceName = g_strdup (DEFAULT_DEVICE_NAME);
|
||||
osrc->device = DEFAULT_DEVICE;
|
||||
osrc->deviceHandle = NULL;
|
||||
GST_DEBUG_OBJECT (openalsrc, "initializing");
|
||||
|
||||
openalsrc->default_device_name = g_strdup (OPENAL_DEFAULT_DEVICE_NAME);
|
||||
openalsrc->default_device = OPENAL_DEFAULT_DEVICE;
|
||||
openalsrc->device = NULL;
|
||||
|
||||
openalsrc->buffer_length = 0;
|
||||
|
||||
openalsrc->probed_caps = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_openal_src_finalize (GObject * object)
|
||||
{
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (object);
|
||||
|
||||
g_free (openalsrc->default_device_name);
|
||||
g_free (openalsrc->default_device);
|
||||
|
||||
G_OBJECT_CLASS (gst_openal_src_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_openal_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (object);
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DEVICE:
|
||||
osrc->device = g_value_dup_string (value);
|
||||
openalsrc->default_device = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_DEVICE_NAME:
|
||||
osrc->deviceName = g_value_dup_string (value);
|
||||
openalsrc->default_device_name = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -218,14 +255,14 @@ static void
|
|||
gst_openal_src_get_property (GObject * object, guint prop_id, GValue * value,
|
||||
GParamSpec * pspec)
|
||||
{
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (object);
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DEVICE:
|
||||
g_value_set_string (value, osrc->device);
|
||||
g_value_set_string (value, openalsrc->default_device);
|
||||
break;
|
||||
case PROP_DEVICE_NAME:
|
||||
g_value_set_string (value, osrc->deviceName);
|
||||
g_value_set_string (value, openalsrc->default_device_name);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -233,127 +270,324 @@ gst_openal_src_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_openal_src_open (GstAudioSrc * asrc)
|
||||
static GstCaps *
|
||||
gst_openal_helper_probe_caps (ALCcontext * context)
|
||||
{
|
||||
GstStructure *structure;
|
||||
GstCaps *caps;
|
||||
// ALCcontext *old;
|
||||
|
||||
// old = pushContext(context);
|
||||
|
||||
caps = gst_caps_new_empty ();
|
||||
|
||||
if (alIsExtensionPresent ("AL_EXT_DOUBLE")) {
|
||||
structure =
|
||||
gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
|
||||
GST_AUDIO_NE (F64), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
|
||||
OPENAL_MAX_RATE, "channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
}
|
||||
|
||||
if (alIsExtensionPresent ("AL_EXT_FLOAT32")) {
|
||||
structure =
|
||||
gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
|
||||
GST_AUDIO_NE (F32), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
|
||||
OPENAL_MAX_RATE, "channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
}
|
||||
|
||||
structure =
|
||||
gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
|
||||
GST_AUDIO_NE (S16), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
|
||||
OPENAL_MAX_RATE, "channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
|
||||
structure =
|
||||
gst_structure_new ("audio/x-raw", "format", G_TYPE_STRING,
|
||||
G_STRINGIFY (U8), "rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE,
|
||||
OPENAL_MAX_RATE, "channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
|
||||
if (alIsExtensionPresent ("AL_EXT_IMA4")) {
|
||||
structure =
|
||||
gst_structure_new ("audio/x-adpcm", "layout", G_TYPE_STRING, "ima",
|
||||
"rate", GST_TYPE_INT_RANGE, OPENAL_MIN_RATE, OPENAL_MAX_RATE,
|
||||
"channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
}
|
||||
|
||||
if (alIsExtensionPresent ("AL_EXT_ALAW")) {
|
||||
structure =
|
||||
gst_structure_new ("audio/x-alaw", "rate", GST_TYPE_INT_RANGE,
|
||||
OPENAL_MIN_RATE, OPENAL_MAX_RATE, "channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
}
|
||||
|
||||
if (alIsExtensionPresent ("AL_EXT_MULAW")) {
|
||||
structure =
|
||||
gst_structure_new ("audio/x-mulaw", "rate", GST_TYPE_INT_RANGE,
|
||||
OPENAL_MIN_RATE, OPENAL_MAX_RATE, "channels", G_TYPE_INT, 1, NULL);
|
||||
gst_caps_append_structure (caps, structure);
|
||||
}
|
||||
// popContext(old, context);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_openal_src_getcaps (GstBaseSrc * basesrc, GstCaps * filter)
|
||||
{
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (basesrc);
|
||||
GstCaps *caps;
|
||||
ALCdevice *device;
|
||||
|
||||
device = alcOpenDevice (NULL);
|
||||
|
||||
if (device == NULL) {
|
||||
GstPad *pad = GST_BASE_SRC_PAD (basesrc);
|
||||
GST_ELEMENT_WARNING (openalsrc, RESOURCE, OPEN_WRITE,
|
||||
("Could not open temporary device."), GST_ALC_ERROR (device));
|
||||
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||
} else if (openalsrc->probed_caps)
|
||||
caps = gst_caps_copy (openalsrc->probed_caps);
|
||||
else {
|
||||
ALCcontext *context = alcCreateContext (device, NULL);
|
||||
if (context) {
|
||||
caps = gst_openal_helper_probe_caps (context);
|
||||
alcDestroyContext (context);
|
||||
} else {
|
||||
GST_ELEMENT_WARNING (openalsrc, RESOURCE, FAILED,
|
||||
("Could not create temporary context."), GST_ALC_ERROR (device));
|
||||
caps = NULL;
|
||||
}
|
||||
|
||||
if (caps && !gst_caps_is_empty (caps))
|
||||
openalsrc->probed_caps = gst_caps_copy (caps);
|
||||
}
|
||||
|
||||
if (device != NULL) {
|
||||
if (alcCloseDevice (device) == ALC_FALSE) {
|
||||
GST_ELEMENT_WARNING (openalsrc, RESOURCE, CLOSE,
|
||||
("Could not close temporary device."), GST_ALC_ERROR (device));
|
||||
}
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
GstCaps *intersection;
|
||||
|
||||
intersection =
|
||||
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
||||
return intersection;
|
||||
} else {
|
||||
return caps;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gst_openal_src_open (GstAudioSrc * audiosrc)
|
||||
{
|
||||
/* We don't do anything here */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_openal_src_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
|
||||
static void
|
||||
gst_openal_src_parse_spec (GstOpenalSrc * openalsrc,
|
||||
const GstAudioRingBufferSpec * spec)
|
||||
{
|
||||
ALuint format = AL_NONE;
|
||||
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (asrc);
|
||||
ALenum format;
|
||||
guint64 bufferSize;
|
||||
GST_DEBUG_OBJECT (openalsrc,
|
||||
"looking up format for type %d, gst-format %d, and %d channels",
|
||||
spec->type, GST_AUDIO_INFO_FORMAT (&spec->info),
|
||||
GST_AUDIO_INFO_CHANNELS (&spec->info));
|
||||
|
||||
switch (spec->width) {
|
||||
case 8:
|
||||
format = AL_FORMAT_STEREO8;
|
||||
switch (spec->type) {
|
||||
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW:
|
||||
switch (GST_AUDIO_INFO_FORMAT (&spec->info)) {
|
||||
case GST_AUDIO_FORMAT_U8:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_AUDIO_FORMAT_U16:
|
||||
case GST_AUDIO_FORMAT_S16:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO16;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_AUDIO_FORMAT_F32:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO_FLOAT32;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_AUDIO_FORMAT_F64:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO_DOUBLE_EXT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
format = AL_FORMAT_STEREO16;
|
||||
|
||||
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO_IMA4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO_ALAW_EXT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW:
|
||||
switch (GST_AUDIO_INFO_CHANNELS (&spec->info)) {
|
||||
case 1:
|
||||
format = AL_FORMAT_MONO_MULAW;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
bufferSize =
|
||||
spec->buffer_time * spec->rate * spec->bytes_per_sample / 1000000;
|
||||
openalsrc->bytes_per_sample = GST_AUDIO_INFO_BPS (&spec->info);
|
||||
openalsrc->rate = GST_AUDIO_INFO_RATE (&spec->info);
|
||||
openalsrc->buffer_length = spec->segsize;
|
||||
openalsrc->format = format;
|
||||
}
|
||||
|
||||
GST_INFO_OBJECT (osrc, "Open device : %s", osrc->deviceName);
|
||||
osrc->deviceHandle =
|
||||
alcCaptureOpenDevice (osrc->device, spec->rate, format, bufferSize);
|
||||
static gboolean
|
||||
gst_openal_src_prepare (GstAudioSrc * audiosrc, GstAudioRingBufferSpec * spec)
|
||||
{
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (audiosrc);
|
||||
|
||||
if (!osrc->deviceHandle) {
|
||||
GST_ELEMENT_ERROR (osrc,
|
||||
RESOURCE,
|
||||
FAILED,
|
||||
("Can't open device \"%s\"", osrc->device),
|
||||
("Can't open device \"%s\"", osrc->device)
|
||||
);
|
||||
gst_openal_src_parse_spec (openalsrc, spec);
|
||||
if (openalsrc->format == AL_NONE) {
|
||||
GST_ELEMENT_ERROR (openalsrc, RESOURCE, SETTINGS, (NULL),
|
||||
("Unable to get type %d, format %d, and %d channels", spec->type,
|
||||
GST_AUDIO_INFO_FORMAT (&spec->info),
|
||||
GST_AUDIO_INFO_CHANNELS (&spec->info)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
osrc->deviceName =
|
||||
g_strdup (alcGetString (osrc->deviceHandle, ALC_DEVICE_SPECIFIER));
|
||||
osrc->bytes_per_sample = spec->bytes_per_sample;
|
||||
openalsrc->device =
|
||||
alcCaptureOpenDevice (openalsrc->default_device, openalsrc->rate,
|
||||
openalsrc->format, openalsrc->buffer_length);
|
||||
|
||||
GST_INFO_OBJECT (osrc, "Start capture");
|
||||
alcCaptureStart (osrc->deviceHandle);
|
||||
if (!openalsrc->device) {
|
||||
GST_ELEMENT_ERROR (openalsrc, RESOURCE, OPEN_READ,
|
||||
("Could not open device."), GST_ALC_ERROR (openalsrc->device));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
openalsrc->default_device_name =
|
||||
g_strdup (alcGetString (openalsrc->device, ALC_DEVICE_SPECIFIER));
|
||||
|
||||
alcCaptureStart (openalsrc->device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_openal_src_unprepare (GstAudioSrc * asrc)
|
||||
gst_openal_src_unprepare (GstAudioSrc * audiosrc)
|
||||
{
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (audiosrc);
|
||||
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (asrc);
|
||||
if (openalsrc->device) {
|
||||
alcCaptureStop (openalsrc->device);
|
||||
|
||||
GST_INFO_OBJECT (osrc, "Close device : %s", osrc->deviceName);
|
||||
if (osrc->deviceHandle) {
|
||||
alcCaptureStop (osrc->deviceHandle);
|
||||
alcCaptureCloseDevice (osrc->deviceHandle);
|
||||
if (alcCaptureCloseDevice (openalsrc->device) == ALC_FALSE) {
|
||||
GST_ELEMENT_ERROR (openalsrc, RESOURCE, CLOSE,
|
||||
("Could not close device."), GST_ALC_ERROR (openalsrc->device));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_openal_src_close (GstAudioSrc * asrc)
|
||||
gst_openal_src_close (GstAudioSrc * audiosrc)
|
||||
{
|
||||
/* We don't do anything here */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static guint
|
||||
gst_openal_src_read (GstAudioSrc * asrc, gpointer data, guint length)
|
||||
gst_openal_src_read (GstAudioSrc * audiosrc, gpointer data, guint length,
|
||||
GstClockTime * timestamp)
|
||||
{
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (asrc);
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (audiosrc);
|
||||
gint samples;
|
||||
|
||||
alcGetIntegerv (osrc->deviceHandle, ALC_CAPTURE_SAMPLES, sizeof (samples),
|
||||
alcGetIntegerv (openalsrc->device, ALC_CAPTURE_SAMPLES, sizeof (samples),
|
||||
&samples);
|
||||
|
||||
if (samples * osrc->bytes_per_sample > length) {
|
||||
samples = length / osrc->bytes_per_sample;
|
||||
if (samples * openalsrc->bytes_per_sample > length) {
|
||||
samples = length / openalsrc->bytes_per_sample;
|
||||
}
|
||||
|
||||
if (samples) {
|
||||
GST_DEBUG_OBJECT (osrc, "Read samples : %d", samples);
|
||||
alcCaptureSamples (osrc->deviceHandle, data, samples);
|
||||
GST_DEBUG_OBJECT (openalsrc, "read samples : %d", samples);
|
||||
alcCaptureSamples (openalsrc->device, data, samples);
|
||||
}
|
||||
|
||||
return samples * osrc->bytes_per_sample;
|
||||
return samples * openalsrc->bytes_per_sample;
|
||||
}
|
||||
|
||||
static guint
|
||||
gst_openal_src_delay (GstAudioSrc * asrc)
|
||||
gst_openal_src_delay (GstAudioSrc * audiosrc)
|
||||
{
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (asrc);
|
||||
gint samples;
|
||||
GstOpenalSrc *openalsrc = GST_OPENAL_SRC (audiosrc);
|
||||
ALint samples;
|
||||
|
||||
alcGetIntegerv (osrc->deviceHandle, ALC_CAPTURE_SAMPLES, sizeof (samples),
|
||||
alcGetIntegerv (openalsrc->device, ALC_CAPTURE_SAMPLES, sizeof (samples),
|
||||
&samples);
|
||||
|
||||
if (G_UNLIKELY (samples < 0)) {
|
||||
/* make sure we never return a negative delay */
|
||||
GST_WARNING_OBJECT (openal_debug, "negative delay");
|
||||
samples = 0;
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_openal_src_reset (GstAudioSrc * asrc)
|
||||
gst_openal_src_reset (GstAudioSrc * audiosrc)
|
||||
{
|
||||
/* We don't do anything here */
|
||||
}
|
||||
|
||||
static void
|
||||
gst_openal_src_finalize (GObject * object)
|
||||
{
|
||||
GstOpenalSrc *osrc = GST_OPENAL_SRC (object);
|
||||
|
||||
g_free (osrc->deviceName);
|
||||
g_free (osrc->device);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
@ -1,105 +1,122 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
|
||||
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
* Copyright (C) 2008 Victor Lin <bornstub@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_OPENAL_SRC_H__
|
||||
#define __GST_OPENAL_SRC_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/gstaudiosrc.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include <alext.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
#include <OpenAL/alext.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#include <AL/alext.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_OPENAL_SRC \
|
||||
(gst_openal_src_get_type())
|
||||
#define GST_OPENAL_SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENAL_SRC,GstOpenalSrc))
|
||||
#define GST_OPENAL_SRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENAL_SRC,GstOpenalSrcClass))
|
||||
#define GST_IS_OPENAL_SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENAL_SRC))
|
||||
#define GST_IS_OPENAL_SRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENAL_SRC))
|
||||
|
||||
typedef struct _GstOpenalSrc GstOpenalSrc;
|
||||
typedef struct _GstOpenalSrcClass GstOpenalSrcClass;
|
||||
|
||||
struct _GstOpenalSrc {
|
||||
GstAudioSrc element;
|
||||
GstPad *srcpad;
|
||||
gboolean silent;
|
||||
|
||||
/* readable name of device */
|
||||
gchar *deviceName;
|
||||
/* name of device to open, default is a NULL pointer to get default device */
|
||||
gchar *device;
|
||||
/* OpenAL device handle */
|
||||
ALCdevice *deviceHandle;
|
||||
|
||||
guint bytes_per_sample;
|
||||
};
|
||||
|
||||
struct _GstOpenalSrcClass {
|
||||
GstAudioSrcClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_openal_src_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_OPENAL_SRC_H__ */
|
||||
/*
|
||||
* GStreamer
|
||||
*
|
||||
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
|
||||
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
* Copyright (C) 2008 Victor Lin <bornstub@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_OPENAL_SRC_H__
|
||||
#define __GST_OPENAL_SRC_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include <alext.h>
|
||||
#elif defined(__APPLE__)
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
#include <OpenAL/alext.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#include <AL/alext.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_OPENAL_SRC \
|
||||
(gst_openal_src_get_type())
|
||||
#define GST_OPENAL_SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_OPENAL_SRC, GstOpenalSrc))
|
||||
#define GST_OPENAL_SRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_OPENAL_SRC, GstOpenalSrcClass))
|
||||
#define GST_IS_OPENAL_SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_OPENAL_SRC))
|
||||
#define GST_IS_OPENAL_SRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_OPENAL_SRC))
|
||||
|
||||
#if 1
|
||||
#define GST_ALC_ERROR(Device) ("ALC error: %s", alcGetString((Device), alcGetError((Device))))
|
||||
#else
|
||||
#define GST_ALC_ERROR(Device) ("ALC error: 0x%x", alcGetError((Device)))
|
||||
#endif
|
||||
|
||||
typedef struct _GstOpenalSrc GstOpenalSrc;
|
||||
typedef struct _GstOpenalSrcClass GstOpenalSrcClass;
|
||||
|
||||
struct _GstOpenalSrc
|
||||
{
|
||||
GstAudioSrc element;
|
||||
GstPad *srcpad;
|
||||
gboolean silent;
|
||||
|
||||
/* readable name of device */
|
||||
gchar *default_device_name;
|
||||
/* name of device to open, default is a NULL pointer to get default device */
|
||||
gchar *default_device;
|
||||
/* OpenAL device handle */
|
||||
ALCdevice *device;
|
||||
|
||||
guint64 buffer_length;
|
||||
|
||||
ALenum format;
|
||||
ALuint rate;
|
||||
ALuint bytes_per_sample;
|
||||
|
||||
GstCaps *probed_caps;
|
||||
};
|
||||
|
||||
struct _GstOpenalSrcClass
|
||||
{
|
||||
GstAudioSrcClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_openal_src_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_OPENAL_SRC_H__ */
|
||||
|
|
Loading…
Reference in a new issue