diff options
Diffstat (limited to 'tinyDAV/include/tinydav/audio')
25 files changed, 1705 insertions, 0 deletions
diff --git a/tinyDAV/include/tinydav/audio/alsa/tdav_common_alsa.h b/tinyDAV/include/tinydav/audio/alsa/tdav_common_alsa.h new file mode 100644 index 0000000..d6b0673 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/alsa/tdav_common_alsa.h @@ -0,0 +1,74 @@ +/* Copyright (C) 2014 Mamadou DIOP. +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +#ifndef TINYDAV_COMMON_ALSA_H +#define TINYDAV_COMMON_ALSA_H + +#include "tinydav_config.h" + +#if HAVE_ALSA_ASOUNDLIB_H + +TDAV_BEGIN_DECLS + +#include "tsk_thread.h" +#include "tsk_memory.h" +#include "tsk_safeobj.h" +#include "tsk_timer.h" +#include "tsk_string.h" +#include "tsk_debug.h" + +#include <alsa/asoundlib.h> + +typedef struct tdav_common_alsa_s +{ + tsk_bool_t b_initialized; + tsk_bool_t b_muted; + tsk_bool_t b_started; + tsk_bool_t b_prepared; + tsk_bool_t b_paused; + tsk_bool_t b_capture; + + tsk_size_t n_buff_size_in_bytes; + tsk_size_t n_buff_size_in_samples; + uint8_t* p_buff_ptr; + + int channels; + int sample_rate; + + snd_pcm_t *p_handle; + snd_pcm_hw_params_t *p_params; + char* p_device_name; + + TSK_DECLARE_SAFEOBJ; +} +tdav_common_alsa_t; + +int tdav_common_alsa_init(tdav_common_alsa_t* p_self); +int tdav_common_alsa_lock(tdav_common_alsa_t* p_self); +int tdav_common_alsa_unlock(tdav_common_alsa_t* p_self); +int tdav_common_alsa_prepare(tdav_common_alsa_t* p_self, tsk_bool_t is_capture, int ptime, int channels, int sample_rate); +int tdav_common_alsa_unprepare(tdav_common_alsa_t* p_self); +int tdav_common_alsa_start(tdav_common_alsa_t* p_self); +int tdav_common_alsa_stop(tdav_common_alsa_t* p_self); +int tdav_common_alsa_deinit(tdav_common_alsa_t* p_self); + +TDAV_END_DECLS + +#endif /* HAVE_ALSA_ASOUNDLIB_H */ + +#endif /* TINYDAV_COMMON_ALSA_H */ + diff --git a/tinyDAV/include/tinydav/audio/alsa/tdav_consumer_alsa.h b/tinyDAV/include/tinydav/audio/alsa/tdav_consumer_alsa.h new file mode 100644 index 0000000..ae9f0f9 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/alsa/tdav_consumer_alsa.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2014 Mamadou DIOP. +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +#ifndef TINYDAV_CONSUMER_ALSA_H +#define TINYDAV_CONSUMER_ALSA_H + +#include "tinydav_config.h" + +#if HAVE_ALSA_ASOUNDLIB_H + +#include "tinydav/audio/tdav_consumer_audio.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_consumer_plugin_def_t *tdav_consumer_alsa_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_ALSA_ASOUNDLIB_H */ + +#endif /* TINYDAV_CONSUMER_ALSA_H */ + diff --git a/tinyDAV/include/tinydav/audio/alsa/tdav_producer_alsa.h b/tinyDAV/include/tinydav/audio/alsa/tdav_producer_alsa.h new file mode 100644 index 0000000..78fd4eb --- /dev/null +++ b/tinyDAV/include/tinydav/audio/alsa/tdav_producer_alsa.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2014 Mamadou DIOP. +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +#ifndef TINYDAV_PRODUCER_ALSA_H +#define TINYDAV_PRODUCER_ALSA_H + +#include "tinydav_config.h" + +#if HAVE_ALSA_ASOUNDLIB_H + +#include "tinydav/audio/tdav_producer_audio.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_producer_plugin_def_t *tdav_producer_alsa_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_ALSA_ASOUNDLIB_H */ + +#endif /* TINYDAV_PRODUCER_ALSA_H */ diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_audiounit.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_audiounit.h new file mode 100644 index 0000000..128681a --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_audiounit.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010-2011 Mamadou Diop. + * + * Contact: Mamadou Diop <diopmamadou(at)doubango.org> + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ +#ifndef TDAV_AUDIO_UNIT_H +#define TDAV_AUDIO_UNIT_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO_AUDIO_UNIT + +#include <AudioUnit/AudioUnit.h> +#include <AudioToolbox/AudioToolbox.h> +#include "tsk_object.h" + +TDAV_BEGIN_DECLS + + +#if TARGET_OS_MAC +# if AUDIO_UNIT_VERSION < 1060 +# define AudioComponent Component +# define AudioComponentInstance ComponentInstance +# define AudioComponentDescription ComponentDescription +# define AudioComponentFindNext FindNextComponent +# define AudioComponentInstanceNew OpenAComponent +# define AudioComponentInstanceDispose CloseComponent +# endif +#endif /* TARGET_OS_MAC */ + +typedef void* tdav_audiounit_handle_t; + +tdav_audiounit_handle_t* tdav_audiounit_handle_create(uint64_t session_id); +AudioComponentInstance tdav_audiounit_handle_get_instance(tdav_audiounit_handle_t* self); +int tdav_audiounit_handle_signal_consumer_prepared(tdav_audiounit_handle_t* self); +int tdav_audiounit_handle_signal_producer_prepared(tdav_audiounit_handle_t* self); +int tdav_audiounit_handle_start(tdav_audiounit_handle_t* self); +uint32_t tdav_audiounit_handle_get_frame_duration(tdav_audiounit_handle_t* self); +int tdav_audiounit_handle_configure(tdav_audiounit_handle_t* self, tsk_bool_t consumer, uint32_t ptime, AudioStreamBasicDescription* audioFormat); +int tdav_audiounit_handle_mute(tdav_audiounit_handle_t* self, tsk_bool_t mute); +int tdav_audiounit_handle_interrupt(tdav_audiounit_handle_t* self, tsk_bool_t interrupt); +int tdav_audiounit_handle_stop(tdav_audiounit_handle_t* self); +int tdav_audiounit_handle_destroy(tdav_audiounit_handle_t** self); + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO_AUDIO_UNIT */ + +#endif /* TDAV_AUDIO_UNIT_H */ diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_audioqueue.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_audioqueue.h new file mode 100644 index 0000000..c7b1954 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_audioqueue.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010-2015 Mamadou DIOP. + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ + +/**@file tdav_consumer_audioqueue.h + * @brief Audio Consumer for MacOSX and iOS platforms using AudioQueue. + * + * @author Laurent Etiemble <laurent.etiemble(at)gmail.com> + * @author Mamadou Diop <diopmamadou(at)doubango(dot)org> + */ +#ifndef TINYDAV_CONSUMER_COREAUDIO_AUDIO_QUEUE_H +#define TINYDAV_CONSUMER_COREAUDIO_AUDIO_QUEUE_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO_AUDIO_QUEUE + +#include <AudioToolbox/AudioToolbox.h> +#include "tinydav/audio/tdav_consumer_audio.h" + +TDAV_BEGIN_DECLS + +#ifndef CoreAudioPlayBuffers +# define CoreAudioPlayBuffers 3 +#endif + +typedef struct tdav_consumer_audioqueue_s +{ + TDAV_DECLARE_CONSUMER_AUDIO; + + tsk_bool_t started; + + AudioStreamBasicDescription description; + AudioQueueRef queue; + AudioQueueBufferRef buffers[CoreAudioPlayBuffers]; + + tsk_size_t buffer_size; +} +tdav_consumer_audioqueue_t; + +TINYDAV_GEXTERN const tmedia_consumer_plugin_def_t *tdav_consumer_audioqueue_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO_AUDIO_QUEUE */ + +#endif /* TINYDAV_CONSUMER_COREAUDIO_AUDIO_QUEUE_H */ diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_audiounit.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_audiounit.h new file mode 100644 index 0000000..509f787 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_audiounit.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010-2011 Mamadou Diop. + * + * Contact: Mamadou Diop <diopmamadou(at)doubango.org> + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ +#ifndef TINYDAV_CONSUMER_COREAUDIO_AUDIO_UNIT_H +#define TINYDAV_CONSUMER_COREAUDIO_AUDIO_UNIT_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO_AUDIO_UNIT + +#include <AudioToolbox/AudioToolbox.h> +#include <speex/speex_buffer.h> +#include "tinydav/audio/coreaudio/tdav_audiounit.h" +#include "tinydav/audio/tdav_consumer_audio.h" +#import "tinymedia/tmedia_resampler.h" + +#include "tsk_mutex.h" + +TDAV_BEGIN_DECLS + +typedef struct tdav_consumer_audiounit_s +{ + TDAV_DECLARE_CONSUMER_AUDIO; + + tdav_audiounit_handle_t* audioUnitHandle; + unsigned started:1; + unsigned paused:1; + + struct { + struct { + void* buffer; + tsk_size_t size; + } chunck; + tsk_ssize_t leftBytes; + SpeexBuffer* buffer; + tsk_size_t size; + tsk_mutex_handle_t* mutex; + } ring; + + tmedia_resampler_t *resampler; +} +tdav_consumer_audiounit_t; + +TINYDAV_GEXTERN const tmedia_consumer_plugin_def_t *tdav_consumer_audiounit_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO_AUDIO_UNIT */ + +#endif /* TINYDAV_CONSUMER_COREAUDIO_AUDIO_UNIT_H */ diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_audioqueue.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_audioqueue.h new file mode 100644 index 0000000..27c9b98 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_audioqueue.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2010-2011 Mamadou Diop. + * + * Contact: Mamadou Diop <diopmamadou(at)doubango.org> + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ +/**@file tdav_producer_audioqueue.h + * @brief Audio Producer for MacOSX and iOS platforms using AudioQueue. + * + * @author Laurent Etiemble <laurent.etiemble(at)gmail.com> + * @author Mamadou Diop <diopmamadou(at)doubango(dot)org> + * + */ +#ifndef TINYDAV_PRODUCER_COREAUDIO_AUDIO_QUEUE_H +#define TINYDAV_PRODUCER_COREAUDIO_AUDIO_QUEUE_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO_AUDIO_QUEUE + +#include <AudioToolbox/AudioToolbox.h> +#include "tinydav/audio/tdav_producer_audio.h" + +TDAV_BEGIN_DECLS + +#define CoreAudioRecordBuffers 3 + +typedef struct tdav_producer_audioqueue_s +{ + TDAV_DECLARE_PRODUCER_AUDIO; + + tsk_bool_t started; + + AudioStreamBasicDescription description; + AudioQueueRef queue; + AudioQueueBufferRef buffers[CoreAudioRecordBuffers]; + + tsk_size_t buffer_size; +} +tdav_producer_audioqueue_t; + +TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tdav_producer_audioqueue_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO_AUDIO_QUEUE */ + +#endif /* TINYDAV_PRODUCER_COREAUDIO_AUDIO_QUEUE_H */ diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_audiounit.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_audiounit.h new file mode 100644 index 0000000..c1a99cb --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_audiounit.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2010-2011 Mamadou Diop. + * + * Contact: Mamadou Diop <diopmamadou(at)doubango.org> + * + * This file is part of Open Source Doubango Framework. + * + * DOUBANGO is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * DOUBANGO 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DOUBANGO. + * + */ +#ifndef TINYDAV_PRODUCER_COREAUDIO_AUDIO_UNIT_H +#define TINYDAV_PRODUCER_COREAUDIO_AUDIO_UNIT_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO_AUDIO_UNIT + +#include <AudioToolbox/AudioToolbox.h> +#include <speex/speex_buffer.h> +#include "tinydav/audio/coreaudio/tdav_audiounit.h" +#include "tinydav/audio/tdav_producer_audio.h" +#include "tsk_condwait.h" +#include "tsk_mutex.h" + +TDAV_BEGIN_DECLS + +typedef struct tdav_producer_audiounit_s +{ + TDAV_DECLARE_PRODUCER_AUDIO; + + tdav_audiounit_handle_t* audioUnitHandle; + unsigned started:1; + unsigned paused:1; + unsigned muted; + + struct { + struct { + void* buffer; + tsk_size_t size; + } chunck; + SpeexBuffer* buffer; + tsk_size_t size; + } ring; +} +tdav_producer_audiounit_t; + +TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tdav_producer_audiounit_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO_AUDIO_UNIT */ + +#endif /* TINYDAV_PRODUCER_COREAUDIO_AUDIO_UNIT_H */ + + + diff --git a/tinyDAV/include/tinydav/audio/directsound/tdav_consumer_dsound.h b/tinyDAV/include/tinydav/audio/directsound/tdav_consumer_dsound.h new file mode 100644 index 0000000..dbba1a8 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/directsound/tdav_consumer_dsound.h @@ -0,0 +1,47 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_consumer_dsound.h + * @brief Microsoft DirectSound consumer. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + + */ +#ifndef TINYDAV_CONSUMER_DSOUND_H +#define TINYDAV_CONSUMER_DSOUND_H + +#include "tinydav_config.h" + +#if HAVE_DSOUND_H + +#include "tinydav/audio/tdav_consumer_audio.h" + +TDAV_BEGIN_DECLS + +TINYDAV_GEXTERN const tmedia_consumer_plugin_def_t *tdav_consumer_dsound_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_DSOUND_H */ + +#endif /* TINYDAV_CONSUMER_DSOUND_H */ diff --git a/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h b/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h new file mode 100644 index 0000000..1f68008 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_producer_dsound.h + * @brief Microsoft DirectSound producer. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + */ +#ifndef TINYDAV_PRODUCER_DSOUND_H +#define TINYDAV_PRODUCER_DSOUND_H + +#include "tinydav_config.h" + +#if HAVE_DSOUND_H || HAVE_DSOUND + +#include "tinydav/audio/tdav_producer_audio.h" + +TDAV_BEGIN_DECLS + +TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tdav_producer_dsound_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_DSOUND_H || HAVE_DSOUND */ + +#endif /* TINYDAV_PRODUCER_DSOUND_H */ diff --git a/tinyDAV/include/tinydav/audio/oss/tdav_consumer_oss.h b/tinyDAV/include/tinydav/audio/oss/tdav_consumer_oss.h new file mode 100644 index 0000000..64deeef --- /dev/null +++ b/tinyDAV/include/tinydav/audio/oss/tdav_consumer_oss.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2014 Mamadou DIOP. +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +#ifndef TINYDAV_CONSUMER_OSS_H +#define TINYDAV_CONSUMER_OSS_H + +#include "tinydav_config.h" + +#if HAVE_LINUX_SOUNDCARD_H + +#include "tinydav/audio/tdav_consumer_audio.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_consumer_plugin_def_t *tdav_consumer_oss_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_LINUX_SOUNDCARD_H */ + +#endif /* TINYDAV_CONSUMER_OSS_H */ + diff --git a/tinyDAV/include/tinydav/audio/oss/tdav_producer_oss.h b/tinyDAV/include/tinydav/audio/oss/tdav_producer_oss.h new file mode 100644 index 0000000..2fa00ff --- /dev/null +++ b/tinyDAV/include/tinydav/audio/oss/tdav_producer_oss.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2014 Mamadou DIOP. +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +#ifndef TINYDAV_PRODUCER_OSS_H +#define TINYDAV_PRODUCER_OSS_H + +#include "tinydav_config.h" + +#if HAVE_LINUX_SOUNDCARD_H + +#include "tinydav/audio/tdav_producer_audio.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_producer_plugin_def_t *tdav_producer_oss_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_LINUX_SOUNDCARD_HH */ + +#endif /* TINYDAV_PRODUCER_OSS_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_consumer_audio.h b/tinyDAV/include/tinydav/audio/tdav_consumer_audio.h new file mode 100644 index 0000000..c561d84 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_consumer_audio.h @@ -0,0 +1,73 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_consumer_audio.h + * @brief Base class for all Audio consumers. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + */ +#ifndef TINYDAV_CONSUMER_AUDIO_H +#define TINYDAV_CONSUMER_AUDIO_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_consumer.h" + +#include "tsk_safeobj.h" + +TDAV_BEGIN_DECLS + +#define TDAV_CONSUMER_AUDIO(self) ((tdav_consumer_audio_t*)(self)) + +typedef struct tdav_consumer_audio_s +{ + TMEDIA_DECLARE_CONSUMER; + + struct tmedia_denoise_s* denoise; + struct tmedia_resampler_s* resampler; + struct tmedia_jitterbuffer_s* jitterbuffer; + + TSK_DECLARE_SAFEOBJ; +} +tdav_consumer_audio_t; + +TINYDAV_API int tdav_consumer_audio_init(tdav_consumer_audio_t* self); +TINYDAV_API int tdav_consumer_audio_cmp(const tsk_object_t* consumer1, const tsk_object_t* consumer2); +#define tdav_consumer_audio_prepare(self, codec) tmedia_consumer_prepare(TDAV_CONSUMER_AUDIO(self), codec) +#define tdav_consumer_audio_start(self) tmedia_consumer_start(TDAV_CONSUMER_AUDIO(self)) +#define tdav_consumer_audio_consume(self, buffer, size) tmedia_consumer_consume(TDAV_CONSUMER_AUDIO(self), buffer, size) +#define tdav_consumer_audio_pause(self) tmedia_consumer_pause(TDAV_CONSUMER_AUDIO(self)) +#define tdav_consumer_audio_stop(self) tmedia_consumer_stop(TDAV_CONSUMER_AUDIO(self)) +TINYDAV_API int tdav_consumer_audio_set(tdav_consumer_audio_t* self, const tmedia_param_t* param); +TINYDAV_API int tdav_consumer_audio_put(tdav_consumer_audio_t* self, const void* data, tsk_size_t data_size, const tsk_object_t* proto_hdr); +TINYDAV_API tsk_size_t tdav_consumer_audio_get(tdav_consumer_audio_t* self, void* out_data, tsk_size_t out_size); +TINYDAV_API int tdav_consumer_audio_tick(tdav_consumer_audio_t* self); +void tdav_consumer_audio_set_denoise(tdav_consumer_audio_t* self, struct tmedia_denoise_s* denoise); +void tdav_consumer_audio_set_jitterbuffer(tdav_consumer_audio_t* self, struct tmedia_jitterbuffer_s* jitterbuffer); +TINYDAV_API int tdav_consumer_audio_reset(tdav_consumer_audio_t* self); +TINYDAV_API int tdav_consumer_audio_deinit(tdav_consumer_audio_t* self); + +#define TDAV_DECLARE_CONSUMER_AUDIO tdav_consumer_audio_t __consumer_audio__ + +TDAV_END_DECLS + +#endif /* TINYDAV_CONSUMER_AUDIO_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_jitterbuffer.h b/tinyDAV/include/tinydav/audio/tdav_jitterbuffer.h new file mode 100644 index 0000000..c6d2449 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_jitterbuffer.h @@ -0,0 +1,333 @@ +/* File from: http://cms.speakup.nl/tech/opensource/jitterbuffer/verslag-20051209.pdf/ */ + +/******************************************************* + * jitterbuffer: + * an application-independent jitterbuffer, which tries + * to achieve the maximum user perception during a call. + * For more information look at: + * http://www.speakup.nl/opensource/jitterbuffer/ + * + * Copyright on this file is held by: + * - Jesse Kaijen <jesse@speakup.nl> + * - SpeakUp <info@speakup.nl> + * + * Contributors: + * Jesse Kaijen <jesse@speakup.nl> + * + * Version: 1.1 + * + * Changelog: +* 1.0 => 1.1 (2006-03-24) (thanks to Micheal Jerris, freeswitch.org) + * - added MSVC 2005 project files + * - added JB_NOJB as return value + * + * + * This program is free software, distributed under the terms of: + * - the GNU Lesser (Library) General Public License + * - the Mozilla Public License + * + * if you are interested in an different licence type, please contact us. + * + * How to use the jitterbuffer, please look at the comments + * in the headerfile. + * + * Further details on specific implementations, + * please look at the comments in the code file. + */ + +#ifndef TINYDAV_JITTERBUFFER_H_ +#define TINYDAV_JITTERBUFFER_H_ + +#include "tinydav_config.h" + +#if !(HAVE_SPEEX_DSP && HAVE_SPEEX_JB) + +TDAV_BEGIN_DECLS + +/*********** + * The header file consists of four parts. + * - configuration constants, structs and parameter definitions + * - functions + * - How to use the jitterbuffer and + * which responsibilities do YOU have + * - debug messages explained + */ + + +// configuration constants +/* Number of historical timestamps to use in calculating jitter and jitterbuffer size */ +#ifndef JB_HISTORY_SIZE +# define JB_HISTORY_SIZE 500 +#endif + +/* minimum jitterbuffer size, disabled if 0 */ +#define JB_MIN_SIZE 0 +/* maximum jitterbuffer size, disabled if 0 */ +#define JB_MAX_SIZE 0 + /* maximum successive interpolating frames, disabled if 0 */ +#define JB_MAX_SUCCESSIVE_INTERP 0 +/* amount of extra delay allowed before shrinking */ +#define JB_ALLOW_EXTRA_DELAY 30 +/* ms between growing */ +#define JB_WAIT_GROW 60 +/* ms between shrinking */ +#define JB_WAIT_SHRINK 250 +/* ms that the JB max may be off */ +#define JB_MAX_DIFF 6000 //in a RTP stream the max_diff may be 3000 packets (most packets are 20ms) + +//structs +typedef struct jb_info { + long frames_received; /* Number of frames received by the jitterbuffer */ + long frames_late; /* Number of frames that were late */ + long frames_lost; /* Number of frames that were lost */ + long frames_ooo; /* Number of frames that were Out Of Order */ + long frames_dropped; /* Number of frames that were dropped due shrinkage of the jitterbuffer */ + long frames_dropped_twice; /* Number of frames that were dropped because this timestamp was already in the jitterbuffer */ + + long delay; /* Current delay due the jitterbuffer */ + long jitter; /* jitter measured within current history interval*/ + long losspct; /* recent lost frame percentage (network and jitterbuffer loss) */ + + long delay_target; /* The delay where we want to grow to */ + long losspct_jb; /* recent lost percentage due the jitterbuffer */ + long last_voice_ms; /* the duration of the last voice frame */ + short silence; /* If we are in silence 1-yes 0-no */ + long iqr; /* Inter Quartile Range of current history, if the squareroot is taken it is a good estimate of jitter */ +} jb_info; + +typedef struct jb_frame { + void *data; /* the frame data */ + long ts; /* the senders timestamp */ + long ms; /* length of this frame in ms */ + int type; /* the type of frame */ + int codec; /* codec of this frame, undefined if nonvoice */ + struct jb_frame *next, *prev; /* pointers to the next and previous frames in the queue */ +} jb_frame; + +typedef struct jb_hist_element { + long delay; /* difference between time of arrival and senders timestamp */ + long ts; /* senders timestamp */ + long ms; /* length of this frame in ms */ + int codec; /* wich codec this frame has */ +} jb_hist_element; + +typedef struct jb_settings { + /* settings */ + long min_jb; /* defines a hard clamp to use in setting the jitterbuffer delay */ + long max_jb; /* defines a hard clamp to use in setting the jitterbuffer delay */ + long max_successive_interp; /* the maximum count of successive interpolations before assuming silence */ + long extra_delay; /* amount of extra delay allowed before shrinking */ + long wait_grow; /* ms between growing */ + long wait_shrink; /* ms between shrinking */ + long max_diff; /* maximum number of milliseconds the jitterbuffer may be off */ +} jb_settings; + +typedef struct jitterbuffer { + struct jb_hist_element hist[JB_HISTORY_SIZE]; /* the history of the last received frames */ + long hist_sorted_delay[JB_HISTORY_SIZE]; /* a sorted buffer of the delays (lowest first) */ + long hist_sorted_timestamp[JB_HISTORY_SIZE]; /* a sorted buffer of the timestamps (lowest first) */ + + int hist_pointer; /* points to index in history for next entry */ + long last_adjustment; /* the time of the last adjustment (growing or shrinking) */ + long next_voice_time; /* the next ts is to be read from the jb (senders timestamp) */ + long cnt_successive_interp; /* the count of consecutive interpolation frames */ + long silence_begin_ts; /* the time of the last CNG frame, when in silence */ + long min; /* the clock difference within current history interval */ + long current; /* the present jitterbuffer adjustment */ + long target; /* the target jitterbuffer adjustment */ + long last_delay; /* the delay of the last packet, used for calc. jitter */ + + jb_frame *voiceframes; /* queued voiceframes */ + jb_frame *controlframes; /* queued controlframes */ + jb_settings settings; /* the settings of the jitterbuffer */ + jb_info info; /* the statistics of the jitterbuffer */ +} jitterbuffer; + +//parameter definitions +/* return codes */ +#define JB_OK 0 +#define JB_EMPTY 1 +#define JB_NOFRAME 2 +#define JB_INTERP 3 +#define JB_NOJB 4 + + +/* frame types */ +#define JB_TYPE_CONTROL 1 +#define JB_TYPE_VOICE 2 +#define JB_TYPE_SILENCE 3 + +/* the jitterbuffer behaives different for each codec. */ +/* Look in the code if a codec has his function defined */ +/* default is g711x behaiviour */ +#define JB_CODEC_SPEEX 10 //NOT defined +#define JB_CODEC_ILBC 9 //NOT defined +#define JB_CODEC_GSM_EFR 8 +#define JB_CODEC_GSM_FR 7 //NOT defined +#define JB_CODEC_G723_1 6 +#define JB_CODEC_G729A 5 +#define JB_CODEC_G729 4 +#define JB_CODEC_G711x_PLC 3 +#define JB_CODEC_G711x 2 +#define JB_CODEC_OTHER 1 //NOT defined + + +/* + * Creates a new jitterbuffer and sets the default settings. + * Always use this function for creating a new jitterbuffer. + */ +jitterbuffer *jb_new(); + +/* + * The control frames and possible personal settings are kept. + * History and voice/silence frames are destroyed. + */ +void jb_reset(jitterbuffer *jb); + +/* + * Resets the jitterbuffer totally, all the control/voice/silence frames are destroyed + * default settings are put as well. + */ +void jb_reset_all(jitterbuffer *jb); + +/* + * Destroy the jitterbuffer and any frame within. + * Always use this function for destroying a jitterbuffer, + * otherwise there is a chance of memory leaking. + */ +void jb_destroy(jitterbuffer *jb); + +/* + * Define your own settings for the jitterbuffer. Only settings !=0 + * are put in the jitterbuffer. + */ +void jb_set_settings(jitterbuffer *jb, jb_settings *settings); + +/* + * Get the statistics for the jitterbuffer. + * Copying the statistics directly for the jitterbuffer won't work because + * The statistics are only calculated when calling this function. + */ +void jb_get_info(jitterbuffer *jb, jb_info *stats); + +/* + * Get the current settings of the jitterbuffer. + */ +void jb_get_settings(jitterbuffer *jb, jb_settings *settings); + +/* + * Gives an estimation of the MOS of a call given the + * packetloss p, delay d, and wich codec is used. + * The assumption is made that the echo cancelation is around 37dB. + */ +float jb_guess_mos(float p, long d, int codec); + +/* + * returns JB_OK if there are still frames left in the jitterbuffer + * otherwise JB_EMPTY is returned. + */ +int jb_has_frames(jitterbuffer *jb); + +/* + * put a packet(frame) into the jitterbuffer. + * *data - points to the packet + * type - type of packet, JB_CONTROL|JB_VOICE|JB_SILENCE + * ms - duration of frame (only voice) + * ts - timestamp sender + * now - current timestamp (timestamp of arrival) + * codec - which codec the frame holds (only voice), if not defined, g711x will be used + * + * if type==control @REQUIRE: *data, type, ts, now + * if type==voice @REQUIRE: *data, type, ms, ts, now @OPTIONAL: codec + * if type==silence @REQUIRE: *data, type, ts, now + * on return *data is undefined + */ +void jb_put(jitterbuffer *jb, void *data, int type, long ms, long ts, long now, int codec); + +/* + * Get a packet from the jitterbuffer if it's available. + * control packets have a higher priority above voice and silence packets + * they are always delivered as fast as possible. The delay of the jitterbuffer + * doesn't work for these packets. + * @REQUIRE 1<interpl <= jb->settings->extra_delay (=default JB_ALLOW_EXTRA_DELAY) + * + * return will be: + * JB_OK, *data points to the packet + * JB_INTERP, please interpolate for interpl milliseconds + * JB_NOFRAME, no frame scheduled + * JB_EMPTY, the jitterbuffer is empty + */ +int jb_get(jitterbuffer *jb, void **data, long now, long interpl); + +/* debug functions */ +typedef void (*jb_output_function_t)(const char *fmt, ...); +void jb_setoutput(jb_output_function_t warn, jb_output_function_t err, jb_output_function_t dbg); + + +/******************************* + * The use of the jitterbuffer * + ******************************* + * Always create a new jitterbuffer with jb_new(). + * Always destroy a jitterbuffer with jb_destroy(). + * + * There is no lock(mutex) mechanism, that your responsibility. + * The reason for this is that different environments require + * different ways of implementing a lock. + * + * The following functions require a lock on the jitterbuffer: + * jb_reset(), jb_reset_all(), jb_destroy(), jb_set_settings(), + * jb_get_info(), jb_get_settings(), jb_has_frames(), jb_put(), + * jb_get() + * + * The following functions do NOT require a lock on the jitterbuffer: + * jb_new(), jb_guess_mos() + * + * Since control packets have a higher priority above any other packet + * a call may already be ended while there is audio left to play. We + * advice that you poll the jitterbuffer if there are frames left. + * + * If the audiopath is oneway (eg. voicemailbox) and the latency doesn't + * matter, we advice to set a minimum jitterbuffer size. Then there is + * less loss and the quality is better. + */ + + +/**************************** + * debug messages explained * + **************************** + * N - jb_new() + * R - jb_reset() + * r - jb_reset_all() + * D - jb_destroy() + * S - jb_set_settings() + * H - jb_has_frames() + * I - jb_get_info() + * S - jb_get_settings() + * pC - jb_put() put Control packet + * pT - jb_put() Timestamp was already in the queue + * pV - jb_put() put Voice packet + * pS - jb_put() put Silence packet + * + * A - jb_get() + * // below are all the possible debug info when trying to get a packet + * gC - get_control() - there is a control message + * gs - get_voice() - there is a silence frame + * gS - get_voice() - we are in silence + * gL - get_voice() - are in silence, frame is late + * gP - get_voice() - are in silence, play frame (end of silence) + * ag - get_voicecase() - grow little bit (diff < interpl/2) + * aG - get_voicecase() - grow interpl + * as - get_voicecase() - shrink by voiceframe we throw out + * aS - get_voicecase() - shrink by interpl + * aN - get_voicecase() - no time yet + * aL - get_voicecase() - frame is late + * aP - get_voicecase() - play frame + * aI - get_voicecase() - interpolate + */ + +TDAV_END_DECLS + +#endif /* !(HAVE_SPEEX_DSP && HAVE_SPEEX_JB) */ + +#endif /* TINYDAV_JITTERBUFFER_H_ */ + diff --git a/tinyDAV/include/tinydav/audio/tdav_producer_audio.h b/tinyDAV/include/tinydav/audio/tdav_producer_audio.h new file mode 100644 index 0000000..47e0a4f --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_producer_audio.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_producer_audio.h + * @brief Base class for all Audio producers. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + + */ +#ifndef TINYDAV_PRODUCER_AUDIO_H +#define TINYDAV_PRODUCER_AUDIO_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_producer.h" + +TDAV_BEGIN_DECLS + +#define TDAV_BITS_PER_SAMPLE_DEFAULT 16 + +#define TDAV_PRODUCER_AUDIO(self) ((tdav_producer_audio_t*)(self)) + +typedef struct tdav_producer_audio_s +{ + TMEDIA_DECLARE_PRODUCER; +} +tdav_producer_audio_t; + +TINYDAV_API int tdav_producer_audio_init(tdav_producer_audio_t* self); +TINYDAV_API int tdav_producer_audio_cmp(const tsk_object_t* producer1, const tsk_object_t* producer2); +#define tdav_producer_audio_prepare(self, codec) tmedia_producer_prepare(TMEDIA_PRODUCER(self), codec) +#define tmedia_producer_audio_set_callback(self, callback, callback_data) tmedia_producer_set_callback(TMEDIA_PRODUCER(self), callback, callback_data) +#define tdav_producer_audio_start(self) tdav_producer_start(TMEDIA_PRODUCER(self)) +#define tdav_producer_audio_pause(self) tdav_producer_pause(TMEDIA_PRODUCER(self)) +#define tdav_producer_audio_stop(self) tdav_producer_stop(TMEDIA_PRODUCER(self)) +TINYDAV_API int tdav_producer_audio_set(tdav_producer_audio_t* self, const tmedia_param_t* param); +TINYDAV_API int tdav_producer_audio_deinit(tdav_producer_audio_t* self); + +#define TDAV_DECLARE_PRODUCER_AUDIO tdav_producer_audio_t __producer_audio__ + +TDAV_END_DECLS + +#endif /* TINYDAV_PRODUCER_AUDIO_H */ + diff --git a/tinyDAV/include/tinydav/audio/tdav_session_audio.h b/tinyDAV/include/tinydav/audio/tdav_session_audio.h new file mode 100644 index 0000000..e2ab66f --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_session_audio.h @@ -0,0 +1,96 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_session_audio.h + * @brief Audio Session plugin. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + */ +#ifndef TINYDAV_SESSION_AUDIO_H +#define TINYDAV_SESSION_AUDIO_H + +#include "tinydav_config.h" + +#include "tinydav/tdav_session_av.h" + +#include "tsk_timer.h" + +TDAV_BEGIN_DECLS + +typedef tsk_list_t tdav_session_audio_dtmfe_L_t; + +typedef struct tdav_session_audio_s +{ + TDAV_DECLARE_SESSION_AV; + + tsk_bool_t is_started; + + struct { + unsigned started:1; + tsk_timer_manager_handle_t* handle_mgr_global; + } timer; + + struct { + uint32_t payload_type; + struct tmedia_codec_s* codec; + + void* buffer; + tsk_size_t buffer_size; + + struct { + void* buffer; + tsk_size_t buffer_size; + struct tmedia_resampler_s* instance; + } resampler; + } encoder; + + struct { + uint32_t payload_type; + struct tmedia_codec_s* codec; + + void* buffer; + tsk_size_t buffer_size; + + struct { + void* buffer; + tsk_size_t buffer_size; + struct tmedia_resampler_s* instance; + } resampler; + } decoder; + + struct tmedia_denoise_s* denoise; + struct tmedia_jitterbuffer_s* jitterbuffer; + + tdav_session_audio_dtmfe_L_t* dtmf_events; + tsk_bool_t is_sending_dtmf_events; +} +tdav_session_audio_t; + +#define TDAV_SESSION_AUDIO(self) ((tdav_session_audio_t*)(self)) + +TINYDAV_GEXTERN const tmedia_session_plugin_def_t *tdav_session_audio_plugin_def_t; +TINYDAV_GEXTERN const tmedia_session_plugin_def_t *tdav_session_bfcpaudio_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_SESSION_AUDIO_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_speakup_jitterbuffer.h b/tinyDAV/include/tinydav/audio/tdav_speakup_jitterbuffer.h new file mode 100644 index 0000000..e80c7b5 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_speakup_jitterbuffer.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_speakup_JitterBuffer.h + * @brief Speakup audio JitterBuffer Plugin + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + */ +#ifndef TINYDAV_SPEAKUP_JITTER_BUFFER_H +#define TINYDAV_SPEAKUP_JITTER_BUFFER_H + +#include "tinydav_config.h" + +#if !(HAVE_SPEEX_DSP && HAVE_SPEEX_JB) + +#include "tinymedia/tmedia_jitterbuffer.h" + +#include "tinydav/audio/tdav_jitterbuffer.h" + +TDAV_BEGIN_DECLS + +/** Speakuo JitterBufferr*/ +typedef struct tdav_speakup_jitterBuffer_s +{ + TMEDIA_DECLARE_JITTER_BUFFER; + + jitterbuffer *jbuffer; + uint8_t jcodec; + uint64_t ref_timestamp; + uint32_t frame_duration; + uint32_t rate; + uint32_t channels; + uint32_t _10ms_size_bytes; +} +tdav_speakup_jitterbuffer_t; + +TINYDAV_GEXTERN const tmedia_jitterbuffer_plugin_def_t *tdav_speakup_jitterbuffer_plugin_def_t; + +TDAV_END_DECLS + +#endif /* !(HAVE_SPEEX_DSP && HAVE_SPEEX_JB) */ + +#endif /* TINYDAV_SPEAKUP_JITTER_BUFFER_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_speex_denoise.h b/tinyDAV/include/tinydav/audio/tdav_speex_denoise.h new file mode 100644 index 0000000..3271066 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_speex_denoise.h @@ -0,0 +1,47 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_speex_denoise.h + * @brief Speex Denoiser (Noise suppression, AGC, AEC) Plugin + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + + */ +#ifndef TINYDAV_SPEEX_DENOISE_H +#define TINYDAV_SPEEX_DENOISE_H + +#include "tinydav_config.h" + +#if HAVE_SPEEX_DSP && (!defined(HAVE_SPEEX_DENOISE) || HAVE_SPEEX_DENOISE) + +#include "tinymedia/tmedia_denoise.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_denoise_plugin_def_t *tdav_speex_denoise_plugin_def_t; + +TDAV_END_DECLS + +#endif /* #if HAVE_SPEEX_DSP */ + +#endif /* TINYDAV_SPEEX_DENOISE_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_speex_jitterbuffer.h b/tinyDAV/include/tinydav/audio/tdav_speex_jitterbuffer.h new file mode 100644 index 0000000..019db5d --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_speex_jitterbuffer.h @@ -0,0 +1,45 @@ +/* +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_speex_JitterBuffer.h + * @brief Speex audio JitterBuffer Plugin + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + */ +#ifndef TINYDAV_SPEEX_JITTER_BUFFER_H +#define TINYDAV_SPEEX_JITTER_BUFFER_H + +#include "tinydav_config.h" + +#if HAVE_SPEEX_DSP && HAVE_SPEEX_JB + +#include "tinymedia/tmedia_jitterbuffer.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_jitterbuffer_plugin_def_t *tdav_speex_jitterbuffer_plugin_def_t; + +TDAV_END_DECLS + +#endif /* #if HAVE_SPEEX_DSP */ + +#endif /* TINYDAV_SPEEX_JITTER_BUFFER_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_speex_resampler.h b/tinyDAV/include/tinydav/audio/tdav_speex_resampler.h new file mode 100644 index 0000000..635882d --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_speex_resampler.h @@ -0,0 +1,45 @@ +/* +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_speex_resampler.h + * @brief Speex audio resampler Plugin + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + */ +#ifndef TINYDAV_SPEEX_RESAMPLER_H +#define TINYDAV_SPEEX_RESAMPLER_H + +#include "tinydav_config.h" + +#if HAVE_SPEEX_DSP && (!defined(HAVE_SPEEX_RESAMPLER) || HAVE_SPEEX_RESAMPLER) + +#include "tinymedia/tmedia_resampler.h" + +TDAV_BEGIN_DECLS + +extern const tmedia_resampler_plugin_def_t *tdav_speex_resampler_plugin_def_t; + +TDAV_END_DECLS + +#endif /* #if HAVE_SPEEX_DSP */ + +#endif /* TINYDAV_SPEEX_RESAMPLER_H */ diff --git a/tinyDAV/include/tinydav/audio/tdav_webrtc_denoise.h b/tinyDAV/include/tinydav/audio/tdav_webrtc_denoise.h new file mode 100644 index 0000000..7c5e956 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_webrtc_denoise.h @@ -0,0 +1,90 @@ +/* +* Copyright (C) 2011 Doubango Telecom <http://www.doubango.org> +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_webrtc_denoise.h + * @brief Google WebRTC Denoiser (Noise suppression, AGC, AEC) Plugin + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + + */ +#ifndef TINYDAV_WEBRTC_DENOISE_H +#define TINYDAV_WEBRTC_DENOISE_H + +#include "tinydav_config.h" + +#if HAVE_WEBRTC && (!defined(HAVE_WEBRTC_DENOISE) || HAVE_WEBRTC_DENOISE) + +#include "tinymedia/tmedia_denoise.h" + +#include "tsk_safeobj.h" + +/* Speex denoiser works better than WebRTC's denoiser. This is obvious on Android. */ +#if !defined(PREFER_SPEEX_DENOISER) +# define PREFER_SPEEX_DENOISER 1 +#endif + +#if TDAV_UNDER_MOBILE +# include <webrtc/echo_control_mobile.h> +# define TDAV_WebRtcAec_Create(aecInst) WebRtcAecm_Create(aecInst) +# define TDAV_WebRtcAec_Free(aecInst) WebRtcAecm_Free(aecInst) +# define TDAV_WebRtcAec_Init(aecInst, sampFreq, scSampFreq) WebRtcAecm_Init(aecInst, sampFreq) +# define TDAV_WebRtcAec_BufferFarend(aecInst, farend, nrOfSamples) WebRtcAecm_BufferFarend(aecInst, farend, nrOfSamples) +# define TDAV_WebRtcAec_Process(aecInst, nearend, nearendH, out, outH, nrOfSamples, msInSndCardBuf, skew) WebRtcAecm_Process(aecInst, nearend, nearend, out, nrOfSamples, msInSndCardBuf) +#else +# include <webrtc/echo_cancellation.h> +# define TDAV_WebRtcAec_Create(aecInst) WebRtcAec_Create(aecInst) +# define TDAV_WebRtcAec_Free(aecInst) WebRtcAec_Free(aecInst) +# define TDAV_WebRtcAec_Init(aecInst, sampFreq, scSampFreq) WebRtcAec_Init(aecInst, sampFreq, scSampFreq) +# define TDAV_WebRtcAec_BufferFarend(aecInst, farend, nrOfSamples) WebRtcAec_BufferFarend(aecInst, farend, nrOfSamples) +# define TDAV_WebRtcAec_Process(aecInst, nearend, nearendH, out, outH, nrOfSamples, msInSndCardBuf, skew) WebRtcAec_Process(aecInst, nearend, nearendH, out, outH, nrOfSamples, msInSndCardBuf, skew) +#endif + +#if HAVE_SPEEX_DSP && PREFER_SPEEX_DENOISER +# include <speex/speex_preprocess.h> +#else +# if TDAV_UNDER_MOBILE // Use fixed implementation for Noise Suppression +# include <webrtc/noise_suppression_x.h> +# define TDAV_WebRtcNs_Process(NS_inst, spframe, spframe_H, outframe, outframe_H) WebRtcNsx_Process(NS_inst, spframe, spframe_H, outframe, outframe_H) +# define TDAV_WebRtcNs_Init(NS_inst, fs) WebRtcNsx_Init(NS_inst, fs) +# define TDAV_WebRtcNs_Free(NS_inst) WebRtcNsx_Free(NS_inst) +# define TDAV_WebRtcNs_Create(NS_inst) WebRtcNsx_Create(NS_inst) +# define TDAV_NsHandle NsxHandle +# else +# include <webrtc/noise_suppression.h> +# define TDAV_WebRtcNs_Process(NS_inst, spframe, spframe_H, outframe, outframe_H) WebRtcNs_Process(NS_inst, spframe, spframe_H, outframe, outframe_H) +# define TDAV_WebRtcNs_Init(NS_inst, fs) WebRtcNs_Init(NS_inst, fs) +# define TDAV_WebRtcNs_Free(NS_inst) WebRtcNs_Free(NS_inst) +# define TDAV_WebRtcNs_Create(NS_inst) WebRtcNs_Create(NS_inst) +# define TDAV_NsHandle NsHandle +# endif +#endif + +TDAV_BEGIN_DECLS + +extern const tmedia_denoise_plugin_def_t *tdav_webrtc_denoise_plugin_def_t; + +TDAV_END_DECLS + +#endif /* #if HAVE_WEBRTC */ + +#endif /* TINYDAV_WEBRTC_DENOISE_H */ diff --git a/tinyDAV/include/tinydav/audio/wasapi/tdav_consumer_wasapi.h b/tinyDAV/include/tinydav/audio/wasapi/tdav_consumer_wasapi.h new file mode 100644 index 0000000..0da22e8 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/wasapi/tdav_consumer_wasapi.h @@ -0,0 +1,39 @@ +/*Copyright (C) 2013 Doubango Telecom <http://www.doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +/**@file tdav_consumer_wasapi.h + * @brief Microsoft Windows Audio Session API (WASAPI) consumer. + * + */ +#ifndef TINYDAV_CONSUMER_WASAPI_H +#define TINYDAV_CONSUMER_WASAPI_H + +#include "tinydav_config.h" + +#if HAVE_WASAPI + +#include "tinydav/audio/tdav_consumer_audio.h" + +TDAV_BEGIN_DECLS + +TINYDAV_GEXTERN const struct tmedia_consumer_plugin_def_s *tdav_consumer_wasapi_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_WASAPI */ + +#endif /* TINYDAV_CONSUMER_WASAPI_H */ diff --git a/tinyDAV/include/tinydav/audio/wasapi/tdav_producer_wasapi.h b/tinyDAV/include/tinydav/audio/wasapi/tdav_producer_wasapi.h new file mode 100644 index 0000000..e215769 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/wasapi/tdav_producer_wasapi.h @@ -0,0 +1,40 @@ +/*Copyright (C) 2013 Mamadou Diop +* Copyright (C) 2013 Doubango Telecom <http://www.doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +*/ +/**@file tdav_producer_wasapi.h + * @brief Microsoft Windows Audio Session API (WASAPI) producer. + * + */ +#ifndef TINYDAV_PRODUCER_WASAPI_H +#define TINYDAV_PRODUCER_WASAPI_H + +#include "tinydav_config.h" + +#if HAVE_WASAPI + +#include "tinydav/audio/tdav_producer_audio.h" + +TDAV_BEGIN_DECLS + +TINYDAV_GEXTERN const struct tmedia_producer_plugin_def_s *tdav_producer_wasapi_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_WASAPI */ + +#endif /* TINYDAV_PRODUCER_WASAPI_H */ diff --git a/tinyDAV/include/tinydav/audio/waveapi/tdav_consumer_waveapi.h b/tinyDAV/include/tinydav/audio/waveapi/tdav_consumer_waveapi.h new file mode 100644 index 0000000..7e136cd --- /dev/null +++ b/tinyDAV/include/tinydav/audio/waveapi/tdav_consumer_waveapi.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_consumer_waveapi.h + * @brief Audio Consumer for Win32 and WinCE platforms. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + + */ +#ifndef TINYDAV_CONSUMER_WAVEAPI_H +#define TINYDAV_CONSUMER_WAVEAPI_H + +#include "tinydav_config.h" + +#if HAVE_WAVE_API + +#include "tinydav/audio/tdav_consumer_audio.h" + +#include <windows.h> + +TDAV_BEGIN_DECLS + +#define TDAV_WAVEAPI_CONSUMER_NOTIF_POS_COUNT 4 + +typedef struct tdav_consumer_waveapi_s +{ + TDAV_DECLARE_CONSUMER_AUDIO; + + tsk_bool_t started; + + WAVEFORMATEX wfx; + HWAVEOUT hWaveOut; + LPWAVEHDR hWaveHeaders[TDAV_WAVEAPI_CONSUMER_NOTIF_POS_COUNT]; + tsk_size_t bytes_per_notif; + + void* tid[1]; + HANDLE events[2]; + CRITICAL_SECTION cs; +} +tdav_consumer_waveapi_t; + +TINYDAV_GEXTERN const tmedia_consumer_plugin_def_t *tdav_consumer_waveapi_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_WAVE_API */ + +#endif /* TINYDAV_CONSUMER_WAVEAPI_H */ diff --git a/tinyDAV/include/tinydav/audio/waveapi/tdav_producer_waveapi.h b/tinyDAV/include/tinydav/audio/waveapi/tdav_producer_waveapi.h new file mode 100644 index 0000000..67614cf --- /dev/null +++ b/tinyDAV/include/tinydav/audio/waveapi/tdav_producer_waveapi.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_producer_waveapi.h + * @brief Audio Consumer for Win32 and WinCE platforms. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + + */ +#ifndef TINYDAV_PRODUCER_WAVEAPI_H +#define TINYDAV_PRODUCER_WAVEAPI_H + +#include "tinydav_config.h" + +#if HAVE_WAVE_API + +#include "tinydav/audio/tdav_producer_audio.h" + +#include <windows.h> + +TDAV_BEGIN_DECLS + +#define TDAV_WAVEAPI_PRODUCER_NOTIF_POS_COUNT 4 + +typedef struct tdav_producer_waveapi_s +{ + TDAV_DECLARE_PRODUCER_AUDIO; + + tsk_bool_t started; + + WAVEFORMATEX wfx; + HWAVEIN hWaveIn; + LPWAVEHDR hWaveHeaders[TDAV_WAVEAPI_PRODUCER_NOTIF_POS_COUNT]; + tsk_size_t bytes_per_notif; + + void* tid[1]; + HANDLE events[2]; + CRITICAL_SECTION cs; +} +tdav_producer_waveapi_t; + +TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tdav_producer_waveapi_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_WAVE_API */ + +#endif /* TINYDAV_PRODUCER_WAVEAPI_H */ |