Update cfscket transport to report correct in/out bytes

This commit is contained in:
System Administrator 2016-02-25 00:54:48 +01:00
parent 40a8a15df6
commit 3d46d2f68c
58 changed files with 9818 additions and 9814 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
AStyle.sh Normal file → Executable file
View File

View File

@ -1,88 +1,88 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
*/ */
#include "ActionConfig.h" #include "ActionConfig.h"
ActionConfig::ActionConfig() ActionConfig::ActionConfig()
{ {
m_pHandle = tsip_action_create(tsip_atype_config, m_pHandle = tsip_action_create(tsip_atype_config,
TSIP_ACTION_SET_NULL()); TSIP_ACTION_SET_NULL());
} }
ActionConfig::~ActionConfig() ActionConfig::~ActionConfig()
{ {
TSK_OBJECT_SAFE_FREE(m_pHandle); TSK_OBJECT_SAFE_FREE(m_pHandle);
} }
bool ActionConfig::addHeader(const char* name, const char* value) bool ActionConfig::addHeader(const char* name, const char* value)
{ {
return (tsip_action_set(m_pHandle, return (tsip_action_set(m_pHandle,
TSIP_ACTION_SET_HEADER(name, value), TSIP_ACTION_SET_HEADER(name, value),
TSIP_ACTION_SET_NULL()) == 0); TSIP_ACTION_SET_NULL()) == 0);
} }
bool ActionConfig::addPayload(const void* payload, unsigned len) bool ActionConfig::addPayload(const void* payload, unsigned len)
{ {
return (tsip_action_set(m_pHandle, return (tsip_action_set(m_pHandle,
TSIP_ACTION_SET_PAYLOAD(payload, len), TSIP_ACTION_SET_PAYLOAD(payload, len),
TSIP_ACTION_SET_NULL()) == 0); TSIP_ACTION_SET_NULL()) == 0);
} }
bool ActionConfig::setActiveMedia(twrap_media_type_t type) bool ActionConfig::setActiveMedia(twrap_media_type_t type)
{ {
tmedia_type_t media_type = twrap_get_native_media_type(type); tmedia_type_t media_type = twrap_get_native_media_type(type);
return (tsip_action_set(m_pHandle, return (tsip_action_set(m_pHandle,
TSIP_ACTION_SET_MEDIA_TYPE(media_type), TSIP_ACTION_SET_MEDIA_TYPE(media_type),
TSIP_ACTION_SET_NULL()) == 0); TSIP_ACTION_SET_NULL()) == 0);
} }
ActionConfig* ActionConfig::setResponseLine(short code, const char* phrase) ActionConfig* ActionConfig::setResponseLine(short code, const char* phrase)
{ {
int32_t _code = code; int32_t _code = code;
tsip_action_set(m_pHandle, tsip_action_set(m_pHandle,
TSIP_ACTION_SET_RESP_LINE(_code, phrase), TSIP_ACTION_SET_RESP_LINE(_code, phrase),
TSIP_ACTION_SET_NULL()); TSIP_ACTION_SET_NULL());
return this; return this;
} }
ActionConfig* ActionConfig::setMediaString(twrap_media_type_t type, const char* key, const char* value) ActionConfig* ActionConfig::setMediaString(twrap_media_type_t type, const char* key, const char* value)
{ {
tmedia_type_t media_type = twrap_get_native_media_type(type); tmedia_type_t media_type = twrap_get_native_media_type(type);
tsip_action_set(m_pHandle, tsip_action_set(m_pHandle,
TSIP_ACTION_SET_MEDIA( TSIP_ACTION_SET_MEDIA(
TMEDIA_SESSION_SET_STR(media_type, key, value), TMEDIA_SESSION_SET_STR(media_type, key, value),
TMEDIA_SESSION_SET_NULL()), TMEDIA_SESSION_SET_NULL()),
TSIP_ACTION_SET_NULL()); TSIP_ACTION_SET_NULL());
return this; return this;
} }
ActionConfig* ActionConfig::setMediaInt(twrap_media_type_t type, const char* key, int value) ActionConfig* ActionConfig::setMediaInt(twrap_media_type_t type, const char* key, int value)
{ {
tmedia_type_t media_type = twrap_get_native_media_type(type); tmedia_type_t media_type = twrap_get_native_media_type(type);
tsip_action_set(m_pHandle, tsip_action_set(m_pHandle,
TSIP_ACTION_SET_MEDIA( TSIP_ACTION_SET_MEDIA(
TMEDIA_SESSION_SET_INT32(media_type, key, value), TMEDIA_SESSION_SET_INT32(media_type, key, value),
TMEDIA_SESSION_SET_NULL()), TMEDIA_SESSION_SET_NULL()),
TSIP_ACTION_SET_NULL()); TSIP_ACTION_SET_NULL());
return this; return this;
} }

View File

@ -1,52 +1,52 @@
/* Copyright (C) 2010-2011 Mamadou Diop. /* Copyright (C) 2010-2011 Mamadou Diop.
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
*/ */
#ifndef TINYWRAP_ACTIONCONFIG_H #ifndef TINYWRAP_ACTIONCONFIG_H
#define TINYWRAP_ACTIONCONFIG_H #define TINYWRAP_ACTIONCONFIG_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinysip.h" #include "tinysip.h"
#include "Common.h" #include "Common.h"
class TINYWRAP_API ActionConfig class TINYWRAP_API ActionConfig
{ {
public: public:
ActionConfig(); ActionConfig();
virtual ~ActionConfig(); virtual ~ActionConfig();
bool addHeader(const char* name, const char* value); bool addHeader(const char* name, const char* value);
bool addPayload(const void* payload, unsigned len); bool addPayload(const void* payload, unsigned len);
bool setActiveMedia(twrap_media_type_t type); bool setActiveMedia(twrap_media_type_t type);
ActionConfig* setResponseLine(short code, const char* phrase); ActionConfig* setResponseLine(short code, const char* phrase);
ActionConfig* setMediaString(twrap_media_type_t type, const char* key, const char* value); ActionConfig* setMediaString(twrap_media_type_t type, const char* key, const char* value);
ActionConfig* setMediaInt(twrap_media_type_t type, const char* key, int value); ActionConfig* setMediaInt(twrap_media_type_t type, const char* key, int value);
private: private:
tsip_action_handle_t* m_pHandle; tsip_action_handle_t* m_pHandle;
#if !defined(SWIG) #if !defined(SWIG)
public: public:
const inline tsip_action_handle_t* getHandle()const { const inline tsip_action_handle_t* getHandle()const {
return m_pHandle; return m_pHandle;
} }
#endif #endif
}; };
#endif /* TINYWRAP_ACTIONCONFIG_H */ #endif /* TINYWRAP_ACTIONCONFIG_H */

View File

@ -1,73 +1,73 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
/**@file AudioResampler.cxx /**@file AudioResampler.cxx
* @brief Audio resampler * @brief Audio resampler
* *
* @author Mamadou Diop <diopmamadou(at)doubango.org> * @author Mamadou Diop <diopmamadou(at)doubango.org>
*/ */
#include "AudioResampler.h" #include "AudioResampler.h"
#include "tinymedia/tmedia_resampler.h" #include "tinymedia/tmedia_resampler.h"
#include "tsk_debug.h" #include "tsk_debug.h"
AudioResampler::AudioResampler(uint32_t nInFreq, uint32_t nOutFreq, uint32_t nFrameDuration, uint32_t nChannels, uint32_t nQuality): AudioResampler::AudioResampler(uint32_t nInFreq, uint32_t nOutFreq, uint32_t nFrameDuration, uint32_t nChannels, uint32_t nQuality):
m_nOutFreq(nOutFreq), m_nOutFreq(nOutFreq),
m_nInFreq(nInFreq), m_nInFreq(nInFreq),
m_nFrameDuration(nFrameDuration), m_nFrameDuration(nFrameDuration),
m_nChannels(nChannels), m_nChannels(nChannels),
m_nQuality(nQuality) m_nQuality(nQuality)
{ {
if ((m_pWrappedResampler = tmedia_resampler_create())) { if ((m_pWrappedResampler = tmedia_resampler_create())) {
int ret; int ret;
if ((ret = tmedia_resampler_open(m_pWrappedResampler, nInFreq, nOutFreq, nFrameDuration, nChannels, nChannels, m_nQuality, 16))) { if ((ret = tmedia_resampler_open(m_pWrappedResampler, nInFreq, nOutFreq, nFrameDuration, nChannels, nChannels, m_nQuality, 16))) {
TSK_DEBUG_ERROR("Failed to open audio resampler (%d)", ret); TSK_DEBUG_ERROR("Failed to open audio resampler (%d)", ret);
TSK_OBJECT_SAFE_FREE(m_pWrappedResampler); TSK_OBJECT_SAFE_FREE(m_pWrappedResampler);
} }
} }
else { else {
TSK_DEBUG_ERROR("No audio resampler could be found. Did you forget to call tdav_init()?"); TSK_DEBUG_ERROR("No audio resampler could be found. Did you forget to call tdav_init()?");
} }
} }
AudioResampler::~AudioResampler() AudioResampler::~AudioResampler()
{ {
TSK_OBJECT_SAFE_FREE(m_pWrappedResampler); TSK_OBJECT_SAFE_FREE(m_pWrappedResampler);
} }
uint32_t AudioResampler::process(const void* pInData, uint32_t nInSizeInBytes, void* pOutData, uint32_t nOutSizeInBytes) uint32_t AudioResampler::process(const void* pInData, uint32_t nInSizeInBytes, void* pOutData, uint32_t nOutSizeInBytes)
{ {
if(!m_pWrappedResampler) { if(!m_pWrappedResampler) {
TSK_DEBUG_ERROR("Embedded resampler is invalid"); TSK_DEBUG_ERROR("Embedded resampler is invalid");
return 0; return 0;
} }
if(nInSizeInBytes < getInputRequiredSizeInShort()/2) { if(nInSizeInBytes < getInputRequiredSizeInShort()/2) {
TSK_DEBUG_ERROR("Input buffer is too short"); TSK_DEBUG_ERROR("Input buffer is too short");
return 0; return 0;
} }
if(nOutSizeInBytes < getOutputRequiredSizeInShort()/2) { if(nOutSizeInBytes < getOutputRequiredSizeInShort()/2) {
TSK_DEBUG_ERROR("Output buffer is too short"); TSK_DEBUG_ERROR("Output buffer is too short");
return 0; return 0;
} }
return 2*tmedia_resampler_process(m_pWrappedResampler, (uint16_t*)pInData, nInSizeInBytes/2, (uint16_t*)pOutData, nOutSizeInBytes/2); return 2*tmedia_resampler_process(m_pWrappedResampler, (uint16_t*)pInData, nInSizeInBytes/2, (uint16_t*)pOutData, nOutSizeInBytes/2);
} }

View File

@ -1,62 +1,62 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
/**@file AudioResampler.h /**@file AudioResampler.h
* @brief Audio resampler * @brief Audio resampler
* *
* @author Mamadou Diop <diopmamadou(at)doubango.org> * @author Mamadou Diop <diopmamadou(at)doubango.org>
*/ */
#ifndef TINYWRAP_AUDIO_RESAMPLER_H #ifndef TINYWRAP_AUDIO_RESAMPLER_H
#define TINYWRAP_AUDIO_RESAMPLER_H #define TINYWRAP_AUDIO_RESAMPLER_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tsk_common.h" #include "tsk_common.h"
class AudioResampler class AudioResampler
{ {
public: public:
AudioResampler(uint32_t nInFreq, uint32_t nOutFreq, uint32_t nFrameDuration, uint32_t nChannels, uint32_t nQuality); AudioResampler(uint32_t nInFreq, uint32_t nOutFreq, uint32_t nFrameDuration, uint32_t nChannels, uint32_t nQuality);
~AudioResampler(); ~AudioResampler();
public: public:
inline bool isValid() { inline bool isValid() {
return (m_pWrappedResampler != tsk_null); return (m_pWrappedResampler != tsk_null);
} }
inline uint32_t getOutputRequiredSizeInShort() { inline uint32_t getOutputRequiredSizeInShort() {
return (m_nOutFreq * m_nFrameDuration)/1000; return (m_nOutFreq * m_nFrameDuration)/1000;
} }
inline uint32_t getInputRequiredSizeInShort() { inline uint32_t getInputRequiredSizeInShort() {
return (m_nInFreq * m_nFrameDuration)/1000; return (m_nInFreq * m_nFrameDuration)/1000;
} }
uint32_t process(const void* pInData, uint32_t nInSizeInBytes, void* pOutData, uint32_t nOutSizeInBytes); uint32_t process(const void* pInData, uint32_t nInSizeInBytes, void* pOutData, uint32_t nOutSizeInBytes);
private: private:
struct tmedia_resampler_s* m_pWrappedResampler; struct tmedia_resampler_s* m_pWrappedResampler;
uint32_t m_nOutFreq; uint32_t m_nOutFreq;
uint32_t m_nInFreq; uint32_t m_nInFreq;
uint32_t m_nFrameDuration; uint32_t m_nFrameDuration;
uint32_t m_nChannels; uint32_t m_nChannels;
uint32_t m_nQuality; uint32_t m_nQuality;
}; };
#endif /* TINYWRAP_AUDIO_RESAMPLER_H */ #endif /* TINYWRAP_AUDIO_RESAMPLER_H */

View File

@ -1,95 +1,95 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_COMMON_H #ifndef TINYWRAP_COMMON_H
#define TINYWRAP_COMMON_H #define TINYWRAP_COMMON_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#if ANDROID #if ANDROID
# define dyn_cast static_cast # define dyn_cast static_cast
# define __JNIENV JNIEnv # define __JNIENV JNIEnv
#else #else
# define dyn_cast dynamic_cast # define dyn_cast dynamic_cast
# define __JNIENV void # define __JNIENV void
#endif #endif
typedef enum twrap_media_type_e { typedef enum twrap_media_type_e {
// because of Java don't use OR // because of Java don't use OR
twrap_media_none = 0x00, twrap_media_none = 0x00,
twrap_media_audio = 0x01, // (0x01 << 0) twrap_media_audio = 0x01, // (0x01 << 0)
twrap_media_video = 0x02, // (0x01 << 1) twrap_media_video = 0x02, // (0x01 << 1)
twrap_media_msrp = 0x04, // (0x01 << 2) twrap_media_msrp = 0x04, // (0x01 << 2)
twrap_media_t140 = 0x08, // (0x01 << 3) twrap_media_t140 = 0x08, // (0x01 << 3)
twrap_media_bfcp = 0x10, // (0x01 << 4) twrap_media_bfcp = 0x10, // (0x01 << 4)
twrap_media_bfcp_audio = 0x30, // (0x01 << 5) | twrap_media_bfcp; twrap_media_bfcp_audio = 0x30, // (0x01 << 5) | twrap_media_bfcp;
twrap_media_bfcp_video = 0x50, // (0x01 << 6) | twrap_media_bfcp; twrap_media_bfcp_video = 0x50, // (0x01 << 6) | twrap_media_bfcp;
twrap_media_audiovideo = 0x03, /* @deprecated */ twrap_media_audiovideo = 0x03, /* @deprecated */
twrap_media_audio_video = twrap_media_audiovideo, twrap_media_audio_video = twrap_media_audiovideo,
} }
twrap_media_type_t; twrap_media_type_t;
#if !defined(SWIG) #if !defined(SWIG)
#include "tinymedia/tmedia_common.h" #include "tinymedia/tmedia_common.h"
struct media_type_bind_s { struct media_type_bind_s {
twrap_media_type_t twrap; twrap_media_type_t twrap;
tmedia_type_t tnative; tmedia_type_t tnative;
}; };
static const struct media_type_bind_s __media_type_binds[] = { static const struct media_type_bind_s __media_type_binds[] = {
{ twrap_media_msrp, tmedia_msrp }, { twrap_media_msrp, tmedia_msrp },
{ twrap_media_audio , tmedia_audio }, { twrap_media_audio , tmedia_audio },
{ twrap_media_video, tmedia_video }, { twrap_media_video, tmedia_video },
{ twrap_media_audio_video, (tmedia_type_t)(tmedia_audio | tmedia_video) }, { twrap_media_audio_video, (tmedia_type_t)(tmedia_audio | tmedia_video) },
{ twrap_media_t140, tmedia_t140 }, { twrap_media_t140, tmedia_t140 },
{ twrap_media_bfcp, tmedia_bfcp }, { twrap_media_bfcp, tmedia_bfcp },
{ twrap_media_bfcp_audio, tmedia_bfcp_audio }, { twrap_media_bfcp_audio, tmedia_bfcp_audio },
{ twrap_media_bfcp_video, tmedia_bfcp_video }, { twrap_media_bfcp_video, tmedia_bfcp_video },
}; };
static const tsk_size_t __media_type_binds_count = sizeof(__media_type_binds)/sizeof(__media_type_binds[0]); static const tsk_size_t __media_type_binds_count = sizeof(__media_type_binds)/sizeof(__media_type_binds[0]);
static tmedia_type_t twrap_get_native_media_type(twrap_media_type_t type) static tmedia_type_t twrap_get_native_media_type(twrap_media_type_t type)
{ {
tsk_size_t u; tsk_size_t u;
tmedia_type_t t = tmedia_none; tmedia_type_t t = tmedia_none;
for (u = 0; u < __media_type_binds_count; ++u) { for (u = 0; u < __media_type_binds_count; ++u) {
if ((__media_type_binds[u].twrap & type) == __media_type_binds[u].twrap) { if ((__media_type_binds[u].twrap & type) == __media_type_binds[u].twrap) {
t = (tmedia_type_t)(t | __media_type_binds[u].tnative); t = (tmedia_type_t)(t | __media_type_binds[u].tnative);
} }
} }
return t; return t;
} }
static twrap_media_type_t twrap_get_wrapped_media_type(tmedia_type_t type) static twrap_media_type_t twrap_get_wrapped_media_type(tmedia_type_t type)
{ {
twrap_media_type_t t = twrap_media_none; twrap_media_type_t t = twrap_media_none;
tsk_size_t u; tsk_size_t u;
for (u = 0; u < __media_type_binds_count; ++u) { for (u = 0; u < __media_type_binds_count; ++u) {
if ((__media_type_binds[u].tnative & type) == __media_type_binds[u].tnative) { if ((__media_type_binds[u].tnative & type) == __media_type_binds[u].tnative) {
t = (twrap_media_type_t)(t | __media_type_binds[u].twrap); t = (twrap_media_type_t)(t | __media_type_binds[u].twrap);
} }
} }
return t; return t;
} }
#endif #endif
#endif /* TINYWRAP_COMMON_H */ #endif /* TINYWRAP_COMMON_H */

View File

@ -1,145 +1,145 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "DDebug.h" #include "DDebug.h"
#include "SipStack.h" #include "SipStack.h"
#include "Common.h" #include "Common.h"
#if ANDROID /* callbacks will fail with jni */ #if ANDROID /* callbacks will fail with jni */
# include <android/log.h> # include <android/log.h>
# define ANDROID_DEBUG_TAG "tinyWRAP" # define ANDROID_DEBUG_TAG "tinyWRAP"
#endif #endif
/* Very Important ==> never call functions which could raise debug callbacks into callback functions /* Very Important ==> never call functions which could raise debug callbacks into callback functions
* Callbacks should not be used with Android (JNI). * Callbacks should not be used with Android (JNI).
*/ */
enum cb_type { enum cb_type {
cb_info, cb_info,
cb_warn, cb_warn,
cb_error, cb_error,
cb_fatal cb_fatal
}; };
int debug_xxx_cb(const void* arg, const char* fmt, enum cb_type type, va_list *app) int debug_xxx_cb(const void* arg, const char* fmt, enum cb_type type, va_list *app)
{ {
int ret = -1; int ret = -1;
if(!arg) { if(!arg) {
return -1; return -1;
} }
const SipStack* stack = dyn_cast<const SipStack*>((const SipStack*)arg); const SipStack* stack = dyn_cast<const SipStack*>((const SipStack*)arg);
if(stack && stack->getDebugCallback()) { if(stack && stack->getDebugCallback()) {
char* message = tsk_null; char* message = tsk_null;
tsk_sprintf_2(&message, fmt, app); tsk_sprintf_2(&message, fmt, app);
switch(type) { switch(type) {
case cb_info: case cb_info:
ret= ret=
#if ANDROID #if ANDROID
__android_log_write(ANDROID_LOG_INFO, ANDROID_DEBUG_TAG, message); __android_log_write(ANDROID_LOG_INFO, ANDROID_DEBUG_TAG, message);
#else #else
stack->getDebugCallback()-> OnDebugInfo(message); stack->getDebugCallback()-> OnDebugInfo(message);
#endif #endif
break; break;
case cb_warn: case cb_warn:
ret= ret=
#if ANDROID #if ANDROID
__android_log_write(ANDROID_LOG_WARN, ANDROID_DEBUG_TAG, message); __android_log_write(ANDROID_LOG_WARN, ANDROID_DEBUG_TAG, message);
#else #else
stack->getDebugCallback()-> OnDebugWarn(message); stack->getDebugCallback()-> OnDebugWarn(message);
#endif #endif
break; break;
case cb_error: case cb_error:
ret= ret=
#if ANDROID #if ANDROID
__android_log_write(ANDROID_LOG_ERROR, ANDROID_DEBUG_TAG, message); __android_log_write(ANDROID_LOG_ERROR, ANDROID_DEBUG_TAG, message);
#else #else
stack->getDebugCallback()-> OnDebugError(message); stack->getDebugCallback()-> OnDebugError(message);
#endif #endif
break; break;
case cb_fatal: case cb_fatal:
ret= ret=
#if ANDROID #if ANDROID
__android_log_write(ANDROID_LOG_FATAL, ANDROID_DEBUG_TAG, message); __android_log_write(ANDROID_LOG_FATAL, ANDROID_DEBUG_TAG, message);
#else #else
stack->getDebugCallback()-> OnDebugFatal(message); stack->getDebugCallback()-> OnDebugFatal(message);
#endif #endif
break; break;
} }
TSK_FREE(message); TSK_FREE(message);
} }
return ret; return ret;
} }
int DDebugCallback::debug_info_cb(const void* arg, const char* fmt, ...) int DDebugCallback::debug_info_cb(const void* arg, const char* fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = debug_xxx_cb(arg, fmt, cb_info, &ap); ret = debug_xxx_cb(arg, fmt, cb_info, &ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }
int DDebugCallback::debug_warn_cb(const void* arg, const char* fmt, ...) int DDebugCallback::debug_warn_cb(const void* arg, const char* fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = debug_xxx_cb(arg, fmt, cb_warn, &ap); ret = debug_xxx_cb(arg, fmt, cb_warn, &ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }
int DDebugCallback::debug_error_cb(const void* arg, const char* fmt, ...) int DDebugCallback::debug_error_cb(const void* arg, const char* fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = debug_xxx_cb(arg, fmt, cb_error, &ap); ret = debug_xxx_cb(arg, fmt, cb_error, &ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }
int DDebugCallback::debug_fatal_cb(const void* arg, const char* fmt, ...) int DDebugCallback::debug_fatal_cb(const void* arg, const char* fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start(ap, fmt); va_start(ap, fmt);
ret = debug_xxx_cb(arg, fmt, cb_fatal, &ap); ret = debug_xxx_cb(arg, fmt, cb_fatal, &ap);
va_end(ap); va_end(ap);
return ret; return ret;
} }

View File

@ -1,57 +1,57 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIP_DEBUG_H #ifndef TINYWRAP_SIP_DEBUG_H
#define TINYWRAP_SIP_DEBUG_H #define TINYWRAP_SIP_DEBUG_H
class DDebugCallback class DDebugCallback
{ {
public: public:
DDebugCallback() { } DDebugCallback() { }
virtual ~DDebugCallback() {} virtual ~DDebugCallback() {}
virtual int OnDebugInfo(const char* message) { virtual int OnDebugInfo(const char* message) {
return -1; return -1;
} }
virtual int OnDebugWarn(const char* message) { virtual int OnDebugWarn(const char* message) {
return -1; return -1;
} }
virtual int OnDebugError(const char* message) { virtual int OnDebugError(const char* message) {
return -1; return -1;
} }
virtual int OnDebugFatal(const char* message) { virtual int OnDebugFatal(const char* message) {
return -1; return -1;
} }
#if !defined(SWIG) #if !defined(SWIG)
public: public:
static int debug_info_cb(const void* arg, const char* fmt, ...); static int debug_info_cb(const void* arg, const char* fmt, ...);
static int debug_warn_cb(const void* arg, const char* fmt, ...); static int debug_warn_cb(const void* arg, const char* fmt, ...);
static int debug_error_cb(const void* arg, const char* fmt, ...); static int debug_error_cb(const void* arg, const char* fmt, ...);
static int debug_fatal_cb(const void* arg, const char* fmt, ...); static int debug_fatal_cb(const void* arg, const char* fmt, ...);
#endif #endif
private: private:
}; };
#endif /* TINYWRAP_SIP_DEBUG_H */ #endif /* TINYWRAP_SIP_DEBUG_H */

View File

@ -1,179 +1,179 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "MediaContent.h" #include "MediaContent.h"
MediaContent::MediaContent(tmedia_content_t* pContent) MediaContent::MediaContent(tmedia_content_t* pContent)
: m_pData(tsk_null) : m_pData(tsk_null)
{ {
m_pContent = (tmedia_content_t*)tsk_object_ref(pContent); m_pContent = (tmedia_content_t*)tsk_object_ref(pContent);
} }
MediaContent::~MediaContent() MediaContent::~MediaContent()
{ {
TSK_OBJECT_SAFE_FREE(m_pContent); TSK_OBJECT_SAFE_FREE(m_pContent);
TSK_OBJECT_SAFE_FREE(m_pData); TSK_OBJECT_SAFE_FREE(m_pData);
} }
const char* MediaContent::getType() const char* MediaContent::getType()
{ {
if(m_pContent) { if(m_pContent) {
return m_pContent->type; return m_pContent->type;
} }
return tsk_null; return tsk_null;
} }
unsigned MediaContent::getDataLength() unsigned MediaContent::getDataLength()
{ {
if(!m_pContent) { if(!m_pContent) {
TSK_DEBUG_ERROR("Invalid internal object"); TSK_DEBUG_ERROR("Invalid internal object");
return 0; return 0;
} }
if(!m_pData) { if(!m_pData) {
m_pData = tmedia_content_get_data(m_pContent); m_pData = tmedia_content_get_data(m_pContent);
} }
return (m_pData ? m_pData->size : 0); return (m_pData ? m_pData->size : 0);
} }
unsigned MediaContent::getData(void* pOutput, unsigned nMaxsize) unsigned MediaContent::getData(void* pOutput, unsigned nMaxsize)
{ {
unsigned nRetsize = 0; unsigned nRetsize = 0;
if(!m_pContent) { if(!m_pContent) {
TSK_DEBUG_ERROR("Invalid internal object"); TSK_DEBUG_ERROR("Invalid internal object");
return 0; return 0;
} }
if(!m_pData) { if(!m_pData) {
m_pData = tmedia_content_get_data(m_pContent); m_pData = tmedia_content_get_data(m_pContent);
} }
if(pOutput && nMaxsize && m_pData) { if(pOutput && nMaxsize && m_pData) {
nRetsize = (m_pData->size > nMaxsize) ? nMaxsize : m_pData->size; nRetsize = (m_pData->size > nMaxsize) ? nMaxsize : m_pData->size;
memcpy(pOutput, m_pData->data, nRetsize); memcpy(pOutput, m_pData->data, nRetsize);
} }
return nRetsize; return nRetsize;
} }
MediaContent* MediaContent::parse(const void* pData, unsigned nSize, const char* pType) MediaContent* MediaContent::parse(const void* pData, unsigned nSize, const char* pType)
{ {
MediaContent* pMediaContent = tsk_null; MediaContent* pMediaContent = tsk_null;
tmedia_content_t* pContent = tmedia_content_parse(pData, (tsk_size_t)nSize, pType); tmedia_content_t* pContent = tmedia_content_parse(pData, (tsk_size_t)nSize, pType);
if(pContent) { if(pContent) {
if(TMEDIA_CONTENT_IS_CPIM(pContent)) { if(TMEDIA_CONTENT_IS_CPIM(pContent)) {
pMediaContent = new MediaContentCPIM(pContent); pMediaContent = new MediaContentCPIM(pContent);
} }
else if(TMEDIA_CONTENT_IS_DUMMY(pContent)) { else if(TMEDIA_CONTENT_IS_DUMMY(pContent)) {
// Todo // Todo
} }
TSK_OBJECT_SAFE_FREE(pContent); TSK_OBJECT_SAFE_FREE(pContent);
} }
return pMediaContent; return pMediaContent;
} }
MediaContentCPIM* MediaContent::parse(const void* pData, unsigned nSize) MediaContentCPIM* MediaContent::parse(const void* pData, unsigned nSize)
{ {
MediaContent* pMediaContent; MediaContent* pMediaContent;
if((pMediaContent = MediaContent::parse(pData, nSize, TMEDIA_CONTENT_CPIM_TYPE))) { if((pMediaContent = MediaContent::parse(pData, nSize, TMEDIA_CONTENT_CPIM_TYPE))) {
return dyn_cast<MediaContentCPIM*>(pMediaContent); return dyn_cast<MediaContentCPIM*>(pMediaContent);
} }
return tsk_null; return tsk_null;
} }
/* ============ message/CPIM ================= */ /* ============ message/CPIM ================= */
MediaContentCPIM::MediaContentCPIM(tmedia_content_t* pContent) MediaContentCPIM::MediaContentCPIM(tmedia_content_t* pContent)
: MediaContent(pContent) : MediaContent(pContent)
{ {
} }
MediaContentCPIM::~MediaContentCPIM() MediaContentCPIM::~MediaContentCPIM()
{ {
} }
unsigned MediaContentCPIM::getPayloadLength() unsigned MediaContentCPIM::getPayloadLength()
{ {
if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) { if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) {
TSK_DEBUG_ERROR("Invalid internal object"); TSK_DEBUG_ERROR("Invalid internal object");
return 0; return 0;
} }
return (TMEDIA_CONTENT_CPIM(m_pContent)->e ? TMEDIA_CONTENT_CPIM(m_pContent)->e->size : 0); return (TMEDIA_CONTENT_CPIM(m_pContent)->e ? TMEDIA_CONTENT_CPIM(m_pContent)->e->size : 0);
} }
unsigned MediaContentCPIM::getPayload(void* pOutput, unsigned nMaxsize) unsigned MediaContentCPIM::getPayload(void* pOutput, unsigned nMaxsize)
{ {
unsigned nRetsize = 0; unsigned nRetsize = 0;
if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) { if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) {
TSK_DEBUG_ERROR("Invalid internal object"); TSK_DEBUG_ERROR("Invalid internal object");
return 0; return 0;
} }
if(pOutput && nMaxsize && TMEDIA_CONTENT_CPIM(m_pContent)->e) { if(pOutput && nMaxsize && TMEDIA_CONTENT_CPIM(m_pContent)->e) {
nRetsize = (TMEDIA_CONTENT_CPIM(m_pContent)->e->size > nMaxsize) ? nMaxsize : TMEDIA_CONTENT_CPIM(m_pContent)->e->size; nRetsize = (TMEDIA_CONTENT_CPIM(m_pContent)->e->size > nMaxsize) ? nMaxsize : TMEDIA_CONTENT_CPIM(m_pContent)->e->size;
memcpy(pOutput, TMEDIA_CONTENT_CPIM(m_pContent)->e->data, nRetsize); memcpy(pOutput, TMEDIA_CONTENT_CPIM(m_pContent)->e->data, nRetsize);
} }
return nRetsize; return nRetsize;
} }
const void* MediaContentCPIM::getPayloadPtr() const void* MediaContentCPIM::getPayloadPtr()
{ {
if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) { if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) {
TSK_DEBUG_ERROR("Invalid internal object"); TSK_DEBUG_ERROR("Invalid internal object");
return tsk_null; return tsk_null;
} }
return TMEDIA_CONTENT_CPIM(m_pContent)->e ? TMEDIA_CONTENT_CPIM(m_pContent)->e->data : tsk_null; return TMEDIA_CONTENT_CPIM(m_pContent)->e ? TMEDIA_CONTENT_CPIM(m_pContent)->e->data : tsk_null;
} }
const char* MediaContentCPIM::getHeaderValue(const char* name) const char* MediaContentCPIM::getHeaderValue(const char* name)
{ {
const tmedia_content_cpim_t* cpim; const tmedia_content_cpim_t* cpim;
const tsk_list_item_t* item; const tsk_list_item_t* item;
if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) { if(!m_pContent || !TMEDIA_CONTENT_IS_CPIM(m_pContent)) {
TSK_DEBUG_ERROR("Invalid internal object"); TSK_DEBUG_ERROR("Invalid internal object");
return tsk_null; return tsk_null;
} }
cpim = TMEDIA_CONTENT_CPIM(m_pContent); cpim = TMEDIA_CONTENT_CPIM(m_pContent);
tsk_list_foreach(item, cpim->h_headers) { tsk_list_foreach(item, cpim->h_headers) {
if(tsk_striequals(name, TMEDIA_CONTENT_HEADER(item->data)->name)) { if(tsk_striequals(name, TMEDIA_CONTENT_HEADER(item->data)->name)) {
return TMEDIA_CONTENT_HEADER(item->data)->value; return TMEDIA_CONTENT_HEADER(item->data)->value;
} }
} }
tsk_list_foreach(item, cpim->m_headers) { tsk_list_foreach(item, cpim->m_headers) {
if(tsk_striequals(name, TMEDIA_CONTENT_HEADER(item->data)->name)) { if(tsk_striequals(name, TMEDIA_CONTENT_HEADER(item->data)->name)) {
return TMEDIA_CONTENT_HEADER(item->data)->value; return TMEDIA_CONTENT_HEADER(item->data)->value;
} }
} }
return tsk_null; return tsk_null;
} }

View File

@ -1,76 +1,76 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_MEDIA_CONTENT_H #ifndef TINYWRAP_MEDIA_CONTENT_H
#define TINYWRAP_MEDIA_CONTENT_H #define TINYWRAP_MEDIA_CONTENT_H
#include "tinymedia.h" #include "tinymedia.h"
#include "Common.h" #include "Common.h"
class MediaContentCPIM; class MediaContentCPIM;
class MediaContent class MediaContent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
MediaContent(tmedia_content_t* content); MediaContent(tmedia_content_t* content);
#endif #endif
virtual ~MediaContent(); virtual ~MediaContent();
public: public:
const char* getType(); const char* getType();
virtual unsigned getDataLength(); virtual unsigned getDataLength();
virtual unsigned getData(void* pOutput, unsigned nMaxsize); virtual unsigned getData(void* pOutput, unsigned nMaxsize);
// SWIG %newobject() // SWIG %newobject()
static MediaContent* parse(const void* pData, unsigned nSize, const char* pType); static MediaContent* parse(const void* pData, unsigned nSize, const char* pType);
static MediaContentCPIM* parse(const void* pData, unsigned nSize); static MediaContentCPIM* parse(const void* pData, unsigned nSize);
virtual unsigned getPayloadLength() = 0; virtual unsigned getPayloadLength() = 0;
virtual unsigned getPayload(void* pOutput, unsigned nMaxsize) = 0; virtual unsigned getPayload(void* pOutput, unsigned nMaxsize) = 0;
protected: protected:
tmedia_content_t* m_pContent; tmedia_content_t* m_pContent;
private: private:
tsk_buffer_t* m_pData; tsk_buffer_t* m_pData;
}; };
/* ============ message/CPIM ================= */ /* ============ message/CPIM ================= */
class MediaContentCPIM : public MediaContent class MediaContentCPIM : public MediaContent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
MediaContentCPIM(tmedia_content_t* pContent); MediaContentCPIM(tmedia_content_t* pContent);
#endif #endif
virtual ~MediaContentCPIM(); virtual ~MediaContentCPIM();
public: public:
virtual unsigned getPayloadLength(); virtual unsigned getPayloadLength();
virtual unsigned getPayload(void* pOutput, unsigned nMaxsize); virtual unsigned getPayload(void* pOutput, unsigned nMaxsize);
#if !defined(SWIG) #if !defined(SWIG)
const void* getPayloadPtr(); const void* getPayloadPtr();
#endif #endif
const char* getHeaderValue(const char* pName); const char* getHeaderValue(const char* pName);
}; };
#endif /*TINYWRAP_MEDIA_CONTENT_H*/ #endif /*TINYWRAP_MEDIA_CONTENT_H*/

File diff suppressed because it is too large Load Diff

View File

@ -1,246 +1,246 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_MEDIA_SESSIONMGR_H #ifndef TINYWRAP_MEDIA_SESSIONMGR_H
#define TINYWRAP_MEDIA_SESSIONMGR_H #define TINYWRAP_MEDIA_SESSIONMGR_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinymedia.h" #include "tinymedia.h"
#include "Common.h" #include "Common.h"
class ProxyPlugin; class ProxyPlugin;
class MediaSessionMgr; class MediaSessionMgr;
class TINYWRAP_API QoS class TINYWRAP_API QoS
{ {
friend class MediaSessionMgr; friend class MediaSessionMgr;
public: public:
#if !defined(SWIG) #if !defined(SWIG)
QoS(float qavg, float q1 = -1.f, float q2 = -1.f, float q3 = -1.f, float q4 = -1.f, float q5 = -1.f); QoS(float qavg, float q1 = -1.f, float q2 = -1.f, float q3 = -1.f, float q4 = -1.f, float q5 = -1.f);
#endif #endif
virtual ~QoS(); virtual ~QoS();
float getQavg() { float getQavg() {
return m_Qqvg; return m_Qqvg;
} }
float getQ1() { float getQ1() {
return m_Qn[0]; return m_Qn[0];
} }
float getQ2() { float getQ2() {
return m_Qn[1]; return m_Qn[1];
} }
float getQ3() { float getQ3() {
return m_Qn[2]; return m_Qn[2];
} }
float getQ4() { float getQ4() {
return m_Qn[3]; return m_Qn[3];
} }
float getQ5() { float getQ5() {
return m_Qn[4]; return m_Qn[4];
} }
unsigned getVideoInWidth() { unsigned getVideoInWidth() {
return m_VideoInWidth; return m_VideoInWidth;
} }
unsigned getVideoOutWidth() { unsigned getVideoOutWidth() {
return m_VideoOutWidth; return m_VideoOutWidth;
} }
unsigned getVideoInHeight() { unsigned getVideoInHeight() {
return m_VideoInHeight; return m_VideoInHeight;
} }
unsigned getVideoOutHeight() { unsigned getVideoOutHeight() {
return m_VideoOutHeight; return m_VideoOutHeight;
} }
unsigned getBandwidthDownKbps() { unsigned getBandwidthDownKbps() {
return m_BandwidthDownKbps; return m_BandwidthDownKbps;
} }
unsigned getBandwidthUpKbps() { unsigned getBandwidthUpKbps() {
return m_BandwidthUpKbps; return m_BandwidthUpKbps;
} }
unsigned getVideoInAvgFps() { unsigned getVideoInAvgFps() {
return m_VideoInAvgFps; return m_VideoInAvgFps;
} }
unsigned getVideoDecAvgTime() { // In millis unsigned getVideoDecAvgTime() { // In millis
return m_VideoDecAvgTime; return m_VideoDecAvgTime;
} }
unsigned getVideoEncAvgTime() { // In millis unsigned getVideoEncAvgTime() { // In millis
return m_VideoEncAvgTime; return m_VideoEncAvgTime;
} }
private: private:
float m_Qqvg; float m_Qqvg;
float m_Qn[5]; float m_Qn[5];
unsigned m_VideoInWidth; unsigned m_VideoInWidth;
unsigned m_VideoOutWidth; unsigned m_VideoOutWidth;
unsigned m_VideoInHeight; unsigned m_VideoInHeight;
unsigned m_VideoOutHeight; unsigned m_VideoOutHeight;
unsigned m_BandwidthDownKbps; unsigned m_BandwidthDownKbps;
unsigned m_BandwidthUpKbps; unsigned m_BandwidthUpKbps;
unsigned m_VideoInAvgFps; unsigned m_VideoInAvgFps;
unsigned m_VideoDecAvgTime; unsigned m_VideoDecAvgTime;
unsigned m_VideoEncAvgTime; unsigned m_VideoEncAvgTime;
}; };
class TINYWRAP_API Codec class TINYWRAP_API Codec
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
Codec(const struct tmedia_codec_s* pWrappedCodec); Codec(const struct tmedia_codec_s* pWrappedCodec);
#endif #endif
virtual ~Codec(); virtual ~Codec();
public: public:
#if !defined(SWIG) #if !defined(SWIG)
const struct tmedia_codec_s* getWrappedCodec() { const struct tmedia_codec_s* getWrappedCodec() {
return m_pWrappedCodec; return m_pWrappedCodec;
} }
inline bool isOpened() { inline bool isOpened() {
return (m_pWrappedCodec && (m_pWrappedCodec->opened == tsk_true)); return (m_pWrappedCodec && (m_pWrappedCodec->opened == tsk_true));
} }
#endif #endif
twrap_media_type_t getMediaType(); twrap_media_type_t getMediaType();
const char* getName(); const char* getName();
const char* getDescription(); const char* getDescription();
const char* getNegFormat(); const char* getNegFormat();
int getAudioSamplingRate(); int getAudioSamplingRate();
int getAudioChannels(); int getAudioChannels();
int getAudioPTime(); int getAudioPTime();
private: private:
struct tmedia_codec_s* m_pWrappedCodec; struct tmedia_codec_s* m_pWrappedCodec;
}; };
class TINYWRAP_API MediaSessionMgr class TINYWRAP_API MediaSessionMgr
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
MediaSessionMgr(tmedia_session_mgr_t* pWrappedMgr); MediaSessionMgr(tmedia_session_mgr_t* pWrappedMgr);
#endif #endif
virtual ~MediaSessionMgr(); virtual ~MediaSessionMgr();
public: public:
bool sessionSetInt32(twrap_media_type_t media, const char* key, int32_t value); bool sessionSetInt32(twrap_media_type_t media, const char* key, int32_t value);
int32_t sessionGetInt32(twrap_media_type_t media, const char* key); int32_t sessionGetInt32(twrap_media_type_t media, const char* key);
QoS* sessionGetQoS(twrap_media_type_t media); QoS* sessionGetQoS(twrap_media_type_t media);
bool consumerSetInt32(twrap_media_type_t media, const char* key, int32_t value); bool consumerSetInt32(twrap_media_type_t media, const char* key, int32_t value);
bool consumerSetInt64(twrap_media_type_t media, const char* key, int64_t value); bool consumerSetInt64(twrap_media_type_t media, const char* key, int64_t value);
bool producerSetInt32(twrap_media_type_t media, const char* key, int32_t value); bool producerSetInt32(twrap_media_type_t media, const char* key, int32_t value);
bool producerSetInt64(twrap_media_type_t media, const char* key, int64_t value); bool producerSetInt64(twrap_media_type_t media, const char* key, int64_t value);
Codec* producerGetCodec(twrap_media_type_t media); Codec* producerGetCodec(twrap_media_type_t media);
#if !defined(SWIG) #if !defined(SWIG)
const ProxyPlugin* findProxyPlugin(twrap_media_type_t media, bool consumer)const; const ProxyPlugin* findProxyPlugin(twrap_media_type_t media, bool consumer)const;
#endif #endif
const ProxyPlugin* findProxyPluginConsumer(twrap_media_type_t media)const { const ProxyPlugin* findProxyPluginConsumer(twrap_media_type_t media)const {
return this->findProxyPlugin(media, true); return this->findProxyPlugin(media, true);
} }
const ProxyPlugin* findProxyPluginProducer(twrap_media_type_t media)const { const ProxyPlugin* findProxyPluginProducer(twrap_media_type_t media)const {
return this->findProxyPlugin(media, false); return this->findProxyPlugin(media, false);
} }
static unsigned int registerAudioPluginFromFile(const char* path); static unsigned int registerAudioPluginFromFile(const char* path);
uint64_t getSessionId(twrap_media_type_t media)const; uint64_t getSessionId(twrap_media_type_t media)const;
#if !defined(SWIG) #if !defined(SWIG)
inline const tmedia_session_mgr_t* getWrappedMgr()const { inline const tmedia_session_mgr_t* getWrappedMgr()const {
return m_pWrappedMgr; return m_pWrappedMgr;
} }
#endif #endif
// Defaults // Defaults
static bool defaultsSetProfile(tmedia_profile_t profile); static bool defaultsSetProfile(tmedia_profile_t profile);
static tmedia_profile_t defaultsGetProfile(); static tmedia_profile_t defaultsGetProfile();
static bool defaultsSetBandwidthLevel(tmedia_bandwidth_level_t bl); // @deprecated static bool defaultsSetBandwidthLevel(tmedia_bandwidth_level_t bl); // @deprecated
static tmedia_bandwidth_level_t defaultsGetBandwidthLevel(); // @deprecated static tmedia_bandwidth_level_t defaultsGetBandwidthLevel(); // @deprecated
static bool defaultsSetCongestionCtrlEnabled(bool enabled); static bool defaultsSetCongestionCtrlEnabled(bool enabled);
static bool defaultsSetVideoMotionRank(int32_t video_motion_rank); static bool defaultsSetVideoMotionRank(int32_t video_motion_rank);
static bool defaultsSetVideoFps(int32_t video_fps); static bool defaultsSetVideoFps(int32_t video_fps);
static bool defaultsSetBandwidthVideoUploadMax(int32_t bw_video_up_max_kbps); static bool defaultsSetBandwidthVideoUploadMax(int32_t bw_video_up_max_kbps);
static bool defaultsSetBandwidthVideoDownloadMax(int32_t bw_video_down_max_kbps); static bool defaultsSetBandwidthVideoDownloadMax(int32_t bw_video_down_max_kbps);
static bool defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size); static bool defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size);
static bool defaultsSetPrefVideoSizeOutRange(tmedia_pref_video_size_t min, tmedia_pref_video_size_t max); static bool defaultsSetPrefVideoSizeOutRange(tmedia_pref_video_size_t min, tmedia_pref_video_size_t max);
static bool defaultsSetAdaptativeVideoSizeOutEnabled(bool enabled); static bool defaultsSetAdaptativeVideoSizeOutEnabled(bool enabled);
static bool defaultsSetJbMargin(uint32_t jb_margin_ms); static bool defaultsSetJbMargin(uint32_t jb_margin_ms);
static bool defaultsSetJbMaxLateRate(uint32_t jb_late_rate_percent); static bool defaultsSetJbMaxLateRate(uint32_t jb_late_rate_percent);
static bool defaultsSetEchoTail(uint32_t echo_tail); static bool defaultsSetEchoTail(uint32_t echo_tail);
static uint32_t defaultsGetEchoTail(); static uint32_t defaultsGetEchoTail();
static bool defaultsSetEchoSkew(uint32_t echo_skew); static bool defaultsSetEchoSkew(uint32_t echo_skew);
static bool defaultsSetEchoSuppEnabled(bool echo_supp_enabled); static bool defaultsSetEchoSuppEnabled(bool echo_supp_enabled);
static bool defaultsGetEchoSuppEnabled(); static bool defaultsGetEchoSuppEnabled();
static bool defaultsSetAgcEnabled(bool agc_enabled); static bool defaultsSetAgcEnabled(bool agc_enabled);
static bool defaultsGetAgcEnabled(); static bool defaultsGetAgcEnabled();
static bool defaultsSetAgcLevel(float agc_level); static bool defaultsSetAgcLevel(float agc_level);
static float defaultsGetAgcLevel(); static float defaultsGetAgcLevel();
static bool defaultsSetVadEnabled(bool vad_enabled); static bool defaultsSetVadEnabled(bool vad_enabled);
static bool defaultsGetGetVadEnabled(); static bool defaultsGetGetVadEnabled();
static bool defaultsSetNoiseSuppEnabled(bool noise_supp_enabled); static bool defaultsSetNoiseSuppEnabled(bool noise_supp_enabled);
static bool defaultsGetNoiseSuppEnabled(); static bool defaultsGetNoiseSuppEnabled();
static bool defaultsSetNoiseSuppLevel(int32_t noise_supp_level); static bool defaultsSetNoiseSuppLevel(int32_t noise_supp_level);
static int32_t defaultsGetNoiseSuppLevel(); static int32_t defaultsGetNoiseSuppLevel();
static bool defaultsSet100relEnabled(bool _100rel_enabled); static bool defaultsSet100relEnabled(bool _100rel_enabled);
static bool defaultsGet100relEnabled(); static bool defaultsGet100relEnabled();
static bool defaultsSetScreenSize(int32_t sx, int32_t sy); static bool defaultsSetScreenSize(int32_t sx, int32_t sy);
static bool defaultsSetAudioGain(int32_t producer_gain, int32_t consumer_gain); static bool defaultsSetAudioGain(int32_t producer_gain, int32_t consumer_gain);
static bool defaultsSetAudioPtime(int32_t ptime); static bool defaultsSetAudioPtime(int32_t ptime);
static bool defaultsSetAudioChannels(int32_t channel_playback, int32_t channel_record); static bool defaultsSetAudioChannels(int32_t channel_playback, int32_t channel_record);
static bool defaultsSetRtpPortRange(uint16_t range_start, uint16_t range_stop); static bool defaultsSetRtpPortRange(uint16_t range_start, uint16_t range_stop);
static bool defaultsSetRtpSymetricEnabled(bool enabled); static bool defaultsSetRtpSymetricEnabled(bool enabled);
static bool defaultsSetMediaType(twrap_media_type_t media_type); static bool defaultsSetMediaType(twrap_media_type_t media_type);
static bool defaultsSetVolume(int32_t volume); static bool defaultsSetVolume(int32_t volume);
static int32_t defaultsGetVolume(); static int32_t defaultsGetVolume();
static bool defaultsSetInviteSessionTimers(int32_t timeout, const char* refresher); static bool defaultsSetInviteSessionTimers(int32_t timeout, const char* refresher);
static bool defaultsSetSRtpMode(tmedia_srtp_mode_t mode); static bool defaultsSetSRtpMode(tmedia_srtp_mode_t mode);
static tmedia_srtp_mode_t defaultsGetSRtpMode(); static tmedia_srtp_mode_t defaultsGetSRtpMode();
static bool defaultsSetSRtpType(tmedia_srtp_type_t srtp_type); static bool defaultsSetSRtpType(tmedia_srtp_type_t srtp_type);
static tmedia_srtp_type_t defaultsGetSRtpType(); static tmedia_srtp_type_t defaultsGetSRtpType();
static bool defaultsSetRtcpEnabled(bool enabled); static bool defaultsSetRtcpEnabled(bool enabled);
static bool defaultsGetRtcpEnabled(); static bool defaultsGetRtcpEnabled();
static bool defaultsSetRtcpMuxEnabled(bool enabled); static bool defaultsSetRtcpMuxEnabled(bool enabled);
static bool defaultsGetRtcpMuxEnabled(); static bool defaultsGetRtcpMuxEnabled();
static bool defaultsSetStunEnabled(bool stun_enabled); static bool defaultsSetStunEnabled(bool stun_enabled);
static bool defaultsSetIceStunEnabled(bool icestun_enabled); static bool defaultsSetIceStunEnabled(bool icestun_enabled);
static bool defaultsSetIceTurnEnabled(bool iceturn_enabled); static bool defaultsSetIceTurnEnabled(bool iceturn_enabled);
static bool defaultsSetStunServer(const char* server_ip, uint16_t server_port); static bool defaultsSetStunServer(const char* server_ip, uint16_t server_port);
static bool defaultsSetStunCred(const char* username, const char* password); static bool defaultsSetStunCred(const char* username, const char* password);
static bool defaultsSetIceEnabled(bool ice_enabled); static bool defaultsSetIceEnabled(bool ice_enabled);
static bool defaultsSetByPassEncoding(bool enabled); static bool defaultsSetByPassEncoding(bool enabled);
static bool defaultsGetByPassEncoding(); static bool defaultsGetByPassEncoding();
static bool defaultsSetByPassDecoding(bool enabled); static bool defaultsSetByPassDecoding(bool enabled);
static bool defaultsGetByPassDecoding(); static bool defaultsGetByPassDecoding();
static bool defaultsSetVideoJbEnabled(bool enabled); static bool defaultsSetVideoJbEnabled(bool enabled);
static bool defaultsGetVideoJbEnabled(); static bool defaultsGetVideoJbEnabled();
static bool defaultsSetVideoZeroArtifactsEnabled(bool enabled); static bool defaultsSetVideoZeroArtifactsEnabled(bool enabled);
static bool defaultsGetVideoZeroArtifactsEnabled(); static bool defaultsGetVideoZeroArtifactsEnabled();
static bool defaultsSetRtpBuffSize(unsigned buffSize); static bool defaultsSetRtpBuffSize(unsigned buffSize);
static unsigned defaultsGetRtpBuffSize(); static unsigned defaultsGetRtpBuffSize();
static bool defaultsSetAvpfTail(unsigned tail_min, unsigned tail_max); static bool defaultsSetAvpfTail(unsigned tail_min, unsigned tail_max);
static bool defaultsSetAvpfMode(enum tmedia_mode_e mode); static bool defaultsSetAvpfMode(enum tmedia_mode_e mode);
static bool defaultsSetOpusMaxCaptureRate(uint32_t opus_maxcapturerate); static bool defaultsSetOpusMaxCaptureRate(uint32_t opus_maxcapturerate);
static bool defaultsSetOpusMaxPlaybackRate(uint32_t opus_maxplaybackrate); static bool defaultsSetOpusMaxPlaybackRate(uint32_t opus_maxplaybackrate);
static bool defaultsSetMaxFds(int32_t max_fds); static bool defaultsSetMaxFds(int32_t max_fds);
private: private:
tmedia_session_mgr_t* m_pWrappedMgr; tmedia_session_mgr_t* m_pWrappedMgr;
}; };
#endif /* TINYWRAP_MEDIA_SESSIONMGR_H */ #endif /* TINYWRAP_MEDIA_SESSIONMGR_H */

View File

@ -1,315 +1,315 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "Msrp.h" #include "Msrp.h"
#include "SipSession.h" #include "SipSession.h"
#include "Common.h" #include "Common.h"
/* ======================== MsrpMessage ========================*/ /* ======================== MsrpMessage ========================*/
MsrpMessage::MsrpMessage() MsrpMessage::MsrpMessage()
:m_pMessage(tsk_null) :m_pMessage(tsk_null)
{ {
} }
MsrpMessage::MsrpMessage(tmsrp_message_t *_message) MsrpMessage::MsrpMessage(tmsrp_message_t *_message)
{ {
m_pMessage = (tmsrp_message_t *)tsk_object_ref(_message); m_pMessage = (tmsrp_message_t *)tsk_object_ref(_message);
} }
MsrpMessage::~MsrpMessage() MsrpMessage::~MsrpMessage()
{ {
TSK_OBJECT_SAFE_FREE(m_pMessage); TSK_OBJECT_SAFE_FREE(m_pMessage);
} }
bool MsrpMessage::isRequest() bool MsrpMessage::isRequest()
{ {
return (m_pMessage->type == tmsrp_request); return (m_pMessage->type == tmsrp_request);
} }
short MsrpMessage::getCode() short MsrpMessage::getCode()
{ {
return TMSRP_RESPONSE_CODE(m_pMessage); return TMSRP_RESPONSE_CODE(m_pMessage);
} }
const char* MsrpMessage::getPhrase() const char* MsrpMessage::getPhrase()
{ {
return TMSRP_RESPONSE_PHRASE(m_pMessage); return TMSRP_RESPONSE_PHRASE(m_pMessage);
} }
tmsrp_request_type_t MsrpMessage::getRequestType() tmsrp_request_type_t MsrpMessage::getRequestType()
{ {
if(TMSRP_MESSAGE_IS_REQUEST(m_pMessage)) { if(TMSRP_MESSAGE_IS_REQUEST(m_pMessage)) {
return m_pMessage->line.request.type; return m_pMessage->line.request.type;
} }
return tmsrp_NONE; return tmsrp_NONE;
} }
void MsrpMessage::getByteRange(int64_t* start, int64_t* end, int64_t* total) void MsrpMessage::getByteRange(int64_t* start, int64_t* end, int64_t* total)
{ {
if(m_pMessage->ByteRange) { if(m_pMessage->ByteRange) {
*start = m_pMessage->ByteRange->start; *start = m_pMessage->ByteRange->start;
*end = m_pMessage->ByteRange->end; *end = m_pMessage->ByteRange->end;
*total = m_pMessage->ByteRange->total; *total = m_pMessage->ByteRange->total;
} }
else { else {
*start = *end = *total = -1; *start = *end = *total = -1;
} }
} }
bool MsrpMessage::isLastChunck() bool MsrpMessage::isLastChunck()
{ {
if(TMSRP_MESSAGE_IS_REQUEST(m_pMessage)) { if(TMSRP_MESSAGE_IS_REQUEST(m_pMessage)) {
return (m_pMessage->end_line.cflag == '$'); return (m_pMessage->end_line.cflag == '$');
} }
else { else {
if(m_pMessage->ByteRange) { if(m_pMessage->ByteRange) {
return (m_pMessage->ByteRange->end >= m_pMessage->ByteRange->total); return (m_pMessage->ByteRange->end >= m_pMessage->ByteRange->total);
} }
} }
return false; return false;
} }
bool MsrpMessage::isSuccessReport() bool MsrpMessage::isSuccessReport()
{ {
if(TMSRP_REQUEST_IS_REPORT(m_pMessage)) { if(TMSRP_REQUEST_IS_REPORT(m_pMessage)) {
if(m_pMessage->Status) { if(m_pMessage->Status) {
return m_pMessage->Status->code >= 200 && m_pMessage->Status->code <= 299; return m_pMessage->Status->code >= 200 && m_pMessage->Status->code <= 299;
} }
} }
return false; return false;
} }
bool MsrpMessage::isFirstChunck() bool MsrpMessage::isFirstChunck()
{ {
return (m_pMessage && m_pMessage->ByteRange->start == 1); return (m_pMessage && m_pMessage->ByteRange->start == 1);
} }
char* MsrpMessage::getMsrpHeaderValue(const char* name) char* MsrpMessage::getMsrpHeaderValue(const char* name)
{ {
const tmsrp_header_t* header = this->getMsrpHeader(name, 0); const tmsrp_header_t* header = this->getMsrpHeader(name, 0);
if(header) { if(header) {
return tmsrp_header_tostring(header); return tmsrp_header_tostring(header);
} }
return tsk_null; return tsk_null;
} }
char* MsrpMessage::getMsrpHeaderParamValue(const char* name, const char* param) char* MsrpMessage::getMsrpHeaderParamValue(const char* name, const char* param)
{ {
return tsk_null; return tsk_null;
} }
unsigned MsrpMessage::getMsrpContentLength() unsigned MsrpMessage::getMsrpContentLength()
{ {
if(m_pMessage && if(m_pMessage &&
m_pMessage->Content && m_pMessage->Content &&
m_pMessage->Content->data && m_pMessage->Content->data &&
m_pMessage->Content->size) { m_pMessage->Content->size) {
return m_pMessage->Content->size; return m_pMessage->Content->size;
} }
return 0; return 0;
} }
unsigned MsrpMessage::getMsrpContent(void* output, unsigned maxsize) unsigned MsrpMessage::getMsrpContent(void* output, unsigned maxsize)
{ {
unsigned retsize = 0; unsigned retsize = 0;
if(!output || if(!output ||
!m_pMessage || !m_pMessage ||
!m_pMessage->Content || !m_pMessage->Content ||
!m_pMessage->Content->data || !m_pMessage->Content->data ||
!m_pMessage->Content->size) { !m_pMessage->Content->size) {
return 0; return 0;
} }
retsize = (m_pMessage->Content->size > maxsize) ? maxsize : m_pMessage->Content->size; retsize = (m_pMessage->Content->size > maxsize) ? maxsize : m_pMessage->Content->size;
memcpy(output, m_pMessage->Content->data, retsize); memcpy(output, m_pMessage->Content->data, retsize);
return retsize; return retsize;
} }
const tmsrp_header_t* MsrpMessage::getMsrpHeader(const char* name, unsigned index /*= 0*/) const tmsrp_header_t* MsrpMessage::getMsrpHeader(const char* name, unsigned index /*= 0*/)
{ {
tsk_size_t pos = 0; tsk_size_t pos = 0;
const tmsrp_header_t* hdr = tsk_null; const tmsrp_header_t* hdr = tsk_null;
const tsk_list_item_t *item; const tsk_list_item_t *item;
/* From tmsrp_message_get_headerAt() */ /* From tmsrp_message_get_headerAt() */
if(!m_pMessage || !name) { if(!m_pMessage || !name) {
return tsk_null; return tsk_null;
} }
if(tsk_striequals(name, "To-Path")) { if(tsk_striequals(name, "To-Path")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->To; hdr = (const tmsrp_header_t*)m_pMessage->To;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "From-Path")) { if(tsk_striequals(name, "From-Path")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->From; hdr = (const tmsrp_header_t*)m_pMessage->From;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "Message-ID")) { if(tsk_striequals(name, "Message-ID")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->MessageID; hdr = (const tmsrp_header_t*)m_pMessage->MessageID;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "Byte-Range")) { if(tsk_striequals(name, "Byte-Range")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->ByteRange; hdr = (const tmsrp_header_t*)m_pMessage->ByteRange;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "Failure-Report")) { if(tsk_striequals(name, "Failure-Report")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->FailureReport; hdr = (const tmsrp_header_t*)m_pMessage->FailureReport;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "Success-Report")) { if(tsk_striequals(name, "Success-Report")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->SuccessReport; hdr = (const tmsrp_header_t*)m_pMessage->SuccessReport;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "Status")) { if(tsk_striequals(name, "Status")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->Status; hdr = (const tmsrp_header_t*)m_pMessage->Status;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "Content-Type")) { if(tsk_striequals(name, "Content-Type")) {
if(index == 0) { if(index == 0) {
hdr = (const tmsrp_header_t*)m_pMessage->ContentType; hdr = (const tmsrp_header_t*)m_pMessage->ContentType;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
/* All other headers */ /* All other headers */
tsk_list_foreach(item, m_pMessage->headers) { tsk_list_foreach(item, m_pMessage->headers) {
if(tsk_striequals(tmsrp_header_get_nameex(TMSRP_HEADER(item->data)), name)) { if(tsk_striequals(tmsrp_header_get_nameex(TMSRP_HEADER(item->data)), name)) {
if(pos++ >= index) { if(pos++ >= index) {
hdr = (const tmsrp_header_t*)item->data; hdr = (const tmsrp_header_t*)item->data;
break; break;
} }
} }
} }
bail: bail:
return hdr; return hdr;
} }
/* ======================== MsrpEvent ========================*/ /* ======================== MsrpEvent ========================*/
MsrpEvent::MsrpEvent(const tmsrp_event_t *_msrpevent) MsrpEvent::MsrpEvent(const tmsrp_event_t *_msrpevent)
{ {
this->_event = _msrpevent; this->_event = _msrpevent;
if(this->_event && this->_event->message) { if(this->_event && this->_event->message) {
m_pMessage = new MsrpMessage((tmsrp_message_t *)this->_event->message); m_pMessage = new MsrpMessage((tmsrp_message_t *)this->_event->message);
} }
else { else {
m_pMessage = tsk_null; m_pMessage = tsk_null;
} }
} }
MsrpEvent::~MsrpEvent() MsrpEvent::~MsrpEvent()
{ {
if(m_pMessage) { if(m_pMessage) {
delete m_pMessage; delete m_pMessage;
} }
} }
tmsrp_event_type_t MsrpEvent::getType() tmsrp_event_type_t MsrpEvent::getType()
{ {
if(this->_event) { if(this->_event) {
return this->_event->type; return this->_event->type;
} }
return tmsrp_event_type_none; return tmsrp_event_type_none;
} }
const MsrpSession* MsrpEvent::getSipSession() const MsrpSession* MsrpEvent::getSipSession()
{ {
if(this->_event && this->_event->callback_data) { if(this->_event && this->_event->callback_data) {
return dyn_cast<const MsrpSession*>((const MsrpSession*)this->_event->callback_data); return dyn_cast<const MsrpSession*>((const MsrpSession*)this->_event->callback_data);
} }
return tsk_null; return tsk_null;
} }
const MsrpMessage* MsrpEvent::getMessage() const const MsrpMessage* MsrpEvent::getMessage() const
{ {
return m_pMessage; return m_pMessage;
} }
int twrap_msrp_cb(const tmsrp_event_t* _event) int twrap_msrp_cb(const tmsrp_event_t* _event)
{ {
const MsrpSession* session = (const MsrpSession*)_event->callback_data; const MsrpSession* session = (const MsrpSession*)_event->callback_data;
MsrpCallback* callback; MsrpCallback* callback;
int ret = -1; int ret = -1;
if(session) { if(session) {
if((callback = session->getCallback())) { if((callback = session->getCallback())) {
MsrpEvent* e = new MsrpEvent(_event); MsrpEvent* e = new MsrpEvent(_event);
ret = callback->OnEvent(e); ret = callback->OnEvent(e);
delete e; delete e;
} }
else { else {
return 0; return 0;
} }
} }
else { else {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
} }
return ret; return ret;
} }

View File

@ -1,101 +1,101 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_MSRP_H #ifndef TINYWRAP_MSRP_H
#define TINYWRAP_MSRP_H #define TINYWRAP_MSRP_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinymsrp.h" #include "tinymsrp.h"
class MsrpSession; class MsrpSession;
class TINYWRAP_API MsrpMessage class TINYWRAP_API MsrpMessage
{ {
public: public:
MsrpMessage(); MsrpMessage();
#if !defined(SWIG) #if !defined(SWIG)
MsrpMessage(tmsrp_message_t *message); MsrpMessage(tmsrp_message_t *message);
#endif #endif
virtual ~MsrpMessage(); virtual ~MsrpMessage();
bool isRequest(); bool isRequest();
short getCode(); short getCode();
const char* getPhrase(); const char* getPhrase();
tmsrp_request_type_t getRequestType(); tmsrp_request_type_t getRequestType();
#if defined(SWIG) #if defined(SWIG)
void getByteRange(int64_t* OUTPUT, int64_t* OUTPUT, int64_t* OUTPUT); void getByteRange(int64_t* OUTPUT, int64_t* OUTPUT, int64_t* OUTPUT);
#else #else
void getByteRange(int64_t* start, int64_t* end, int64_t* total); void getByteRange(int64_t* start, int64_t* end, int64_t* total);
#endif #endif
bool isLastChunck(); bool isLastChunck();
bool isFirstChunck(); bool isFirstChunck();
bool isSuccessReport(); bool isSuccessReport();
char* getMsrpHeaderValue(const char* name); char* getMsrpHeaderValue(const char* name);
char* getMsrpHeaderParamValue(const char* name, const char* param); char* getMsrpHeaderParamValue(const char* name, const char* param);
unsigned getMsrpContentLength(); unsigned getMsrpContentLength();
unsigned getMsrpContent(void* output, unsigned maxsize); unsigned getMsrpContent(void* output, unsigned maxsize);
#if !defined(SWIG) #if !defined(SWIG)
const tmsrp_message_t* getWrappedMsrpMessage() { const tmsrp_message_t* getWrappedMsrpMessage() {
return m_pMessage; return m_pMessage;
} }
#endif #endif
private: private:
const tmsrp_header_t* getMsrpHeader(const char* name, unsigned index = 0); const tmsrp_header_t* getMsrpHeader(const char* name, unsigned index = 0);
private: private:
tmsrp_message_t *m_pMessage; tmsrp_message_t *m_pMessage;
}; };
class TINYWRAP_API MsrpEvent class TINYWRAP_API MsrpEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
MsrpEvent(const tmsrp_event_t *_event); MsrpEvent(const tmsrp_event_t *_event);
#endif #endif
virtual ~MsrpEvent(); virtual ~MsrpEvent();
tmsrp_event_type_t getType(); tmsrp_event_type_t getType();
const MsrpSession* getSipSession(); const MsrpSession* getSipSession();
const MsrpMessage* getMessage() const; const MsrpMessage* getMessage() const;
protected: protected:
const tmsrp_event_t *_event; const tmsrp_event_t *_event;
MsrpMessage* m_pMessage; MsrpMessage* m_pMessage;
}; };
class TINYWRAP_API MsrpCallback class TINYWRAP_API MsrpCallback
{ {
public: public:
MsrpCallback() { } MsrpCallback() { }
virtual ~MsrpCallback() {} virtual ~MsrpCallback() {}
virtual int OnEvent(const MsrpEvent* e) { virtual int OnEvent(const MsrpEvent* e) {
return -1; return -1;
} }
}; };
#if !defined(SWIG) #if !defined(SWIG)
int twrap_msrp_cb(const tmsrp_event_t* _event); int twrap_msrp_cb(const tmsrp_event_t* _event);
#endif #endif
#endif /* TINYWRAP_MSRP_H */ #endif /* TINYWRAP_MSRP_H */

View File

@ -1,34 +1,34 @@
%{ %{
#include "Msrp.h" #include "Msrp.h"
%} %}
/* Callbacks */ /* Callbacks */
%feature("director") MsrpCallback; %feature("director") MsrpCallback;
%nodefaultctor; %nodefaultctor;
%include "Msrp.h" %include "Msrp.h"
%clearnodefaultctor; %clearnodefaultctor;
/* From tinyMSRP/tmsrp_message.h */ /* From tinyMSRP/tmsrp_message.h */
typedef enum tmsrp_request_type_e typedef enum tmsrp_request_type_e
{ {
tmsrp_NONE = 0, tmsrp_NONE = 0,
tmsrp_SEND, tmsrp_SEND,
tmsrp_REPORT, tmsrp_REPORT,
tmsrp_AUTH tmsrp_AUTH
//... //...
} }
tmsrp_request_type_t; tmsrp_request_type_t;
/* From tinyMSRP/tmsrp_event.h */ /* From tinyMSRP/tmsrp_event.h */
typedef enum tmsrp_event_type_e typedef enum tmsrp_event_type_e
{ {
tmsrp_event_type_none, tmsrp_event_type_none,
tmsrp_event_type_connected, tmsrp_event_type_connected,
tmsrp_event_type_disconnected, tmsrp_event_type_disconnected,
tmsrp_event_type_message, tmsrp_event_type_message,
} }
tmsrp_event_type_t; tmsrp_event_type_t;

File diff suppressed because it is too large Load Diff

View File

@ -1,265 +1,265 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
/**@file ProxyConsumer.h /**@file ProxyConsumer.h
* @brief Audio/Video proxy consumers. * @brief Audio/Video proxy consumers.
* *
* @author Mamadou Diop <diopmamadou(at)doubango.org> * @author Mamadou Diop <diopmamadou(at)doubango.org>
*/ */
#ifndef TINYWRAP_CONSUMER_PROXY_H #ifndef TINYWRAP_CONSUMER_PROXY_H
#define TINYWRAP_CONSUMER_PROXY_H #define TINYWRAP_CONSUMER_PROXY_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "ProxyPluginMgr.h" #include "ProxyPluginMgr.h"
#include "tinymedia/tmedia_common.h" #include "tinymedia/tmedia_common.h"
#include "tinymedia/tmedia_consumer.h" #include "tinymedia/tmedia_consumer.h"
class AudioResampler; class AudioResampler;
/* ============ ProxyAudioConsumerCallback Class ================= */ /* ============ ProxyAudioConsumerCallback Class ================= */
class ProxyAudioConsumerCallback class ProxyAudioConsumerCallback
{ {
public: public:
ProxyAudioConsumerCallback() { } ProxyAudioConsumerCallback() { }
virtual ~ProxyAudioConsumerCallback() { } virtual ~ProxyAudioConsumerCallback() { }
virtual int prepare(int ptime, int rate, int channels) { virtual int prepare(int ptime, int rate, int channels) {
return -1; return -1;
} }
virtual int start() { virtual int start() {
return -1; return -1;
} }
virtual int pause() { virtual int pause() {
return -1; return -1;
} }
virtual int stop() { virtual int stop() {
return -1; return -1;
} }
#if !defined(SWIG) #if !defined(SWIG)
// whether the audio buffer have to be stored in the JB then pulled using "ProxyAudioConsumer::pull()" or not // whether the audio buffer have to be stored in the JB then pulled using "ProxyAudioConsumer::pull()" or not
virtual bool putInJitterBuffer() { virtual bool putInJitterBuffer() {
return true; return true;
} }
// whether we are using the "telepresence" system (PIVOT audio settings must not be changed) // whether we are using the "telepresence" system (PIVOT audio settings must not be changed)
virtual bool isPivotSettings() { virtual bool isPivotSettings() {
return false; return false;
} }
// only called if "putInJitterBuffer()" return "true" // only called if "putInJitterBuffer()" return "true"
virtual int consume(const void* buffer_ptr, tsk_size_t buffer_size, const tsk_object_t* proto_hdr) { virtual int consume(const void* buffer_ptr, tsk_size_t buffer_size, const tsk_object_t* proto_hdr) {
return -1; return -1;
} }
#endif #endif
}; };
/* ============ ProxyAudioConsumer Class ================= */ /* ============ ProxyAudioConsumer Class ================= */
class ProxyAudioConsumer : public ProxyPlugin class ProxyAudioConsumer : public ProxyPlugin
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
ProxyAudioConsumer(struct twrap_consumer_proxy_audio_s* pConsumer); ProxyAudioConsumer(struct twrap_consumer_proxy_audio_s* pConsumer);
#endif #endif
virtual ~ProxyAudioConsumer(); virtual ~ProxyAudioConsumer();
bool setActualSndCardPlaybackParams(int nPtime, int nRate, int nChannels); bool setActualSndCardPlaybackParams(int nPtime, int nRate, int nChannels);
bool queryForResampler(uint16_t nInFreq, uint16_t nOutFreq, uint16_t nFrameDuration, uint16_t nChannels, uint16_t nResamplerQuality); bool queryForResampler(uint16_t nInFreq, uint16_t nOutFreq, uint16_t nFrameDuration, uint16_t nChannels, uint16_t nResamplerQuality);
bool setPullBuffer(const void* pPullBufferPtr, unsigned nPullBufferSize); bool setPullBuffer(const void* pPullBufferPtr, unsigned nPullBufferSize);
unsigned pull(void* pOutput=tsk_null, unsigned nSize=0); unsigned pull(void* pOutput=tsk_null, unsigned nSize=0);
bool setGain(unsigned nGain); bool setGain(unsigned nGain);
unsigned getGain(); unsigned getGain();
bool reset(); bool reset();
void setCallback(ProxyAudioConsumerCallback* pCallback) { void setCallback(ProxyAudioConsumerCallback* pCallback) {
m_pCallback = pCallback; m_pCallback = pCallback;
} }
#if !defined(SWIG) #if !defined(SWIG)
inline ProxyAudioConsumerCallback* getCallback()const { inline ProxyAudioConsumerCallback* getCallback()const {
return m_pCallback; return m_pCallback;
} }
virtual inline bool isWrapping(tsk_object_t* pWrappedPlugin) { virtual inline bool isWrapping(tsk_object_t* pWrappedPlugin) {
return m_pWrappedPlugin == pWrappedPlugin; return m_pWrappedPlugin == pWrappedPlugin;
} }
#endif #endif
virtual inline uint64_t getMediaSessionId() { virtual inline uint64_t getMediaSessionId() {
return m_pWrappedPlugin ? TMEDIA_CONSUMER(m_pWrappedPlugin)->session_id : 0; return m_pWrappedPlugin ? TMEDIA_CONSUMER(m_pWrappedPlugin)->session_id : 0;
} }
public: public:
static bool registerPlugin(); static bool registerPlugin();
private: private:
struct twrap_consumer_proxy_audio_s* m_pWrappedPlugin; struct twrap_consumer_proxy_audio_s* m_pWrappedPlugin;
ProxyAudioConsumerCallback* m_pCallback; ProxyAudioConsumerCallback* m_pCallback;
struct { struct {
const void* pPullBufferPtr; const void* pPullBufferPtr;
unsigned nPullBufferSize; unsigned nPullBufferSize;
} m_PullBuffer; } m_PullBuffer;
struct { struct {
void* pInBufferPtr; void* pInBufferPtr;
unsigned nInBufferSizeInByte; unsigned nInBufferSizeInByte;
AudioResampler* pResampler; AudioResampler* pResampler;
} m_Resampler; } m_Resampler;
}; };
class ProxyVideoFrame; class ProxyVideoFrame;
/* ============ ProxyVideoConsumerCallback Class ================= */ /* ============ ProxyVideoConsumerCallback Class ================= */
class ProxyVideoConsumerCallback class ProxyVideoConsumerCallback
{ {
public: public:
ProxyVideoConsumerCallback() {} ProxyVideoConsumerCallback() {}
virtual ~ProxyVideoConsumerCallback() {} virtual ~ProxyVideoConsumerCallback() {}
virtual int prepare(int nWidth, int nHeight, int nFps) { virtual int prepare(int nWidth, int nHeight, int nFps) {
return -1; return -1;
} }
virtual int consume(const ProxyVideoFrame* frame) { virtual int consume(const ProxyVideoFrame* frame) {
return -1; return -1;
} }
// only called if a buffer is registered using setPullBuffer(). Otherwise, consume() will be called // only called if a buffer is registered using setPullBuffer(). Otherwise, consume() will be called
virtual int bufferCopied(unsigned nCopiedSize, unsigned nAvailableSize) { virtual int bufferCopied(unsigned nCopiedSize, unsigned nAvailableSize) {
return -1; return -1;
} }
virtual int start() { virtual int start() {
return -1; return -1;
} }
virtual int pause() { virtual int pause() {
return -1; return -1;
} }
virtual int stop() { virtual int stop() {
return -1; return -1;
} }
}; };
/* ============ ProxyVideoConsumer Class ================= */ /* ============ ProxyVideoConsumer Class ================= */
class ProxyVideoConsumer : public ProxyPlugin class ProxyVideoConsumer : public ProxyPlugin
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
ProxyVideoConsumer(tmedia_chroma_t eChroma, struct twrap_consumer_proxy_video_s* pConsumer); ProxyVideoConsumer(tmedia_chroma_t eChroma, struct twrap_consumer_proxy_video_s* pConsumer);
#endif #endif
virtual ~ProxyVideoConsumer(); virtual ~ProxyVideoConsumer();
bool setDisplaySize(unsigned nWidth, unsigned nHeight); bool setDisplaySize(unsigned nWidth, unsigned nHeight);
unsigned getDisplayWidth(); unsigned getDisplayWidth();
unsigned getDisplayHeight(); unsigned getDisplayHeight();
unsigned getDecodedWidth(); unsigned getDecodedWidth();
unsigned getDecodedHeight(); unsigned getDecodedHeight();
void setCallback(ProxyVideoConsumerCallback* pCallback) { void setCallback(ProxyVideoConsumerCallback* pCallback) {
m_pCallback = pCallback; m_pCallback = pCallback;
} }
bool setAutoResizeDisplay(bool bAutoResizeDisplay); bool setAutoResizeDisplay(bool bAutoResizeDisplay);
bool getAutoResizeDisplay()const; bool getAutoResizeDisplay()const;
bool setConsumeBuffer(const void* pConsumeBufferPtr, unsigned nConsumeBufferSize); bool setConsumeBuffer(const void* pConsumeBufferPtr, unsigned nConsumeBufferSize);
unsigned pull(void* pOutput, unsigned nSize); unsigned pull(void* pOutput, unsigned nSize);
bool reset(); bool reset();
#if !defined(SWIG) #if !defined(SWIG)
bool hasConsumeBuffer()const { bool hasConsumeBuffer()const {
return m_ConsumeBuffer.pConsumeBufferPtr && m_ConsumeBuffer.nConsumeBufferSize; return m_ConsumeBuffer.pConsumeBufferPtr && m_ConsumeBuffer.nConsumeBufferSize;
} }
unsigned copyBuffer(const void* pBuffer, unsigned nSize)const; unsigned copyBuffer(const void* pBuffer, unsigned nSize)const;
inline ProxyVideoConsumerCallback* getCallback()const { inline ProxyVideoConsumerCallback* getCallback()const {
return m_pCallback; return m_pCallback;
} }
virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) { virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) {
return m_pWrappedPlugin == wrapped_plugin; return m_pWrappedPlugin == wrapped_plugin;
} }
#endif #endif
virtual inline uint64_t getMediaSessionId() { virtual inline uint64_t getMediaSessionId() {
return m_pWrappedPlugin ? TMEDIA_CONSUMER(m_pWrappedPlugin)->session_id : 0; return m_pWrappedPlugin ? TMEDIA_CONSUMER(m_pWrappedPlugin)->session_id : 0;
} }
public: public:
static bool registerPlugin(); static bool registerPlugin();
static void setDefaultChroma(tmedia_chroma_t eChroma) { static void setDefaultChroma(tmedia_chroma_t eChroma) {
s_eDefaultChroma = eChroma; s_eDefaultChroma = eChroma;
} }
static void setDefaultAutoResizeDisplay(bool bAutoResizeDisplay) { static void setDefaultAutoResizeDisplay(bool bAutoResizeDisplay) {
s_bAutoResizeDisplay = bAutoResizeDisplay; s_bAutoResizeDisplay = bAutoResizeDisplay;
} }
#if !defined(SWIG) #if !defined(SWIG)
tmedia_chroma_t getChroma()const; tmedia_chroma_t getChroma()const;
static tmedia_chroma_t getDefaultChroma() { static tmedia_chroma_t getDefaultChroma() {
return s_eDefaultChroma; return s_eDefaultChroma;
} }
static bool getDefaultAutoResizeDisplay() { static bool getDefaultAutoResizeDisplay() {
return s_bAutoResizeDisplay; return s_bAutoResizeDisplay;
} }
#endif #endif
private: private:
struct twrap_consumer_proxy_video_s* m_pWrappedPlugin; struct twrap_consumer_proxy_video_s* m_pWrappedPlugin;
tmedia_chroma_t m_eChroma; tmedia_chroma_t m_eChroma;
ProxyVideoConsumerCallback* m_pCallback; ProxyVideoConsumerCallback* m_pCallback;
struct { struct {
const void* pConsumeBufferPtr; const void* pConsumeBufferPtr;
unsigned nConsumeBufferSize; unsigned nConsumeBufferSize;
} m_ConsumeBuffer; } m_ConsumeBuffer;
bool m_bAutoResizeDisplay; bool m_bAutoResizeDisplay;
static tmedia_chroma_t s_eDefaultChroma; static tmedia_chroma_t s_eDefaultChroma;
static bool s_bAutoResizeDisplay; static bool s_bAutoResizeDisplay;
}; };
/* ============ ProxyVideoFrame Class ================= */ /* ============ ProxyVideoFrame Class ================= */
class ProxyVideoFrame class ProxyVideoFrame
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
ProxyVideoFrame(const void* pBufferPtr, unsigned nBufferSize, unsigned nFrameWidth, unsigned nFrameHeight, const tsk_object_t* pProtoHdr); ProxyVideoFrame(const void* pBufferPtr, unsigned nBufferSize, unsigned nFrameWidth, unsigned nFrameHeight, const tsk_object_t* pProtoHdr);
#endif #endif
virtual ~ProxyVideoFrame(); virtual ~ProxyVideoFrame();
public: /* For Java/C# applications */ public: /* For Java/C# applications */
unsigned getSize(); unsigned getSize();
unsigned getContent(void* pOutput, unsigned nMaxsize); unsigned getContent(void* pOutput, unsigned nMaxsize);
inline unsigned getFrameWidth()const { inline unsigned getFrameWidth()const {
return m_nFrameWidth; return m_nFrameWidth;
} }
inline unsigned getFrameHeight()const { inline unsigned getFrameHeight()const {
return m_nFrameHeight; return m_nFrameHeight;
} }
#if !defined(SWIG) /* For C/C++ applications */ #if !defined(SWIG) /* For C/C++ applications */
public: public:
inline unsigned getBufferSize()const { inline unsigned getBufferSize()const {
return m_nBufferSize; return m_nBufferSize;
} }
inline const void* getBufferPtr()const { inline const void* getBufferPtr()const {
return m_pBufferPtr; return m_pBufferPtr;
} }
inline const tsk_object_t* getProtoHdr()const { inline const tsk_object_t* getProtoHdr()const {
return m_pProtoHdr; return m_pProtoHdr;
} }
#endif #endif
private: private:
const void* m_pBufferPtr; const void* m_pBufferPtr;
unsigned m_nBufferSize, m_nFrameWidth, m_nFrameHeight; unsigned m_nBufferSize, m_nFrameWidth, m_nFrameHeight;
const tsk_object_t* m_pProtoHdr; const tsk_object_t* m_pProtoHdr;
}; };
#endif /* TINYWRAP_CONSUMER_PROXY_H */ #endif /* TINYWRAP_CONSUMER_PROXY_H */

View File

@ -1,308 +1,308 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "ProxyPluginMgr.h" #include "ProxyPluginMgr.h"
#include "ProxyConsumer.h" #include "ProxyConsumer.h"
#include "ProxyProducer.h" #include "ProxyProducer.h"
// //
// "twrap_proxy_plugin_t" Declarations // "twrap_proxy_plugin_t" Declarations
// //
typedef struct twrap_proxy_plugin_s { typedef struct twrap_proxy_plugin_s {
TSK_DECLARE_OBJECT; TSK_DECLARE_OBJECT;
ProxyPlugin* plugin; ProxyPlugin* plugin;
} }
twrap_proxy_plugin_t; twrap_proxy_plugin_t;
#define TWRAP_PROXY_PLUGIN(self) ((twrap_proxy_plugin_t*)(self)) #define TWRAP_PROXY_PLUGIN(self) ((twrap_proxy_plugin_t*)(self))
static int pred_find_plugin_by_value(const tsk_list_item_t *item, const void *proxyPlugin); static int pred_find_plugin_by_value(const tsk_list_item_t *item, const void *proxyPlugin);
static twrap_proxy_plugin_t* twrap_proxy_plugin_create(ProxyPlugin** plugin); static twrap_proxy_plugin_t* twrap_proxy_plugin_create(ProxyPlugin** plugin);
// //
// "ProxyPluginMgr" Class Implementation // "ProxyPluginMgr" Class Implementation
// //
ProxyPluginMgr* ProxyPluginMgr::instance = tsk_null; ProxyPluginMgr* ProxyPluginMgr::instance = tsk_null;
static uint64_t __uniqueId = 0; static uint64_t __uniqueId = 0;
ProxyPluginMgr::ProxyPluginMgr(ProxyPluginMgrCallback* _callback) ProxyPluginMgr::ProxyPluginMgr(ProxyPluginMgrCallback* _callback)
:callback(_callback) :callback(_callback)
{ {
this->plugins = tsk_list_create(); this->plugins = tsk_list_create();
if(!this->callback) { if(!this->callback) {
TSK_DEBUG_WARN("Callback function is Null => You will have big problems as we won't check it before call"); TSK_DEBUG_WARN("Callback function is Null => You will have big problems as we won't check it before call");
} }
} }
ProxyPluginMgr::~ProxyPluginMgr() ProxyPluginMgr::~ProxyPluginMgr()
{ {
if(this == ProxyPluginMgr::instance) { if(this == ProxyPluginMgr::instance) {
ProxyPluginMgr::instance = tsk_null; ProxyPluginMgr::instance = tsk_null;
} }
TSK_OBJECT_SAFE_FREE(this->plugins); TSK_OBJECT_SAFE_FREE(this->plugins);
} }
ProxyPluginMgr* ProxyPluginMgr::createInstance(ProxyPluginMgrCallback* pCallback) ProxyPluginMgr* ProxyPluginMgr::createInstance(ProxyPluginMgrCallback* pCallback)
{ {
if(!ProxyPluginMgr::instance) { if(!ProxyPluginMgr::instance) {
ProxyPluginMgr::instance = new ProxyPluginMgr(pCallback); ProxyPluginMgr::instance = new ProxyPluginMgr(pCallback);
} }
else { else {
TSK_DEBUG_WARN("Plugin instance already exist"); TSK_DEBUG_WARN("Plugin instance already exist");
ProxyPluginMgr::instance->callback = pCallback; ProxyPluginMgr::instance->callback = pCallback;
} }
return ProxyPluginMgr::instance; return ProxyPluginMgr::instance;
} }
void ProxyPluginMgr::destroyInstance(ProxyPluginMgr** ppInstance) void ProxyPluginMgr::destroyInstance(ProxyPluginMgr** ppInstance)
{ {
if(ppInstance && *ppInstance) { if(ppInstance && *ppInstance) {
bool bMatch = ProxyPluginMgr::instance && (*ppInstance == ProxyPluginMgr::instance); bool bMatch = ProxyPluginMgr::instance && (*ppInstance == ProxyPluginMgr::instance);
delete *ppInstance, *ppInstance = tsk_null; delete *ppInstance, *ppInstance = tsk_null;
if(bMatch) { if(bMatch) {
ProxyPluginMgr::instance = tsk_null; ProxyPluginMgr::instance = tsk_null;
} }
} }
} }
ProxyPluginMgr* ProxyPluginMgr::getInstance() ProxyPluginMgr* ProxyPluginMgr::getInstance()
{ {
if(!ProxyPluginMgr::instance) { if(!ProxyPluginMgr::instance) {
TSK_DEBUG_ERROR("No instance of the manager could be found"); TSK_DEBUG_ERROR("No instance of the manager could be found");
} }
return ProxyPluginMgr::instance; return ProxyPluginMgr::instance;
} }
uint64_t ProxyPluginMgr::getUniqueId() uint64_t ProxyPluginMgr::getUniqueId()
{ {
return ++__uniqueId; return ++__uniqueId;
} }
int ProxyPluginMgr::addPlugin(ProxyPlugin** plugin) int ProxyPluginMgr::addPlugin(ProxyPlugin** plugin)
{ {
twrap_proxy_plugin_t* twrap_plugin; twrap_proxy_plugin_t* twrap_plugin;
int ret = -1; int ret = -1;
tsk_list_lock(this->plugins); tsk_list_lock(this->plugins);
if(!plugin || !*plugin) { if(!plugin || !*plugin) {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
goto bail; goto bail;
} }
if(tsk_list_find_item_by_pred(this->plugins, pred_find_plugin_by_value, *plugin)) { if(tsk_list_find_item_by_pred(this->plugins, pred_find_plugin_by_value, *plugin)) {
TSK_DEBUG_ERROR("Plugin already exist"); TSK_DEBUG_ERROR("Plugin already exist");
goto bail; goto bail;
} }
if((twrap_plugin = twrap_proxy_plugin_create(plugin))) { if((twrap_plugin = twrap_proxy_plugin_create(plugin))) {
tsk_list_push_back_data(this->plugins, (void**)&twrap_plugin); tsk_list_push_back_data(this->plugins, (void**)&twrap_plugin);
ret = 0; ret = 0;
} }
else { else {
TSK_DEBUG_ERROR("Failed to create plugin"); TSK_DEBUG_ERROR("Failed to create plugin");
goto bail; goto bail;
} }
bail: bail:
tsk_list_unlock(this->plugins); tsk_list_unlock(this->plugins);
return ret; return ret;
} }
int ProxyPluginMgr::removePlugin(ProxyPlugin** plugin) int ProxyPluginMgr::removePlugin(ProxyPlugin** plugin)
{ {
if(!plugin || !*plugin) { if(!plugin || !*plugin) {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
return -1; return -1;
} }
return this->removePlugin((*plugin)->getId()); return this->removePlugin((*plugin)->getId());
} }
const ProxyPlugin* ProxyPluginMgr::findPlugin(uint64_t id) const ProxyPlugin* ProxyPluginMgr::findPlugin(uint64_t id)
{ {
ProxyPlugin* ret = tsk_null; ProxyPlugin* ret = tsk_null;
tsk_list_item_t* item; tsk_list_item_t* item;
tsk_list_lock(this->plugins); tsk_list_lock(this->plugins);
tsk_list_foreach(item, this->plugins) { tsk_list_foreach(item, this->plugins) {
if(TWRAP_PROXY_PLUGIN(item->data)->plugin->getId() == id) { if(TWRAP_PROXY_PLUGIN(item->data)->plugin->getId() == id) {
ret = TWRAP_PROXY_PLUGIN(item->data)->plugin; ret = TWRAP_PROXY_PLUGIN(item->data)->plugin;
break; break;
} }
} }
tsk_list_unlock(this->plugins); tsk_list_unlock(this->plugins);
return ret; return ret;
} }
const ProxyPlugin* ProxyPluginMgr::findPlugin(tsk_object_t* wrapped_plugin) const ProxyPlugin* ProxyPluginMgr::findPlugin(tsk_object_t* wrapped_plugin)
{ {
ProxyPlugin* ret = tsk_null; ProxyPlugin* ret = tsk_null;
tsk_list_item_t* item; tsk_list_item_t* item;
if(!wrapped_plugin) { if(!wrapped_plugin) {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
return tsk_null; return tsk_null;
} }
tsk_list_lock(this->plugins); tsk_list_lock(this->plugins);
tsk_list_foreach(item, this->plugins) { tsk_list_foreach(item, this->plugins) {
if(TWRAP_PROXY_PLUGIN(item->data)->plugin->isWrapping(wrapped_plugin)) { if(TWRAP_PROXY_PLUGIN(item->data)->plugin->isWrapping(wrapped_plugin)) {
ret = TWRAP_PROXY_PLUGIN(item->data)->plugin; ret = TWRAP_PROXY_PLUGIN(item->data)->plugin;
break; break;
} }
} }
tsk_list_unlock(this->plugins); tsk_list_unlock(this->plugins);
return ret; return ret;
} }
int ProxyPluginMgr::removePlugin(uint64_t id) int ProxyPluginMgr::removePlugin(uint64_t id)
{ {
tsk_list_item_t* item; tsk_list_item_t* item;
tsk_list_lock(this->plugins); tsk_list_lock(this->plugins);
tsk_list_foreach(item, this->plugins) { tsk_list_foreach(item, this->plugins) {
if(TWRAP_PROXY_PLUGIN(item->data)->plugin->getId() == id) { if(TWRAP_PROXY_PLUGIN(item->data)->plugin->getId() == id) {
tsk_list_remove_item(this->plugins, item); tsk_list_remove_item(this->plugins, item);
break; break;
} }
} }
tsk_list_unlock(this->plugins); tsk_list_unlock(this->plugins);
return 0; return 0;
} }
const ProxyAudioConsumer* ProxyPluginMgr::findAudioConsumer(uint64_t id) const ProxyAudioConsumer* ProxyPluginMgr::findAudioConsumer(uint64_t id)
{ {
const ProxyPlugin* audioConsumer = this->findPlugin(id); const ProxyPlugin* audioConsumer = this->findPlugin(id);
if(audioConsumer && audioConsumer->getType() == twrap_proxy_plugin_audio_consumer) { if(audioConsumer && audioConsumer->getType() == twrap_proxy_plugin_audio_consumer) {
return dyn_cast<const ProxyAudioConsumer*>(audioConsumer); return dyn_cast<const ProxyAudioConsumer*>(audioConsumer);
} }
return tsk_null; return tsk_null;
} }
const ProxyVideoConsumer* ProxyPluginMgr::findVideoConsumer(uint64_t id) const ProxyVideoConsumer* ProxyPluginMgr::findVideoConsumer(uint64_t id)
{ {
const ProxyPlugin* videoConsumer = this->findPlugin(id); const ProxyPlugin* videoConsumer = this->findPlugin(id);
if(videoConsumer && videoConsumer->getType() == twrap_proxy_plugin_video_consumer) { if(videoConsumer && videoConsumer->getType() == twrap_proxy_plugin_video_consumer) {
return dyn_cast<const ProxyVideoConsumer*>(videoConsumer); return dyn_cast<const ProxyVideoConsumer*>(videoConsumer);
} }
return tsk_null; return tsk_null;
} }
const ProxyAudioProducer* ProxyPluginMgr::findAudioProducer(uint64_t id) const ProxyAudioProducer* ProxyPluginMgr::findAudioProducer(uint64_t id)
{ {
const ProxyPlugin* audioProducer = this->findPlugin(id); const ProxyPlugin* audioProducer = this->findPlugin(id);
if(audioProducer && audioProducer->getType() == twrap_proxy_plugin_audio_producer) { if(audioProducer && audioProducer->getType() == twrap_proxy_plugin_audio_producer) {
return dyn_cast<const ProxyAudioProducer*>(audioProducer); return dyn_cast<const ProxyAudioProducer*>(audioProducer);
} }
return tsk_null; return tsk_null;
} }
const ProxyVideoProducer* ProxyPluginMgr::findVideoProducer(uint64_t id) const ProxyVideoProducer* ProxyPluginMgr::findVideoProducer(uint64_t id)
{ {
const ProxyPlugin* videoProducer = this->findPlugin(id); const ProxyPlugin* videoProducer = this->findPlugin(id);
if(videoProducer && videoProducer->getType() == twrap_proxy_plugin_video_producer) { if(videoProducer && videoProducer->getType() == twrap_proxy_plugin_video_producer) {
return dyn_cast<const ProxyVideoProducer*>(videoProducer); return dyn_cast<const ProxyVideoProducer*>(videoProducer);
} }
return tsk_null; return tsk_null;
} }
// //
// "twrap_proxy_plugin_t" Implementations // "twrap_proxy_plugin_t" Implementations
// //
static tsk_object_t* twrap_proxy_plugin_ctor(tsk_object_t * self, va_list * app) static tsk_object_t* twrap_proxy_plugin_ctor(tsk_object_t * self, va_list * app)
{ {
twrap_proxy_plugin_t *_self = dyn_cast<twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(self)); twrap_proxy_plugin_t *_self = dyn_cast<twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(self));
if(_self) { if(_self) {
} }
return self; return self;
} }
static tsk_object_t* twrap_proxy_plugin_dtor(tsk_object_t * self) static tsk_object_t* twrap_proxy_plugin_dtor(tsk_object_t * self)
{ {
twrap_proxy_plugin_t *_self = dyn_cast<twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(self)); twrap_proxy_plugin_t *_self = dyn_cast<twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(self));
if(_self) { if(_self) {
if(_self->plugin) { if(_self->plugin) {
delete _self->plugin, _self->plugin = tsk_null; delete _self->plugin, _self->plugin = tsk_null;
} }
} }
return self; return self;
} }
static int twrap_proxy_plugin_cmp(const tsk_object_t *_c1, const tsk_object_t *_c2) static int twrap_proxy_plugin_cmp(const tsk_object_t *_c1, const tsk_object_t *_c2)
{ {
const twrap_proxy_plugin_t *c1 = dyn_cast<const twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(_c1)); const twrap_proxy_plugin_t *c1 = dyn_cast<const twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(_c1));
const twrap_proxy_plugin_t *c2 = dyn_cast<const twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(_c2)); const twrap_proxy_plugin_t *c2 = dyn_cast<const twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(_c2));
if(c1 && c2) { if(c1 && c2) {
return (c1->plugin == c2->plugin); // See "ProxyPlugin::operator ==" return (c1->plugin == c2->plugin); // See "ProxyPlugin::operator =="
} }
else if(!c1 && !c2) { else if(!c1 && !c2) {
return 0; return 0;
} }
else { else {
return -1; return -1;
} }
} }
static const tsk_object_def_t twrap_proxy_plugin_def_s = { static const tsk_object_def_t twrap_proxy_plugin_def_s = {
sizeof(twrap_proxy_plugin_t), sizeof(twrap_proxy_plugin_t),
twrap_proxy_plugin_ctor, twrap_proxy_plugin_ctor,
twrap_proxy_plugin_dtor, twrap_proxy_plugin_dtor,
twrap_proxy_plugin_cmp, twrap_proxy_plugin_cmp,
}; };
const tsk_object_def_t *twrap_proxy_plugin_def_t = &twrap_proxy_plugin_def_s; const tsk_object_def_t *twrap_proxy_plugin_def_t = &twrap_proxy_plugin_def_s;
static int pred_find_plugin_by_value(const tsk_list_item_t *item, const void *proxyPlugin) static int pred_find_plugin_by_value(const tsk_list_item_t *item, const void *proxyPlugin)
{ {
if(item && item->data) { if(item && item->data) {
const twrap_proxy_plugin_t *twrap_plugin = dyn_cast<const twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(item->data)); const twrap_proxy_plugin_t *twrap_plugin = dyn_cast<const twrap_proxy_plugin_t *>(TWRAP_PROXY_PLUGIN(item->data));
return (twrap_plugin->plugin == dyn_cast<const ProxyPlugin *>((const ProxyPlugin*)proxyPlugin)) ? 0 : -1; return (twrap_plugin->plugin == dyn_cast<const ProxyPlugin *>((const ProxyPlugin*)proxyPlugin)) ? 0 : -1;
} }
return -1; return -1;
} }
static twrap_proxy_plugin_t* twrap_proxy_plugin_create(ProxyPlugin** plugin) static twrap_proxy_plugin_t* twrap_proxy_plugin_create(ProxyPlugin** plugin)
{ {
if(!plugin || !*plugin) { if(!plugin || !*plugin) {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
return tsk_null; return tsk_null;
} }
twrap_proxy_plugin_t* twrap_plugin = (twrap_proxy_plugin_t*)tsk_object_new(twrap_proxy_plugin_def_t); twrap_proxy_plugin_t* twrap_plugin = (twrap_proxy_plugin_t*)tsk_object_new(twrap_proxy_plugin_def_t);
if(!twrap_plugin) { if(!twrap_plugin) {
TSK_DEBUG_ERROR("Failed to create new instance of 'twrap_proxy_plugin_t'"); TSK_DEBUG_ERROR("Failed to create new instance of 'twrap_proxy_plugin_t'");
return tsk_null; return tsk_null;
} }
twrap_plugin->plugin = *plugin, twrap_plugin->plugin = *plugin,
*plugin = tsk_null; *plugin = tsk_null;
return twrap_plugin; return twrap_plugin;
} }

View File

@ -1,137 +1,137 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_PROXY_PLUGIN_MGR_H #ifndef TINYWRAP_PROXY_PLUGIN_MGR_H
#define TINYWRAP_PROXY_PLUGIN_MGR_H #define TINYWRAP_PROXY_PLUGIN_MGR_H
#include "tinymedia.h" #include "tinymedia.h"
#include "Common.h" #include "Common.h"
class ProxyPlugin; class ProxyPlugin;
class ProxyConsumer; class ProxyConsumer;
class ProxyAudioConsumer; class ProxyAudioConsumer;
class ProxyVideoConsumer; class ProxyVideoConsumer;
class ProxyAudioProducer; class ProxyAudioProducer;
class ProxyVideoProducer; class ProxyVideoProducer;
class ProxyPluginMgrCallback; class ProxyPluginMgrCallback;
typedef enum twrap_proxy_plugin_type_e { typedef enum twrap_proxy_plugin_type_e {
twrap_proxy_plugin_audio_producer, twrap_proxy_plugin_audio_producer,
twrap_proxy_plugin_video_producer, twrap_proxy_plugin_video_producer,
twrap_proxy_plugin_audio_consumer, twrap_proxy_plugin_audio_consumer,
twrap_proxy_plugin_video_consumer, twrap_proxy_plugin_video_consumer,
} }
twrap_proxy_plugin_type_t; twrap_proxy_plugin_type_t;
/* ============ ProxyPluginMgr Class ================= */ /* ============ ProxyPluginMgr Class ================= */
typedef tsk_list_t twrap_proxy_plungins_L_t; // contains "twrap_proxy_plungin_t" elements typedef tsk_list_t twrap_proxy_plungins_L_t; // contains "twrap_proxy_plungin_t" elements
class ProxyPluginMgr class ProxyPluginMgr
{ {
private: private:
ProxyPluginMgr(ProxyPluginMgrCallback* callback); ProxyPluginMgr(ProxyPluginMgrCallback* callback);
public: public:
virtual ~ProxyPluginMgr(); virtual ~ProxyPluginMgr();
// SWIG %newobject // SWIG %newobject
static ProxyPluginMgr* createInstance(ProxyPluginMgrCallback* pCallback); static ProxyPluginMgr* createInstance(ProxyPluginMgrCallback* pCallback);
#if !defined(SWIG) #if !defined(SWIG)
static void destroyInstance(ProxyPluginMgr** ppInstance); static void destroyInstance(ProxyPluginMgr** ppInstance);
#endif #endif
static ProxyPluginMgr* getInstance(); static ProxyPluginMgr* getInstance();
#if !defined(SWIG) #if !defined(SWIG)
static uint64_t getUniqueId(); static uint64_t getUniqueId();
int addPlugin(ProxyPlugin**); int addPlugin(ProxyPlugin**);
const ProxyPlugin* findPlugin(tsk_object_t* wrapped_plugin); const ProxyPlugin* findPlugin(tsk_object_t* wrapped_plugin);
int removePlugin(uint64_t id); int removePlugin(uint64_t id);
int removePlugin(ProxyPlugin**); int removePlugin(ProxyPlugin**);
inline ProxyPluginMgrCallback* getCallback() { inline ProxyPluginMgrCallback* getCallback() {
return this->callback; return this->callback;
} }
#endif #endif
const ProxyPlugin* findPlugin(uint64_t id); const ProxyPlugin* findPlugin(uint64_t id);
const ProxyAudioConsumer* findAudioConsumer(uint64_t id); const ProxyAudioConsumer* findAudioConsumer(uint64_t id);
const ProxyVideoConsumer* findVideoConsumer(uint64_t id); const ProxyVideoConsumer* findVideoConsumer(uint64_t id);
const ProxyAudioProducer* findAudioProducer(uint64_t id); const ProxyAudioProducer* findAudioProducer(uint64_t id);
const ProxyVideoProducer* findVideoProducer(uint64_t id); const ProxyVideoProducer* findVideoProducer(uint64_t id);
private: private:
static ProxyPluginMgr* instance; static ProxyPluginMgr* instance;
ProxyPluginMgrCallback* callback; ProxyPluginMgrCallback* callback;
twrap_proxy_plungins_L_t* plugins; twrap_proxy_plungins_L_t* plugins;
}; };
/* ============ ProxyPluginMgrCallback Class ================= */ /* ============ ProxyPluginMgrCallback Class ================= */
class ProxyPluginMgrCallback class ProxyPluginMgrCallback
{ {
public: public:
ProxyPluginMgrCallback() { } ProxyPluginMgrCallback() { }
virtual ~ProxyPluginMgrCallback() { } virtual ~ProxyPluginMgrCallback() { }
virtual int OnPluginCreated(uint64_t id, enum twrap_proxy_plugin_type_e type) { virtual int OnPluginCreated(uint64_t id, enum twrap_proxy_plugin_type_e type) {
return -1; return -1;
} }
virtual int OnPluginDestroyed(uint64_t id, enum twrap_proxy_plugin_type_e type) { virtual int OnPluginDestroyed(uint64_t id, enum twrap_proxy_plugin_type_e type) {
return -1; return -1;
} }
}; };
/* ============ ProxyPlugin Class ================= */ /* ============ ProxyPlugin Class ================= */
class ProxyPlugin class ProxyPlugin
{ {
public: public:
#if !defined SWIG #if !defined SWIG
ProxyPlugin(twrap_proxy_plugin_type_t _type) { ProxyPlugin(twrap_proxy_plugin_type_t _type) {
this->type=_type; this->type=_type;
this->id = ProxyPluginMgr::getUniqueId(); this->id = ProxyPluginMgr::getUniqueId();
} }
#endif #endif
virtual ~ProxyPlugin() {} virtual ~ProxyPlugin() {}
#if !defined(SWIG) #if !defined(SWIG)
virtual bool operator ==(const ProxyPlugin &plugin)const { virtual bool operator ==(const ProxyPlugin &plugin)const {
return this->getId() == plugin.getId(); return this->getId() == plugin.getId();
} }
virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) = 0; virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) = 0;
virtual inline uint64_t getMediaSessionId() = 0; virtual inline uint64_t getMediaSessionId() = 0;
#endif #endif
inline twrap_proxy_plugin_type_t getType()const { inline twrap_proxy_plugin_type_t getType()const {
return this->type; return this->type;
} }
inline uint64_t getId()const { inline uint64_t getId()const {
return this->id; return this->id;
} }
protected: protected:
uint64_t id; uint64_t id;
twrap_proxy_plugin_type_t type; twrap_proxy_plugin_type_t type;
}; };
#endif /* TINYWRAP_PROXY_PLUGIN_MGR_H */ #endif /* TINYWRAP_PROXY_PLUGIN_MGR_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +1,200 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
/**@file ProxyProducer.h /**@file ProxyProducer.h
* @brief Audio/Video proxy consumers. * @brief Audio/Video proxy consumers.
* *
* @author Mamadou Diop <diopmamadou(at)doubango.org> * @author Mamadou Diop <diopmamadou(at)doubango.org>
* *
*/ */
#ifndef TINYWRAP_PRODUCER_PROXY_H #ifndef TINYWRAP_PRODUCER_PROXY_H
#define TINYWRAP_PRODUCER_PROXY_H #define TINYWRAP_PRODUCER_PROXY_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "ProxyPluginMgr.h" #include "ProxyPluginMgr.h"
#include "tinymedia/tmedia_common.h" #include "tinymedia/tmedia_common.h"
#include "tinymedia/tmedia_producer.h" #include "tinymedia/tmedia_producer.h"
/* ============ ProxyAudioProducerCallback Class ================= */ /* ============ ProxyAudioProducerCallback Class ================= */
class ProxyAudioProducerCallback class ProxyAudioProducerCallback
{ {
public: public:
ProxyAudioProducerCallback() { } ProxyAudioProducerCallback() { }
virtual ~ProxyAudioProducerCallback() { } virtual ~ProxyAudioProducerCallback() { }
virtual int prepare(int ptime, int rate, int channels) { virtual int prepare(int ptime, int rate, int channels) {
return -1; return -1;
} }
virtual int start() { virtual int start() {
return -1; return -1;
} }
virtual int pause() { virtual int pause() {
return -1; return -1;
} }
virtual int stop() { virtual int stop() {
return -1; return -1;
} }
// this function is called to signal that it's time to copy push data // this function is called to signal that it's time to copy push data
virtual int fillPushBuffer() { virtual int fillPushBuffer() {
return -1; return -1;
} }
}; };
/* ============ ProxyAudioProducer Class ================= */ /* ============ ProxyAudioProducer Class ================= */
class ProxyAudioProducer : public ProxyPlugin class ProxyAudioProducer : public ProxyPlugin
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
ProxyAudioProducer(struct twrap_producer_proxy_audio_s* pProducer); ProxyAudioProducer(struct twrap_producer_proxy_audio_s* pProducer);
#endif #endif
virtual ~ProxyAudioProducer(); virtual ~ProxyAudioProducer();
bool setActualSndCardRecordParams(int nPtime, int nRate, int nChannels); bool setActualSndCardRecordParams(int nPtime, int nRate, int nChannels);
bool setPushBuffer(const void* pPushBufferPtr, unsigned nPushBufferSize, bool bUsePushCallback=false); bool setPushBuffer(const void* pPushBufferPtr, unsigned nPushBufferSize, bool bUsePushCallback=false);
int push(const void* pBuffer=tsk_null, unsigned nSize=0); int push(const void* pBuffer=tsk_null, unsigned nSize=0);
bool setGain(unsigned nGain); bool setGain(unsigned nGain);
unsigned getGain(); unsigned getGain();
void setCallback(ProxyAudioProducerCallback* pCallback) { void setCallback(ProxyAudioProducerCallback* pCallback) {
m_pCallback = pCallback; m_pCallback = pCallback;
} }
#if !defined(SWIG) #if !defined(SWIG)
inline bool usePushCallback() { inline bool usePushCallback() {
return m_bUsePushCallback; return m_bUsePushCallback;
} }
inline ProxyAudioProducerCallback* getCallback()const { inline ProxyAudioProducerCallback* getCallback()const {
return m_pCallback; return m_pCallback;
} }
virtual inline bool isWrapping(tsk_object_t* pWrappedPlugin) { virtual inline bool isWrapping(tsk_object_t* pWrappedPlugin) {
return m_pWrappedPlugin == pWrappedPlugin; return m_pWrappedPlugin == pWrappedPlugin;
} }
#endif #endif
virtual inline uint64_t getMediaSessionId() { virtual inline uint64_t getMediaSessionId() {
return m_pWrappedPlugin ? TMEDIA_PRODUCER(m_pWrappedPlugin)->session_id : 0; return m_pWrappedPlugin ? TMEDIA_PRODUCER(m_pWrappedPlugin)->session_id : 0;
} }
#if !defined(SWIG) #if !defined(SWIG)
public: public:
bool startPushCallback(); bool startPushCallback();
bool stopPushCallback(); bool stopPushCallback();
private: private:
static int pushTimerCallback(const void* arg, tsk_timer_id_t timer_id); static int pushTimerCallback(const void* arg, tsk_timer_id_t timer_id);
#endif #endif
public: public:
static bool registerPlugin(); static bool registerPlugin();
private: private:
struct twrap_producer_proxy_audio_s* m_pWrappedPlugin; struct twrap_producer_proxy_audio_s* m_pWrappedPlugin;
ProxyAudioProducerCallback* m_pCallback; ProxyAudioProducerCallback* m_pCallback;
struct { struct {
const void* pPushBufferPtr; const void* pPushBufferPtr;
unsigned nPushBufferSize; unsigned nPushBufferSize;
} m_PushBuffer; } m_PushBuffer;
bool m_bUsePushCallback; bool m_bUsePushCallback;
void* m_hPushTimerMgr; void* m_hPushTimerMgr;
uint64_t m_uPushTimer; uint64_t m_uPushTimer;
}; };
/* ============ ProxyVideoProducerCallback Class ================= */ /* ============ ProxyVideoProducerCallback Class ================= */
class ProxyVideoProducerCallback class ProxyVideoProducerCallback
{ {
public: public:
ProxyVideoProducerCallback() { } ProxyVideoProducerCallback() { }
virtual ~ProxyVideoProducerCallback() { } virtual ~ProxyVideoProducerCallback() { }
virtual int prepare(int width, int height, int fps) { virtual int prepare(int width, int height, int fps) {
return -1; return -1;
} }
virtual int start() { virtual int start() {
return -1; return -1;
} }
virtual int pause() { virtual int pause() {
return -1; return -1;
} }
virtual int stop() { virtual int stop() {
return -1; return -1;
} }
}; };
/* ============ ProxyVideoProducer Class ================= */ /* ============ ProxyVideoProducer Class ================= */
class ProxyVideoProducer : public ProxyPlugin class ProxyVideoProducer : public ProxyPlugin
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
ProxyVideoProducer(tmedia_chroma_t eChroma, struct twrap_producer_proxy_video_s* pProducer); ProxyVideoProducer(tmedia_chroma_t eChroma, struct twrap_producer_proxy_video_s* pProducer);
#endif #endif
virtual ~ProxyVideoProducer(); virtual ~ProxyVideoProducer();
int getRotation()const; int getRotation()const;
bool setRotation(int nRot); bool setRotation(int nRot);
bool getMirror()const; bool getMirror()const;
bool setMirror(bool bMirror); bool setMirror(bool bMirror);
bool setActualCameraOutputSize(unsigned nWidth, unsigned nHeight); bool setActualCameraOutputSize(unsigned nWidth, unsigned nHeight);
int push(const void* pBuffer, unsigned nSize); int push(const void* pBuffer, unsigned nSize);
void setCallback(ProxyVideoProducerCallback* pCallback) { void setCallback(ProxyVideoProducerCallback* pCallback) {
m_pCallback = pCallback; m_pCallback = pCallback;
} }
#if !defined(SWIG) #if !defined(SWIG)
int sendRaw(const void* pBuffer, unsigned nSize, unsigned nDuration, bool bMarker); int sendRaw(const void* pBuffer, unsigned nSize, unsigned nDuration, bool bMarker);
int sendRaw(const void* pBuffer, unsigned nSize, const void* proto_hdr); int sendRaw(const void* pBuffer, unsigned nSize, const void* proto_hdr);
inline ProxyVideoProducerCallback* getCallback()const { inline ProxyVideoProducerCallback* getCallback()const {
return m_pCallback; return m_pCallback;
} }
virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) { virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) {
return m_pWrappedPlugin == wrapped_plugin; return m_pWrappedPlugin == wrapped_plugin;
} }
virtual inline const tmedia_producer_t* getWrappedPlugin()const { virtual inline const tmedia_producer_t* getWrappedPlugin()const {
return (tmedia_producer_t*)m_pWrappedPlugin; return (tmedia_producer_t*)m_pWrappedPlugin;
} }
#endif #endif
virtual inline uint64_t getMediaSessionId() { virtual inline uint64_t getMediaSessionId() {
return m_pWrappedPlugin ? TMEDIA_PRODUCER(m_pWrappedPlugin)->session_id : 0; return m_pWrappedPlugin ? TMEDIA_PRODUCER(m_pWrappedPlugin)->session_id : 0;
} }
public: public:
static bool registerPlugin(); static bool registerPlugin();
static void setDefaultChroma(tmedia_chroma_t eChroma) { static void setDefaultChroma(tmedia_chroma_t eChroma) {
s_eDefaultChroma = eChroma; s_eDefaultChroma = eChroma;
} }
#if !defined(SWIG) #if !defined(SWIG)
tmedia_chroma_t getChroma()const; tmedia_chroma_t getChroma()const;
static tmedia_chroma_t getDefaultChroma() { static tmedia_chroma_t getDefaultChroma() {
return s_eDefaultChroma; return s_eDefaultChroma;
} }
#endif #endif
private: private:
struct twrap_producer_proxy_video_s* m_pWrappedPlugin; struct twrap_producer_proxy_video_s* m_pWrappedPlugin;
ProxyVideoProducerCallback* m_pCallback; ProxyVideoProducerCallback* m_pCallback;
tmedia_chroma_t m_eChroma; tmedia_chroma_t m_eChroma;
int m_nRotation; int m_nRotation;
bool m_bMirror; bool m_bMirror;
static tmedia_chroma_t s_eDefaultChroma; static tmedia_chroma_t s_eDefaultChroma;
}; };
#endif /* TINYWRAP_PRODUCER_PROXY_H */ #endif /* TINYWRAP_PRODUCER_PROXY_H */

View File

@ -1,7 +1,7 @@
%{ %{
#include "SMSEncoder.h" #include "SMSEncoder.h"
%} %}
%nodefaultctor; %nodefaultctor;
%include "SMSEncoder.h" %include "SMSEncoder.h"
%clearnodefaultctor; %clearnodefaultctor;

View File

@ -1,371 +1,371 @@
/* /*
* Copyright (C) 2009 Mamadou Diop. * Copyright (C) 2009 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou@doubango.org> * Contact: Mamadou Diop <diopmamadou@doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "SMSEncoder.h" #include "SMSEncoder.h"
// Short description: http://betelco.blogspot.com/2009/10/sms-over-3gpp-ims-network.html // Short description: http://betelco.blogspot.com/2009/10/sms-over-3gpp-ims-network.html
RPMessage::RPMessage(twrap_rpmessage_type_t _type, tsms_rpdu_message_t* _rp_message) RPMessage::RPMessage(twrap_rpmessage_type_t _type, tsms_rpdu_message_t* _rp_message)
{ {
this->rp_message = (tsms_rpdu_message_t*)tsk_object_ref(_rp_message); this->rp_message = (tsms_rpdu_message_t*)tsk_object_ref(_rp_message);
this->type = _type; this->type = _type;
this->tmpBuffer = tsk_null; this->tmpBuffer = tsk_null;
} }
RPMessage::RPMessage() : RPMessage::RPMessage() :
rp_message(tsk_null), rp_message(tsk_null),
type(twrap_rpmessage_type_sms_none), type(twrap_rpmessage_type_sms_none),
tmpBuffer(tsk_null) tmpBuffer(tsk_null)
{ {
} }
twrap_rpmessage_type_t RPMessage::getType() twrap_rpmessage_type_t RPMessage::getType()
{ {
return this->type; return this->type;
} }
unsigned RPMessage::getPayloadLength() unsigned RPMessage::getPayloadLength()
{ {
if(!this->tmpBuffer) { if(!this->tmpBuffer) {
if((this->tmpBuffer = tsk_buffer_create_null())) { if((this->tmpBuffer = tsk_buffer_create_null())) {
tsms_rpdu_data_serialize(this->rp_message, this->tmpBuffer); tsms_rpdu_data_serialize(this->rp_message, this->tmpBuffer);
} }
} }
return this->tmpBuffer ? this->tmpBuffer->size : 0; return this->tmpBuffer ? this->tmpBuffer->size : 0;
} }
unsigned RPMessage::getPayload(void* output, unsigned maxsize) unsigned RPMessage::getPayload(void* output, unsigned maxsize)
{ {
unsigned retsize = 0; unsigned retsize = 0;
if(!this->tmpBuffer) { if(!this->tmpBuffer) {
if((this->tmpBuffer = tsk_buffer_create_null())) { if((this->tmpBuffer = tsk_buffer_create_null())) {
tsms_rpdu_message_serialize(this->rp_message, this->tmpBuffer); tsms_rpdu_message_serialize(this->rp_message, this->tmpBuffer);
} }
} }
if(output && maxsize && this->tmpBuffer && this->tmpBuffer->data) { if(output && maxsize && this->tmpBuffer && this->tmpBuffer->data) {
retsize = (this->tmpBuffer->size > maxsize) ? maxsize : this->tmpBuffer->size; retsize = (this->tmpBuffer->size > maxsize) ? maxsize : this->tmpBuffer->size;
memcpy(output, this->tmpBuffer->data, retsize); memcpy(output, this->tmpBuffer->data, retsize);
} }
return retsize; return retsize;
} }
RPMessage::~RPMessage() RPMessage::~RPMessage()
{ {
TSK_OBJECT_SAFE_FREE(this->rp_message); TSK_OBJECT_SAFE_FREE(this->rp_message);
TSK_OBJECT_SAFE_FREE(this->tmpBuffer); TSK_OBJECT_SAFE_FREE(this->tmpBuffer);
} }
SMSData::SMSData(twrap_sms_type_t _type, int _mr, const void* _ascii, tsk_size_t _size): oa(tsk_null), da(tsk_null) SMSData::SMSData(twrap_sms_type_t _type, int _mr, const void* _ascii, tsk_size_t _size): oa(tsk_null), da(tsk_null)
{ {
this->type = _type; this->type = _type;
this->mr = _mr; this->mr = _mr;
if((this->size = _size)) { if((this->size = _size)) {
if((this->ascii = tsk_calloc(size+1, 1))) { if((this->ascii = tsk_calloc(size+1, 1))) {
memcpy(this->ascii, _ascii, _size); memcpy(this->ascii, _ascii, _size);
} }
} }
else { else {
this->ascii = tsk_null; this->ascii = tsk_null;
} }
} }
SMSData::SMSData(): oa(tsk_null), da(tsk_null) SMSData::SMSData(): oa(tsk_null), da(tsk_null)
{ {
this->type = twrap_sms_type_none; this->type = twrap_sms_type_none;
this->mr = 0; this->mr = 0;
this->size = 0; this->size = 0;
this->ascii = tsk_null; this->ascii = tsk_null;
} }
SMSData::~SMSData() SMSData::~SMSData()
{ {
TSK_FREE(this->ascii); TSK_FREE(this->ascii);
TSK_FREE(this->oa); TSK_FREE(this->oa);
TSK_FREE(this->da); TSK_FREE(this->da);
} }
twrap_sms_type_t SMSData::getType() twrap_sms_type_t SMSData::getType()
{ {
return this->type; return this->type;
} }
int SMSData::getMR() int SMSData::getMR()
{ {
return this->mr; return this->mr;
} }
unsigned SMSData::getPayloadLength() unsigned SMSData::getPayloadLength()
{ {
return this->size; return this->size;
} }
unsigned SMSData::getPayload(void* output, unsigned maxsize) unsigned SMSData::getPayload(void* output, unsigned maxsize)
{ {
unsigned retsize = 0; unsigned retsize = 0;
if(output && maxsize && this->ascii) { if(output && maxsize && this->ascii) {
retsize = (this->size > maxsize) ? maxsize : this->size; retsize = (this->size > maxsize) ? maxsize : this->size;
memcpy(output, this->ascii, retsize); memcpy(output, this->ascii, retsize);
} }
return retsize; return retsize;
} }
const char* SMSData::getOA() const char* SMSData::getOA()
{ {
return this->oa; return this->oa;
} }
const char* SMSData::getDA() const char* SMSData::getDA()
{ {
return this->da; return this->da;
} }
void SMSData::setOA(const char* _oa) void SMSData::setOA(const char* _oa)
{ {
TSK_FREE(this->oa); TSK_FREE(this->oa);
this->oa = tsk_strdup(_oa); this->oa = tsk_strdup(_oa);
} }
void SMSData::setDA(const char* _da) void SMSData::setDA(const char* _da)
{ {
TSK_FREE(this->da); TSK_FREE(this->da);
this->da = tsk_strdup(_da); this->da = tsk_strdup(_da);
} }
// More information about RP-DATA: http://www.doubango.org/API/tinySMS/group__tsms__rpdu__group.html#tsms_rpdu_group_DATA // More information about RP-DATA: http://www.doubango.org/API/tinySMS/group__tsms__rpdu__group.html#tsms_rpdu_group_DATA
RPMessage* SMSEncoder::encodeSubmit(int mr, const char *smsc, const char *destination, const char *ascii) RPMessage* SMSEncoder::encodeSubmit(int mr, const char *smsc, const char *destination, const char *ascii)
{ {
int ret; int ret;
tsk_buffer_t* buffer = tsk_null; tsk_buffer_t* buffer = tsk_null;
tsms_tpdu_submit_t* sms_submit = tsk_null; tsms_tpdu_submit_t* sms_submit = tsk_null;
tsms_rpdu_data_t* rp_data = tsk_null; tsms_rpdu_data_t* rp_data = tsk_null;
RPMessage* encodedData = tsk_null; RPMessage* encodedData = tsk_null;
if(!smsc || ! destination || !ascii) { if(!smsc || ! destination || !ascii) {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
return tsk_null; return tsk_null;
} }
if(mr<0 || mr>0xFF) { if(mr<0 || mr>0xFF) {
TSK_DEBUG_WARN("Invalid Message Reference"); TSK_DEBUG_WARN("Invalid Message Reference");
mr &= 0xFF; mr &= 0xFF;
} }
// create SMS-SUBMIT message // create SMS-SUBMIT message
if(!(sms_submit = tsms_tpdu_submit_create(mr, (const uint8_t*)smsc, (const uint8_t*)destination))) { if(!(sms_submit = tsms_tpdu_submit_create(mr, (const uint8_t*)smsc, (const uint8_t*)destination))) {
TSK_DEBUG_ERROR("Failed to create the TPDU SMS-SUBMIT message"); TSK_DEBUG_ERROR("Failed to create the TPDU SMS-SUBMIT message");
goto bail; goto bail;
} }
// Set content for SMS-SUBMIT // Set content for SMS-SUBMIT
if((buffer = tsms_pack_to_7bit(ascii))) { if((buffer = tsms_pack_to_7bit(ascii))) {
ret = tsms_tpdu_submit_set_userdata(sms_submit, buffer, tsms_alpha_7bit); ret = tsms_tpdu_submit_set_userdata(sms_submit, buffer, tsms_alpha_7bit);
TSK_OBJECT_SAFE_FREE(buffer); TSK_OBJECT_SAFE_FREE(buffer);
} }
else { else {
TSK_DEBUG_ERROR("Failed to encode the TPDU SMS-SUBMIT message"); TSK_DEBUG_ERROR("Failed to encode the TPDU SMS-SUBMIT message");
goto bail; goto bail;
} }
// create RP-DATA(SMS-SUBMIT) // create RP-DATA(SMS-SUBMIT)
if((rp_data = tsms_rpdu_data_create_mo(mr, (const uint8_t*)smsc, TSMS_TPDU_MESSAGE(sms_submit)))) { if((rp_data = tsms_rpdu_data_create_mo(mr, (const uint8_t*)smsc, TSMS_TPDU_MESSAGE(sms_submit)))) {
encodedData = new RPMessage(twrap_rpmessage_type_sms_submit, TSMS_RPDU_MESSAGE(rp_data)); encodedData = new RPMessage(twrap_rpmessage_type_sms_submit, TSMS_RPDU_MESSAGE(rp_data));
} }
else { else {
TSK_DEBUG_ERROR("Failed to create the RP-DATA(SMS-SUBMIT) message"); TSK_DEBUG_ERROR("Failed to create the RP-DATA(SMS-SUBMIT) message");
goto bail; goto bail;
} }
bail: bail:
TSK_OBJECT_SAFE_FREE(buffer); TSK_OBJECT_SAFE_FREE(buffer);
TSK_OBJECT_SAFE_FREE(sms_submit); TSK_OBJECT_SAFE_FREE(sms_submit);
TSK_OBJECT_SAFE_FREE(rp_data); TSK_OBJECT_SAFE_FREE(rp_data);
return encodedData; return encodedData;
} }
// More information about RP-DATA: http://www.doubango.org/API/tinySMS/group__tsms__rpdu__group.html#tsms_rpdu_group_DATA // More information about RP-DATA: http://www.doubango.org/API/tinySMS/group__tsms__rpdu__group.html#tsms_rpdu_group_DATA
RPMessage* SMSEncoder::encodeDeliver(int mr, const char* smsc, const char* originator, const char* ascii) RPMessage* SMSEncoder::encodeDeliver(int mr, const char* smsc, const char* originator, const char* ascii)
{ {
int ret; int ret;
tsk_buffer_t* buffer = tsk_null; tsk_buffer_t* buffer = tsk_null;
tsms_tpdu_deliver_t* sms_deliver = tsk_null; tsms_tpdu_deliver_t* sms_deliver = tsk_null;
tsms_rpdu_data_t* rp_data = tsk_null; tsms_rpdu_data_t* rp_data = tsk_null;
RPMessage* encodedData = tsk_null; RPMessage* encodedData = tsk_null;
if(!smsc || ! originator || !ascii) { if(!smsc || ! originator || !ascii) {
TSK_DEBUG_ERROR("Invalid parameter"); TSK_DEBUG_ERROR("Invalid parameter");
return tsk_null; return tsk_null;
} }
if(mr<0 || mr>0xFF) { if(mr<0 || mr>0xFF) {
TSK_DEBUG_WARN("Invalid Message Reference"); TSK_DEBUG_WARN("Invalid Message Reference");
mr &= 0xFF; mr &= 0xFF;
} }
// create SMS-DELIVER message // create SMS-DELIVER message
sms_deliver = tsms_tpdu_deliver_create((const uint8_t*)smsc, (const uint8_t*)originator); sms_deliver = tsms_tpdu_deliver_create((const uint8_t*)smsc, (const uint8_t*)originator);
// Set content for SMS-DELIVER // Set content for SMS-DELIVER
if((buffer = tsms_pack_to_7bit(ascii))) { if((buffer = tsms_pack_to_7bit(ascii))) {
ret = tsms_tpdu_deliver_set_userdata(sms_deliver, buffer, tsms_alpha_7bit); ret = tsms_tpdu_deliver_set_userdata(sms_deliver, buffer, tsms_alpha_7bit);
TSK_OBJECT_SAFE_FREE(buffer); TSK_OBJECT_SAFE_FREE(buffer);
} }
// create RP-DATA message // create RP-DATA message
if((rp_data = tsms_rpdu_data_create_mt(mr, (const uint8_t*)smsc, TSMS_TPDU_MESSAGE(sms_deliver)))) { if((rp_data = tsms_rpdu_data_create_mt(mr, (const uint8_t*)smsc, TSMS_TPDU_MESSAGE(sms_deliver)))) {
encodedData = new RPMessage(twrap_rpmessage_type_sms_deliver, TSMS_RPDU_MESSAGE(rp_data)); encodedData = new RPMessage(twrap_rpmessage_type_sms_deliver, TSMS_RPDU_MESSAGE(rp_data));
} }
else { else {
TSK_DEBUG_ERROR("Failed to create the RP-DATA(SMS-DELIVER) message"); TSK_DEBUG_ERROR("Failed to create the RP-DATA(SMS-DELIVER) message");
goto bail; goto bail;
} }
bail: bail:
TSK_OBJECT_SAFE_FREE(buffer); TSK_OBJECT_SAFE_FREE(buffer);
TSK_OBJECT_SAFE_FREE(sms_deliver); TSK_OBJECT_SAFE_FREE(sms_deliver);
TSK_OBJECT_SAFE_FREE(rp_data); TSK_OBJECT_SAFE_FREE(rp_data);
return encodedData; return encodedData;
} }
RPMessage* SMSEncoder::encodeACK(int mr, const char* smsc, const char* destination, bool forSUBMIT) RPMessage* SMSEncoder::encodeACK(int mr, const char* smsc, const char* destination, bool forSUBMIT)
{ {
tsms_tpdu_report_t* sms_report = tsk_null; tsms_tpdu_report_t* sms_report = tsk_null;
tsms_rpdu_ack_t* rp_ack = tsk_null; tsms_rpdu_ack_t* rp_ack = tsk_null;
tsk_bool_t isSUBMIT = forSUBMIT ? tsk_true : tsk_false; tsk_bool_t isSUBMIT = forSUBMIT ? tsk_true : tsk_false;
tsk_bool_t isERROR = tsk_false; tsk_bool_t isERROR = tsk_false;
RPMessage* encodedData = tsk_null; RPMessage* encodedData = tsk_null;
// create SMS-DELIVER(or SUBMIT)-REPORT message // create SMS-DELIVER(or SUBMIT)-REPORT message
sms_report = tsms_tpdu_report_create((const uint8_t*)smsc, isSUBMIT, isERROR); sms_report = tsms_tpdu_report_create((const uint8_t*)smsc, isSUBMIT, isERROR);
// create RP-ACK message (From MS to SC) // create RP-ACK message (From MS to SC)
if((rp_ack = tsms_rpdu_ack_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report)))) { if((rp_ack = tsms_rpdu_ack_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report)))) {
encodedData = new RPMessage(twrap_rpmessage_type_sms_ack, TSMS_RPDU_MESSAGE(rp_ack)); encodedData = new RPMessage(twrap_rpmessage_type_sms_ack, TSMS_RPDU_MESSAGE(rp_ack));
} }
TSK_OBJECT_SAFE_FREE(sms_report); TSK_OBJECT_SAFE_FREE(sms_report);
TSK_OBJECT_SAFE_FREE(rp_ack); TSK_OBJECT_SAFE_FREE(rp_ack);
return encodedData; return encodedData;
} }
RPMessage* SMSEncoder::encodeError(int mr, const char* smsc, const char* destination, bool forSUBMIT) RPMessage* SMSEncoder::encodeError(int mr, const char* smsc, const char* destination, bool forSUBMIT)
{ {
tsms_tpdu_report_t* sms_report = tsk_null; tsms_tpdu_report_t* sms_report = tsk_null;
tsms_rpdu_error_t* rp_error= tsk_null; tsms_rpdu_error_t* rp_error= tsk_null;
tsk_bool_t isSUBMIT = forSUBMIT ? tsk_true : tsk_false; tsk_bool_t isSUBMIT = forSUBMIT ? tsk_true : tsk_false;
tsk_bool_t isERROR = tsk_true; tsk_bool_t isERROR = tsk_true;
RPMessage* encodedData = tsk_null; RPMessage* encodedData = tsk_null;
// create SMS-DELIVER-REPORT message // create SMS-DELIVER-REPORT message
sms_report = tsms_tpdu_report_create((const uint8_t*)smsc, isSUBMIT, isERROR); sms_report = tsms_tpdu_report_create((const uint8_t*)smsc, isSUBMIT, isERROR);
// create RP-ERROR message // create RP-ERROR message
if((rp_error = tsms_rpdu_error_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report), 0x0A/*call barred*/))) { if((rp_error = tsms_rpdu_error_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report), 0x0A/*call barred*/))) {
encodedData = new RPMessage(twrap_rpmessage_type_sms_error, TSMS_RPDU_MESSAGE(rp_error)); encodedData = new RPMessage(twrap_rpmessage_type_sms_error, TSMS_RPDU_MESSAGE(rp_error));
} }
TSK_OBJECT_SAFE_FREE(sms_report); TSK_OBJECT_SAFE_FREE(sms_report);
TSK_OBJECT_SAFE_FREE(rp_error); TSK_OBJECT_SAFE_FREE(rp_error);
return encodedData; return encodedData;
} }
SMSData* SMSEncoder::decode(const void* data, unsigned size, bool MobOrig) SMSData* SMSEncoder::decode(const void* data, unsigned size, bool MobOrig)
{ {
tsms_rpdu_message_t* rp_message = tsk_null; tsms_rpdu_message_t* rp_message = tsk_null;
tsms_tpdu_message_t* tpdu = tsk_null; tsms_tpdu_message_t* tpdu = tsk_null;
SMSData* decodedData = tsk_null; SMSData* decodedData = tsk_null;
if(!(rp_message = tsms_rpdu_message_deserialize(data, size))) { if(!(rp_message = tsms_rpdu_message_deserialize(data, size))) {
TSK_DEBUG_ERROR("Failed to deserialize the RP-MESSAGE"); TSK_DEBUG_ERROR("Failed to deserialize the RP-MESSAGE");
goto bail; goto bail;
} }
switch(rp_message->mti) { switch(rp_message->mti) {
case tsms_rpdu_type_data_mo: case tsms_rpdu_type_data_mo:
case tsms_rpdu_type_data_mt: { case tsms_rpdu_type_data_mt: {
char* ascii = tsk_null; char* ascii = tsk_null;
tsms_rpdu_data_t* rp_data = TSMS_RPDU_DATA(rp_message); tsms_rpdu_data_t* rp_data = TSMS_RPDU_DATA(rp_message);
if((tpdu = tsms_tpdu_message_deserialize(rp_data->udata->data, rp_data->udata->size, MobOrig))) { if((tpdu = tsms_tpdu_message_deserialize(rp_data->udata->data, rp_data->udata->size, MobOrig))) {
if(tpdu->mti == tsms_tpdu_mti_deliver_mt || tpdu->mti == tsms_tpdu_mti_submit_mo) { /* SMS-SUBMIT or SMS-DELIVER? */ if(tpdu->mti == tsms_tpdu_mti_deliver_mt || tpdu->mti == tsms_tpdu_mti_submit_mo) { /* SMS-SUBMIT or SMS-DELIVER? */
ascii = tsms_tpdu_message_get_payload(tpdu); ascii = tsms_tpdu_message_get_payload(tpdu);
decodedData = new SMSData(twrap_sms_type_rpdata, rp_message->mr, ascii, (tsk_size_t)tsk_strlen(ascii)); decodedData = new SMSData(twrap_sms_type_rpdata, rp_message->mr, ascii, (tsk_size_t)tsk_strlen(ascii));
if(tpdu->mti == tsms_tpdu_mti_deliver_mt) { if(tpdu->mti == tsms_tpdu_mti_deliver_mt) {
tsms_tpdu_deliver_t* tpdu_deliver = (tsms_tpdu_deliver_t*)tpdu; tsms_tpdu_deliver_t* tpdu_deliver = (tsms_tpdu_deliver_t*)tpdu;
decodedData->setOA(tpdu_deliver->oa ? tpdu_deliver->oa->digits : tsk_null); decodedData->setOA(tpdu_deliver->oa ? tpdu_deliver->oa->digits : tsk_null);
} }
/* IMPORTANT: to not uncomment /* IMPORTANT: to not uncomment
else if(TSK_OBJECT_DEF(tpdu) == tsms_tpdu_submit_def_t){ else if(TSK_OBJECT_DEF(tpdu) == tsms_tpdu_submit_def_t){
tsms_tpdu_submit_t* tpdu_submit = (tsms_tpdu_submit_t*)tpdu; tsms_tpdu_submit_t* tpdu_submit = (tsms_tpdu_submit_t*)tpdu;
decodedData->setDA(tpdu_submit->da ? tpdu_submit->da->digits : tsk_null); decodedData->setDA(tpdu_submit->da ? tpdu_submit->da->digits : tsk_null);
}*/ }*/
TSK_FREE(ascii); TSK_FREE(ascii);
} }
} }
break; break;
} }
case tsms_rpdu_type_ack_mo: case tsms_rpdu_type_ack_mo:
case tsms_rpdu_type_ack_mt: { case tsms_rpdu_type_ack_mt: {
tsms_rpdu_ack_t* rp_ack = TSMS_RPDU_ACK(rp_message); tsms_rpdu_ack_t* rp_ack = TSMS_RPDU_ACK(rp_message);
// ...do whatever you want // ...do whatever you want
if(rp_ack->udata && (tpdu = tsms_tpdu_message_deserialize(rp_ack->udata->data, rp_ack->udata->size, MobOrig))) { if(rp_ack->udata && (tpdu = tsms_tpdu_message_deserialize(rp_ack->udata->data, rp_ack->udata->size, MobOrig))) {
// ...do whatever you want // ...do whatever you want
} }
decodedData = new SMSData(twrap_sms_type_ack, rp_message->mr, tsk_null, 0); decodedData = new SMSData(twrap_sms_type_ack, rp_message->mr, tsk_null, 0);
break; break;
} }
case tsms_rpdu_type_error_mo: case tsms_rpdu_type_error_mo:
case tsms_rpdu_type_error_mt: { case tsms_rpdu_type_error_mt: {
tsms_rpdu_error_t* rp_error = TSMS_RPDU_ERROR(rp_message); tsms_rpdu_error_t* rp_error = TSMS_RPDU_ERROR(rp_message);
// ...do whatever you want // ...do whatever you want
if(rp_error->udata && (tpdu = tsms_tpdu_message_deserialize(rp_error->udata->data, rp_error->udata->size, MobOrig))) { if(rp_error->udata && (tpdu = tsms_tpdu_message_deserialize(rp_error->udata->data, rp_error->udata->size, MobOrig))) {
// ...do whatever you want // ...do whatever you want
} }
decodedData = new SMSData(twrap_sms_type_error, rp_message->mr, tsk_null, 0); decodedData = new SMSData(twrap_sms_type_error, rp_message->mr, tsk_null, 0);
break; break;
} }
case tsms_rpdu_type_smma_mo: { case tsms_rpdu_type_smma_mo: {
// tsms_rpdu_smma_t* rp_smma = TSMS_RPDU_SMMA(rp_message); // tsms_rpdu_smma_t* rp_smma = TSMS_RPDU_SMMA(rp_message);
// ...do whatever you want // ...do whatever you want
decodedData = new SMSData(twrap_sms_type_smma, rp_message->mr, tsk_null, 0); decodedData = new SMSData(twrap_sms_type_smma, rp_message->mr, tsk_null, 0);
break; break;
} }
default: { default: {
TSK_DEBUG_INFO("Unknown RP-Message type (%u).", rp_message->mti); TSK_DEBUG_INFO("Unknown RP-Message type (%u).", rp_message->mti);
break; break;
} }
} }
bail: bail:
TSK_OBJECT_SAFE_FREE(rp_message); TSK_OBJECT_SAFE_FREE(rp_message);
TSK_OBJECT_SAFE_FREE(tpdu); TSK_OBJECT_SAFE_FREE(tpdu);
return decodedData; return decodedData;
} }

View File

@ -1,113 +1,113 @@
/* /*
* Copyright (C) 2009 Mamadou Diop. * Copyright (C) 2009 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou@doubango.org> * Contact: Mamadou Diop <diopmamadou@doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SMSENCODER_H #ifndef TINYWRAP_SMSENCODER_H
#define TINYWRAP_SMSENCODER_H #define TINYWRAP_SMSENCODER_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinysip.h" /* SIP/IMS */ #include "tinysip.h" /* SIP/IMS */
#include "tinysms.h" /* Binary SMS API*/ #include "tinysms.h" /* Binary SMS API*/
typedef enum twrap_rpmessage_type_e { typedef enum twrap_rpmessage_type_e {
twrap_rpmessage_type_sms_none, twrap_rpmessage_type_sms_none,
twrap_rpmessage_type_sms_submit, twrap_rpmessage_type_sms_submit,
twrap_rpmessage_type_sms_deliver, twrap_rpmessage_type_sms_deliver,
twrap_rpmessage_type_sms_ack, twrap_rpmessage_type_sms_ack,
twrap_rpmessage_type_sms_error, twrap_rpmessage_type_sms_error,
} }
twrap_rpmessage_type_t; twrap_rpmessage_type_t;
typedef enum twrap_sms_type_e { typedef enum twrap_sms_type_e {
twrap_sms_type_none, twrap_sms_type_none,
twrap_sms_type_rpdata, twrap_sms_type_rpdata,
twrap_sms_type_smma, twrap_sms_type_smma,
twrap_sms_type_ack, twrap_sms_type_ack,
twrap_sms_type_error, twrap_sms_type_error,
} }
twrap_sms_type_t; twrap_sms_type_t;
class RPMessage class RPMessage
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
RPMessage(twrap_rpmessage_type_t type, tsms_rpdu_message_t* rp_message); RPMessage(twrap_rpmessage_type_t type, tsms_rpdu_message_t* rp_message);
#endif #endif
RPMessage(); RPMessage();
virtual ~RPMessage(); virtual ~RPMessage();
public: public:
/* Public API functions */ /* Public API functions */
twrap_rpmessage_type_t getType(); twrap_rpmessage_type_t getType();
unsigned getPayloadLength(); unsigned getPayloadLength();
unsigned getPayload(void* output, unsigned maxsize); unsigned getPayload(void* output, unsigned maxsize);
private: private:
twrap_rpmessage_type_t type; twrap_rpmessage_type_t type;
tsms_rpdu_message_t* rp_message; tsms_rpdu_message_t* rp_message;
tsk_buffer_t* tmpBuffer; tsk_buffer_t* tmpBuffer;
}; };
class SMSData class SMSData
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
SMSData(twrap_sms_type_t type, int mr, const void* ascii, tsk_size_t size); SMSData(twrap_sms_type_t type, int mr, const void* ascii, tsk_size_t size);
#endif #endif
SMSData(); SMSData();
virtual ~SMSData(); virtual ~SMSData();
public: public:
/* Public API functions */ /* Public API functions */
twrap_sms_type_t getType(); twrap_sms_type_t getType();
int getMR(); int getMR();
unsigned getPayloadLength(); unsigned getPayloadLength();
unsigned getPayload(void* output, unsigned maxsize); unsigned getPayload(void* output, unsigned maxsize);
const char* getOA(); const char* getOA();
const char* getDA(); const char* getDA();
#if !defined(SWIG) #if !defined(SWIG)
void setOA(const char* oa); void setOA(const char* oa);
void setDA(const char* da); void setDA(const char* da);
#endif #endif
private: private:
twrap_sms_type_t type; twrap_sms_type_t type;
int mr; int mr;
void* ascii; void* ascii;
char* oa; char* oa;
char* da; char* da;
tsk_size_t size; tsk_size_t size;
}; };
class SMSEncoder class SMSEncoder
{ {
public: public:
static RPMessage* encodeSubmit(int mr, const char* smsc, const char* destination, const char* ascii); static RPMessage* encodeSubmit(int mr, const char* smsc, const char* destination, const char* ascii);
static RPMessage* encodeDeliver(int mr, const char* smsc, const char* originator, const char* ascii); static RPMessage* encodeDeliver(int mr, const char* smsc, const char* originator, const char* ascii);
static RPMessage* encodeACK(int mr, const char* smsc, const char* destination, bool forSUBMIT); static RPMessage* encodeACK(int mr, const char* smsc, const char* destination, bool forSUBMIT);
static RPMessage* encodeError(int mr, const char* smsc, const char* destination, bool forSUBMIT); static RPMessage* encodeError(int mr, const char* smsc, const char* destination, bool forSUBMIT);
static SMSData* decode(const void* data, unsigned size, bool MobOrig); static SMSData* decode(const void* data, unsigned size, bool MobOrig);
}; };
#endif /* TINYWRAP_SMSENCODER_H */ #endif /* TINYWRAP_SMSENCODER_H */

View File

@ -1,42 +1,42 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "SafeObject.h" #include "SafeObject.h"
SafeObject::SafeObject() SafeObject::SafeObject()
{ {
this->mutex = tsk_mutex_create(); this->mutex = tsk_mutex_create();
} }
int SafeObject::Lock()const int SafeObject::Lock()const
{ {
return tsk_mutex_lock(this->mutex); return tsk_mutex_lock(this->mutex);
} }
int SafeObject::UnLock()const int SafeObject::UnLock()const
{ {
return tsk_mutex_unlock(this->mutex); return tsk_mutex_unlock(this->mutex);
} }
SafeObject::~SafeObject() SafeObject::~SafeObject()
{ {
tsk_mutex_destroy(&this->mutex); tsk_mutex_destroy(&this->mutex);
} }

View File

@ -1,43 +1,43 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SAFEOBJECT_H #ifndef TINYWRAP_SAFEOBJECT_H
#define TINYWRAP_SAFEOBJECT_H #define TINYWRAP_SAFEOBJECT_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tsk_mutex.h" #include "tsk_mutex.h"
class TINYWRAP_API SafeObject class TINYWRAP_API SafeObject
{ {
public: public:
SafeObject(); SafeObject();
virtual ~SafeObject(); virtual ~SafeObject();
/* protected: */ /* protected: */
int Lock()const; int Lock()const;
int UnLock()const; int UnLock()const;
private: private:
tsk_mutex_handle_t *mutex; tsk_mutex_handle_t *mutex;
}; };
#endif /* TINYWRAP_SAFEOBJECT_H */ #endif /* TINYWRAP_SAFEOBJECT_H */

View File

@ -1,31 +1,31 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "SipCallback.h" #include "SipCallback.h"

View File

@ -1,74 +1,74 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIPCALLBACK_H #ifndef TINYWRAP_SIPCALLBACK_H
#define TINYWRAP_SIPCALLBACK_H #define TINYWRAP_SIPCALLBACK_H
class DialogEvent; class DialogEvent;
class StackEvent; class StackEvent;
class InviteEvent; class InviteEvent;
class MessagingEvent; class MessagingEvent;
class InfoEvent; class InfoEvent;
class OptionsEvent; class OptionsEvent;
class PublicationEvent; class PublicationEvent;
class RegistrationEvent; class RegistrationEvent;
class SubscriptionEvent; class SubscriptionEvent;
class SipCallback class SipCallback
{ {
public: public:
SipCallback() { } SipCallback() { }
virtual ~SipCallback() {} virtual ~SipCallback() {}
virtual int OnDialogEvent(const DialogEvent* e) { virtual int OnDialogEvent(const DialogEvent* e) {
return -1; return -1;
} }
virtual int OnStackEvent(const StackEvent* e) { virtual int OnStackEvent(const StackEvent* e) {
return -1; return -1;
} }
virtual int OnInviteEvent(const InviteEvent* e) { virtual int OnInviteEvent(const InviteEvent* e) {
return -1; return -1;
} }
virtual int OnMessagingEvent(const MessagingEvent* e) { virtual int OnMessagingEvent(const MessagingEvent* e) {
return -1; return -1;
} }
virtual int OnInfoEvent(const InfoEvent* e) { virtual int OnInfoEvent(const InfoEvent* e) {
return -1; return -1;
} }
virtual int OnOptionsEvent(const OptionsEvent* e) { virtual int OnOptionsEvent(const OptionsEvent* e) {
return -1; return -1;
} }
virtual int OnPublicationEvent(const PublicationEvent* e) { virtual int OnPublicationEvent(const PublicationEvent* e) {
return -1; return -1;
} }
virtual int OnRegistrationEvent(const RegistrationEvent* e) { virtual int OnRegistrationEvent(const RegistrationEvent* e) {
return -1; return -1;
} }
virtual int OnSubscriptionEvent(const SubscriptionEvent* e) { virtual int OnSubscriptionEvent(const SubscriptionEvent* e) {
return -1; return -1;
} }
private: private:
}; };
#endif /* TINYWRAP_SIPCALLBACK_H */ #endif /* TINYWRAP_SIPCALLBACK_H */

View File

@ -1,284 +1,284 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "SipEvent.h" #include "SipEvent.h"
#include "SipSession.h" #include "SipSession.h"
#include "SipMessage.h" #include "SipMessage.h"
#include "SipStack.h" #include "SipStack.h"
#define takeOwnership_Implement(cls, name, session) \ #define takeOwnership_Implement(cls, name, session) \
name##Session* cls##Event::take##session##Ownership() const \ name##Session* cls##Event::take##session##Ownership() const \
{ \ { \
if(this->sipevent && this->sipevent->ss /*&& !tsip_ssession_have_ownership(this->sipevent->ss)*/){ \ if(this->sipevent && this->sipevent->ss /*&& !tsip_ssession_have_ownership(this->sipevent->ss)*/){ \
SipStack* stack = this->getStack(); \ SipStack* stack = this->getStack(); \
if(stack){ \ if(stack){ \
/* The constructor will call take_ownerhip() */ \ /* The constructor will call take_ownerhip() */ \
return new name##Session(stack, this->sipevent->ss); \ return new name##Session(stack, this->sipevent->ss); \
} \ } \
} \ } \
return tsk_null; \ return tsk_null; \
} \ } \
/* ======================== SipEvent ========================*/ /* ======================== SipEvent ========================*/
SipEvent::SipEvent(const tsip_event_t *_sipevent) SipEvent::SipEvent(const tsip_event_t *_sipevent)
{ {
this->sipevent = _sipevent; this->sipevent = _sipevent;
if(_sipevent) { if(_sipevent) {
this->sipmessage = new SipMessage(_sipevent->sipmessage); this->sipmessage = new SipMessage(_sipevent->sipmessage);
} }
else { else {
this->sipmessage = tsk_null; this->sipmessage = tsk_null;
} }
} }
SipEvent::~SipEvent() SipEvent::~SipEvent()
{ {
if(this->sipmessage) { if(this->sipmessage) {
delete this->sipmessage; delete this->sipmessage;
} }
} }
short SipEvent::getCode() const short SipEvent::getCode() const
{ {
return this->sipevent->code; return this->sipevent->code;
} }
const char* SipEvent::getPhrase() const const char* SipEvent::getPhrase() const
{ {
return this->sipevent->phrase; return this->sipevent->phrase;
} }
const SipSession* SipEvent::getBaseSession() const const SipSession* SipEvent::getBaseSession() const
{ {
const void* userdata = tsip_ssession_get_userdata(this->sipevent->ss); const void* userdata = tsip_ssession_get_userdata(this->sipevent->ss);
if(userdata) { if(userdata) {
return dyn_cast<const SipSession*>((const SipSession*)userdata); return dyn_cast<const SipSession*>((const SipSession*)userdata);
} }
return tsk_null; return tsk_null;
} }
const SipMessage* SipEvent::getSipMessage() const const SipMessage* SipEvent::getSipMessage() const
{ {
return this->sipmessage; return this->sipmessage;
} }
SipStack* SipEvent::getStack()const SipStack* SipEvent::getStack()const
{ {
const tsip_stack_handle_t* stack_handle = tsip_ssession_get_stack(sipevent->ss); const tsip_stack_handle_t* stack_handle = tsip_ssession_get_stack(sipevent->ss);
const void* userdata; const void* userdata;
if(stack_handle && (userdata = tsip_stack_get_userdata(stack_handle))) { if(stack_handle && (userdata = tsip_stack_get_userdata(stack_handle))) {
return dyn_cast<SipStack*>((SipStack*)userdata); return dyn_cast<SipStack*>((SipStack*)userdata);
} }
return tsk_null; return tsk_null;
} }
/* ======================== DialogEvent ========================*/ /* ======================== DialogEvent ========================*/
DialogEvent::DialogEvent(const tsip_event_t *_sipevent) DialogEvent::DialogEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) { } :SipEvent(_sipevent) { }
DialogEvent::~DialogEvent() { } DialogEvent::~DialogEvent() { }
/* ======================== DialogEvent ========================*/ /* ======================== DialogEvent ========================*/
StackEvent::StackEvent(const tsip_event_t *_sipevent) StackEvent::StackEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) { } :SipEvent(_sipevent) { }
StackEvent::~StackEvent() { } StackEvent::~StackEvent() { }
/* ======================== InviteEvent ========================*/ /* ======================== InviteEvent ========================*/
InviteEvent::InviteEvent(const tsip_event_t *_sipevent) InviteEvent::InviteEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) :SipEvent(_sipevent)
{ {
} }
InviteEvent::~InviteEvent() InviteEvent::~InviteEvent()
{ {
} }
tsip_invite_event_type_t InviteEvent::getType() const tsip_invite_event_type_t InviteEvent::getType() const
{ {
return TSIP_INVITE_EVENT(this->sipevent)->type; return TSIP_INVITE_EVENT(this->sipevent)->type;
} }
twrap_media_type_t InviteEvent::getMediaType() const twrap_media_type_t InviteEvent::getMediaType() const
{ {
// Ignore Mixed session (both audio/video and MSRP) as specified by GSMA RCS. // Ignore Mixed session (both audio/video and MSRP) as specified by GSMA RCS.
if (this->sipevent && this->sipevent->ss) { if (this->sipevent && this->sipevent->ss) {
tmedia_type_t type = tsip_ssession_get_mediatype(this->sipevent->ss); tmedia_type_t type = tsip_ssession_get_mediatype(this->sipevent->ss);
if ((type & tmedia_msrp) == tmedia_msrp) { if ((type & tmedia_msrp) == tmedia_msrp) {
return twrap_media_msrp; return twrap_media_msrp;
} }
else { else {
return twrap_get_wrapped_media_type(type); return twrap_get_wrapped_media_type(type);
} }
} }
return twrap_media_none; return twrap_media_none;
} }
const InviteSession* InviteEvent::getSession() const const InviteSession* InviteEvent::getSession() const
{ {
return dyn_cast<const InviteSession*>(this->getBaseSession()); return dyn_cast<const InviteSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Invite, Call, CallSession); takeOwnership_Implement(Invite, Call, CallSession);
takeOwnership_Implement(Invite, Msrp, MsrpSession); takeOwnership_Implement(Invite, Msrp, MsrpSession);
/* ======================== MessagingEvent ========================*/ /* ======================== MessagingEvent ========================*/
MessagingEvent::MessagingEvent(const tsip_event_t *_sipevent) MessagingEvent::MessagingEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) :SipEvent(_sipevent)
{ {
} }
MessagingEvent::~MessagingEvent() MessagingEvent::~MessagingEvent()
{ {
} }
tsip_message_event_type_t MessagingEvent::getType() const tsip_message_event_type_t MessagingEvent::getType() const
{ {
return TSIP_MESSAGE_EVENT(this->sipevent)->type; return TSIP_MESSAGE_EVENT(this->sipevent)->type;
} }
const MessagingSession* MessagingEvent::getSession() const const MessagingSession* MessagingEvent::getSession() const
{ {
return dyn_cast<const MessagingSession*>(this->getBaseSession()); return dyn_cast<const MessagingSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Messaging, Messaging, Session); takeOwnership_Implement(Messaging, Messaging, Session);
/* ======================== InfoEvent ========================*/ /* ======================== InfoEvent ========================*/
InfoEvent::InfoEvent(const tsip_event_t *_sipevent) InfoEvent::InfoEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) :SipEvent(_sipevent)
{ {
} }
InfoEvent::~InfoEvent() InfoEvent::~InfoEvent()
{ {
} }
tsip_info_event_type_t InfoEvent::getType() const tsip_info_event_type_t InfoEvent::getType() const
{ {
return TSIP_INFO_EVENT(this->sipevent)->type; return TSIP_INFO_EVENT(this->sipevent)->type;
} }
const InfoSession* InfoEvent::getSession() const const InfoSession* InfoEvent::getSession() const
{ {
return dyn_cast<const InfoSession*>(this->getBaseSession()); return dyn_cast<const InfoSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Info, Info, Session); takeOwnership_Implement(Info, Info, Session);
/* ======================== OptionsEvent ========================*/ /* ======================== OptionsEvent ========================*/
OptionsEvent::OptionsEvent(const tsip_event_t *_sipevent) OptionsEvent::OptionsEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) :SipEvent(_sipevent)
{ {
} }
OptionsEvent::~OptionsEvent() OptionsEvent::~OptionsEvent()
{ {
} }
tsip_options_event_type_t OptionsEvent::getType() const tsip_options_event_type_t OptionsEvent::getType() const
{ {
return TSIP_OPTIONS_EVENT(this->sipevent)->type; return TSIP_OPTIONS_EVENT(this->sipevent)->type;
} }
const OptionsSession* OptionsEvent::getSession() const const OptionsSession* OptionsEvent::getSession() const
{ {
return dyn_cast<const OptionsSession*>(this->getBaseSession()); return dyn_cast<const OptionsSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Options, Options, Session); takeOwnership_Implement(Options, Options, Session);
/* ======================== PublicationEvent ========================*/ /* ======================== PublicationEvent ========================*/
PublicationEvent::PublicationEvent(const tsip_event_t *_sipevent) PublicationEvent::PublicationEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) :SipEvent(_sipevent)
{ {
} }
PublicationEvent::~PublicationEvent() PublicationEvent::~PublicationEvent()
{ {
} }
tsip_publish_event_type_t PublicationEvent::getType() const tsip_publish_event_type_t PublicationEvent::getType() const
{ {
return TSIP_PUBLISH_EVENT(this->sipevent)->type; return TSIP_PUBLISH_EVENT(this->sipevent)->type;
} }
const PublicationSession* PublicationEvent::getSession() const const PublicationSession* PublicationEvent::getSession() const
{ {
return dyn_cast<const PublicationSession*>(this->getBaseSession()); return dyn_cast<const PublicationSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Publication, Publication, Session); takeOwnership_Implement(Publication, Publication, Session);
/* ======================== RegistrationEvent ========================*/ /* ======================== RegistrationEvent ========================*/
RegistrationEvent::RegistrationEvent(const tsip_event_t *_sipevent) RegistrationEvent::RegistrationEvent(const tsip_event_t *_sipevent)
:SipEvent(_sipevent) :SipEvent(_sipevent)
{ {
} }
RegistrationEvent::~RegistrationEvent() RegistrationEvent::~RegistrationEvent()
{ {
} }
tsip_register_event_type_t RegistrationEvent::getType() const tsip_register_event_type_t RegistrationEvent::getType() const
{ {
return TSIP_REGISTER_EVENT(this->sipevent)->type; return TSIP_REGISTER_EVENT(this->sipevent)->type;
} }
const RegistrationSession* RegistrationEvent::getSession() const const RegistrationSession* RegistrationEvent::getSession() const
{ {
return dyn_cast<const RegistrationSession*>(this->getBaseSession()); return dyn_cast<const RegistrationSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Registration, Registration, Session); takeOwnership_Implement(Registration, Registration, Session);
/* ======================== SubscriptionEvent ========================*/ /* ======================== SubscriptionEvent ========================*/
SubscriptionEvent::SubscriptionEvent(const tsip_event_t *sipevent) SubscriptionEvent::SubscriptionEvent(const tsip_event_t *sipevent)
:SipEvent(sipevent) :SipEvent(sipevent)
{ {
} }
SubscriptionEvent::~SubscriptionEvent() SubscriptionEvent::~SubscriptionEvent()
{ {
} }
tsip_subscribe_event_type_t SubscriptionEvent::getType() const tsip_subscribe_event_type_t SubscriptionEvent::getType() const
{ {
return TSIP_SUBSCRIBE_EVENT(this->sipevent)->type; return TSIP_SUBSCRIBE_EVENT(this->sipevent)->type;
} }
const SubscriptionSession* SubscriptionEvent::getSession() const const SubscriptionSession* SubscriptionEvent::getSession() const
{ {
return dyn_cast<const SubscriptionSession*>(this->getBaseSession()); return dyn_cast<const SubscriptionSession*>(this->getBaseSession());
} }
takeOwnership_Implement(Subscription, Subscription, Session); takeOwnership_Implement(Subscription, Subscription, Session);

View File

@ -1,218 +1,218 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIPEVENT_H #ifndef TINYWRAP_SIPEVENT_H
#define TINYWRAP_SIPEVENT_H #define TINYWRAP_SIPEVENT_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinysip.h" #include "tinysip.h"
#include "Common.h" #include "Common.h"
class SipStack; class SipStack;
class SipSession; class SipSession;
class InviteSession; class InviteSession;
class CallSession; class CallSession;
class MsrpSession; class MsrpSession;
class MessagingSession; class MessagingSession;
class InfoSession; class InfoSession;
class OptionsSession; class OptionsSession;
class PublicationSession; class PublicationSession;
class RegistrationSession; class RegistrationSession;
class SubscriptionSession; class SubscriptionSession;
class SipMessage; class SipMessage;
/* ======================== SipEvent ========================*/ /* ======================== SipEvent ========================*/
class TINYWRAP_API SipEvent class TINYWRAP_API SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
SipEvent(const tsip_event_t *sipevent); SipEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~SipEvent(); virtual ~SipEvent();
public: public:
short getCode() const; short getCode() const;
const char* getPhrase() const; const char* getPhrase() const;
const SipSession* getBaseSession() const; const SipSession* getBaseSession() const;
const SipMessage* getSipMessage() const; const SipMessage* getSipMessage() const;
#if !defined(SWIG) #if !defined(SWIG)
const tsip_event_t * getWrappedEvent() { const tsip_event_t * getWrappedEvent() {
return sipevent; return sipevent;
} }
#endif #endif
#if !defined(SWIG) #if !defined(SWIG)
SipStack* getStack()const; SipStack* getStack()const;
#endif #endif
protected: protected:
const tsip_event_t *sipevent; const tsip_event_t *sipevent;
SipMessage* sipmessage; SipMessage* sipmessage;
}; };
/* ======================== DialogEvent ========================*/ /* ======================== DialogEvent ========================*/
class TINYWRAP_API DialogEvent: public SipEvent class TINYWRAP_API DialogEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
DialogEvent(const tsip_event_t *sipevent); DialogEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~DialogEvent(); virtual ~DialogEvent();
public: /* Public API functions */ public: /* Public API functions */
}; };
/* ======================== StackEvent ========================*/ /* ======================== StackEvent ========================*/
class TINYWRAP_API StackEvent: public SipEvent class TINYWRAP_API StackEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
StackEvent(const tsip_event_t *sipevent); StackEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~StackEvent(); virtual ~StackEvent();
public: /* Public API functions */ public: /* Public API functions */
}; };
/* ======================== InviteEvent ========================*/ /* ======================== InviteEvent ========================*/
class TINYWRAP_API InviteEvent: public SipEvent class TINYWRAP_API InviteEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
InviteEvent(const tsip_event_t *sipevent); InviteEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~InviteEvent(); virtual ~InviteEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_invite_event_type_t getType() const; tsip_invite_event_type_t getType() const;
twrap_media_type_t getMediaType() const; twrap_media_type_t getMediaType() const;
const InviteSession* getSession() const; const InviteSession* getSession() const;
CallSession* takeCallSessionOwnership() const; CallSession* takeCallSessionOwnership() const;
MsrpSession* takeMsrpSessionOwnership() const; MsrpSession* takeMsrpSessionOwnership() const;
}; };
/* ======================== MessagingEvent ========================*/ /* ======================== MessagingEvent ========================*/
class TINYWRAP_API MessagingEvent: public SipEvent class TINYWRAP_API MessagingEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
MessagingEvent(const tsip_event_t *sipevent); MessagingEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~MessagingEvent(); virtual ~MessagingEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_message_event_type_t getType() const; tsip_message_event_type_t getType() const;
const MessagingSession* getSession() const; const MessagingSession* getSession() const;
MessagingSession* takeSessionOwnership() const; MessagingSession* takeSessionOwnership() const;
}; };
/* ======================== InfoEvent ========================*/ /* ======================== InfoEvent ========================*/
class TINYWRAP_API InfoEvent: public SipEvent class TINYWRAP_API InfoEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
InfoEvent(const tsip_event_t *sipevent); InfoEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~InfoEvent(); virtual ~InfoEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_info_event_type_t getType() const; tsip_info_event_type_t getType() const;
const InfoSession* getSession() const; const InfoSession* getSession() const;
InfoSession* takeSessionOwnership() const; InfoSession* takeSessionOwnership() const;
}; };
/* ======================== OptionsEvent ========================*/ /* ======================== OptionsEvent ========================*/
class TINYWRAP_API OptionsEvent: public SipEvent class TINYWRAP_API OptionsEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
OptionsEvent(const tsip_event_t *sipevent); OptionsEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~OptionsEvent(); virtual ~OptionsEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_options_event_type_t getType() const; tsip_options_event_type_t getType() const;
const OptionsSession* getSession() const; const OptionsSession* getSession() const;
OptionsSession* takeSessionOwnership() const; OptionsSession* takeSessionOwnership() const;
}; };
/* ======================== PublicationEvent ========================*/ /* ======================== PublicationEvent ========================*/
class TINYWRAP_API PublicationEvent: public SipEvent class TINYWRAP_API PublicationEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
PublicationEvent(const tsip_event_t *sipevent); PublicationEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~PublicationEvent(); virtual ~PublicationEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_publish_event_type_t getType() const; tsip_publish_event_type_t getType() const;
const PublicationSession* getSession() const; const PublicationSession* getSession() const;
PublicationSession* takeSessionOwnership() const; PublicationSession* takeSessionOwnership() const;
}; };
/* ======================== RegistrationEvent ========================*/ /* ======================== RegistrationEvent ========================*/
class TINYWRAP_API RegistrationEvent: public SipEvent class TINYWRAP_API RegistrationEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
RegistrationEvent(const tsip_event_t *sipevent); RegistrationEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~RegistrationEvent(); virtual ~RegistrationEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_register_event_type_t getType() const; tsip_register_event_type_t getType() const;
const RegistrationSession* getSession() const; const RegistrationSession* getSession() const;
RegistrationSession* takeSessionOwnership() const; RegistrationSession* takeSessionOwnership() const;
}; };
/* ======================== SubscriptionEvent ========================*/ /* ======================== SubscriptionEvent ========================*/
class TINYWRAP_API SubscriptionEvent: public SipEvent class TINYWRAP_API SubscriptionEvent: public SipEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
SubscriptionEvent(const tsip_event_t *sipevent); SubscriptionEvent(const tsip_event_t *sipevent);
#endif #endif
virtual ~SubscriptionEvent(); virtual ~SubscriptionEvent();
public: /* Public API functions */ public: /* Public API functions */
tsip_subscribe_event_type_t getType() const; tsip_subscribe_event_type_t getType() const;
const SubscriptionSession* getSession() const; const SubscriptionSession* getSession() const;
SubscriptionSession* takeSessionOwnership() const; SubscriptionSession* takeSessionOwnership() const;
}; };
#endif /* TINYWRAP_SIPEVENT_H */ #endif /* TINYWRAP_SIPEVENT_H */

View File

@ -1,355 +1,355 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "SipMessage.h" #include "SipMessage.h"
SdpMessage::SdpMessage() SdpMessage::SdpMessage()
:m_pSdpMessage(tsk_null) :m_pSdpMessage(tsk_null)
{ {
} }
SdpMessage::SdpMessage(tsdp_message_t *_sdpmessage) SdpMessage::SdpMessage(tsdp_message_t *_sdpmessage)
{ {
m_pSdpMessage = (tsdp_message_t *)tsk_object_ref(_sdpmessage); m_pSdpMessage = (tsdp_message_t *)tsk_object_ref(_sdpmessage);
} }
SdpMessage::~SdpMessage() SdpMessage::~SdpMessage()
{ {
TSK_OBJECT_SAFE_FREE(m_pSdpMessage); TSK_OBJECT_SAFE_FREE(m_pSdpMessage);
} }
char* SdpMessage::getSdpHeaderValue(const char* media, char name, unsigned index /*= 0*/) char* SdpMessage::getSdpHeaderValue(const char* media, char name, unsigned index /*= 0*/)
{ {
const tsdp_header_M_t* M; const tsdp_header_M_t* M;
if((M = (const tsdp_header_M_t*)tsdp_message_get_header(m_pSdpMessage, tsdp_htype_M))) { if((M = (const tsdp_header_M_t*)tsdp_message_get_header(m_pSdpMessage, tsdp_htype_M))) {
tsdp_header_type_t type = tsdp_htype_Dummy; tsdp_header_type_t type = tsdp_htype_Dummy;
const tsdp_header_t* header; const tsdp_header_t* header;
switch(name) { switch(name) {
case 'a': case 'a':
type = tsdp_htype_A; type = tsdp_htype_A;
break; break;
case 'b': case 'b':
type = tsdp_htype_B; type = tsdp_htype_B;
break; break;
case 'c': case 'c':
type = tsdp_htype_C; type = tsdp_htype_C;
break; break;
case 'e': case 'e':
type = tsdp_htype_E; type = tsdp_htype_E;
break; break;
case 'i': case 'i':
type = tsdp_htype_I; type = tsdp_htype_I;
break; break;
case 'k': case 'k':
type = tsdp_htype_K; type = tsdp_htype_K;
break; break;
case 'm': case 'm':
type = tsdp_htype_M; type = tsdp_htype_M;
break; break;
case 'o': case 'o':
type = tsdp_htype_O; type = tsdp_htype_O;
break; break;
case 'p': case 'p':
type = tsdp_htype_P; type = tsdp_htype_P;
break; break;
case 'r': case 'r':
type = tsdp_htype_R; type = tsdp_htype_R;
break; break;
case 's': case 's':
type = tsdp_htype_S; type = tsdp_htype_S;
break; break;
case 't': case 't':
type = tsdp_htype_T; type = tsdp_htype_T;
break; break;
case 'u': case 'u':
type = tsdp_htype_U; type = tsdp_htype_U;
break; break;
case 'v': case 'v':
type = tsdp_htype_V; type = tsdp_htype_V;
break; break;
case 'z': case 'z':
type = tsdp_htype_Z; type = tsdp_htype_Z;
break; break;
} }
if((header = tsdp_message_get_headerAt(m_pSdpMessage, type, index))) { if((header = tsdp_message_get_headerAt(m_pSdpMessage, type, index))) {
return tsdp_header_tostring(header); return tsdp_header_tostring(header);
} }
} }
return tsk_null; return tsk_null;
} }
char* SdpMessage::getSdpHeaderAValue(const char* media, const char* attributeName) char* SdpMessage::getSdpHeaderAValue(const char* media, const char* attributeName)
{ {
const tsdp_header_M_t* M; const tsdp_header_M_t* M;
tsk_size_t i; tsk_size_t i;
for(i = 0; (M = (const tsdp_header_M_t*)tsdp_message_get_headerAt(m_pSdpMessage, tsdp_htype_M, i)); i++) { for(i = 0; (M = (const tsdp_header_M_t*)tsdp_message_get_headerAt(m_pSdpMessage, tsdp_htype_M, i)); i++) {
if(tsk_striequals(M->media, media)) { if(tsk_striequals(M->media, media)) {
const tsdp_header_A_t* A; const tsdp_header_A_t* A;
if((A = tsdp_header_M_findA(M, attributeName))) { if((A = tsdp_header_M_findA(M, attributeName))) {
return tsk_strdup(A->value); return tsk_strdup(A->value);
} }
} }
} }
return tsk_null; return tsk_null;
} }
SipMessage::SipMessage() SipMessage::SipMessage()
:m_pSipMessage(tsk_null), m_pSdpMessage(tsk_null) :m_pSipMessage(tsk_null), m_pSdpMessage(tsk_null)
{ {
} }
SipMessage::SipMessage(tsip_message_t *_sipmessage) SipMessage::SipMessage(tsip_message_t *_sipmessage)
: m_pSdpMessage(tsk_null) : m_pSdpMessage(tsk_null)
{ {
m_pSipMessage = (tsip_message_t *)tsk_object_ref(_sipmessage); m_pSipMessage = (tsip_message_t *)tsk_object_ref(_sipmessage);
} }
SipMessage::~SipMessage() SipMessage::~SipMessage()
{ {
TSK_OBJECT_SAFE_FREE(m_pSipMessage); TSK_OBJECT_SAFE_FREE(m_pSipMessage);
if(m_pSdpMessage) { if(m_pSdpMessage) {
delete m_pSdpMessage; delete m_pSdpMessage;
} }
} }
bool SipMessage::isResponse() bool SipMessage::isResponse()
{ {
return TSIP_MESSAGE_IS_RESPONSE(m_pSipMessage); return TSIP_MESSAGE_IS_RESPONSE(m_pSipMessage);
} }
tsip_request_type_t SipMessage::getRequestType() tsip_request_type_t SipMessage::getRequestType()
{ {
if(TSIP_MESSAGE_IS_REQUEST(m_pSipMessage)) { if(TSIP_MESSAGE_IS_REQUEST(m_pSipMessage)) {
return (m_pSipMessage)->line.request.request_type; return (m_pSipMessage)->line.request.request_type;
} }
return tsip_NONE; return tsip_NONE;
} }
short SipMessage::getResponseCode() short SipMessage::getResponseCode()
{ {
return TSIP_RESPONSE_CODE(m_pSipMessage); return TSIP_RESPONSE_CODE(m_pSipMessage);
} }
const char* SipMessage::getResponsePhrase() const char* SipMessage::getResponsePhrase()
{ {
return TSIP_RESPONSE_PHRASE(m_pSipMessage); return TSIP_RESPONSE_PHRASE(m_pSipMessage);
} }
const tsip_header_t* SipMessage::getSipHeader(const char* name, unsigned index /* =0 */) const tsip_header_t* SipMessage::getSipHeader(const char* name, unsigned index /* =0 */)
{ {
/* Do not worry about calling tsk_striequals() several times because the function /* Do not worry about calling tsk_striequals() several times because the function
* is fully optimized. * is fully optimized.
*/ */
/* Code below comes from tsip_message_get_headerAt() */ /* Code below comes from tsip_message_get_headerAt() */
tsk_size_t pos = 0; tsk_size_t pos = 0;
const tsk_list_item_t *item; const tsk_list_item_t *item;
const tsip_header_t* hdr = tsk_null; const tsip_header_t* hdr = tsk_null;
if(!m_pSipMessage || !name) { if(!m_pSipMessage || !name) {
return tsk_null; return tsk_null;
} }
if(tsk_striequals(name, "v") || tsk_striequals(name, "via")) { if(tsk_striequals(name, "v") || tsk_striequals(name, "via")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->firstVia; hdr = (const tsip_header_t*)m_pSipMessage->firstVia;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "f") || tsk_striequals(name, "from")) { if(tsk_striequals(name, "f") || tsk_striequals(name, "from")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->From; hdr = (const tsip_header_t*)m_pSipMessage->From;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "t") || tsk_striequals(name, "to")) { if(tsk_striequals(name, "t") || tsk_striequals(name, "to")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->To; hdr = (const tsip_header_t*)m_pSipMessage->To;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "m") || tsk_striequals(name, "contact")) { if(tsk_striequals(name, "m") || tsk_striequals(name, "contact")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->Contact; hdr = (const tsip_header_t*)m_pSipMessage->Contact;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "i") || tsk_striequals(name, "call-id")) { if(tsk_striequals(name, "i") || tsk_striequals(name, "call-id")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->Call_ID; hdr = (const tsip_header_t*)m_pSipMessage->Call_ID;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "cseq")) { if(tsk_striequals(name, "cseq")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->CSeq; hdr = (const tsip_header_t*)m_pSipMessage->CSeq;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "expires")) { if(tsk_striequals(name, "expires")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->Expires; hdr = (const tsip_header_t*)m_pSipMessage->Expires;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "c") || tsk_striequals(name, "content-type")) { if(tsk_striequals(name, "c") || tsk_striequals(name, "content-type")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->Content_Type; hdr = (const tsip_header_t*)m_pSipMessage->Content_Type;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
if(tsk_striequals(name, "l") || tsk_striequals(name, "content-length")) { if(tsk_striequals(name, "l") || tsk_striequals(name, "content-length")) {
if(index == 0) { if(index == 0) {
hdr = (const tsip_header_t*)m_pSipMessage->Content_Length; hdr = (const tsip_header_t*)m_pSipMessage->Content_Length;
goto bail; goto bail;
} }
else { else {
pos++; pos++;
} }
} }
tsk_list_foreach(item, m_pSipMessage->headers) { tsk_list_foreach(item, m_pSipMessage->headers) {
if(tsk_striequals(tsip_header_get_name_2(TSIP_HEADER(item->data)), name)) { if(tsk_striequals(tsip_header_get_name_2(TSIP_HEADER(item->data)), name)) {
if(pos++ >= index) { if(pos++ >= index) {
hdr = (const tsip_header_t*)item->data; hdr = (const tsip_header_t*)item->data;
break; break;
} }
} }
} }
bail: bail:
return hdr; return hdr;
} }
// e.g. getHeaderParamValue("content-type"); // e.g. getHeaderParamValue("content-type");
char* SipMessage::getSipHeaderValue(const char* name, unsigned index /* = 0*/) char* SipMessage::getSipHeaderValue(const char* name, unsigned index /* = 0*/)
{ {
const tsip_header_t* header; const tsip_header_t* header;
if((header = this->getSipHeader(name, index))) { if((header = this->getSipHeader(name, index))) {
switch(header->type) { switch(header->type) {
case tsip_htype_From: case tsip_htype_From:
return tsip_uri_tostring(((const tsip_header_From_t*)header)->uri, tsk_false, tsk_false); return tsip_uri_tostring(((const tsip_header_From_t*)header)->uri, tsk_false, tsk_false);
case tsip_htype_To: case tsip_htype_To:
return tsip_uri_tostring(((const tsip_header_To_t*)header)->uri, tsk_false, tsk_false); return tsip_uri_tostring(((const tsip_header_To_t*)header)->uri, tsk_false, tsk_false);
break; break;
case tsip_htype_P_Asserted_Identity: case tsip_htype_P_Asserted_Identity:
return tsip_uri_tostring(((const tsip_header_P_Asserted_Identity_t*)header)->uri, tsk_false, tsk_false); return tsip_uri_tostring(((const tsip_header_P_Asserted_Identity_t*)header)->uri, tsk_false, tsk_false);
break; break;
default: default:
return tsip_header_value_tostring(header); return tsip_header_value_tostring(header);
} }
} }
// SWIG: %newobject getHeaderValueAt; // SWIG: %newobject getHeaderValueAt;
return tsk_null; return tsk_null;
} }
// e.g. getHeaderParamValue("content-type", "charset"); // e.g. getHeaderParamValue("content-type", "charset");
char* SipMessage::getSipHeaderParamValue(const char* name, const char* param, unsigned index /*=0*/) char* SipMessage::getSipHeaderParamValue(const char* name, const char* param, unsigned index /*=0*/)
{ {
const tsip_header_t* header; const tsip_header_t* header;
if((header = this->getSipHeader(name, index))) { if((header = this->getSipHeader(name, index))) {
return tsip_header_get_param_value(header, param); return tsip_header_get_param_value(header, param);
} }
// SWIG: %newobject getSipHeaderParamValue; // SWIG: %newobject getSipHeaderParamValue;
return tsk_null; return tsk_null;
} }
/** Returns the content length. /** Returns the content length.
*/ */
unsigned SipMessage::getSipContentLength() unsigned SipMessage::getSipContentLength()
{ {
return TSIP_MESSAGE_CONTENT_DATA_LENGTH(m_pSipMessage); return TSIP_MESSAGE_CONTENT_DATA_LENGTH(m_pSipMessage);
} }
/** Gets the message content /** Gets the message content
* @param output A pointer to the output buffer where to copy the data. MUST * @param output A pointer to the output buffer where to copy the data. MUST
* be allocated by the caller. * be allocated by the caller.
* @param maxsize The maximum number of octets to copy. Should be less than the size of the * @param maxsize The maximum number of octets to copy. Should be less than the size of the
* @a output buffer. You can use @a getSipContentLength() to get the right value to use. * @a output buffer. You can use @a getSipContentLength() to get the right value to use.
* @retval The number of octet copied in the @a output buffer. * @retval The number of octet copied in the @a output buffer.
*/ */
unsigned SipMessage::getSipContent(void* output, unsigned maxsize) unsigned SipMessage::getSipContent(void* output, unsigned maxsize)
{ {
unsigned retsize = 0; unsigned retsize = 0;
if(output && maxsize && TSIP_MESSAGE_HAS_CONTENT(m_pSipMessage)) { if(output && maxsize && TSIP_MESSAGE_HAS_CONTENT(m_pSipMessage)) {
retsize = (m_pSipMessage->Content->size > maxsize) ? maxsize : m_pSipMessage->Content->size; retsize = (m_pSipMessage->Content->size > maxsize) ? maxsize : m_pSipMessage->Content->size;
memcpy(output, m_pSipMessage->Content->data, retsize); memcpy(output, m_pSipMessage->Content->data, retsize);
} }
return retsize; return retsize;
} }
const void* SipMessage::getSipContentPtr() const void* SipMessage::getSipContentPtr()
{ {
if(m_pSipMessage && m_pSipMessage->Content) { if(m_pSipMessage && m_pSipMessage->Content) {
return m_pSipMessage->Content->data; return m_pSipMessage->Content->data;
} }
return tsk_null; return tsk_null;
} }
const SdpMessage* SipMessage::getSdpMessage() const SdpMessage* SipMessage::getSdpMessage()
{ {
if(!m_pSdpMessage && TSIP_MESSAGE_HAS_CONTENT(m_pSipMessage)) { if(!m_pSdpMessage && TSIP_MESSAGE_HAS_CONTENT(m_pSipMessage)) {
tsdp_message_t* sdp = tsdp_message_parse(m_pSipMessage->Content->data, m_pSipMessage->Content->size); tsdp_message_t* sdp = tsdp_message_parse(m_pSipMessage->Content->data, m_pSipMessage->Content->size);
if(sdp) { if(sdp) {
m_pSdpMessage = new SdpMessage(sdp); m_pSdpMessage = new SdpMessage(sdp);
TSK_OBJECT_SAFE_FREE(sdp); TSK_OBJECT_SAFE_FREE(sdp);
} }
} }
return m_pSdpMessage; return m_pSdpMessage;
} }

View File

@ -1,82 +1,82 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIPMESSAGE_H #ifndef TINYWRAP_SIPMESSAGE_H
#define TINYWRAP_SIPMESSAGE_H #define TINYWRAP_SIPMESSAGE_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinysip.h" #include "tinysip.h"
class TINYWRAP_API SdpMessage class TINYWRAP_API SdpMessage
{ {
public: public:
SdpMessage(); SdpMessage();
#if !defined(SWIG) #if !defined(SWIG)
SdpMessage(tsdp_message_t *sdpmessage); SdpMessage(tsdp_message_t *sdpmessage);
#endif #endif
virtual ~SdpMessage(); virtual ~SdpMessage();
char* getSdpHeaderValue(const char* media, char name, unsigned index = 0); char* getSdpHeaderValue(const char* media, char name, unsigned index = 0);
char* getSdpHeaderAValue(const char* media, const char* attributeName); char* getSdpHeaderAValue(const char* media, const char* attributeName);
#if !defined(SWIG) #if !defined(SWIG)
const tsdp_message_t * getWrappedSdpMessage() { const tsdp_message_t * getWrappedSdpMessage() {
return m_pSdpMessage; return m_pSdpMessage;
} }
#endif #endif
private: private:
tsdp_message_t *m_pSdpMessage; tsdp_message_t *m_pSdpMessage;
}; };
class TINYWRAP_API SipMessage class TINYWRAP_API SipMessage
{ {
public: public:
SipMessage(); SipMessage();
#if !defined(SWIG) #if !defined(SWIG)
SipMessage(tsip_message_t *sipmessage); SipMessage(tsip_message_t *sipmessage);
#endif #endif
virtual ~SipMessage(); virtual ~SipMessage();
bool isResponse(); bool isResponse();
tsip_request_type_t getRequestType(); tsip_request_type_t getRequestType();
short getResponseCode(); short getResponseCode();
const char* getResponsePhrase(); const char* getResponsePhrase();
char* getSipHeaderValue(const char* name, unsigned index = 0); char* getSipHeaderValue(const char* name, unsigned index = 0);
char* getSipHeaderParamValue(const char* name, const char* param, unsigned index = 0); char* getSipHeaderParamValue(const char* name, const char* param, unsigned index = 0);
unsigned getSipContentLength(); unsigned getSipContentLength();
unsigned getSipContent(void* output, unsigned maxsize); unsigned getSipContent(void* output, unsigned maxsize);
#if !defined(SWIG) #if !defined(SWIG)
const void* getSipContentPtr(); const void* getSipContentPtr();
const tsip_message_t* getWrappedSipMessage()const { const tsip_message_t* getWrappedSipMessage()const {
return m_pSipMessage; return m_pSipMessage;
} }
#endif #endif
const SdpMessage* getSdpMessage(); const SdpMessage* getSdpMessage();
private: private:
const tsip_header_t* getSipHeader(const char* name, unsigned index = 0); const tsip_header_t* getSipHeader(const char* name, unsigned index = 0);
private: private:
tsip_message_t *m_pSipMessage; tsip_message_t *m_pSipMessage;
SdpMessage *m_pSdpMessage; SdpMessage *m_pSdpMessage;
}; };
#endif /* TINYWRAP_SIPMESSAGE_H */ #endif /* TINYWRAP_SIPMESSAGE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,374 +1,374 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIPSESSION_H #ifndef TINYWRAP_SIPSESSION_H
#define TINYWRAP_SIPSESSION_H #define TINYWRAP_SIPSESSION_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinysip.h" #include "tinysip.h"
#include "tinymedia/tmedia_qos.h" #include "tinymedia/tmedia_qos.h"
#include "ActionConfig.h" #include "ActionConfig.h"
class SipUri; class SipUri;
class SipStack; class SipStack;
class MsrpCallback; class MsrpCallback;
class MediaSessionMgr; class MediaSessionMgr;
/* ======================== T140Callback ========================*/ /* ======================== T140Callback ========================*/
class TINYWRAP_API T140CallbackData class TINYWRAP_API T140CallbackData
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
T140CallbackData(enum tmedia_t140_data_type_e data_type, const void* data_ptr, unsigned data_size) { T140CallbackData(enum tmedia_t140_data_type_e data_type, const void* data_ptr, unsigned data_size) {
m_eType = data_type; m_eType = data_type;
m_pPtr = data_ptr; m_pPtr = data_ptr;
m_nSize = data_size; m_nSize = data_size;
} }
#endif #endif
virtual ~T140CallbackData() {} virtual ~T140CallbackData() {}
inline enum tmedia_t140_data_type_e getType()const { inline enum tmedia_t140_data_type_e getType()const {
return m_eType; return m_eType;
} }
inline unsigned getSize()const { inline unsigned getSize()const {
return m_nSize; return m_nSize;
} }
inline unsigned getData(void* pOutput, unsigned nMaxsize)const { inline unsigned getData(void* pOutput, unsigned nMaxsize)const {
unsigned nRetsize = 0; unsigned nRetsize = 0;
if(pOutput && nMaxsize && m_pPtr) { if(pOutput && nMaxsize && m_pPtr) {
nRetsize = (m_nSize > nMaxsize) ? nMaxsize : m_nSize; nRetsize = (m_nSize > nMaxsize) ? nMaxsize : m_nSize;
memcpy(pOutput, m_pPtr, nRetsize); memcpy(pOutput, m_pPtr, nRetsize);
} }
return nRetsize; return nRetsize;
} }
private: private:
enum tmedia_t140_data_type_e m_eType; enum tmedia_t140_data_type_e m_eType;
const void* m_pPtr; const void* m_pPtr;
unsigned m_nSize; unsigned m_nSize;
}; };
class TINYWRAP_API T140Callback class TINYWRAP_API T140Callback
{ {
public: public:
T140Callback() {} T140Callback() {}
virtual ~T140Callback() {} virtual ~T140Callback() {}
virtual int ondata(const T140CallbackData* pData) { virtual int ondata(const T140CallbackData* pData) {
return 0; return 0;
} }
}; };
#if !defined(SWIG) #if !defined(SWIG)
class RtcpCallbackData class RtcpCallbackData
{ {
public: public:
RtcpCallbackData(enum tmedia_rtcp_event_type_e event_type, uint32_t ssrc_media) { RtcpCallbackData(enum tmedia_rtcp_event_type_e event_type, uint32_t ssrc_media) {
m_eType = event_type; m_eType = event_type;
m_nSSRC = ssrc_media; m_nSSRC = ssrc_media;
} }
virtual ~RtcpCallbackData() {} virtual ~RtcpCallbackData() {}
inline enum tmedia_rtcp_event_type_e getType()const { inline enum tmedia_rtcp_event_type_e getType()const {
return m_eType; return m_eType;
} }
inline uint32_t getSSRC()const { inline uint32_t getSSRC()const {
return m_nSSRC; return m_nSSRC;
} }
private: private:
enum tmedia_rtcp_event_type_e m_eType; enum tmedia_rtcp_event_type_e m_eType;
uint32_t m_nSSRC; uint32_t m_nSSRC;
}; };
class TINYWRAP_API RtcpCallback class TINYWRAP_API RtcpCallback
{ {
public: public:
RtcpCallback() {} RtcpCallback() {}
virtual ~RtcpCallback() {} virtual ~RtcpCallback() {}
virtual int onevent(const RtcpCallbackData* e) { virtual int onevent(const RtcpCallbackData* e) {
return 0; return 0;
} }
}; };
#endif /* #if !defined(SWIG) */ #endif /* #if !defined(SWIG) */
/* ======================== SipSession ========================*/ /* ======================== SipSession ========================*/
class TINYWRAP_API SipSession class TINYWRAP_API SipSession
{ {
public: public:
SipSession(SipStack* stack); SipSession(SipStack* stack);
#if !defined(SWIG) #if !defined(SWIG)
SipSession(SipStack* stack, tsip_ssession_handle_t* pHandle); SipSession(SipStack* stack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~SipSession(); virtual ~SipSession();
public: public:
bool haveOwnership(); bool haveOwnership();
bool addHeader(const char* name, const char* value); bool addHeader(const char* name, const char* value);
bool removeHeader(const char* name); bool removeHeader(const char* name);
bool addCaps(const char* name, const char* value); bool addCaps(const char* name, const char* value);
bool addCaps(const char* name); bool addCaps(const char* name);
bool removeCaps(const char* name); bool removeCaps(const char* name);
bool setExpires(unsigned expires); bool setExpires(unsigned expires);
bool setFromUri(const char* fromUriString); bool setFromUri(const char* fromUriString);
bool setFromUri(const SipUri* fromUri); bool setFromUri(const SipUri* fromUri);
bool setToUri(const char* toUriString); bool setToUri(const char* toUriString);
bool setToUri(const SipUri* toUri); bool setToUri(const SipUri* toUri);
bool setSilentHangup(bool silent); bool setSilentHangup(bool silent);
bool addSigCompCompartment(const char* compId); bool addSigCompCompartment(const char* compId);
bool removeSigCompCompartment(); bool removeSigCompCompartment();
#if !defined(SWIG) #if !defined(SWIG)
bool setAuth(const char* authHa1, const char* authIMPI); bool setAuth(const char* authHa1, const char* authIMPI);
#endif #endif
unsigned getId()const; unsigned getId()const;
#if !defined(SWIG) #if !defined(SWIG)
bool setWebSocketSrc(const char* host, int32_t port, const char* proto); bool setWebSocketSrc(const char* host, int32_t port, const char* proto);
const SipStack* getStack() const; const SipStack* getStack() const;
const tsip_ssession_handle_t* getWrappedSession() { const tsip_ssession_handle_t* getWrappedSession() {
return m_pHandle; return m_pHandle;
} }
#endif #endif
private: private:
void init(SipStack* stack, tsip_ssession_handle_t* pHandle=tsk_null); void init(SipStack* stack, tsip_ssession_handle_t* pHandle=tsk_null);
protected: protected:
tsip_ssession_handle_t* m_pHandle; tsip_ssession_handle_t* m_pHandle;
const SipStack* m_pStack; const SipStack* m_pStack;
}; };
/* ======================== InviteSession ========================*/ /* ======================== InviteSession ========================*/
class TINYWRAP_API InviteSession : public SipSession class TINYWRAP_API InviteSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
InviteSession(SipStack* Stack); InviteSession(SipStack* Stack);
#if !defined(SWIG) #if !defined(SWIG)
InviteSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); InviteSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~InviteSession(); virtual ~InviteSession();
public: /* Public functions */ public: /* Public functions */
bool accept(ActionConfig* config=tsk_null); bool accept(ActionConfig* config=tsk_null);
bool hangup(ActionConfig* config=tsk_null); bool hangup(ActionConfig* config=tsk_null);
bool reject(ActionConfig* config=tsk_null); bool reject(ActionConfig* config=tsk_null);
bool sendInfo(const void* payload, unsigned len, ActionConfig* config=tsk_null); bool sendInfo(const void* payload, unsigned len, ActionConfig* config=tsk_null);
const MediaSessionMgr* getMediaMgr(); const MediaSessionMgr* getMediaMgr();
private: private:
MediaSessionMgr* m_pMediaMgr; MediaSessionMgr* m_pMediaMgr;
}; };
/* ======================== CallSession ========================*/ /* ======================== CallSession ========================*/
class TINYWRAP_API CallSession : public InviteSession class TINYWRAP_API CallSession : public InviteSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
CallSession(SipStack* pStack); CallSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
CallSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); CallSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~CallSession(); virtual ~CallSession();
public: /* Public functions */ public: /* Public functions */
bool callAudio(const char* remoteUriString, ActionConfig* config=tsk_null); /* @deprecated */ bool callAudio(const char* remoteUriString, ActionConfig* config=tsk_null); /* @deprecated */
bool callAudio(const SipUri* remoteUri, ActionConfig* config=tsk_null); /* @deprecated */ bool callAudio(const SipUri* remoteUri, ActionConfig* config=tsk_null); /* @deprecated */
bool callAudioVideo(const char* remoteUriString, ActionConfig* config=tsk_null); /* @deprecated */ bool callAudioVideo(const char* remoteUriString, ActionConfig* config=tsk_null); /* @deprecated */
bool callAudioVideo(const SipUri* remoteUri, ActionConfig* config=tsk_null); /* @deprecated */ bool callAudioVideo(const SipUri* remoteUri, ActionConfig* config=tsk_null); /* @deprecated */
bool callVideo(const char* remoteUriString, ActionConfig* config=tsk_null); /* @deprecated */ bool callVideo(const char* remoteUriString, ActionConfig* config=tsk_null); /* @deprecated */
bool callVideo(const SipUri* remoteUri, ActionConfig* config=tsk_null); /* @deprecated */ bool callVideo(const SipUri* remoteUri, ActionConfig* config=tsk_null); /* @deprecated */
bool call(const char* remoteUriString, twrap_media_type_t media, ActionConfig* config=tsk_null); bool call(const char* remoteUriString, twrap_media_type_t media, ActionConfig* config=tsk_null);
bool call(const SipUri* remoteUri, twrap_media_type_t media, ActionConfig* config=tsk_null); bool call(const SipUri* remoteUri, twrap_media_type_t media, ActionConfig* config=tsk_null);
#if !defined(SWIG) #if !defined(SWIG)
bool setSupportedCodecs(int32_t codecs); bool setSupportedCodecs(int32_t codecs);
int32_t getNegotiatedCodecs(); int32_t getNegotiatedCodecs();
bool setMediaSSRC(twrap_media_type_t media, uint32_t ssrc); bool setMediaSSRC(twrap_media_type_t media, uint32_t ssrc);
#endif #endif
bool setSessionTimer(unsigned timeout, const char* refresher); bool setSessionTimer(unsigned timeout, const char* refresher);
bool set100rel(bool enabled); bool set100rel(bool enabled);
bool setRtcp(bool enabled); bool setRtcp(bool enabled);
bool setRtcpMux(bool enabled); bool setRtcpMux(bool enabled);
bool setSRtpMode(enum tmedia_srtp_mode_e mode); bool setSRtpMode(enum tmedia_srtp_mode_e mode);
bool setAvpfMode(enum tmedia_mode_e mode); bool setAvpfMode(enum tmedia_mode_e mode);
bool setICE(bool enabled); bool setICE(bool enabled);
bool setICEStun(bool enabled); bool setICEStun(bool enabled);
bool setICETurn(bool enabled); bool setICETurn(bool enabled);
bool setSTUNServer(const char* hostname, uint16_t port); bool setSTUNServer(const char* hostname, uint16_t port);
bool setSTUNCred(const char* username, const char* password); bool setSTUNCred(const char* username, const char* password);
bool setVideoFps(int32_t fps); bool setVideoFps(int32_t fps);
bool setVideoBandwidthUploadMax(int32_t max); bool setVideoBandwidthUploadMax(int32_t max);
bool setVideoBandwidthDownloadMax(int32_t max); bool setVideoBandwidthDownloadMax(int32_t max);
bool setVideoPrefSize(tmedia_pref_video_size_t pref_video_size); bool setVideoPrefSize(tmedia_pref_video_size_t pref_video_size);
bool setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength); bool setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength);
bool hold(ActionConfig* config=tsk_null); bool hold(ActionConfig* config=tsk_null);
bool resume(ActionConfig* config=tsk_null); bool resume(ActionConfig* config=tsk_null);
bool transfer(const char* referToUriString, ActionConfig* config=tsk_null); bool transfer(const char* referToUriString, ActionConfig* config=tsk_null);
bool acceptTransfer(ActionConfig* config=tsk_null); bool acceptTransfer(ActionConfig* config=tsk_null);
bool rejectTransfer(ActionConfig* config=tsk_null); bool rejectTransfer(ActionConfig* config=tsk_null);
bool sendDTMF(int number); bool sendDTMF(int number);
unsigned getSessionTransferId(); unsigned getSessionTransferId();
bool sendT140Data(enum tmedia_t140_data_type_e data_type, const void* data_ptr = NULL, unsigned data_size = 0); bool sendT140Data(enum tmedia_t140_data_type_e data_type, const void* data_ptr = NULL, unsigned data_size = 0);
bool setT140Callback(const T140Callback* pT140Callback); bool setT140Callback(const T140Callback* pT140Callback);
#if !defined(SWIG) #if !defined(SWIG)
bool sendRtcpEvent(enum tmedia_rtcp_event_type_e event_type, twrap_media_type_t media_type, uint32_t ssrc_media = 0); bool sendRtcpEvent(enum tmedia_rtcp_event_type_e event_type, twrap_media_type_t media_type, uint32_t ssrc_media = 0);
bool setRtcpCallback(const RtcpCallback* pRtcpCallback, twrap_media_type_t media_type); bool setRtcpCallback(const RtcpCallback* pRtcpCallback, twrap_media_type_t media_type);
const T140Callback* getT140Callback() const; const T140Callback* getT140Callback() const;
static int t140OnDataCallback(const void* context, enum tmedia_t140_data_type_e data_type, const void* data_ptr, unsigned data_size); static int t140OnDataCallback(const void* context, enum tmedia_t140_data_type_e data_type, const void* data_ptr, unsigned data_size);
const RtcpCallback* getRtcpCallback() const; const RtcpCallback* getRtcpCallback() const;
static int rtcpOnCallback(const void* context, enum tmedia_rtcp_event_type_e event_type, uint32_t ssrc_media); static int rtcpOnCallback(const void* context, enum tmedia_rtcp_event_type_e event_type, uint32_t ssrc_media);
#endif /* #if !defined(SWIG) */ #endif /* #if !defined(SWIG) */
private: private:
const T140Callback* m_pT140Callback; const T140Callback* m_pT140Callback;
const RtcpCallback* m_pRtcpCallback; const RtcpCallback* m_pRtcpCallback;
}; };
/* ======================== MsrpSession ========================*/ /* ======================== MsrpSession ========================*/
class TINYWRAP_API MsrpSession : public InviteSession class TINYWRAP_API MsrpSession : public InviteSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
MsrpSession(SipStack* pStack, MsrpCallback* pCallback); MsrpSession(SipStack* pStack, MsrpCallback* pCallback);
#if !defined(SWIG) #if !defined(SWIG)
MsrpSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); MsrpSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~MsrpSession(); virtual ~MsrpSession();
public: /* Public functions */ public: /* Public functions */
bool setCallback(MsrpCallback* pCallback); bool setCallback(MsrpCallback* pCallback);
bool callMsrp(const char* remoteUriString, ActionConfig* config=tsk_null); bool callMsrp(const char* remoteUriString, ActionConfig* config=tsk_null);
bool callMsrp(const SipUri* remoteUri, ActionConfig* config=tsk_null); bool callMsrp(const SipUri* remoteUri, ActionConfig* config=tsk_null);
bool sendMessage(const void* payload, unsigned len, ActionConfig* config=tsk_null); bool sendMessage(const void* payload, unsigned len, ActionConfig* config=tsk_null);
bool sendFile(ActionConfig* config=tsk_null); bool sendFile(ActionConfig* config=tsk_null);
public: /* Public helper function */ public: /* Public helper function */
#if !defined(SWIG) #if !defined(SWIG)
inline MsrpCallback* getCallback()const { inline MsrpCallback* getCallback()const {
return m_pCallback; return m_pCallback;
} }
#endif #endif
private: private:
MsrpCallback* m_pCallback; MsrpCallback* m_pCallback;
}; };
/* ======================== MessagingSession ========================*/ /* ======================== MessagingSession ========================*/
class TINYWRAP_API MessagingSession : public SipSession class TINYWRAP_API MessagingSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
MessagingSession(SipStack* pStack); MessagingSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
MessagingSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); MessagingSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~MessagingSession(); virtual ~MessagingSession();
public: /* Public functions */ public: /* Public functions */
bool send(const void* payload, unsigned len, ActionConfig* config=tsk_null); bool send(const void* payload, unsigned len, ActionConfig* config=tsk_null);
bool accept(ActionConfig* config=tsk_null); bool accept(ActionConfig* config=tsk_null);
bool reject(ActionConfig* config=tsk_null); bool reject(ActionConfig* config=tsk_null);
}; };
/* ======================== InfoSession ========================*/ /* ======================== InfoSession ========================*/
class TINYWRAP_API InfoSession : public SipSession class TINYWRAP_API InfoSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
InfoSession(SipStack* pStack); InfoSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
InfoSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); InfoSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~InfoSession(); virtual ~InfoSession();
public: /* Public functions */ public: /* Public functions */
bool send(const void* payload, unsigned len, ActionConfig* config=tsk_null); bool send(const void* payload, unsigned len, ActionConfig* config=tsk_null);
bool accept(ActionConfig* config=tsk_null); bool accept(ActionConfig* config=tsk_null);
bool reject(ActionConfig* config=tsk_null); bool reject(ActionConfig* config=tsk_null);
}; };
/* ======================== OptionsSession ========================*/ /* ======================== OptionsSession ========================*/
class TINYWRAP_API OptionsSession : public SipSession class TINYWRAP_API OptionsSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
OptionsSession(SipStack* pStack); OptionsSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
OptionsSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); OptionsSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~OptionsSession(); virtual ~OptionsSession();
public: /* Public functions */ public: /* Public functions */
bool send(ActionConfig* config=tsk_null); bool send(ActionConfig* config=tsk_null);
bool accept(ActionConfig* config=tsk_null); bool accept(ActionConfig* config=tsk_null);
bool reject(ActionConfig* config=tsk_null); bool reject(ActionConfig* config=tsk_null);
}; };
/* ======================== PublicationSession ========================*/ /* ======================== PublicationSession ========================*/
class TINYWRAP_API PublicationSession : public SipSession class TINYWRAP_API PublicationSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
PublicationSession(SipStack* pStack); PublicationSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
PublicationSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); PublicationSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~PublicationSession(); virtual ~PublicationSession();
public: /* Public functions */ public: /* Public functions */
bool publish(const void* payload, unsigned len, ActionConfig* config=tsk_null); bool publish(const void* payload, unsigned len, ActionConfig* config=tsk_null);
bool unPublish(ActionConfig* config=tsk_null); bool unPublish(ActionConfig* config=tsk_null);
}; };
/* ======================== RegistrationSession ========================*/ /* ======================== RegistrationSession ========================*/
class TINYWRAP_API RegistrationSession : public SipSession class TINYWRAP_API RegistrationSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
RegistrationSession(SipStack* pStack); RegistrationSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
RegistrationSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); RegistrationSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~RegistrationSession(); virtual ~RegistrationSession();
public: /* Public functions */ public: /* Public functions */
bool register_(ActionConfig* config=tsk_null); bool register_(ActionConfig* config=tsk_null);
bool unRegister(ActionConfig* config=tsk_null); bool unRegister(ActionConfig* config=tsk_null);
bool accept(ActionConfig* config=tsk_null); bool accept(ActionConfig* config=tsk_null);
bool reject(ActionConfig* config=tsk_null); bool reject(ActionConfig* config=tsk_null);
}; };
/* ======================== SubscriptionSession ========================*/ /* ======================== SubscriptionSession ========================*/
class TINYWRAP_API SubscriptionSession : public SipSession class TINYWRAP_API SubscriptionSession : public SipSession
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
SubscriptionSession(SipStack* pStack); SubscriptionSession(SipStack* pStack);
#if !defined(SWIG) #if !defined(SWIG)
SubscriptionSession(SipStack* pStack, tsip_ssession_handle_t* pHandle); SubscriptionSession(SipStack* pStack, tsip_ssession_handle_t* pHandle);
#endif #endif
virtual ~SubscriptionSession(); virtual ~SubscriptionSession();
public: /* Public functions */ public: /* Public functions */
bool subscribe(); bool subscribe();
bool unSubscribe(); bool unSubscribe();
}; };
#endif /* TINYWRAP_SIPSESSION_H */ #endif /* TINYWRAP_SIPSESSION_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,123 +1,123 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIPSTACK_H #ifndef TINYWRAP_SIPSTACK_H
#define TINYWRAP_SIPSTACK_H #define TINYWRAP_SIPSTACK_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "SipCallback.h" #include "SipCallback.h"
#include "SafeObject.h" #include "SafeObject.h"
#include "tinydav/tdav.h" #include "tinydav/tdav.h"
#include "tinysip.h" #include "tinysip.h"
#include "tinyhttp.h" #include "tinyhttp.h"
class DDebugCallback; class DDebugCallback;
class TINYWRAP_API SipStack: public SafeObject class TINYWRAP_API SipStack: public SafeObject
{ {
public: /* ctor() and dtor() */ public: /* ctor() and dtor() */
SipStack(SipCallback* pCallback, const char* realm_uri, const char* impi_uri, const char* impu_uri); SipStack(SipCallback* pCallback, const char* realm_uri, const char* impi_uri, const char* impu_uri);
~SipStack(); ~SipStack();
public: /* API functions */ public: /* API functions */
bool start(); bool start();
bool setDebugCallback(DDebugCallback* pCallback); bool setDebugCallback(DDebugCallback* pCallback);
bool setDisplayName(const char* display_name); bool setDisplayName(const char* display_name);
bool setRealm(const char* realm_uri); bool setRealm(const char* realm_uri);
bool setIMPI(const char* impi); bool setIMPI(const char* impi);
bool setIMPU(const char* impu_uri); bool setIMPU(const char* impu_uri);
bool setPassword(const char* password); bool setPassword(const char* password);
bool setAMF(const char* amf); bool setAMF(const char* amf);
bool setOperatorId(const char* opid); bool setOperatorId(const char* opid);
bool setProxyCSCF(const char* fqdn, unsigned short port, const char* transport, const char* ipversion); bool setProxyCSCF(const char* fqdn, unsigned short port, const char* transport, const char* ipversion);
bool setLocalIP(const char* ip, const char* transport=tsk_null); bool setLocalIP(const char* ip, const char* transport=tsk_null);
bool setLocalPort(unsigned short port, const char* transport=tsk_null); bool setLocalPort(unsigned short port, const char* transport=tsk_null);
bool setEarlyIMS(bool enabled); bool setEarlyIMS(bool enabled);
bool addHeader(const char* name, const char* value); bool addHeader(const char* name, const char* value);
bool removeHeader(const char* name); bool removeHeader(const char* name);
bool addDnsServer(const char* ip); bool addDnsServer(const char* ip);
bool setDnsDiscovery(bool enabled); bool setDnsDiscovery(bool enabled);
bool setAoR(const char* ip, int port); bool setAoR(const char* ip, int port);
#if !defined(SWIG) #if !defined(SWIG)
bool setMode(enum tsip_stack_mode_e mode); bool setMode(enum tsip_stack_mode_e mode);
#endif #endif
bool setSigCompParams(unsigned dms, unsigned sms, unsigned cpb, bool enablePresDict); bool setSigCompParams(unsigned dms, unsigned sms, unsigned cpb, bool enablePresDict);
bool addSigCompCompartment(const char* compId); bool addSigCompCompartment(const char* compId);
bool removeSigCompCompartment(const char* compId); bool removeSigCompCompartment(const char* compId);
bool setSTUNEnabledForICE(bool enabled); // @deprecated bool setSTUNEnabledForICE(bool enabled); // @deprecated
bool setSTUNServer(const char* hostname, unsigned short port); // @deprecated bool setSTUNServer(const char* hostname, unsigned short port); // @deprecated
bool setSTUNCred(const char* login, const char* password); // @deprecated bool setSTUNCred(const char* login, const char* password); // @deprecated
bool setSTUNEnabled(bool enabled); bool setSTUNEnabled(bool enabled);
bool setTLSSecAgree(bool enabled); bool setTLSSecAgree(bool enabled);
bool setSSLCertificates(const char* privKey, const char* pubKey, const char* caKey, bool verify = false); bool setSSLCertificates(const char* privKey, const char* pubKey, const char* caKey, bool verify = false);
bool setSSLCretificates(const char* privKey, const char* pubKey, const char* caKey, bool verify = false); /*@deprecated: typo */ bool setSSLCretificates(const char* privKey, const char* pubKey, const char* caKey, bool verify = false); /*@deprecated: typo */
bool setIPSecSecAgree(bool enabled); bool setIPSecSecAgree(bool enabled);
bool setIPSecParameters(const char* algo, const char* ealgo, const char* mode, const char* proto); bool setIPSecParameters(const char* algo, const char* ealgo, const char* mode, const char* proto);
char* dnsENUM(const char* service, const char* e164num, const char* domain); char* dnsENUM(const char* service, const char* e164num, const char* domain);
char* dnsNaptrSrv(const char* domain, const char* service, unsigned short *OUTPUT); char* dnsNaptrSrv(const char* domain, const char* service, unsigned short *OUTPUT);
char* dnsSrv(const char* service, unsigned short* OUTPUT); char* dnsSrv(const char* service, unsigned short* OUTPUT);
bool setMaxFDs(unsigned max_fds); bool setMaxFDs(unsigned max_fds);
char* getLocalIPnPort(const char* protocol, unsigned short* OUTPUT); char* getLocalIPnPort(const char* protocol, unsigned short* OUTPUT);
char* getPreferredIdentity(); char* getPreferredIdentity();
bool isValid(); bool isValid();
bool stop(); bool stop();
static bool initialize(); static bool initialize();
static bool deInitialize(); static bool deInitialize();
static void setCodecs(tdav_codec_id_t codecs); static void setCodecs(tdav_codec_id_t codecs);
static void setCodecs_2(int64_t codecs); // For stupid languages static void setCodecs_2(int64_t codecs); // For stupid languages
static bool setCodecPriority(tdav_codec_id_t codec_id, int priority); static bool setCodecPriority(tdav_codec_id_t codec_id, int priority);
static bool setCodecPriority_2(int codec, int priority);// For stupid languages static bool setCodecPriority_2(int codec, int priority);// For stupid languages
static bool isCodecSupported(tdav_codec_id_t codec_id); static bool isCodecSupported(tdav_codec_id_t codec_id);
static bool isIPSecSupported(); static bool isIPSecSupported();
public: /* Public helper function */ public: /* Public helper function */
#if !defined(SWIG) #if !defined(SWIG)
inline tsip_stack_handle_t* getHandle()const { inline tsip_stack_handle_t* getHandle()const {
return m_pHandle; return m_pHandle;
} }
inline SipCallback* getCallback()const { inline SipCallback* getCallback()const {
return m_pCallback; return m_pCallback;
} }
inline DDebugCallback* getDebugCallback() const { inline DDebugCallback* getDebugCallback() const {
return m_pDebugCallback; return m_pDebugCallback;
} }
#endif #endif
private: private:
SipCallback* m_pCallback; SipCallback* m_pCallback;
DDebugCallback* m_pDebugCallback; DDebugCallback* m_pDebugCallback;
tsip_stack_handle_t* m_pHandle; tsip_stack_handle_t* m_pHandle;
static bool g_bInitialized; static bool g_bInitialized;
}; };
#endif /* TINYWRAP_SIPSTACK_H */ #endif /* TINYWRAP_SIPSTACK_H */

View File

@ -1,457 +1,457 @@
%{ %{
#include "ActionConfig.h" #include "ActionConfig.h"
#include "MediaSessionMgr.h" #include "MediaSessionMgr.h"
#include "MediaContent.h" #include "MediaContent.h"
#include "SipUri.h" #include "SipUri.h"
#include "SipMessage.h" #include "SipMessage.h"
#include "SipEvent.h" #include "SipEvent.h"
#include "SipSession.h" #include "SipSession.h"
#include "ProxyPluginMgr.h" #include "ProxyPluginMgr.h"
#include "ProxyConsumer.h" #include "ProxyConsumer.h"
#include "ProxyProducer.h" #include "ProxyProducer.h"
#include "SipCallback.h" #include "SipCallback.h"
#include "SafeObject.h" #include "SafeObject.h"
#include "SipStack.h" #include "SipStack.h"
%} %}
/* Callbacks */ /* Callbacks */
%feature("director") SipCallback; %feature("director") SipCallback;
%feature("director") ProxyPluginMgrCallback; %feature("director") ProxyPluginMgrCallback;
%feature("director") ProxyAudioConsumerCallback; %feature("director") ProxyAudioConsumerCallback;
%feature("director") ProxyVideoConsumerCallback; %feature("director") ProxyVideoConsumerCallback;
%feature("director") ProxyAudioProducerCallback; %feature("director") ProxyAudioProducerCallback;
%feature("director") ProxyVideoProducerCallback; %feature("director") ProxyVideoProducerCallback;
%feature("director") T140Callback; %feature("director") T140Callback;
%nodefaultctor; %nodefaultctor;
%include "ActionConfig.h" %include "ActionConfig.h"
%include "MediaSessionMgr.h" %include "MediaSessionMgr.h"
%include "MediaContent.h" %include "MediaContent.h"
%include "SipUri.h" %include "SipUri.h"
%include "SipMessage.h" %include "SipMessage.h"
%include "SipEvent.h" %include "SipEvent.h"
%include "SipSession.h" %include "SipSession.h"
%include "ProxyPluginMgr.h" %include "ProxyPluginMgr.h"
%include "ProxyConsumer.h" %include "ProxyConsumer.h"
%include "ProxyProducer.h" %include "ProxyProducer.h"
%include "SipCallback.h" %include "SipCallback.h"
%include "SafeObject.h" %include "SafeObject.h"
%include "SipStack.h" %include "SipStack.h"
%clearnodefaultctor; %clearnodefaultctor;
/* ====== From "tinySIP\include\tsip.h" ====== */ /* ====== From "tinySIP\include\tsip.h" ====== */
typedef enum tsip_stack_mode_e typedef enum tsip_stack_mode_e
{ {
tsip_stack_mode_ua, tsip_stack_mode_ua,
tsip_stack_mode_p2p, tsip_stack_mode_p2p,
tsip_stack_mode_mediaproxy, tsip_stack_mode_mediaproxy,
tsip_stack_mode_mcu tsip_stack_mode_mcu
} }
tsip_stack_mode_t; tsip_stack_mode_t;
/* ====== From "tinySIP\include\tinysip\tsip_messag_common.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_messag_common.h" ====== */
typedef enum tsip_request_type_e typedef enum tsip_request_type_e
{ {
tsip_NONE = 0, tsip_NONE = 0,
tsip_ACK, tsip_ACK,
tsip_BYE, tsip_BYE,
tsip_CANCEL, tsip_CANCEL,
tsip_INVITE, tsip_INVITE,
tsip_OPTIONS, tsip_OPTIONS,
tsip_REGISTER, tsip_REGISTER,
tsip_SUBSCRIBE, tsip_SUBSCRIBE,
tsip_NOTIFY, tsip_NOTIFY,
tsip_REFER, tsip_REFER,
tsip_INFO, tsip_INFO,
tsip_UPDATE, tsip_UPDATE,
tsip_MESSAGE, tsip_MESSAGE,
tsip_PUBLISH, tsip_PUBLISH,
tsip_PRACK tsip_PRACK
} }
tsip_request_type_t; tsip_request_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_event.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_event.h" ====== */
typedef enum tsip_event_type_e typedef enum tsip_event_type_e
{ {
tsip_event_invite, tsip_event_invite,
tsip_event_message, tsip_event_message,
tsip_event_info, tsip_event_info,
tsip_event_options, tsip_event_options,
tsip_event_publish, tsip_event_publish,
tsip_event_register, tsip_event_register,
tsip_event_subscribe, tsip_event_subscribe,
tsip_event_dialog tsip_event_dialog
} }
tsip_event_type_t; tsip_event_type_t;
// 7xx ==> errors // 7xx ==> errors
#define tsip_event_code_dialog_transport_error 702 #define tsip_event_code_dialog_transport_error 702
#define tsip_event_code_dialog_global_error 703 #define tsip_event_code_dialog_global_error 703
#define tsip_event_code_dialog_message_error 704 #define tsip_event_code_dialog_message_error 704
// 8xx ==> success // 8xx ==> success
#define tsip_event_code_dialog_request_incoming 800 #define tsip_event_code_dialog_request_incoming 800
#define tsip_event_code_dialog_request_outgoing 802 #define tsip_event_code_dialog_request_outgoing 802
#define tsip_event_code_dialog_request_cancelled 803 #define tsip_event_code_dialog_request_cancelled 803
#define tsip_event_code_dialog_request_sent 804 #define tsip_event_code_dialog_request_sent 804
// 9xx ==> Informational // 9xx ==> Informational
#define tsip_event_code_dialog_connecting 900 #define tsip_event_code_dialog_connecting 900
#define tsip_event_code_dialog_connected 901 #define tsip_event_code_dialog_connected 901
#define tsip_event_code_dialog_terminating 902 #define tsip_event_code_dialog_terminating 902
#define tsip_event_code_dialog_terminated 903 #define tsip_event_code_dialog_terminated 903
#define tsip_event_code_stack_starting 950 #define tsip_event_code_stack_starting 950
#define tsip_event_code_stack_started 951 #define tsip_event_code_stack_started 951
#define tsip_event_code_stack_stopping 952 #define tsip_event_code_stack_stopping 952
#define tsip_event_code_stack_stopped 953 #define tsip_event_code_stack_stopped 953
#define tsip_event_code_stack_failed_to_start 954 #define tsip_event_code_stack_failed_to_start 954
#define tsip_event_code_stack_failed_to_stop 955 #define tsip_event_code_stack_failed_to_stop 955
#define tsip_event_code_stack_disconnected 956 #define tsip_event_code_stack_disconnected 956
/* ====== From "tinySIP\include\tinysip\tsip_api_register.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_register.h" ====== */
typedef enum tsip_register_event_type_e typedef enum tsip_register_event_type_e
{ {
tsip_i_newreg, tsip_i_newreg,
tsip_i_register, // refresh tsip_i_register, // refresh
tsip_ao_register, tsip_ao_register,
tsip_i_unregister, tsip_i_unregister,
tsip_ao_unregister, tsip_ao_unregister,
} }
tsip_register_event_type_t; tsip_register_event_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_api_subscribe.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_subscribe.h" ====== */
typedef enum tsip_subscribe_event_type_e typedef enum tsip_subscribe_event_type_e
{ {
tsip_i_subscribe, tsip_i_subscribe,
tsip_ao_subscribe, tsip_ao_subscribe,
tsip_i_unsubscribe, tsip_i_unsubscribe,
tsip_ao_unsubscribe, tsip_ao_unsubscribe,
tsip_i_notify, tsip_i_notify,
tsip_ao_notify tsip_ao_notify
} }
tsip_subscribe_event_type_t; tsip_subscribe_event_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_api_publish.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_publish.h" ====== */
typedef enum tsip_publish_event_type_e typedef enum tsip_publish_event_type_e
{ {
tsip_i_publish, tsip_i_publish,
tsip_ao_publish, tsip_ao_publish,
tsip_i_unpublish, tsip_i_unpublish,
tsip_ao_unpublish tsip_ao_unpublish
} }
tsip_publish_event_type_t; tsip_publish_event_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_api_message.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_message.h" ====== */
typedef enum tsip_message_event_type_e typedef enum tsip_message_event_type_e
{ {
tsip_i_message, tsip_i_message,
tsip_ao_message, tsip_ao_message,
} }
tsip_message_event_type_t; tsip_message_event_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_api_info.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_info.h" ====== */
typedef enum tsip_info_event_type_e typedef enum tsip_info_event_type_e
{ {
tsip_i_info, tsip_i_info,
tsip_ao_info, tsip_ao_info,
} }
tsip_info_event_type_t; tsip_info_event_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_api_options.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_options.h" ====== */
typedef enum tsip_options_event_type_e typedef enum tsip_options_event_type_e
{ {
tsip_i_options, tsip_i_options,
tsip_ao_options, tsip_ao_options,
} }
tsip_options_event_type_t; tsip_options_event_type_t;
/* ====== From "tinySIP\include\tinysip\tsip_api_invite.h" ====== */ /* ====== From "tinySIP\include\tinysip\tsip_api_invite.h" ====== */
typedef enum tsip_invite_event_type_e typedef enum tsip_invite_event_type_e
{ {
// ============================ // ============================
// Sip Events // Sip Events
// //
tsip_i_newcall, tsip_i_newcall,
//! in-dialog requests/reponses //! in-dialog requests/reponses
tsip_i_request, tsip_i_request,
tsip_ao_request, tsip_ao_request,
/* 3GPP TS 24.629: Explicit Call Transfer (ECT) */ /* 3GPP TS 24.629: Explicit Call Transfer (ECT) */
tsip_o_ect_trying, tsip_o_ect_trying,
tsip_o_ect_accepted, tsip_o_ect_accepted,
tsip_o_ect_completed, tsip_o_ect_completed,
tsip_o_ect_failed, tsip_o_ect_failed,
tsip_o_ect_notify, tsip_o_ect_notify,
tsip_i_ect_requested, tsip_i_ect_requested,
tsip_i_ect_newcall, tsip_i_ect_newcall,
tsip_i_ect_completed, tsip_i_ect_completed,
tsip_i_ect_failed, tsip_i_ect_failed,
tsip_i_ect_notify, tsip_i_ect_notify,
// ============================ // ============================
// Media Events // Media Events
// //
tsip_m_early_media, tsip_m_early_media,
tsip_m_updating, // Trying to update from Audio -> Video for example tsip_m_updating, // Trying to update from Audio -> Video for example
tsip_m_updated, // succeed to update tsip_m_updated, // succeed to update
/* 3GPP TS 24.610: Communication Hold */ /* 3GPP TS 24.610: Communication Hold */
tsip_m_local_hold_ok, tsip_m_local_hold_ok,
tsip_m_local_hold_nok, tsip_m_local_hold_nok,
tsip_m_local_resume_ok, tsip_m_local_resume_ok,
tsip_m_local_resume_nok, tsip_m_local_resume_nok,
tsip_m_remote_hold, tsip_m_remote_hold,
tsip_m_remote_resume, tsip_m_remote_resume,
} }
tsip_invite_event_type_t; tsip_invite_event_type_t;
/* ====== From "tinymedia/tmedia_qos.h" ====== */ /* ====== From "tinymedia/tmedia_qos.h" ====== */
typedef enum tmedia_qos_stype_e typedef enum tmedia_qos_stype_e
{ {
tmedia_qos_stype_none,/* not part of the RFC */ tmedia_qos_stype_none,/* not part of the RFC */
tmedia_qos_stype_segmented, tmedia_qos_stype_segmented,
tmedia_qos_stype_e2e, tmedia_qos_stype_e2e,
} }
tmedia_qos_stype_t; tmedia_qos_stype_t;
/* ====== From "tinymedia/tmedia_qos.h" ====== */ /* ====== From "tinymedia/tmedia_qos.h" ====== */
typedef enum tmedia_qos_strength_e typedef enum tmedia_qos_strength_e
{ {
/* do no change the order (none -> optional -> manadatory) */ /* do no change the order (none -> optional -> manadatory) */
tmedia_qos_strength_none, tmedia_qos_strength_none,
tmedia_qos_strength_failure, tmedia_qos_strength_failure,
tmedia_qos_strength_unknown, tmedia_qos_strength_unknown,
tmedia_qos_strength_optional, tmedia_qos_strength_optional,
tmedia_qos_strength_mandatory tmedia_qos_strength_mandatory
} }
tmedia_qos_strength_t; tmedia_qos_strength_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
// used by tinyWRAP // used by tinyWRAP
typedef enum tmedia_chroma_e typedef enum tmedia_chroma_e
{ {
tmedia_chroma_none=0, tmedia_chroma_none=0,
tmedia_chroma_rgb24, // will be stored as bgr24 on x86 (little endians) machines; e.g. WindowsPhone7 tmedia_chroma_rgb24, // will be stored as bgr24 on x86 (little endians) machines; e.g. WindowsPhone7
tmedia_chroma_bgr24, // used by windows consumer (DirectShow) - tmedia_chroma_bgr24, // used by windows consumer (DirectShow) -
tmedia_chroma_rgb32, // used by iOS4 consumer (iPhone and iPod touch) tmedia_chroma_rgb32, // used by iOS4 consumer (iPhone and iPod touch)
tmedia_chroma_rgb565le, // (used by both android and wince consumers) tmedia_chroma_rgb565le, // (used by both android and wince consumers)
tmedia_chroma_rgb565be, tmedia_chroma_rgb565be,
tmedia_chroma_nv12, // used by iOS4 producer (iPhone and iPod Touch 3GS and 4) tmedia_chroma_nv12, // used by iOS4 producer (iPhone and iPod Touch 3GS and 4)
tmedia_chroma_nv21, // Yuv420 SP (used by android producer) tmedia_chroma_nv21, // Yuv420 SP (used by android producer)
tmedia_chroma_yuv422p, tmedia_chroma_yuv422p,
tmedia_chroma_uyvy422, // used by iOS4 producer (iPhone and iPod Touch 3G) tmedia_chroma_uyvy422, // used by iOS4 producer (iPhone and iPod Touch 3G)
tmedia_chroma_yuv420p, // Default tmedia_chroma_yuv420p, // Default
tmedia_chroma_mjpeg, // Compressed. e.g. used by VirtualBox (Windows as host and Ubuntu as guest) tmedia_chroma_mjpeg, // Compressed. e.g. used by VirtualBox (Windows as host and Ubuntu as guest)
tmedia_chroma_yuyv422, // YUYV422 (V4L2 preferred format) tmedia_chroma_yuyv422, // YUYV422 (V4L2 preferred format)
} }
tmedia_chroma_t; tmedia_chroma_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
typedef enum tmedia_mode_e typedef enum tmedia_mode_e
{ {
tmedia_mode_none, tmedia_mode_none,
tmedia_mode_optional, tmedia_mode_optional,
tmedia_mode_mandatory tmedia_mode_mandatory
} }
tmedia_mode_t; tmedia_mode_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
typedef enum tmedia_srtp_mode_e typedef enum tmedia_srtp_mode_e
{ {
tmedia_srtp_mode_none, tmedia_srtp_mode_none,
tmedia_srtp_mode_optional, tmedia_srtp_mode_optional,
tmedia_srtp_mode_mandatory tmedia_srtp_mode_mandatory
} }
tmedia_srtp_mode_t; tmedia_srtp_mode_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
typedef enum tmedia_srtp_type_e typedef enum tmedia_srtp_type_e
{ {
tmedia_srtp_type_none = 0x00, tmedia_srtp_type_none = 0x00,
tmedia_srtp_type_sdes = 0x01, tmedia_srtp_type_sdes = 0x01,
tmedia_srtp_type_dtls = 0x02, tmedia_srtp_type_dtls = 0x02,
tmedia_srtp_type_sdes_dtls = (0x01 | 0x02) tmedia_srtp_type_sdes_dtls = (0x01 | 0x02)
} }
tmedia_srtp_type_t; tmedia_srtp_type_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
typedef enum tmedia_t140_data_type_e typedef enum tmedia_t140_data_type_e
{ {
tmedia_t140_data_type_utf8, tmedia_t140_data_type_utf8,
tmedia_t140_data_type_zero_width_no_break_space = 0xefbbbf, tmedia_t140_data_type_zero_width_no_break_space = 0xefbbbf,
tmedia_t140_data_type_backspace = 0x08, tmedia_t140_data_type_backspace = 0x08,
tmedia_t140_data_type_esc = 0x1b, tmedia_t140_data_type_esc = 0x1b,
tmedia_t140_data_type_cr = 0x0d, tmedia_t140_data_type_cr = 0x0d,
tmedia_t140_data_type_lf = 0x0a, tmedia_t140_data_type_lf = 0x0a,
tmedia_t140_data_type_cr_lf = 0x0d0a, tmedia_t140_data_type_cr_lf = 0x0d0a,
tmedia_t140_data_type_interrupt2 = 0x61, tmedia_t140_data_type_interrupt2 = 0x61,
tmedia_t140_data_type_bell = 0x07, tmedia_t140_data_type_bell = 0x07,
tmedia_t140_data_type_sos = 0x98, tmedia_t140_data_type_sos = 0x98,
tmedia_t140_data_type_string_term = 0x9c, tmedia_t140_data_type_string_term = 0x9c,
tmedia_t140_data_type_graphic_start = 0x9b, tmedia_t140_data_type_graphic_start = 0x9b,
tmedia_t140_data_type_graphic_end = 0x6d, tmedia_t140_data_type_graphic_end = 0x6d,
tmedia_t140_data_type_loss_char_char = 0xfffd, tmedia_t140_data_type_loss_char_char = 0xfffd,
tmedia_t140_data_type_loss_utf8 = 0xefbfbd, tmedia_t140_data_type_loss_utf8 = 0xefbfbd,
} }
tmedia_t140_data_type_t; tmedia_t140_data_type_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
#typedef enum tmedia_rtcp_event_type_e #typedef enum tmedia_rtcp_event_type_e
#{ #{
# tmedia_rtcp_event_type_fir, // Full Intra Refresh # tmedia_rtcp_event_type_fir, // Full Intra Refresh
#} #}
#tmedia_rtcp_event_type_t; #tmedia_rtcp_event_type_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
typedef enum tmedia_profile_e typedef enum tmedia_profile_e
{ {
tmedia_profile_default, tmedia_profile_default,
tmedia_profile_rtcweb tmedia_profile_rtcweb
} }
tmedia_profile_t; tmedia_profile_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
// @deprecated // @deprecated
typedef enum tmedia_bandwidth_level_e typedef enum tmedia_bandwidth_level_e
{ {
tmedia_bl_low, tmedia_bl_low,
tmedia_bl_medium, tmedia_bl_medium,
tmedia_bl_hight, tmedia_bl_hight,
tmedia_bl_unrestricted tmedia_bl_unrestricted
} }
tmedia_bandwidth_level_t; tmedia_bandwidth_level_t;
/* ====== From "tinymedia/tmedia_common.h" ====== */ /* ====== From "tinymedia/tmedia_common.h" ====== */
typedef enum tmedia_pref_video_size_s typedef enum tmedia_pref_video_size_s
{ /* must be sorted like this */ { /* must be sorted like this */
tmedia_pref_video_size_sqcif, // 128 x 98 tmedia_pref_video_size_sqcif, // 128 x 98
tmedia_pref_video_size_qcif, // 176 x 144 tmedia_pref_video_size_qcif, // 176 x 144
tmedia_pref_video_size_qvga, // 320 x 240 tmedia_pref_video_size_qvga, // 320 x 240
tmedia_pref_video_size_cif, // 352 x 288 tmedia_pref_video_size_cif, // 352 x 288
tmedia_pref_video_size_hvga, // 480 x 320 tmedia_pref_video_size_hvga, // 480 x 320
tmedia_pref_video_size_vga, // 640 x 480 tmedia_pref_video_size_vga, // 640 x 480
tmedia_pref_video_size_4cif, // 704 x 576 tmedia_pref_video_size_4cif, // 704 x 576
tmedia_pref_video_size_wvga, // 800 x 480 tmedia_pref_video_size_wvga, // 800 x 480
tmedia_pref_video_size_svga, // 800 x 600 tmedia_pref_video_size_svga, // 800 x 600
tmedia_pref_video_size_480p, // 852 x 480 tmedia_pref_video_size_480p, // 852 x 480
tmedia_pref_video_size_xga, // 1024 x 768 tmedia_pref_video_size_xga, // 1024 x 768
tmedia_pref_video_size_720p, // 1280 x 720 tmedia_pref_video_size_720p, // 1280 x 720
tmedia_pref_video_size_16cif, // 1408 x 1152 tmedia_pref_video_size_16cif, // 1408 x 1152
tmedia_pref_video_size_1080p, // 1920 x 1080 tmedia_pref_video_size_1080p, // 1920 x 1080
tmedia_pref_video_size_2160p, // 3840 x 2160 tmedia_pref_video_size_2160p, // 3840 x 2160
} }
tmedia_pref_video_size_t; tmedia_pref_video_size_t;
/* ====== From "tinymedia/tmedia_codec.h" ====== */ /* ====== From "tinymedia/tmedia_codec.h" ====== */
typedef enum tmedia_codec_id_e typedef enum tmedia_codec_id_e
{ {
tmedia_codec_id_none = 0x00000000, tmedia_codec_id_none = 0x00000000,
tmedia_codec_id_amr_nb_oa = 0x00000001<<0, tmedia_codec_id_amr_nb_oa = 0x00000001<<0,
tmedia_codec_id_amr_nb_be = 0x00000001<<1, tmedia_codec_id_amr_nb_be = 0x00000001<<1,
tmedia_codec_id_amr_wb_oa = 0x00000001<<2, tmedia_codec_id_amr_wb_oa = 0x00000001<<2,
tmedia_codec_id_amr_wb_be = 0x00000001<<3, tmedia_codec_id_amr_wb_be = 0x00000001<<3,
tmedia_codec_id_gsm = 0x00000001<<4, tmedia_codec_id_gsm = 0x00000001<<4,
tmedia_codec_id_pcma = 0x00000001<<5, tmedia_codec_id_pcma = 0x00000001<<5,
tmedia_codec_id_pcmu = 0x00000001<<6, tmedia_codec_id_pcmu = 0x00000001<<6,
tmedia_codec_id_ilbc = 0x00000001<<7, tmedia_codec_id_ilbc = 0x00000001<<7,
tmedia_codec_id_speex_nb = 0x00000001<<8, tmedia_codec_id_speex_nb = 0x00000001<<8,
tmedia_codec_id_speex_wb = 0x00000001<<9, tmedia_codec_id_speex_wb = 0x00000001<<9,
tmedia_codec_id_speex_uwb = 0x00000001<<10, tmedia_codec_id_speex_uwb = 0x00000001<<10,
tmedia_codec_id_bv16 = 0x00000001<<11, tmedia_codec_id_bv16 = 0x00000001<<11,
tmedia_codec_id_bv32 = 0x00000001<<12, tmedia_codec_id_bv32 = 0x00000001<<12,
tmedia_codec_id_opus = 0x00000001<<13, tmedia_codec_id_opus = 0x00000001<<13,
tmedia_codec_id_g729ab = 0x00000001<<14, tmedia_codec_id_g729ab = 0x00000001<<14,
tmedia_codec_id_g722 = 0x00000001<<15, tmedia_codec_id_g722 = 0x00000001<<15,
/* room for new Audio codecs */ /* room for new Audio codecs */
tmedia_codec_id_h261 = 0x00010000<<0, tmedia_codec_id_h261 = 0x00010000<<0,
tmedia_codec_id_h263 = 0x00010000<<1, tmedia_codec_id_h263 = 0x00010000<<1,
tmedia_codec_id_h263p = 0x00010000<<2, tmedia_codec_id_h263p = 0x00010000<<2,
tmedia_codec_id_h263pp = 0x00010000<<3, tmedia_codec_id_h263pp = 0x00010000<<3,
tmedia_codec_id_h264_bp = 0x00010000<<4, tmedia_codec_id_h264_bp = 0x00010000<<4,
tmedia_codec_id_h264_mp = 0x00010000<<5, tmedia_codec_id_h264_mp = 0x00010000<<5,
tmedia_codec_id_h264_hp = 0x00010000<<6, tmedia_codec_id_h264_hp = 0x00010000<<6,
tmedia_codec_id_h264_bp10 = tmedia_codec_id_h264_bp, // @deprecated tmedia_codec_id_h264_bp10 = tmedia_codec_id_h264_bp, // @deprecated
tmedia_codec_id_h264_bp20 = tmedia_codec_id_h264_bp, // @deprecated tmedia_codec_id_h264_bp20 = tmedia_codec_id_h264_bp, // @deprecated
tmedia_codec_id_h264_bp30 = tmedia_codec_id_h264_bp, // @deprecated tmedia_codec_id_h264_bp30 = tmedia_codec_id_h264_bp, // @deprecated
tmedia_codec_id_h264_svc = 0x00010000<<7, tmedia_codec_id_h264_svc = 0x00010000<<7,
tmedia_codec_id_theora = 0x00010000<<8, tmedia_codec_id_theora = 0x00010000<<8,
tmedia_codec_id_mp4ves_es = 0x00010000<<9, tmedia_codec_id_mp4ves_es = 0x00010000<<9,
tmedia_codec_id_vp8 = 0x00010000<<10, tmedia_codec_id_vp8 = 0x00010000<<10,
/* room for new Video codecs */ /* room for new Video codecs */
tmedia_codec_id_t140 = 0x00010000<<14, tmedia_codec_id_t140 = 0x00010000<<14,
tmedia_codec_id_red = 0x00010000<<15, tmedia_codec_id_red = 0x00010000<<15,
} }
tmedia_codec_id_t; tmedia_codec_id_t;
/* ====== From "tinydav/tdav.h" ====== */ /* ====== From "tinydav/tdav.h" ====== */
// @deprecated: to be replaced by "tmedia_codec_id_t" in Doubango 3.0 // @deprecated: to be replaced by "tmedia_codec_id_t" in Doubango 3.0
typedef enum tdav_codec_id_e typedef enum tdav_codec_id_e
{ {
tdav_codec_id_none = 0x00000000, tdav_codec_id_none = 0x00000000,
tdav_codec_id_amr_nb_oa = 0x00000001<<0, tdav_codec_id_amr_nb_oa = 0x00000001<<0,
tdav_codec_id_amr_nb_be = 0x00000001<<1, tdav_codec_id_amr_nb_be = 0x00000001<<1,
tdav_codec_id_amr_wb_oa = 0x00000001<<2, tdav_codec_id_amr_wb_oa = 0x00000001<<2,
tdav_codec_id_amr_wb_be = 0x00000001<<3, tdav_codec_id_amr_wb_be = 0x00000001<<3,
tdav_codec_id_gsm = 0x00000001<<4, tdav_codec_id_gsm = 0x00000001<<4,
tdav_codec_id_pcma = 0x00000001<<5, tdav_codec_id_pcma = 0x00000001<<5,
tdav_codec_id_pcmu = 0x00000001<<6, tdav_codec_id_pcmu = 0x00000001<<6,
tdav_codec_id_ilbc = 0x00000001<<7, tdav_codec_id_ilbc = 0x00000001<<7,
tdav_codec_id_speex_nb = 0x00000001<<8, tdav_codec_id_speex_nb = 0x00000001<<8,
tdav_codec_id_speex_wb = 0x00000001<<9, tdav_codec_id_speex_wb = 0x00000001<<9,
tdav_codec_id_speex_uwb = 0x00000001<<10, tdav_codec_id_speex_uwb = 0x00000001<<10,
tdav_codec_id_bv16 = 0x00000001<<11, tdav_codec_id_bv16 = 0x00000001<<11,
tdav_codec_id_bv32 = 0x00000001<<12, tdav_codec_id_bv32 = 0x00000001<<12,
tdav_codec_id_opus = 0x00000001<<13, tdav_codec_id_opus = 0x00000001<<13,
tdav_codec_id_g729ab = 0x00000001<<14, tdav_codec_id_g729ab = 0x00000001<<14,
tdav_codec_id_g722 = 0x00000001<<15, tdav_codec_id_g722 = 0x00000001<<15,
/* room for new Audio codecs */ /* room for new Audio codecs */
tdav_codec_id_h261 = 0x00010000<<0, tdav_codec_id_h261 = 0x00010000<<0,
tdav_codec_id_h263 = 0x00010000<<1, tdav_codec_id_h263 = 0x00010000<<1,
tdav_codec_id_h263p = 0x00010000<<2, tdav_codec_id_h263p = 0x00010000<<2,
tdav_codec_id_h263pp = 0x00010000<<3, tdav_codec_id_h263pp = 0x00010000<<3,
tdav_codec_id_h264_bp = 0x00010000<<4, tdav_codec_id_h264_bp = 0x00010000<<4,
tdav_codec_id_h264_mp = 0x00010000<<5, tdav_codec_id_h264_mp = 0x00010000<<5,
tdav_codec_id_h264_hp = 0x00010000<<6, tdav_codec_id_h264_hp = 0x00010000<<6,
tdav_codec_id_h264_bp10 = tdav_codec_id_h264_bp, // @deprecated tdav_codec_id_h264_bp10 = tdav_codec_id_h264_bp, // @deprecated
tdav_codec_id_h264_bp20 = tdav_codec_id_h264_bp, // @deprecated tdav_codec_id_h264_bp20 = tdav_codec_id_h264_bp, // @deprecated
tdav_codec_id_h264_bp30 = tdav_codec_id_h264_bp, // @deprecated tdav_codec_id_h264_bp30 = tdav_codec_id_h264_bp, // @deprecated
tdav_codec_id_h264_svc = 0x00010000<<7, tdav_codec_id_h264_svc = 0x00010000<<7,
tdav_codec_id_theora = 0x00010000<<8, tdav_codec_id_theora = 0x00010000<<8,
tdav_codec_id_mp4ves_es = 0x00010000<<9, tdav_codec_id_mp4ves_es = 0x00010000<<9,
tdav_codec_id_vp8 = 0x00010000<<10, tdav_codec_id_vp8 = 0x00010000<<10,
/* room for new Video codecs */ /* room for new Video codecs */
tdav_codec_id_t140 = 0x00010000<<14, tdav_codec_id_t140 = 0x00010000<<14,
tdav_codec_id_red = 0x00010000<<15, tdav_codec_id_red = 0x00010000<<15,
} }
tdav_codec_id_t; tdav_codec_id_t;

View File

@ -1,102 +1,102 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#include "SipUri.h" #include "SipUri.h"
SipUri::SipUri(const char* uriString, const char* displayName/*=tsk_null*/) SipUri::SipUri(const char* uriString, const char* displayName/*=tsk_null*/)
{ {
if((m_pUri = tsip_uri_parse(uriString, (tsk_size_t)tsk_strlen(uriString))) && displayName) { if((m_pUri = tsip_uri_parse(uriString, (tsk_size_t)tsk_strlen(uriString))) && displayName) {
m_pUri->display_name = tsk_strdup(displayName); m_pUri->display_name = tsk_strdup(displayName);
} }
} }
SipUri::~SipUri() SipUri::~SipUri()
{ {
TSK_OBJECT_SAFE_FREE(m_pUri); TSK_OBJECT_SAFE_FREE(m_pUri);
} }
bool SipUri::isValid(const char* uriString) bool SipUri::isValid(const char* uriString)
{ {
tsip_uri_t* uri; tsip_uri_t* uri;
bool ret = false; bool ret = false;
if((uri = tsip_uri_parse(uriString, (tsk_size_t)tsk_strlen(uriString)))) { if((uri = tsip_uri_parse(uriString, (tsk_size_t)tsk_strlen(uriString)))) {
ret = (uri->type != uri_unknown) ret = (uri->type != uri_unknown)
&& (!tsk_strnullORempty(uri->host)); && (!tsk_strnullORempty(uri->host));
TSK_OBJECT_SAFE_FREE(uri); TSK_OBJECT_SAFE_FREE(uri);
} }
return ret; return ret;
} }
bool SipUri::isValid() bool SipUri::isValid()
{ {
return (m_pUri != tsk_null); return (m_pUri != tsk_null);
} }
const char* SipUri::getScheme() const char* SipUri::getScheme()
{ {
if(m_pUri) { if(m_pUri) {
return m_pUri->scheme; return m_pUri->scheme;
} }
return tsk_null; return tsk_null;
} }
const char* SipUri::getHost() const char* SipUri::getHost()
{ {
return m_pUri ? m_pUri->host : tsk_null; return m_pUri ? m_pUri->host : tsk_null;
} }
unsigned short SipUri::getPort() unsigned short SipUri::getPort()
{ {
return m_pUri ? m_pUri->port : 0; return m_pUri ? m_pUri->port : 0;
} }
const char* SipUri::getUserName() const char* SipUri::getUserName()
{ {
return m_pUri ? m_pUri->user_name : tsk_null; return m_pUri ? m_pUri->user_name : tsk_null;
} }
const char* SipUri::getPassword() const char* SipUri::getPassword()
{ {
return m_pUri ? m_pUri->password : tsk_null; return m_pUri ? m_pUri->password : tsk_null;
} }
const char* SipUri::getDisplayName() const char* SipUri::getDisplayName()
{ {
return m_pUri ? m_pUri->display_name : tsk_null; return m_pUri ? m_pUri->display_name : tsk_null;
} }
void SipUri::setDisplayName(const char* displayName) void SipUri::setDisplayName(const char* displayName)
{ {
if(m_pUri) { if(m_pUri) {
tsk_strupdate(&m_pUri->display_name, displayName); tsk_strupdate(&m_pUri->display_name, displayName);
} }
} }
const char* SipUri::getParamValue(const char* pname) const char* SipUri::getParamValue(const char* pname)
{ {
if(m_pUri && m_pUri->params) { if(m_pUri && m_pUri->params) {
const char* pvalue = tsk_params_get_param_value(m_pUri->params, pname); const char* pvalue = tsk_params_get_param_value(m_pUri->params, pname);
return pvalue; return pvalue;
} }
return tsk_null; return tsk_null;
} }

View File

@ -1,57 +1,57 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_SIPURI_H #ifndef TINYWRAP_SIPURI_H
#define TINYWRAP_SIPURI_H #define TINYWRAP_SIPURI_H
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "tinysip.h" #include "tinysip.h"
class TINYWRAP_API SipUri class TINYWRAP_API SipUri
{ {
public: public:
SipUri(const char* uriString, const char* displayName=tsk_null); SipUri(const char* uriString, const char* displayName=tsk_null);
~SipUri(); ~SipUri();
public: public:
static bool isValid(const char*); static bool isValid(const char*);
bool isValid(); bool isValid();
const char* getScheme(); const char* getScheme();
const char* getHost(); const char* getHost();
unsigned short getPort(); unsigned short getPort();
const char* getUserName(); const char* getUserName();
const char* getPassword(); const char* getPassword();
const char* getDisplayName(); const char* getDisplayName();
const char* getParamValue(const char* pname); const char* getParamValue(const char* pname);
void setDisplayName(const char* displayName); void setDisplayName(const char* displayName);
#if !defined(SWIG) #if !defined(SWIG)
inline const tsip_uri_t* getWrappedUri()const { inline const tsip_uri_t* getWrappedUri()const {
return m_pUri; return m_pUri;
} }
#endif #endif
private: private:
tsip_uri_t* m_pUri; tsip_uri_t* m_pUri;
}; };
#endif /* TINYWRAP_SIPURI_H */ #endif /* TINYWRAP_SIPURI_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,167 +1,167 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_XCAP_H #ifndef TINYWRAP_XCAP_H
#define TINYWRAP_XCAP_H #define TINYWRAP_XCAP_H
#include "tinyxcap.h" #include "tinyxcap.h"
class XcapStack; class XcapStack;
typedef tsk_list_t twrap_xcap_steps_L_t; typedef tsk_list_t twrap_xcap_steps_L_t;
// //
// XcapSelector // XcapSelector
// //
class XcapSelector class XcapSelector
{ {
public: public:
XcapSelector(XcapStack* stack); XcapSelector(XcapStack* stack);
virtual ~XcapSelector(); virtual ~XcapSelector();
public: /* API functions */ public: /* API functions */
XcapSelector* setAUID(const char* auid); XcapSelector* setAUID(const char* auid);
XcapSelector* setName(const char* qname); XcapSelector* setName(const char* qname);
XcapSelector* setAttribute(const char* qname, const char* att_qname, const char* att_value); XcapSelector* setAttribute(const char* qname, const char* att_qname, const char* att_value);
XcapSelector* setPos(const char* qname, unsigned pos); XcapSelector* setPos(const char* qname, unsigned pos);
XcapSelector* setPosAttribute(const char* qname, unsigned pos, const char* att_qname, const char* att_value); XcapSelector* setPosAttribute(const char* qname, unsigned pos, const char* att_qname, const char* att_value);
XcapSelector* setNamespace(const char* prefix, const char* value); XcapSelector* setNamespace(const char* prefix, const char* value);
char* getString();// %newobject char* getString();// %newobject
void reset(); void reset();
private: private:
txcap_stack_handle_t* stack_handle; txcap_stack_handle_t* stack_handle;
char* auid; char* auid;
twrap_xcap_steps_L_t* steps; twrap_xcap_steps_L_t* steps;
}; };
// //
// XcapMessage // XcapMessage
// //
class XcapMessage class XcapMessage
{ {
public: public:
XcapMessage(); XcapMessage();
#if !defined(SWIG) #if !defined(SWIG)
XcapMessage(const thttp_message_t *httpmessage); XcapMessage(const thttp_message_t *httpmessage);
#endif #endif
virtual ~XcapMessage(); virtual ~XcapMessage();
short getCode() const; short getCode() const;
const char* getPhrase() const; const char* getPhrase() const;
char* getXcapHeaderValue(const char* name, unsigned index = 0); char* getXcapHeaderValue(const char* name, unsigned index = 0);
char* getXcapHeaderParamValue(const char* name, const char* param, unsigned index = 0); char* getXcapHeaderParamValue(const char* name, const char* param, unsigned index = 0);
unsigned getXcapContentLength(); unsigned getXcapContentLength();
unsigned getXcapContent(void* output, unsigned maxsize); unsigned getXcapContent(void* output, unsigned maxsize);
private: private:
const thttp_message_t *httpmessage; const thttp_message_t *httpmessage;
}; };
// //
// XcapEvent // XcapEvent
// //
class XcapEvent class XcapEvent
{ {
public: public:
#if !defined(SWIG) #if !defined(SWIG)
XcapEvent(const thttp_event_t *httpevent); XcapEvent(const thttp_event_t *httpevent);
#endif #endif
virtual ~XcapEvent(); virtual ~XcapEvent();
thttp_event_type_t getType(); thttp_event_type_t getType();
const XcapMessage* getXcapMessage() const; const XcapMessage* getXcapMessage() const;
private: private:
const thttp_event_t *httpevent; const thttp_event_t *httpevent;
const XcapMessage* httpmessage; const XcapMessage* httpmessage;
}; };
// //
// XcapCallback // XcapCallback
// //
class XcapCallback class XcapCallback
{ {
public: public:
XcapCallback(); XcapCallback();
virtual ~XcapCallback(); virtual ~XcapCallback();
virtual int onEvent(const XcapEvent* e)const { virtual int onEvent(const XcapEvent* e)const {
return -1; return -1;
} }
}; };
// //
// XcapStack // XcapStack
// //
class XcapStack class XcapStack
{ {
public: public:
XcapStack(XcapCallback* callback, const char* xui, const char* password, const char* xcap_root); XcapStack(XcapCallback* callback, const char* xui, const char* password, const char* xcap_root);
virtual ~XcapStack(); virtual ~XcapStack();
public: /* API functions */ public: /* API functions */
bool registerAUID(const char* id, const char* mime_type, const char* ns, const char* document_name, bool is_global); bool registerAUID(const char* id, const char* mime_type, const char* ns, const char* document_name, bool is_global);
bool start(); bool start();
bool setCredentials(const char* xui, const char* password); bool setCredentials(const char* xui, const char* password);
bool setXcapRoot(const char* xcap_root); bool setXcapRoot(const char* xcap_root);
bool setLocalIP(const char* ip); bool setLocalIP(const char* ip);
bool setLocalPort(unsigned port); bool setLocalPort(unsigned port);
bool addHeader(const char* name, const char* value); bool addHeader(const char* name, const char* value);
bool removeHeader(const char* name); bool removeHeader(const char* name);
bool setTimeout(unsigned timeout); bool setTimeout(unsigned timeout);
bool getDocument(const char* url); bool getDocument(const char* url);
bool getElement(const char* url); bool getElement(const char* url);
bool getAttribute(const char* url); bool getAttribute(const char* url);
bool deleteDocument(const char* url); bool deleteDocument(const char* url);
bool deleteElement(const char* url); bool deleteElement(const char* url);
bool deleteAttribute(const char* url); bool deleteAttribute(const char* url);
bool putDocument(const char* url, const void* payload, unsigned len, const char* contentType); bool putDocument(const char* url, const void* payload, unsigned len, const char* contentType);
bool putElement(const char* url, const void* payload, unsigned len); bool putElement(const char* url, const void* payload, unsigned len);
bool putAttribute(const char* url, const void* payload, unsigned len); bool putAttribute(const char* url, const void* payload, unsigned len);
bool stop(); bool stop();
public: /* Public helper function */ public: /* Public helper function */
#if !defined(SWIG) #if !defined(SWIG)
txcap_stack_handle_t* getHandle() { txcap_stack_handle_t* getHandle() {
return this->handle; return this->handle;
} }
XcapCallback* getCallback()const { XcapCallback* getCallback()const {
return this->callback; return this->callback;
} }
#endif #endif
private: private:
txcap_stack_handle_t* handle; txcap_stack_handle_t* handle;
XcapCallback* callback; XcapCallback* callback;
static unsigned count; static unsigned count;
}; };
#endif /* TINYWRAP_XCAP_H */ #endif /* TINYWRAP_XCAP_H */

View File

@ -1,22 +1,22 @@
%{ %{
#include "Xcap.h" #include "Xcap.h"
%} %}
/* Callbacks */ /* Callbacks */
%feature("director") XcapCallback; %feature("director") XcapCallback;
%nodefaultctor; %nodefaultctor;
%include "Xcap.h" %include "Xcap.h"
%clearnodefaultctor; %clearnodefaultctor;
typedef enum thttp_event_type_e typedef enum thttp_event_type_e
{ {
thttp_event_dialog_started, thttp_event_dialog_started,
thttp_event_message, thttp_event_message,
thttp_event_auth_failed, thttp_event_auth_failed,
thttp_event_closed, thttp_event_closed,
thttp_event_transport_error, thttp_event_transport_error,
thttp_event_dialog_terminated thttp_event_dialog_terminated
} }
thttp_event_type_t; thttp_event_type_t;

View File

@ -1,73 +1,73 @@
/* File : tinyWRAP.i */ /* File : tinyWRAP.i */
%module(directors="1") tinyWRAP %module(directors="1") tinyWRAP
%include "typemaps.i" %include "typemaps.i"
%include <stdint.i> %include <stdint.i>
%{ %{
#include "tinyWRAP_config.h" #include "tinyWRAP_config.h"
#include "DDebug.h" #include "DDebug.h"
#include "AudioResampler.h" #include "AudioResampler.h"
%} %}
%feature("director") DDebugCallback; %feature("director") DDebugCallback;
%nodefaultctor; %nodefaultctor;
%include "tinyWRAP_config.h" %include "tinyWRAP_config.h"
%include "DDebug.h" %include "DDebug.h"
%include "AudioResampler.h" %include "AudioResampler.h"
%include "Common.h" %include "Common.h"
%clearnodefaultctor; %clearnodefaultctor;
/* ========== Sip/Sdp Stack ========== */ /* ========== Sip/Sdp Stack ========== */
%newobject getSipHeaderValue; %newobject getSipHeaderValue;
%newobject getSdpHeaderValue; %newobject getSdpHeaderValue;
%newobject getSdpHeaderAValue; %newobject getSdpHeaderAValue;
%newobject getSipHeaderParamValue; %newobject getSipHeaderParamValue;
%newobject SipStack::dnsENUM; %newobject SipStack::dnsENUM;
%newobject SipStack::dnsNaptrSrv; %newobject SipStack::dnsNaptrSrv;
%newobject SipStack::dnsSrv; %newobject SipStack::dnsSrv;
%newobject SipStack::getPreferredIdentity; %newobject SipStack::getPreferredIdentity;
%newobject SipStack::getLocalIPnPort; %newobject SipStack::getLocalIPnPort;
%newobject MediaSessionMgr::producerGetCodec; %newobject MediaSessionMgr::producerGetCodec;
%newobject MediaSessionMgr::sessionGetQoS; %newobject MediaSessionMgr::sessionGetQoS;
%newobject MessagingEvent::takeSessionOwnership; %newobject MessagingEvent::takeSessionOwnership;
%newobject InviteEvent::takeCallSessionOwnership; %newobject InviteEvent::takeCallSessionOwnership;
%newobject InviteEvent::takeMsrpSessionOwnership; %newobject InviteEvent::takeMsrpSessionOwnership;
%newobject RegistrationEvent::takeSessionOwnership; %newobject RegistrationEvent::takeSessionOwnership;
%newobject ProxyPluginMgr::createInstance; %newobject ProxyPluginMgr::createInstance;
%newobject MediaContent::parse; %newobject MediaContent::parse;
%include SipStack.i %include SipStack.i
/* ========== Xcap Stack ========== */ /* ========== Xcap Stack ========== */
%newobject XcapSelector::getString; %newobject XcapSelector::getString;
%newobject getXcapHeaderValue; %newobject getXcapHeaderValue;
%newobject getXcapHeaderParamValue; %newobject getXcapHeaderParamValue;
%include Xcap.i %include Xcap.i
/* ========== SMS ========== */ /* ========== SMS ========== */
%newobject SMSEncoder::encodeSubmit; %newobject SMSEncoder::encodeSubmit;
%newobject SMSEncoder::encodeDeliver; %newobject SMSEncoder::encodeDeliver;
%newobject SMSEncoder::encodeACK; %newobject SMSEncoder::encodeACK;
%newobject SMSEncoder::encodeError; %newobject SMSEncoder::encodeError;
%newobject SMSEncoder::decode; %newobject SMSEncoder::decode;
%include SMS.i %include SMS.i
/* ========== MSRP ========== */ /* ========== MSRP ========== */
%newobject getMsrpHeaderValue; %newobject getMsrpHeaderValue;
%newobject getMsrpHeaderParamValue; %newobject getMsrpHeaderParamValue;
%include Msrp.i %include Msrp.i

View File

@ -1,72 +1,72 @@
/* /*
* Copyright (C) 2010-2011 Mamadou Diop. * Copyright (C) 2010-2011 Mamadou Diop.
* *
* Contact: Mamadou Diop <diopmamadou(at)doubango.org> * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
* *
* This file is part of Open Source Doubango Framework. * This file is part of Open Source Doubango Framework.
* *
* DOUBANGO is free software: you can redistribute it and/or modify * DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* DOUBANGO is distributed in the hope that it will be useful, * DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with DOUBANGO. * along with DOUBANGO.
* *
*/ */
#ifndef TINYWRAP_CONFIG_H #ifndef TINYWRAP_CONFIG_H
#define TINYWRAP_CONFIG_H #define TINYWRAP_CONFIG_H
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
#undef _WIN32 /* Because of WINSCW */ #undef _WIN32 /* Because of WINSCW */
#endif #endif
// Windows (XP/Vista/7/CE and Windows Mobile) macro definition. // Windows (XP/Vista/7/CE and Windows Mobile) macro definition.
#if defined(WIN32)|| defined(_WIN32) || defined(_WIN32_WCE) #if defined(WIN32)|| defined(_WIN32) || defined(_WIN32_WCE)
# define TWRAP_UNDER_WINDOWS 1 # define TWRAP_UNDER_WINDOWS 1
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP || WINAPI_FAMILY == WINAPI_FAMILY_APP) # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP || WINAPI_FAMILY == WINAPI_FAMILY_APP)
# define TWRAP_UNDER_WINDOWS_RT 1 # define TWRAP_UNDER_WINDOWS_RT 1
# endif # endif
#endif #endif
#if (TWRAP_UNDER_WINDOWS || defined(__SYMBIAN32__)) && defined(TINYWRAP_EXPORTS) #if (TWRAP_UNDER_WINDOWS || defined(__SYMBIAN32__)) && defined(TINYWRAP_EXPORTS)
# define TINYWRAP_API __declspec(dllexport) # define TINYWRAP_API __declspec(dllexport)
# define TINYWRAP_GEXTERN extern __declspec(dllexport) # define TINYWRAP_GEXTERN extern __declspec(dllexport)
#elif (TWRAP_UNDER_WINDOWS || defined(__SYMBIAN32__)) && !defined(TINYWRAP_IMPORTS_IGNORE) #elif (TWRAP_UNDER_WINDOWS || defined(__SYMBIAN32__)) && !defined(TINYWRAP_IMPORTS_IGNORE)
# define TINYWRAP_API __declspec(dllimport) # define TINYWRAP_API __declspec(dllimport)
# define TINYWRAP_GEXTERN __declspec(dllimport) # define TINYWRAP_GEXTERN __declspec(dllimport)
#else #else
# define TINYWRAP_API # define TINYWRAP_API
# define TINYWRAP_GEXTERN extern # define TINYWRAP_GEXTERN extern
#endif #endif
/* Guards against C++ name mangling /* Guards against C++ name mangling
*/ */
#ifdef __cplusplus #ifdef __cplusplus
# define TWRAP_BEGIN_DECLS extern "C" { # define TWRAP_BEGIN_DECLS extern "C" {
# define TWRAP_END_DECLS } # define TWRAP_END_DECLS }
#else #else
# define TWRAP_BEGIN_DECLS # define TWRAP_BEGIN_DECLS
# define TWRAP_END_DECLS # define TWRAP_END_DECLS
#endif #endif
/* Disable some well-known warnings /* Disable some well-known warnings
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
# define _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS
#endif #endif
#include <stdint.h> #include <stdint.h>
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
#endif // TINYWRAP_CONFIG_H #endif // TINYWRAP_CONFIG_H

0
bindings/csharp/QoS.cs Normal file → Executable file
View File

0
bindings/java/QoS.java Normal file → Executable file
View File

0
bindings/java/android/QoS.java Normal file → Executable file
View File

0
thirdparties/mac/include/srtp/config.h Normal file → Executable file
View File

0
thirdparties/mac/lib/i386/libcrypto.a Normal file → Executable file
View File

0
thirdparties/mac/lib/i386/libsrtp.a Normal file → Executable file
View File

0
thirdparties/mac/lib/i386/libssl.a Normal file → Executable file
View File

0
thirdparties/mac/lib/x86_64/libcrypto.a Normal file → Executable file
View File

0
thirdparties/mac/lib/x86_64/libsrtp.a Normal file → Executable file
View File

0
thirdparties/mac/lib/x86_64/libssl.a Normal file → Executable file
View File

View File

@ -614,12 +614,12 @@ static int tdav_session_video_rtcp_cb(const void* callback_data, const trtp_rtcp
case trtp_rtcp_psfb_fci_type_afb: { case trtp_rtcp_psfb_fci_type_afb: {
if (psfb->afb.type == trtp_rtcp_psfb_afb_type_remb) { if (psfb->afb.type == trtp_rtcp_psfb_afb_type_remb) {
uint64_t bw_up_reported_kpbs = ((psfb->afb.remb.mantissa << psfb->afb.remb.exp) >> 10); uint64_t bw_up_reported_kpbs = ((psfb->afb.remb.mantissa << psfb->afb.remb.exp) >> 10);
TSK_DEBUG_INFO("Receiving RTCP-AFB-REMB (%u), exp=%u, mantissa=%u, bandwidth=%ukbps", ((const trtp_rtcp_report_fb_t*)psfb)->ssrc_media, psfb->afb.remb.exp, psfb->afb.remb.mantissa, bw_up_reported_kpbs); TSK_DEBUG_INFO("Receiving RTCP-AFB-REMB (%u), exp=%u, mantissa=%u, bandwidth=%llukbps", ((const trtp_rtcp_report_fb_t*)psfb)->ssrc_media, psfb->afb.remb.exp, psfb->afb.remb.mantissa, bw_up_reported_kpbs);
if (base->congestion_ctrl_enabled) { if (base->congestion_ctrl_enabled) {
if (session->qos_metrics.bw_up_est_kbps != 0) { if (session->qos_metrics.bw_up_est_kbps != 0) {
float q3 = bw_up_reported_kpbs / (float)session->qos_metrics.bw_up_est_kbps; float q3 = bw_up_reported_kpbs / (float)session->qos_metrics.bw_up_est_kbps;
q3 = TSK_CLAMP(0.f, q3, 1.f); q3 = TSK_CLAMP(0.f, q3, 1.f);
TSK_DEBUG_INFO("bw_up_estimated_kbps=%llu, bw_up_reported_kpbs=%llu, q3=%f", session->qos_metrics.bw_up_est_kbps, bw_up_reported_kpbs, q3); TSK_DEBUG_INFO("bw_up_estimated_kbps=%u, bw_up_reported_kpbs=%llu, q3=%f", session->qos_metrics.bw_up_est_kbps, bw_up_reported_kpbs, q3);
tsk_mutex_lock(video->h_mutex_qos); tsk_mutex_lock(video->h_mutex_qos);
session->qos_metrics.q3 = (session->qos_metrics.q3 + q3) / (video->q3_n++ ? 2.f : 1.f); session->qos_metrics.q3 = (session->qos_metrics.q3 + q3) / (video->q3_n++ ? 2.f : 1.f);
tsk_mutex_unlock(video->h_mutex_qos); tsk_mutex_unlock(video->h_mutex_qos);
@ -1539,7 +1539,7 @@ static int _tdav_session_video_report_bw_usage_and_jcng(tdav_session_video_t* se
jcng_q = q5; jcng_q = q5;
} }
} }
TSK_DEBUG_INFO("video with congestion control enabled: est_bw_down=%llukbps, est_jcng=%f", session->qos_metrics.bw_down_est_kbps, jcng_q); TSK_DEBUG_INFO("video with congestion control enabled: est_bw_down=%ukbps, est_jcng=%f", session->qos_metrics.bw_down_est_kbps, jcng_q);
ret = trtp_manager_set_app_bw_and_jcng(base->rtp_manager, INT_MAX/* unused */, (int32_t)session->qos_metrics.bw_down_est_kbps, jcng_q); ret = trtp_manager_set_app_bw_and_jcng(base->rtp_manager, INT_MAX/* unused */, (int32_t)session->qos_metrics.bw_down_est_kbps, jcng_q);
self->last_sendreport_time = tsk_time_now(); self->last_sendreport_time = tsk_time_now();
} }

View File

@ -319,6 +319,7 @@ static int recvData(tnet_transport_t *transport, transport_socket_xt* active_soc
if (len && buffer) { if (len && buffer) {
tnet_transport_event_t* e = tnet_transport_event_create(event_data, transport->callback_data, active_socket->fd); tnet_transport_event_t* e = tnet_transport_event_create(event_data, transport->callback_data, active_socket->fd);
transport->bytes_in += len;
if (e && buffer && len) { if (e && buffer && len) {
e->data = buffer; e->data = buffer;
buffer = NULL; buffer = NULL;
@ -485,6 +486,7 @@ tsk_size_t tnet_transport_send(const tnet_transport_handle_t *handle, tnet_fd_t
} }
bail: bail:
transport->bytes_out += numberOfBytesSent;
return numberOfBytesSent; return numberOfBytesSent;
} }
@ -517,6 +519,7 @@ tsk_size_t tnet_transport_sendto(const tnet_transport_handle_t *handle, tnet_fd_
} }
bail: bail:
transport->bytes_out += numberOfBytesSent;
return numberOfBytesSent; return numberOfBytesSent;
} }
@ -1034,6 +1037,7 @@ void __CFSocketCallBack(CFSocketRef s, CFSocketCallBackType callbackType, CFData
int len = (int)CFDataGetLength((CFDataRef)data); int len = (int)CFDataGetLength((CFDataRef)data);
if (ptr && len > 0) { if (ptr && len > 0) {
tnet_transport_event_t* e = tnet_transport_event_create(event_data, transport->callback_data, sock->fd); tnet_transport_event_t* e = tnet_transport_event_create(event_data, transport->callback_data, sock->fd);
transport->bytes_in += len;
if (e) { if (e) {
e->data = tsk_malloc(len); e->data = tsk_malloc(len);
if (e->data) { if (e->data) {

0
website/.htaccess Normal file → Executable file
View File