From 1ebf5a5fcda0c9154e22ed02404fd46525a7fd9f Mon Sep 17 00:00:00 2001 From: bossiel Date: Wed, 10 Aug 2011 22:59:15 +0000 Subject: Move deprecated v1.0 from trunk to branches --- .../audio/coreaudio/tdav_consumer_coreaudio.h | 64 ++++ .../audio/coreaudio/tdav_producer_coreaudio.h | 42 +++ .../audio/directsound/tdav_consumer_dsound.h | 67 +++++ .../audio/directsound/tdav_producer_dsound.h | 66 +++++ .../include/tinydav/audio/tdav_consumer_audio.h | 83 ++++++ tinyDAV/include/tinydav/audio/tdav_jitterbuffer.h | 329 +++++++++++++++++++++ .../include/tinydav/audio/tdav_producer_audio.h | 68 +++++ tinyDAV/include/tinydav/audio/tdav_session_audio.h | 98 ++++++ tinyDAV/include/tinydav/audio/tdav_speex_denoise.h | 64 ++++ .../tinydav/audio/waveapi/tdav_consumer_waveapi.h | 68 +++++ .../tinydav/audio/waveapi/tdav_producer_waveapi.h | 68 +++++ .../include/tinydav/codecs/amr/tdav_codec_amr.h | 95 ++++++ .../include/tinydav/codecs/bv/tdav_codec_bv16.h | 67 +++++ .../include/tinydav/codecs/bv/tdav_codec_bv32.h | 0 .../include/tinydav/codecs/dtmf/tdav_codec_dtmf.h | 49 +++ tinyDAV/include/tinydav/codecs/g711/g711.h | 44 +++ .../include/tinydav/codecs/g711/tdav_codec_g711.h | 59 ++++ .../include/tinydav/codecs/g729/tdav_codec_g729.h | 80 +++++ .../include/tinydav/codecs/gsm/tdav_codec_gsm.h | 59 ++++ .../include/tinydav/codecs/h261/tdav_codec_h261.h | 84 ++++++ .../include/tinydav/codecs/h263/tdav_codec_h263.h | 116 ++++++++ .../include/tinydav/codecs/h264/tdav_codec_h264.h | 105 +++++++ .../tinydav/codecs/h264/tdav_codec_h264_rtp.h | 123 ++++++++ .../include/tinydav/codecs/ilbc/tdav_codec_ilbc.h | 64 ++++ .../tinydav/codecs/mp4ves/tdav_codec_mp4ves.h | 85 ++++++ .../include/tinydav/codecs/msrp/tdav_codec_msrp.h | 51 ++++ .../tinydav/codecs/speex/tdav_codec_speex.h | 79 +++++ .../tinydav/codecs/theora/tdav_codec_theora.h | 90 ++++++ tinyDAV/include/tinydav/msrp/tdav_consumer_msrp.h | 51 ++++ tinyDAV/include/tinydav/msrp/tdav_producer_msrp.h | 41 +++ tinyDAV/include/tinydav/msrp/tdav_session_msrp.h | 104 +++++++ tinyDAV/include/tinydav/tdav.h | 80 +++++ tinyDAV/include/tinydav/tdav_win32.h | 46 +++ .../include/tinydav/video/tdav_converter_video.h | 100 +++++++ .../include/tinydav/video/tdav_runnable_video.h | 54 ++++ tinyDAV/include/tinydav/video/tdav_session_video.h | 105 +++++++ 36 files changed, 2848 insertions(+) create mode 100644 tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_coreaudio.h create mode 100644 tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_coreaudio.h create mode 100644 tinyDAV/include/tinydav/audio/directsound/tdav_consumer_dsound.h create mode 100644 tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h create mode 100644 tinyDAV/include/tinydav/audio/tdav_consumer_audio.h create mode 100644 tinyDAV/include/tinydav/audio/tdav_jitterbuffer.h create mode 100644 tinyDAV/include/tinydav/audio/tdav_producer_audio.h create mode 100644 tinyDAV/include/tinydav/audio/tdav_session_audio.h create mode 100644 tinyDAV/include/tinydav/audio/tdav_speex_denoise.h create mode 100644 tinyDAV/include/tinydav/audio/waveapi/tdav_consumer_waveapi.h create mode 100644 tinyDAV/include/tinydav/audio/waveapi/tdav_producer_waveapi.h create mode 100644 tinyDAV/include/tinydav/codecs/amr/tdav_codec_amr.h create mode 100644 tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv16.h create mode 100644 tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv32.h create mode 100644 tinyDAV/include/tinydav/codecs/dtmf/tdav_codec_dtmf.h create mode 100644 tinyDAV/include/tinydav/codecs/g711/g711.h create mode 100644 tinyDAV/include/tinydav/codecs/g711/tdav_codec_g711.h create mode 100644 tinyDAV/include/tinydav/codecs/g729/tdav_codec_g729.h create mode 100644 tinyDAV/include/tinydav/codecs/gsm/tdav_codec_gsm.h create mode 100644 tinyDAV/include/tinydav/codecs/h261/tdav_codec_h261.h create mode 100644 tinyDAV/include/tinydav/codecs/h263/tdav_codec_h263.h create mode 100644 tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264.h create mode 100644 tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264_rtp.h create mode 100644 tinyDAV/include/tinydav/codecs/ilbc/tdav_codec_ilbc.h create mode 100644 tinyDAV/include/tinydav/codecs/mp4ves/tdav_codec_mp4ves.h create mode 100644 tinyDAV/include/tinydav/codecs/msrp/tdav_codec_msrp.h create mode 100644 tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h create mode 100644 tinyDAV/include/tinydav/codecs/theora/tdav_codec_theora.h create mode 100644 tinyDAV/include/tinydav/msrp/tdav_consumer_msrp.h create mode 100644 tinyDAV/include/tinydav/msrp/tdav_producer_msrp.h create mode 100644 tinyDAV/include/tinydav/msrp/tdav_session_msrp.h create mode 100644 tinyDAV/include/tinydav/tdav.h create mode 100644 tinyDAV/include/tinydav/tdav_win32.h create mode 100644 tinyDAV/include/tinydav/video/tdav_converter_video.h create mode 100644 tinyDAV/include/tinydav/video/tdav_runnable_video.h create mode 100644 tinyDAV/include/tinydav/video/tdav_session_video.h (limited to 'tinyDAV/include/tinydav') diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_coreaudio.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_coreaudio.h new file mode 100644 index 0000000..b79d1fd --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_consumer_coreaudio.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_coreaudio.h + * @brief Audio Consumer for MacOSX and iOS platforms. + * + * @author Laurent Etiemble + * + * @date Created: Sat Nov 8 16:54:58 2009 letiemble + */ +#ifndef TINYDAV_CONSUMER_COREAUDIO_H +#define TINYDAV_CONSUMER_COREAUDIO_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO + +#include +#include "tinydav/audio/tdav_consumer_audio.h" + +TDAV_BEGIN_DECLS + +#define CoreAudioPlayBuffers 3 + +typedef struct tdav_consumer_coreaudio_s +{ + TDAV_DECLARE_CONSUMER_AUDIO; + + tsk_bool_t started; + + AudioStreamBasicDescription description; + AudioQueueRef queue; + AudioQueueBufferRef buffers[CoreAudioPlayBuffers]; + + tsk_size_t buffer_size; +} +tdav_consumer_coreaudio_t; + +TINYDAV_GEXTERN const tmedia_consumer_plugin_def_t *tdav_consumer_coreaudio_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO */ + +#endif /* TINYDAV_CONSUMER_COREAUDIO_H */ diff --git a/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_coreaudio.h b/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_coreaudio.h new file mode 100644 index 0000000..9a30242 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/coreaudio/tdav_producer_coreaudio.h @@ -0,0 +1,42 @@ +/**@file tdav_consumer_coreaudio.h + * @brief Audio Producer for MacOSX and iOS platforms. + * + * @author Laurent Etiemble + * + * @date Created: Sat Nov 8 16:54:58 2009 letiemble + */ +#ifndef TINYDAV_PRODUCER_COREAUDIO_H +#define TINYDAV_PRODUCER_COREAUDIO_H + +#include "tinydav_config.h" + +#if HAVE_COREAUDIO + +#include +#include "tinydav/audio/tdav_producer_audio.h" + +TDAV_BEGIN_DECLS + +#define CoreAudioRecordBuffers 3 + +typedef struct tdav_producer_coreaudio_s +{ + TDAV_DECLARE_PRODUCER_AUDIO; + + tsk_bool_t started; + + AudioStreamBasicDescription description; + AudioQueueRef queue; + AudioQueueBufferRef buffers[CoreAudioRecordBuffers]; + + tsk_size_t buffer_size; +} +tdav_producer_coreaudio_t; + +TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tdav_producer_coreaudio_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_COREAUDIO */ + +#endif /* TINYDAV_PRODUCER_COREAUDIO_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..5dfec92 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/directsound/tdav_consumer_dsound.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_dsound.h + * @brief Microsoft DirectSound consumer. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#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" + +#include + +TDAV_BEGIN_DECLS + +#define TDAV_DSOUNS_CONSUMER_NOTIF_POS_COUNT 4 + +typedef struct tdav_consumer_dsound_s +{ + TDAV_DECLARE_CONSUMER_AUDIO; + + tsk_bool_t started; + tsk_size_t bytes_per_notif; + void* tid[1]; + + LPDIRECTSOUND device; + LPDIRECTSOUNDBUFFER primaryBuffer; + LPDIRECTSOUNDBUFFER secondaryBuffer; + HANDLE notifEvents[TDAV_DSOUNS_CONSUMER_NOTIF_POS_COUNT]; +} +tdav_consumer_dsound_t; + +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..c2b78b9 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/directsound/tdav_producer_dsound.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_producer_dsound.h + * @brief Microsoft DirectSound producer. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_PRODUCER_DSOUND_H +#define TINYDAV_PRODUCER_DSOUND_H + +#include "tinydav_config.h" + +#if HAVE_DSOUND_H + +#include "tinydav/audio/tdav_producer_audio.h" + +#include + +TDAV_BEGIN_DECLS + +#define TDAV_DSOUNS_PRODUCER_NOTIF_POS_COUNT 4 + +typedef struct tdav_producer_dsound_s +{ + TDAV_DECLARE_PRODUCER_AUDIO; + + tsk_bool_t started; + tsk_size_t bytes_per_notif; + void* tid[1]; + + LPDIRECTSOUNDCAPTURE device; + LPDIRECTSOUNDCAPTUREBUFFER captureBuffer; + HANDLE notifEvents[TDAV_DSOUNS_PRODUCER_NOTIF_POS_COUNT]; +} +tdav_producer_dsound_t; + +TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tdav_producer_dsound_plugin_def_t; + + +TDAV_END_DECLS + +#endif /* HAVE_DSOUND_H */ + +#endif /* TINYDAV_PRODUCER_DSOUND_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..91d3518 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_consumer_audio.h @@ -0,0 +1,83 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_audio.h + * @brief Base class for all Audio consumers. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CONSUMER_AUDIO_H +#define TINYDAV_CONSUMER_AUDIO_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_consumer.h" + +#include "tinydav/audio/tdav_jitterbuffer.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; + + uint8_t channels; + uint32_t rate; + uint8_t bits_per_sample; + uint8_t ptime; + + struct{ + jitterbuffer *jbuffer; + uint8_t jcodec; + uint64_t ref_timestamp; + } jb; + + struct tmedia_denoise_s* denoise; + + 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_put(tdav_consumer_audio_t* self, void** data, tsk_size_t size, const tsk_object_t* proto_hdr); +TINYDAV_API void* tdav_consumer_audio_get(tdav_consumer_audio_t* self, tsk_size_t* out_size); +void tdav_consumer_audio_set_denoise(tdav_consumer_audio_t* self, struct tmedia_denoise_s* denoise); +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..0d8aacc --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_jitterbuffer.h @@ -0,0 +1,329 @@ +/* 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 + * - SpeakUp + * + * Contributors: + * Jesse Kaijen + * + * 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" + +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 1settings->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 /* 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..f7faa54 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_producer_audio.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_producer_audio.h + * @brief Base class for all Audio producers. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#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; + + uint8_t channels; + uint32_t rate; + uint8_t bits_per_sample; + uint8_t ptime; +} +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_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..7af6643 --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_session_audio.h @@ -0,0 +1,98 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_session_audio.h + * @brief Audio Session plugin. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_SESSION_AUDIO_H +#define TINYDAV_SESSION_AUDIO_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_session.h" + +#include "tsk_safeobj.h" + +TDAV_BEGIN_DECLS + +// Forward declaration +struct trtp_manager_s; +struct tdav_consumer_audio_s; + +typedef tsk_list_t tdav_session_audio_dtmfe_L_t; + +typedef struct tdav_session_audio_s +{ + TMEDIA_DECLARE_SESSION_AUDIO; + + tsk_bool_t useIPv6; + + struct { + unsigned created; + unsigned started:1; + } timer; + + struct { + tmedia_codec_t* codec; + void* buffer; + tsk_size_t buffer_size; + } encoder; + + struct { + void* buffer; + tsk_size_t buffer_size; + } decoder; + + char* local_ip; + //uint16_t local_port; + + /* NAT Traversal context */ + tnet_nat_context_handle_t* natt_ctx; + + char* remote_ip; + uint16_t remote_port; + + tsk_bool_t rtcp_enabled; + + struct trtp_manager_s* rtp_manager; + + struct tmedia_consumer_s* consumer; + struct tmedia_producer_s* producer; + struct tmedia_denoise_s* denoise; + + tdav_session_audio_dtmfe_L_t* dtmf_events; + + TSK_DECLARE_SAFEOBJ; +} +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; + +TDAV_END_DECLS + +#endif /* TINYDAV_SESSION_AUDIO_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..03a086a --- /dev/null +++ b/tinyDAV/include/tinydav/audio/tdav_speex_denoise.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_speex_denoise.h + * @brief Speex Denoiser (Noise suppression, AGC, AEC) Plugin + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_SPEEX_DENOISE_H +#define TINYDAV_SPEEX_DENOISE_H + +#include "tinydav_config.h" + +#if HAVE_SPEEX_DSP + +#include "tinymedia/tmedia_denoise.h" + +#include +#include + +TDAV_BEGIN_DECLS + +/** Speex denoiser*/ +typedef struct tdav_speex_denoise_s +{ + TMEDIA_DECLARE_DENOISE; + + SpeexPreprocessState *preprocess_state; + SpeexEchoState *echo_state; + + spx_int16_t* echo_output_frame; + uint32_t frame_size; + tsk_bool_t vad_on; +} +tdav_speex_denoise_t; + +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/waveapi/tdav_consumer_waveapi.h b/tinyDAV/include/tinydav/audio/waveapi/tdav_consumer_waveapi.h new file mode 100644 index 0000000..aa93afc --- /dev/null +++ b/tinyDAV/include/tinydav/audio/waveapi/tdav_consumer_waveapi.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_waveapi.h + * @brief Audio Consumer for Win32 and WinCE platforms. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#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 + +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..ffee69c --- /dev/null +++ b/tinyDAV/include/tinydav/audio/waveapi/tdav_producer_waveapi.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_producer_waveapi.h + * @brief Audio Consumer for Win32 and WinCE platforms. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#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 + +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 */ diff --git a/tinyDAV/include/tinydav/codecs/amr/tdav_codec_amr.h b/tinyDAV/include/tinydav/codecs/amr/tdav_codec_amr.h new file mode 100644 index 0000000..b72d1a0 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/amr/tdav_codec_amr.h @@ -0,0 +1,95 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_amr.h + * @brief AMR-NB and AMR-WB codecs. + * RTP payloader/depayloader are based on RFC 4867 + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_AMR_H +#define TINYDAV_CODEC_AMR_H + +#include "tinydav_config.h" + +#if HAVE_OPENCORE_AMR + +#include "tinymedia/tmedia_codec.h" + +#include +#include + +TDAV_BEGIN_DECLS + +#define TDAV_CODEC_AMR(self) ((tdav_codec_amr_t*)(self)) + +typedef enum tdav_codec_amr_type_e +{ + tdav_codec_amr_type_nb, + tdav_codec_amr_type_wb, +} +tdav_codec_amr_type_t; + +typedef enum tdav_codec_amr_mode_e +{ + tdav_codec_amr_mode_oa, + tdav_codec_amr_mode_be, +} +tdav_codec_amr_mode_t; + +/** Base class for all AMR codecs */ +typedef struct tdav_codec_amr_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; + + tdav_codec_amr_type_t type; + tdav_codec_amr_mode_t mode; + + enum Mode encoder_mode; + void* encoder; + void* decoder; + + unsigned modes:16; /**< 0..7 for NB and 0..8 for WB plus SID, SPEECH_LOST, NO_DATA etc etc */ + unsigned mcp:2; /**< mode-change-periode (1 or 2) */ + unsigned mcc:2; /**< mode-change-capability (1 or 2) */ + unsigned mcn:1; /**< mode-change-neighnor (0 or 1) */ + unsigned crc:1; /**< 0 or 1 */ + unsigned robust_sorting:1; /**< robust-sorting (0 or 1) */ +} +tdav_codec_amr_t; + +#define TDAV_DECLARE_CODEC_AMR tdav_codec_amr_t __codec_amr__ + + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_amrnb_oa_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_amrnb_be_plugin_def_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_amrwb_oa_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_amrwb_be_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_OPENCORE_AMR */ + +#endif /* TINYDAV_CODEC_AMR_H */ diff --git a/tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv16.h b/tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv16.h new file mode 100644 index 0000000..0b5ffff --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv16.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_bv16.h + * @brief BroadVoice16 codec + * The payloader/depayloader follow RFC 4298 + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_BV16_H +#define TINYDAV_CODEC_BV16_H + +#include "tinydav_config.h" + +#if HAVE_BV16 + +#include "tinymedia/tmedia_codec.h" + + +TDAV_BEGIN_DECLS + +/** BV16 codec */ +typedef struct tdav_codec_bv16_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; + + struct { + void *state; + void *bs; + void *x; + } encoder; + + struct { + void *state; + void *bs; + void *x; + } decoder; +} +tdav_codec_bv16_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_bv16_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_BV16 */ + +#endif /* TINYDAV_CODEC_BV16_H */ diff --git a/tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv32.h b/tinyDAV/include/tinydav/codecs/bv/tdav_codec_bv32.h new file mode 100644 index 0000000..e69de29 diff --git a/tinyDAV/include/tinydav/codecs/dtmf/tdav_codec_dtmf.h b/tinyDAV/include/tinydav/codecs/dtmf/tdav_codec_dtmf.h new file mode 100644 index 0000000..13f6392 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/dtmf/tdav_codec_dtmf.h @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_dtmf.h + * @brief DTMF (RFC 4733) codec plugins. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_DTMF_H +#define TINYDAV_CODEC_DTMF_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_codec.h" + +TDAV_BEGIN_DECLS + +typedef struct tdav_codec_dtmf_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; +} +tdav_codec_dtmf_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_dtmf_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_DTMF_H */ diff --git a/tinyDAV/include/tinydav/codecs/g711/g711.h b/tinyDAV/include/tinydav/codecs/g711/g711.h new file mode 100644 index 0000000..9981f00 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/g711/g711.h @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_g711.h + * @brief G.711u and G.711a (a.k.a PCMU and PCMA) codec plugins. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_G711_IMPLEMENTATION_H +#define TINYDAV_CODEC_G711_IMPLEMENTATION_H + +#include "tinydav_config.h" + +TDAV_BEGIN_DECLS + +unsigned char linear2alaw(short pcm_val); +short alaw2linear(unsigned char a_val); +unsigned char linear2ulaw(short pcm_val); +short ulaw2linear(unsigned char u_val); + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_G711_IMPLEMENTATION_H */ diff --git a/tinyDAV/include/tinydav/codecs/g711/tdav_codec_g711.h b/tinyDAV/include/tinydav/codecs/g711/tdav_codec_g711.h new file mode 100644 index 0000000..73fd018 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/g711/tdav_codec_g711.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_g711.h + * @brief G.711u and G.711a (a.k.a PCMU and PCMA) codec plugins. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_G711_H +#define TINYDAV_CODEC_G711_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_codec.h" + +TDAV_BEGIN_DECLS + +/** G.711u codec */ +typedef struct tdav_codec_g711u_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; +} +tdav_codec_g711u_t; + +/** G.711a codec */ +typedef struct tdav_codec_g711a_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; +} +tdav_codec_g711a_t; + + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_g711a_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_g711u_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_G711_H */ diff --git a/tinyDAV/include/tinydav/codecs/g729/tdav_codec_g729.h b/tinyDAV/include/tinydav/codecs/g729/tdav_codec_g729.h new file mode 100644 index 0000000..92c5a9a --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/g729/tdav_codec_g729.h @@ -0,0 +1,80 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_g729.h + * @brief G729a codec. + * Source from: http://www.itu.int/rec/T-REC-G.729-199611-S!AnnA/en + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_G729_H +#define TINYDAV_CODEC_G729_H + +#include "tinydav_config.h" + +#if HAVE_G729 + +#include "tinymedia/tmedia_codec.h" + +#include "g729b/typedef.h" +#include "g729b/ld8a.h" + + +TDAV_BEGIN_DECLS + +/** G.729abb codec */ +typedef struct tdav_codec_g729ab_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; + + struct{ + Word16 prm[PRM_SIZE+1]; /* Analysis parameters + frame type */ + Word16 serial[SERIAL_SIZE]; /* Output bitstream buffer */ + + Word16 frame; /* frame counter */ + + /* For G.729B */ + Word16 vad_enable; + } encoder; + + struct{ + Word16 serial[SERIAL_SIZE]; /* Serial stream */ + Word16 synth_buf[L_FRAME+M], *synth; /* Synthesis */ + Word16 parm[PRM_SIZE+2]; /* Synthesis parameters */ + Word16 Az_dec[MP1*2]; /* Decoded Az for post-filter */ + Word16 T2[2]; /* Pitch lag for 2 subframes */ + + /* For G.729B */ + Word16 Vad; + } decoder; +} +tdav_codec_g729ab_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_g729ab_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_G729_H */ + +#endif diff --git a/tinyDAV/include/tinydav/codecs/gsm/tdav_codec_gsm.h b/tinyDAV/include/tinydav/codecs/gsm/tdav_codec_gsm.h new file mode 100644 index 0000000..0ed0d17 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/gsm/tdav_codec_gsm.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_gsm.h + * @brief GSM Full Rate Codec (Based on libgsm) + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_GSM_H +#define TINYDAV_CODEC_GSM_H + +#include "tinydav_config.h" + +#if HAVE_LIBGSM + +#include "tinymedia/tmedia_codec.h" + +#include + +TDAV_BEGIN_DECLS + +/** GSM codec */ +typedef struct tdav_codec_gsm_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; + + gsm encoder; + gsm decoder; +} +tdav_codec_gsm_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_gsm_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_LIBGSM */ + +#endif /* TINYDAV_CODEC_GSM_H */ diff --git a/tinyDAV/include/tinydav/codecs/h261/tdav_codec_h261.h b/tinyDAV/include/tinydav/codecs/h261/tdav_codec_h261.h new file mode 100644 index 0000000..939d19b --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/h261/tdav_codec_h261.h @@ -0,0 +1,84 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_h261.h + * @brief H.261 codec plugin. + * RTP payloader follows RFC 4587 + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_H261_H +#define TINYDAV_CODEC_H261_H + +#include "tinydav_config.h" + +#if HAVE_FFMPEG + +#include "tinymedia/tmedia_codec.h" + +#include + +TDAV_BEGIN_DECLS + +#define TDAV_CODEC_H261(self) ((tdav_codec_h261_t*)(self)) + +/** H.2261 codec */ +typedef struct tdav_codec_h261_s +{ + TMEDIA_DECLARE_CODEC_VIDEO; + + struct{ + uint8_t* ptr; + tsk_size_t size; + } rtp; + + // Encoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + void* buffer; + } encoder; + + // decoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + + void* accumulator; + uint8_t ebit; + tsk_size_t accumulator_pos; + uint16_t last_seq; + } decoder; +} +tdav_codec_h261_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h261_plugin_def_t; +TDAV_END_DECLS + + +#endif /* HAVE_FFMPEG */ + +#endif /* TINYDAV_CODEC_H261_H */ diff --git a/tinyDAV/include/tinydav/codecs/h263/tdav_codec_h263.h b/tinyDAV/include/tinydav/codecs/h263/tdav_codec_h263.h new file mode 100644 index 0000000..3103e4a --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/h263/tdav_codec_h263.h @@ -0,0 +1,116 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_h263.h + * @brief H.263-1996 and H.263-1998 codec plugins. + * RTP payloader follows RFC 4629 for H263+ and RFC 2190 for H263. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_H263_H +#define TINYDAV_CODEC_H263_H + +#include "tinydav_config.h" + +#if HAVE_FFMPEG + +#include "tinymedia/tmedia_codec.h" + +#include + +TDAV_BEGIN_DECLS + +#define TDAV_CODEC_H263(self) ((tdav_codec_h263_t*)(self)) + +typedef enum tdav_codec_h263_type_e +{ + tdav_codec_h263_1996, + tdav_codec_h263_1998, + tdav_codec_h263_2000, +} +tdav_codec_h263_type_t; + +/** H.263-1996 codec */ +typedef struct tdav_codec_h263_s +{ + TMEDIA_DECLARE_CODEC_VIDEO; + + tdav_codec_h263_type_t type; + + struct{ + uint8_t* ptr; + tsk_size_t size; + } rtp; + + // Encoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + void* buffer; + } encoder; + + // decoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + + void* accumulator; + uint8_t ebit; + tsk_size_t accumulator_pos; + uint16_t last_seq; + } decoder; +} +tdav_codec_h263_t; + +#define TDAV_DECLARE_CODEC_H263 tdav_codec_h263_t __codec_h263__ + +int tdav_codec_h263_init(tdav_codec_h263_t* self, tdav_codec_h263_type_t type, enum CodecID encoder, enum CodecID decoder); +int tdav_codec_h263_deinit(tdav_codec_h263_t* self); + +/** H.263-1998 codec */ +typedef struct tdav_codec_h263p_s +{ + TDAV_DECLARE_CODEC_H263; +} +tdav_codec_h263p_t; + +/** H.263-2000 codec */ +typedef struct tdav_codec_h263pp_s +{ + TDAV_DECLARE_CODEC_H263; +} +tdav_codec_h263pp_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h263_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h263p_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h263pp_plugin_def_t; + +TDAV_END_DECLS + + +#endif /* HAVE_FFMPEG */ + +#endif /* TINYDAV_CODEC_H263_H */ diff --git a/tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264.h b/tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264.h new file mode 100644 index 0000000..17c7680 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264.h @@ -0,0 +1,105 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_h264.h + * @brief H.264 codec plugin + * RTP payloader/depayloader follows RFC 3984. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_H264_H +#define TINYDAV_CODEC_H264_H + +#include "tinydav_config.h" + +#if HAVE_FFMPEG && (!defined(HAVE_H264) || HAVE_H264) + +#include "tinymedia/tmedia_codec.h" + +#include + +TDAV_BEGIN_DECLS + +// Because of FD, declare it here +typedef enum packetization_mode_e{ + Single_NAL_Unit_Mode = 0, /* Single NAL mode (Only nals from 1-23 are allowed) */ + Non_Interleaved_Mode = 1, /* Non-interleaved Mode: 1-23, 24 (STAP-A), 28 (FU-A) are allowed */ + Interleaved_Mode = 2 /* 25 (STAP-B), 26 (MTAP16), 27 (MTAP24), 28 (FU-A), and 29 (FU-B) are allowed.*/ +} +packetization_mode_t; + +typedef enum tdav_codec_h264_profile_e +{ + tdav_codec_h264_bp99, + + tdav_codec_h264_bp10, + tdav_codec_h264_bp20, + tdav_codec_h264_bp30, +} +tdav_codec_h264_profile_t; + +typedef struct tdav_codec_h264_s +{ + TMEDIA_DECLARE_CODEC_VIDEO; + + tdav_codec_h264_profile_t profile; + + packetization_mode_t pack_mode; + + struct{ + uint8_t* ptr; + tsk_size_t size; + } rtp; + + // Encoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + void* buffer; + int frame_count; + } encoder; + + // decoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + + void* accumulator; + tsk_size_t accumulator_pos; + uint16_t last_seq; + } decoder; +} +tdav_codec_h264_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h264_bp10_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h264_bp20_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_h264_bp30_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_FFMPEG */ + +#endif /* TINYDAV_CODEC_H264_H */ \ No newline at end of file diff --git a/tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264_rtp.h b/tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264_rtp.h new file mode 100644 index 0000000..83001b1 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/h264/tdav_codec_h264_rtp.h @@ -0,0 +1,123 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_h264_rtp.h + * @brief H.264 payloader/depayloder as per RFC 3984 + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_H264_RTP_H +#define TINYDAV_CODEC_H264_RTP_H + +#include "tinydav_config.h" + +#if HAVE_FFMPEG && (!defined(HAVE_H264) || HAVE_H264) + +#include "tsk_common.h" + +TDAV_BEGIN_DECLS + +#if TDAV_UNDER_WINDOWS +# define H264_RTP_PAYLOAD_SIZE 1300 +#else +# define H264_RTP_PAYLOAD_SIZE 900 +#endif + +#define H264_START_CODE_PREFIX_SIZE 4 + +struct tdav_codec_h264_s; + +extern uint8_t H264_START_CODE_PREFIX[4]; + +typedef enum profile_idc_e { + profile_idc_none = 0, + + profile_idc_baseline = 66, + profile_idc_extended = 88, + profile_idc_main = 77, + profile_idc_high = 100 +} +profile_idc_t; + +typedef struct profile_iop_s { + unsigned constraint_set0_flag:1; + unsigned constraint_set1_flag:1; + unsigned constraint_set2_flag:1; + unsigned reserved_zero_5bits:5; +} +profile_iop_t; + +typedef enum level_idc_e { + level_idc_none = 0, + + level_idc_1_0 = 10, + level_idc_1_b = 14, + level_idc_1_1 = 11, + level_idc_1_2 = 12, + level_idc_1_3 = 13, + level_idc_2_0 = 20, + level_idc_2_1 = 21, + level_idc_2_2 = 22, + level_idc_3_0 = 30 +} +level_idc_t; + + +/* 5.2. Common Structure of the RTP Payload Format + Type Packet Type name Section + --------------------------------------------------------- + 0 undefined - + 1-23 NAL unit Single NAL unit packet per H.264 5.6 + 24 STAP-A Single-time aggregation packet 5.7.1 + 25 STAP-B Single-time aggregation packet 5.7.1 + 26 MTAP16 Multi-time aggregation packet 5.7.2 + 27 MTAP24 Multi-time aggregation packet 5.7.2 + 28 FU-A Fragmentation unit 5.8 + 29 FU-B Fragmentation unit 5.8 + 30-31 undefined - +*/ +typedef enum nal_unit_type_e{ + undefined_0 = 0, + nal_unit, + stap_a = 24, + stap_b = 25, + mtap16 = 26, + mtap24 = 27, + fu_a = 28, + fu_b = 29, + undefined_30 = 30, + undefined_31 = 31 +} +nal_unit_type_t; + +int tdav_codec_h264_parse_profile(const char* profile_level_id, profile_idc_t *p_idc, profile_iop_t *p_iop, level_idc_t *l_idc); +int tdav_codec_h264_get_pay(const void* in_data, tsk_size_t in_size, const void** out_data, tsk_size_t *out_size, tsk_bool_t* append_scp); + +void tdav_codec_h264_rtp_callback(struct tdav_codec_h264_s *self, const void *data, tsk_size_t size, tsk_bool_t marker); + +TDAV_END_DECLS + +#endif /* HAVE_FFMPEG */ + +#endif /* TINYDAV_CODEC_H264_RTP_H */ diff --git a/tinyDAV/include/tinydav/codecs/ilbc/tdav_codec_ilbc.h b/tinyDAV/include/tinydav/codecs/ilbc/tdav_codec_ilbc.h new file mode 100644 index 0000000..974b7b8 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/ilbc/tdav_codec_ilbc.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_ilbc.h + * @brief iLBC codec + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_ILBC_H +#define TINYDAV_CODEC_ILBC_H + +#include "tinydav_config.h" + +#if HAVE_ILBC + +#include "tinymedia/tmedia_codec.h" + +#include +#include +#include + +TDAV_BEGIN_DECLS + +/** iLBC codec */ +typedef struct tdav_codec_ilbc_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; + + iLBC_Enc_Inst_t encoder; + iLBC_Dec_Inst_t decoder; + + float encblock[BLOCKL_MAX]; + float decblock[BLOCKL_MAX]; +} +tdav_codec_ilbc_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_ilbc_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_ILBC */ + +#endif /* TINYDAV_CODEC_ILBC_H */ diff --git a/tinyDAV/include/tinydav/codecs/mp4ves/tdav_codec_mp4ves.h b/tinyDAV/include/tinydav/codecs/mp4ves/tdav_codec_mp4ves.h new file mode 100644 index 0000000..ce75cba --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/mp4ves/tdav_codec_mp4ves.h @@ -0,0 +1,85 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_mp4ves.h + * @brief MP4V-ES codec plugin + * RTP payloader/depayloader follows RFC 3016. + * ISO-IEC-14496-2: http://www.csus.edu/indiv/p/pangj/aresearch/video_compression/presentation/ISO-IEC-14496-2_2001_MPEG4_Visual.pdf + * + * @author Mamadou Diop + * + * @date Created: Th Dec 2 16:54:58 2010 mdiop + */ +#ifndef TINYDAV_CODEC_MP4VES_H +#define TINYDAV_CODEC_MP4VES_H + +#include "tinydav_config.h" + +#if HAVE_FFMPEG + +#include "tinymedia/tmedia_codec.h" + +#include + +TDAV_BEGIN_DECLS + +typedef struct tdav_codec_mp4ves_s +{ + TMEDIA_DECLARE_CODEC_VIDEO; + + int profile; + + struct{ + uint8_t* ptr; + tsk_size_t size; + } rtp; + + // Encoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + void* buffer; + } encoder; + + // decoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + + void* accumulator; + uint8_t ebit; + tsk_size_t accumulator_pos; + uint16_t last_seq; + } decoder; +} +tdav_codec_mp4ves_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_mp4ves_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_FFMPEG */ + +#endif /* TINYDAV_CODEC_MP4VES_H */ + diff --git a/tinyDAV/include/tinydav/codecs/msrp/tdav_codec_msrp.h b/tinyDAV/include/tinydav/codecs/msrp/tdav_codec_msrp.h new file mode 100644 index 0000000..12b7057 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/msrp/tdav_codec_msrp.h @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_msrp.h + * @brief The Message Session Relay Protocol (MSRP) fake codec. + * Used for both Message (RFC 4975) and file transfer (RFC 5547). + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_MSRP_H +#define TINYDAV_CODEC_MSRP_H + +#include "tinydav_config.h" + +#include "tinymedia/tmedia_codec.h" + +TDAV_BEGIN_DECLS + +/** MSRP codec */ +typedef struct tdav_codec_msrp_s +{ + TMEDIA_DECLARE_CODEC_MSRP; +} +tdav_codec_msrp_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_msrp_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_MSRP_H */ diff --git a/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h b/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h new file mode 100644 index 0000000..9c70fb1 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_ilbc.h + * @brief Speex codecs + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_SPEEX_H +#define TINYDAV_CODEC_SPEEX_H + +#include "tinydav_config.h" + +#if HAVE_LIB_SPEEX + +#include "tinymedia/tmedia_codec.h" + +#include + +TDAV_BEGIN_DECLS + +typedef enum tdav_codec_speex_type_e +{ + tdav_codec_speex_type_nb, + tdav_codec_speex_type_wb, + tdav_codec_speex_type_uwb, +} +tdav_codec_speex_type_t; + +/** Speex codec */ +typedef struct tdav_codec_speex_s +{ + TMEDIA_DECLARE_CODEC_AUDIO; + + tdav_codec_speex_type_t type; + + struct{ + void* state; + SpeexBits bits; + tsk_size_t size; + } encoder; + + struct { + void* state; + SpeexBits bits; + spx_int16_t* buffer; + tsk_size_t size; + } decoder; +} +tdav_codec_speex_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_speex_nb_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_SPEEX_H */ + +#endif /* TINYDAV_CODEC_SPEEX_H */ diff --git a/tinyDAV/include/tinydav/codecs/theora/tdav_codec_theora.h b/tinyDAV/include/tinydav/codecs/theora/tdav_codec_theora.h new file mode 100644 index 0000000..38c7dbb --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/theora/tdav_codec_theora.h @@ -0,0 +1,90 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_codec_theora.h + * @brief Theora codec plugin + * RTP payloader/depayloader follows draft-barbato-avt-rtp-theora-01. + * For more information about Theora, http://www.theora.org/doc/Theora.pdf. + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CODEC_THEORA_H +#define TINYDAV_CODEC_THEORA_H + +#include "tinydav_config.h" + +#if HAVE_FFMPEG + +#include "tinymedia/tmedia_codec.h" + +#include "tsk_buffer.h" + +#include + +TDAV_BEGIN_DECLS + +typedef struct tdav_codec_theora_s +{ + TMEDIA_DECLARE_CODEC_VIDEO; + + struct{ + uint8_t* ptr; + tsk_size_t size; + } rtp; + + // Encoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + void* buffer; + + uint64_t conf_last; + int conf_count; + } encoder; + + // decoder + struct{ + AVCodec* codec; + AVCodecContext* context; + AVFrame* picture; + + tsk_bool_t opened; + uint8_t conf_ident[3]; + tsk_buffer_t* conf_pkt; + + void* accumulator; + uint8_t ebit; + tsk_size_t accumulator_pos; + uint16_t last_seq; + } decoder; +} +tdav_codec_theora_t; + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_theora_plugin_def_t; + +TDAV_END_DECLS + +#endif /* HAVE_FFMPEG */ + +#endif /* TINYDAV_CODEC_THEORA_H */ \ No newline at end of file diff --git a/tinyDAV/include/tinydav/msrp/tdav_consumer_msrp.h b/tinyDAV/include/tinydav/msrp/tdav_consumer_msrp.h new file mode 100644 index 0000000..9bb9017 --- /dev/null +++ b/tinyDAV/include/tinydav/msrp/tdav_consumer_msrp.h @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_msrp.h + * @brief The Message Session Relay Protocol (MSRP) consumer. + * Used for both Message (RFC 4975) and file transfer (RFC 5547). + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CONSUMER_MSRP_H +#define TINYDAV_CONSUMER_MSRP_H + +#include "tinydav_config.h" + +TDAV_BEGIN_DECLS + + +#define TDAV_CONSUMER_MSRP(self) ((tdav_consumer_msrp_t*)(self)) + + +typedef struct tdav_consumer_msrp_s +{ + TMEDIA_DECLARE_CONSUMER; +} +tdav_consumer_msrp_t; + + +TDAV_END_DECLS + +#endif /* TINYDAV_CONSUMER_MSRP_H */ diff --git a/tinyDAV/include/tinydav/msrp/tdav_producer_msrp.h b/tinyDAV/include/tinydav/msrp/tdav_producer_msrp.h new file mode 100644 index 0000000..4a14402 --- /dev/null +++ b/tinyDAV/include/tinydav/msrp/tdav_producer_msrp.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_producer_msrp.h + * @brief The Message Session Relay Protocol (MSRP) producer. + * Used for both Message (RFC 4975) and file transfer (RFC 5547). + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_PRODUCER_MSRP_H +#define TINYDAV_PRODUCER_MSRP_H + +#include "tinydav_config.h" + +TDAV_BEGIN_DECLS + + +TDAV_END_DECLS + +#endif /* TINYDAV_PRODUCER_MSRP_H */ diff --git a/tinyDAV/include/tinydav/msrp/tdav_session_msrp.h b/tinyDAV/include/tinydav/msrp/tdav_session_msrp.h new file mode 100644 index 0000000..f4be82a --- /dev/null +++ b/tinyDAV/include/tinydav/msrp/tdav_session_msrp.h @@ -0,0 +1,104 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_session_msrp.h + * @brief The Message Session Relay Protocol (MSRP) session. + * Used for both Message (RFC 4975) and file transfer (RFC 5547). + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ + +#ifndef TINYDAV_SESSION_MSRP_H +#define TINYDAV_SESSION_MSRP_H + +#include "tinydav_config.h" + +#include "tinymsrp/session/tmsrp_sender.h" +#include "tinymsrp/session/tmsrp_receiver.h" +#include "tmsrp.h" + +#include "tnet_transport.h" + +#include "tinymedia/tmedia_session.h" + +TDAV_BEGIN_DECLS + +typedef enum tdav_msrp_setup_e +{ + msrp_setup_active, + msrp_setup_passive, + msrp_setup_actpass, + msrp_setup_holdconn +} +tdav_msrp_setup_t; + +typedef struct tdav_session_msrp_s +{ + TMEDIA_DECLARE_SESSION_MSRP; + + tsk_bool_t useIPv6; + + tnet_transport_t *transport; + tmsrp_config_t* config; + tdav_msrp_setup_t setup; + tnet_fd_t connectedFD; // FullDuplex Socket + tmsrp_sender_t* sender; + tmsrp_receiver_t* receiver; + + char* local_ip; + //uint16_t local_port; + + /* NAT Traversal context */ + tnet_nat_context_handle_t* natt_ctx; + + char* remote_ip; + uint16_t remote_port; + + char* neg_accept_type; + char* neg_accept_w_type; + char* accept_types; + char* accept_w_types; + uint64_t chunck_duration; + + struct { + char* path; //full-path + char* selector; + char* disposition; + char* date; + char* icon; + char* transfer_id; + unsigned sent:1; + } file; + + unsigned fresh_conn:1; + unsigned offerer:1; + unsigned send_bodiless:1; +} +tdav_session_msrp_t; + +TINYDAV_GEXTERN const tmedia_session_plugin_def_t *tdav_session_msrp_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_SESSION_MSRP_H */ diff --git a/tinyDAV/include/tinydav/tdav.h b/tinyDAV/include/tinydav/tdav.h new file mode 100644 index 0000000..65c718c --- /dev/null +++ b/tinyDAV/include/tinydav/tdav.h @@ -0,0 +1,80 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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.h + * @brief tinyDAV. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYMEDIA_TDAV_H +#define TINYMEDIA_TDAV_H + +#include "tinydav_config.h" + +#include "tsk_common.h" /* tsk_bool_t */ + +TDAV_BEGIN_DECLS + +typedef enum tdav_codec_id_e +{ + tdav_codec_id_none = 0x00000000, + + tdav_codec_id_amr_nb_oa = 0x00000001<<0, + tdav_codec_id_amr_nb_be = 0x00000001<<1, + tdav_codec_id_amr_wb_oa = 0x00000001<<2, + tdav_codec_id_amr_wb_be = 0x00000001<<3, + tdav_codec_id_gsm = 0x00000001<<4, + tdav_codec_id_pcma = 0x00000001<<5, + tdav_codec_id_pcmu = 0x00000001<<6, + tdav_codec_id_ilbc = 0x00000001<<7, + tdav_codec_id_speex_nb = 0x00000001<<8, + tdav_codec_id_speex_wb = 0x00000001<<9, + tdav_codec_id_speex_uwb = 0x00000001<<10, + tdav_codec_id_bv16 = 0x00000001<<11, + tdav_codec_id_bv32 = 0x00000001<<12, + tdav_codec_id_evrc = 0x00000001<<13, + tdav_codec_id_g729ab = 0x00000001<<14, + + /* room for new Audio codecs */ + + tdav_codec_id_h261 = 0x00010000<<0, + tdav_codec_id_h263 = 0x00010000<<1, + tdav_codec_id_h263p = 0x00010000<<2, + tdav_codec_id_h263pp = 0x00010000<<3, + tdav_codec_id_h264_bp10 = 0x00010000<<4, + tdav_codec_id_h264_bp20 = 0x00010000<<5, + tdav_codec_id_h264_bp30 = 0x00010000<<6, + tdav_codec_id_theora = 0x00010000<<7, + tdav_codec_id_mp4ves_es = 0x00010000<<8, + +} +tdav_codec_id_t; + +TINYDAV_API int tdav_init(); +TINYDAV_API void tdav_set_codecs(tdav_codec_id_t codecs); +TINYDAV_API tsk_bool_t tdav_codec_is_supported(tdav_codec_id_t codec); +TINYDAV_API int tdav_deinit(); + +TDAV_END_DECLS + +#endif /* TINYMEDIA_TDAV_H */ diff --git a/tinyDAV/include/tinydav/tdav_win32.h b/tinyDAV/include/tinydav/tdav_win32.h new file mode 100644 index 0000000..4e85a9e --- /dev/null +++ b/tinyDAV/include/tinydav/tdav_win32.h @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_win32.h + * @brief tinyDAV WIN32 helper functions. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYMEDIA_TDAV_WIN32_H +#define TINYMEDIA_TDAV_WIN32_H + +#include "tinydav_config.h" + +#if TDAV_UNDER_WINDOWS + +#include + +TDAV_BEGIN_DECLS + +void tdav_win32_print_error(const char* func, HRESULT hr); + +TDAV_END_DECLS + +#endif /* TDAV_UNDER_WINDOWS */ + +#endif /* TINYMEDIA_TDAV_WIN32_H */ diff --git a/tinyDAV/include/tinydav/video/tdav_converter_video.h b/tinyDAV/include/tinydav/video/tdav_converter_video.h new file mode 100644 index 0000000..4d52fba --- /dev/null +++ b/tinyDAV/include/tinydav/video/tdav_converter_video.h @@ -0,0 +1,100 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_converter_video.h + * @brief Video converter. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_CONVERTER_VIDEO_H +#define TINYDAV_CONVERTER_VIDEO_H + +#include "tinydav_config.h" + + +#include "tinymedia/tmedia_common.h" + +#if HAVE_FFMPEG || HAVE_SWSSCALE +#include +#include +#endif + +#include "tsk_object.h" + +TDAV_BEGIN_DECLS + +typedef struct tdav_converter_video_s +{ + TSK_DECLARE_OBJECT; + +#if HAVE_FFMPEG || HAVE_SWSSCALE + struct SwsContext *context; + + enum PixelFormat pixfmt; + + AVFrame* srcFrame; + AVFrame* dstFrame; + + struct { + struct SwsContext *context; + AVFrame* frame; + uint8_t* buffer; + } rot; + +#endif + + tsk_size_t srcWidth; + tsk_size_t srcHeight; + + tsk_size_t dstWidth; + tsk_size_t dstHeight; + + tsk_bool_t toYUV420; + + int rotation; +} +tdav_converter_video_t; + +tdav_converter_video_t* tdav_converter_video_create(tsk_size_t srcWidth, tsk_size_t srcHeight, tsk_size_t dstWidth, tsk_size_t dstHeight, tmedia_chroma_t chroma, tsk_bool_t toYUV420); +tsk_size_t tdav_converter_video_convert(tdav_converter_video_t* self, const void* buffer, void** output, tsk_size_t* output_max_size); + +#define tdav_converter_video_init(self, _rotation/*...To be completed with other parameters*/) \ + if((self)){ \ + (self)->rotation = (_rotation); \ + } + +#define tdav_converter_video_flip(frame, height) \ + frame->data[0] += frame->linesize[0] * (height -1); \ + frame->data[1] += frame->linesize[1] * ((height -1)/2); \ + frame->data[2] += frame->linesize[2] * ((height -1)/2); \ + \ + frame->linesize[0] *= -1; \ + frame->linesize[1] *= -1; \ + frame->linesize[2] *= -1; + +TINYDAV_GEXTERN const tsk_object_def_t *tdav_converter_video_def_t; + +TDAV_END_DECLS + + +#endif /* TINYDAV_CONVERTER_VIDEO_H */ diff --git a/tinyDAV/include/tinydav/video/tdav_runnable_video.h b/tinyDAV/include/tinydav/video/tdav_runnable_video.h new file mode 100644 index 0000000..3b461de --- /dev/null +++ b/tinyDAV/include/tinydav/video/tdav_runnable_video.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_runnable_video.h + * @brief Video runnable used by codecs. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_RUNNABLE_VIDEO_H +#define TINYDAV_RUNNABLE_VIDEO_H + +#include "tinydav_config.h" + +#include "tsk_runnable.h" + +TDAV_BEGIN_DECLS + +typedef struct tdav_runnable_video_s +{ + TSK_DECLARE_RUNNABLE; + + const void* userdata; +} +tdav_runnable_video_t; + +tdav_runnable_video_t* tdav_runnable_video_create(tsk_runnable_func_run run_f, const void* userdata); +int tdav_runnable_video_start(tdav_runnable_video_t* self); +int tdav_runnable_video_stop(tdav_runnable_video_t* self); + +TINYDAV_GEXTERN const tsk_object_def_t *tdav_runnable_video_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_RUNNABLE_VIDEO_H */ diff --git a/tinyDAV/include/tinydav/video/tdav_session_video.h b/tinyDAV/include/tinydav/video/tdav_session_video.h new file mode 100644 index 0000000..01a80f2 --- /dev/null +++ b/tinyDAV/include/tinydav/video/tdav_session_video.h @@ -0,0 +1,105 @@ +/* +* Copyright (C) 2009-2010 Mamadou Diop. +* +* Contact: 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_session_video.h + * @brief Video Session plugin. + * + * @author Mamadou Diop + * + * @date Created: Sat Nov 8 16:54:58 2009 mdiop + */ +#ifndef TINYDAV_SESSION_VIDEO_H +#define TINYDAV_SESSION_VIDEO_H + +#include "tinydav_config.h" + +#include "tinydav/video/tdav_converter_video.h" + +#include "tinymedia/tmedia_session.h" + +#include "tsk_safeobj.h" + +TDAV_BEGIN_DECLS + +// Forward declaration +struct trtp_manager_s; +struct tdav_consumer_video_s; +struct tdav_converter_video_s; + +typedef struct tdav_session_video_s +{ + TMEDIA_DECLARE_SESSION_VIDEO; + + tsk_bool_t useIPv6; + + char* local_ip; + + char* remote_ip; + uint16_t remote_port; + + /* NAT Traversal context */ + tnet_nat_context_handle_t* natt_ctx; + + tsk_bool_t rtcp_enabled; + + struct trtp_manager_s* rtp_manager; + + struct{ + void* buffer; + tsk_size_t buffer_size; + + void* conv_buffer; + tsk_size_t conv_buffer_size; + } encoder; + + struct{ + void* buffer; + tsk_size_t buffer_size; + + void* conv_buffer; + tsk_size_t conv_buffer_size; + } decoder; + + struct tmedia_consumer_s* consumer; + struct tmedia_producer_s* producer; + struct { + tsk_size_t consumerLastWidth; + tsk_size_t consumerLastHeight; + struct tdav_converter_video_s* fromYUV420; + + tsk_size_t producerWidth; + tsk_size_t producerHeight; + tsk_size_t xProducerSize; + struct tdav_converter_video_s* toYUV420; + } conv; + + TSK_DECLARE_SAFEOBJ; +} +tdav_session_video_t; + +#define TDAV_SESSION_VIDEO(self) ((tdav_session_video_t*)(self)) + +TINYDAV_GEXTERN const tmedia_session_plugin_def_t *tdav_session_video_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_SESSION_VIDEO_H */ -- cgit v1.1