[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI/GStreamer?
- From: David Hollander <dhllndr@...>
- Date: Sat, 29 Oct 2011 20:01:13 -0500
What type of media are you streaming? If it's audio and not video, I
have audio streaming working with OpenAL and the LuaJIT FFI
(generating sine waves and passing through filters), as no callbacks
are needed for that API. The FFI headers are attached.
- David Hollander
On Thu, Oct 27, 2011 at 7:17 AM, Daurnimator <quae@daurnimator.com> wrote:
> On 27 October 2011 21:16, Ralf Van Bogaert <pooshhmao@gmail.com> wrote:
>> Hi, Thanks for your reply.
>> It was your project I learned to use GStreamer via lgob-gst from; however I
>> can find NO further documentation on how to use this besides the examples
>> you have provided.
>> I'm taking a look at ffmpeg, but I'm not sure I'm willing to invest time in
>> it since GStreamer seems to be the more complete project. I also would like
>> to make use of plugins such as pitch control and other stuff.
>> Regards
>> Ralf
>>
>
> I'm not the creator of lgob; I just read the gstreamer docs + the lgob
> gstreamer example.
> I ran into problems with the playbin2 interface; the message passing
> would make a callback into lua code at a random time and corrupt the
> lua state.
>
> I did look into lgi; but the lack of gobject-introspection packages in
> my distro at the time stopped me....
>
>
> I'm looking at ffmpeg+openal now; as its the least error prone
> approach (I think): I tell it to decode a file for me; then I buffer
> the file manually to the sound card myself.
> You could easily insert any effect engine in the pipeline....
>
> D
>
>
ffi = require 'ffi'
local al = ffi.load "openal"
ffi.cdef[[
typedef char ALboolean; /** 8-bit boolean */
typedef char ALchar; /** character */
typedef signed char ALbyte; /** signed 8-bit 2's complement integer */
typedef unsigned char ALubyte; /** unsigned 8-bit integer */
typedef short ALshort; /** signed 16-bit 2's complement integer */
typedef unsigned short ALushort;/** unsigned 16-bit integer */
typedef int ALint; /** signed 32-bit 2's complement integer */
typedef unsigned int ALuint; /** unsigned 32-bit integer */
typedef int ALsizei; /** non-negative 32-bit binary integer size */
typedef int ALenum; /** enumerated 32-bit value */
typedef float ALfloat; /** 32-bit IEEE754 floating-point */
typedef double ALdouble; /** 64-bit IEEE754 floating-point */
typedef void ALvoid; /** void type (for opaque pointers only) */
enum {
AL_NONE = 0,
AL_FALSE = 0,
AL_TRUE = 1,
AL_SOURCE_RELATIVE = 0x202,
AL_CONE_INNER_ANGLE = 0x1001,
AL_CONE_OUTER_ANGLE = 0x1002,
AL_PITCH = 0x1003,
AL_POSITION = 0x1004,
AL_DIRECTION = 0x1005,
AL_VELOCITY = 0x1006,
AL_LOOPING = 0x1007,
AL_BUFFER = 0x1009,
AL_GAIN = 0x100A,
AL_MIN_GAIN = 0x100D,
AL_MAX_GAIN = 0x100E,
AL_ORIENTATION = 0x100F,
AL_SOURCE_STATE = 0x1010,
AL_INITIAL = 0x1011,
AL_PLAYING = 0x1012,
AL_PAUSED = 0x1013,
AL_STOPPED = 0x1014,
AL_BUFFERS_QUEUED = 0x1015,
AL_BUFFERS_PROCESSED = 0x1016,
AL_SEC_OFFSET = 0x1024,
AL_SAMPLE_OFFSET = 0x1025,
AL_BYTE_OFFSET = 0x1026,
AL_SOURCE_TYPE = 0x1027,
AL_STATIC = 0x1028,
AL_STREAMING = 0x1029,
AL_UNDETERMINED = 0x1030,
AL_FORMAT_MONO8 = 0x1100,
AL_FORMAT_MONO16 = 0x1101,
AL_FORMAT_STEREO8 = 0x1102,
AL_FORMAT_STEREO16 = 0x1103,
AL_REFERENCE_DISTANCE = 0x1020,
AL_ROLLOFF_FACTOR = 0x1021,
AL_CONE_OUTER_GAIN = 0x1022,
AL_MAX_DISTANCE = 0x1023,
AL_FREQUENCY = 0x2001,
AL_BITS = 0x2002,
AL_CHANNELS = 0x2003,
AL_SIZE = 0x2004,
AL_UNUSED = 0x2010,
AL_PENDING = 0x2011,
AL_PROCESSED = 0x2012,
AL_NO_ERROR = 0,
AL_INVALID_NAME = 0xA001,
AL_INVALID_ENUM = 0xA002,
AL_INVALID_VALUE = 0xA003,
AL_INVALID_OPERATION = 0xA004,
AL_OUT_OF_MEMORY = 0xA005,
AL_VENDOR = 0xB001,
AL_VERSION = 0xB002,
AL_RENDERER = 0xB003,
AL_EXTENSIONS = 0xB004,
AL_DOPPLER_FACTOR = 0xC000,
AL_DOPPLER_VELOCITY = 0xC001,
AL_SPEED_OF_SOUND = 0xC003,
AL_DISTANCE_MODEL = 0xD000,
AL_INVERSE_DISTANCE = 0xD001,
AL_INVERSE_DISTANCE_CLAMPED = 0xD002,
AL_LINEAR_DISTANCE = 0xD003,
AL_LINEAR_DISTANCE_CLAMPED = 0xD004,
AL_EXPONENT_DISTANCE = 0xD005,
AL_EXPONENT_DISTANCE_CLAMPED = 0xD006,
};
void alEnable( ALenum capability );
void alDisable( ALenum capability );
ALboolean alIsEnabled( ALenum capability );
const ALchar* alGetString( ALenum param );
void alGetBooleanv( ALenum param, ALboolean* data );
void alGetIntegerv( ALenum param, ALint* data );
void alGetFloatv( ALenum param, ALfloat* data );
void alGetDoublev( ALenum param, ALdouble* data );
ALboolean alGetBoolean( ALenum param );
ALint alGetInteger( ALenum param );
ALfloat alGetFloat( ALenum param );
ALdouble alGetDouble( ALenum param );
ALenum alGetError( void );
ALboolean alIsExtensionPresent( const ALchar* extname );
void* alGetProcAddress( const ALchar* fname );
ALenum alGetEnumValue( const ALchar* ename );
void alListenerf( ALenum param, ALfloat value );
void alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
void alListenerfv( ALenum param, const ALfloat* values );
void alListeneri( ALenum param, ALint value );
void alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 );
void alListeneriv( ALenum param, const ALint* values );
void alGetListenerf( ALenum param, ALfloat* value );
void alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
void alGetListenerfv( ALenum param, ALfloat* values );
void alGetListeneri( ALenum param, ALint* value );
void alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 );
void alGetListeneriv( ALenum param, ALint* values );
void alGenSources( ALsizei n, ALuint* sources );
void alDeleteSources( ALsizei n, const ALuint* sources );
ALboolean alIsSource( ALuint sid );
void alSourcef( ALuint sid, ALenum param, ALfloat value );
void alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
void alSourcefv( ALuint sid, ALenum param, const ALfloat* values );
void alSourcei( ALuint sid, ALenum param, ALint value );
void alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 );
void alSourceiv( ALuint sid, ALenum param, const ALint* values );
void alGetSourcef( ALuint sid, ALenum param, ALfloat* value );
void alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
void alGetSourcefv( ALuint sid, ALenum param, ALfloat* values );
void alGetSourcei( ALuint sid, ALenum param, ALint* value );
void alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
void alGetSourceiv( ALuint sid, ALenum param, ALint* values );
void alSourcePlayv( ALsizei ns, const ALuint *sids );
void alSourceStopv( ALsizei ns, const ALuint *sids );
void alSourceRewindv( ALsizei ns, const ALuint *sids );
void alSourcePausev( ALsizei ns, const ALuint *sids );
void alSourcePlay( ALuint sid );
void alSourceStop( ALuint sid );
void alSourceRewind( ALuint sid );
void alSourcePause( ALuint sid );
void alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids );
void alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids );
void alGenBuffers( ALsizei n, ALuint* buffers );
void alDeleteBuffers( ALsizei n, const ALuint* buffers );
ALboolean alIsBuffer( ALuint bid );
void alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
void alBufferf( ALuint bid, ALenum param, ALfloat value );
void alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
void alBufferfv( ALuint bid, ALenum param, const ALfloat* values );
void alBufferi( ALuint bid, ALenum param, ALint value );
void alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 );
void alBufferiv( ALuint bid, ALenum param, const ALint* values );
void alGetBufferf( ALuint bid, ALenum param, ALfloat* value );
void alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
void alGetBufferfv( ALuint bid, ALenum param, ALfloat* values );
void alGetBufferi( ALuint bid, ALenum param, ALint* value );
void alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3);
void alGetBufferiv( ALuint bid, ALenum param, ALint* values );
void alDopplerFactor( ALfloat value );
void alDopplerVelocity( ALfloat value );
void alSpeedOfSound( ALfloat value );
void alDistanceModel( ALenum distanceModel );
]]
return al
local ffi = require 'ffi'
local al = require 'openal'
local alut = ffi.load 'alut'
ffi.cdef[[
enum {
ALUT_API_MAJOR_VERSION = 1,
ALUT_API_MINOR_VERSION = 1,
ALUT_ERROR_NO_ERROR = 0,
ALUT_ERROR_OUT_OF_MEMORY = 0x200,
ALUT_ERROR_INVALID_ENUM = 0x201,
ALUT_ERROR_INVALID_VALUE = 0x202,
ALUT_ERROR_INVALID_OPERATION = 0x203,
ALUT_ERROR_NO_CURRENT_CONTEXT = 0x204,
ALUT_ERROR_AL_ERROR_ON_ENTRY = 0x205,
ALUT_ERROR_ALC_ERROR_ON_ENTRY = 0x206,
ALUT_ERROR_OPEN_DEVICE = 0x207,
ALUT_ERROR_CLOSE_DEVICE = 0x208,
ALUT_ERROR_CREATE_CONTEXT = 0x209,
ALUT_ERROR_MAKE_CONTEXT_CURRENT = 0x20A,
ALUT_ERROR_DESTROY_CONTEXT = 0x20B,
ALUT_ERROR_GEN_BUFFERS = 0x20C,
ALUT_ERROR_BUFFER_DATA = 0x20D,
ALUT_ERROR_IO_ERROR = 0x20E,
ALUT_ERROR_UNSUPPORTED_FILE_TYPE = 0x20F,
ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE = 0x210,
ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA = 0x211,
ALUT_WAVEFORM_SINE = 0x100,
ALUT_WAVEFORM_SQUARE = 0x101,
ALUT_WAVEFORM_SAWTOOTH = 0x102,
ALUT_WAVEFORM_WHITENOISE = 0x103,
ALUT_WAVEFORM_IMPULSE = 0x104,
ALUT_LOADER_BUFFER = 0x300,
ALUT_LOADER_MEMORY = 0x301,
};
ALboolean alutInit (int *argcp, char **argv);
ALboolean alutInitWithoutContext (int *argcp, char **argv);
ALboolean alutExit (void);
ALenum alutGetError (void);
const char *alutGetErrorString (ALenum error);
ALuint alutCreateBufferFromFile (const char *fileName);
ALuint alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
ALuint alutCreateBufferHelloWorld (void);
ALuint alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
ALvoid *alutLoadMemoryFromFile (const char *fileName, ALenum *format, ALsizei *size, ALfloat *frequency);
ALvoid *alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length, ALenum *format, ALsizei *size, ALfloat *frequency);
ALvoid *alutLoadMemoryHelloWorld (ALenum *format, ALsizei *size, ALfloat *frequency);
ALvoid *alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum *format, ALsizei *size, ALfloat *freq);
const char *alutGetMIMETypes (ALenum loader);
ALint alutGetMajorVersion (void);
ALint alutGetMinorVersion (void);
ALboolean alutSleep (ALfloat duration);
]]
return alut