Update cfscket transport to report correct in/out bytes

laforge/wip
System Administrator 7 years ago
parent 40a8a15df6
commit 3d46d2f68c
  1. 0
      .gitignore
  2. 0
      AStyle.sh
  3. 174
      bindings/_common/ActionConfig.cxx
  4. 104
      bindings/_common/ActionConfig.h
  5. 146
      bindings/_common/AudioResampler.cxx
  6. 124
      bindings/_common/AudioResampler.h
  7. 190
      bindings/_common/Common.h
  8. 290
      bindings/_common/DDebug.cxx
  9. 114
      bindings/_common/DDebug.h
  10. 356
      bindings/_common/MediaContent.cxx
  11. 152
      bindings/_common/MediaContent.h
  12. 1328
      bindings/_common/MediaSessionMgr.cxx
  13. 492
      bindings/_common/MediaSessionMgr.h
  14. 628
      bindings/_common/Msrp.cxx
  15. 202
      bindings/_common/Msrp.h
  16. 66
      bindings/_common/Msrp.i
  17. 1620
      bindings/_common/ProxyConsumer.cxx
  18. 530
      bindings/_common/ProxyConsumer.h
  19. 616
      bindings/_common/ProxyPluginMgr.cxx
  20. 274
      bindings/_common/ProxyPluginMgr.h
  21. 1240
      bindings/_common/ProxyProducer.cxx
  22. 400
      bindings/_common/ProxyProducer.h
  23. 12
      bindings/_common/SMS.i
  24. 740
      bindings/_common/SMSEncoder.cxx
  25. 226
      bindings/_common/SMSEncoder.h
  26. 84
      bindings/_common/SafeObject.cxx
  27. 86
      bindings/_common/SafeObject.h
  28. 62
      bindings/_common/SipCallback.cxx
  29. 148
      bindings/_common/SipCallback.h
  30. 566
      bindings/_common/SipEvent.cxx
  31. 436
      bindings/_common/SipEvent.h
  32. 710
      bindings/_common/SipMessage.cxx
  33. 164
      bindings/_common/SipMessage.h
  34. 2086
      bindings/_common/SipSession.cxx
  35. 748
      bindings/_common/SipSession.h
  36. 1242
      bindings/_common/SipStack.cxx
  37. 246
      bindings/_common/SipStack.h
  38. 914
      bindings/_common/SipStack.i
  39. 204
      bindings/_common/SipUri.cxx
  40. 114
      bindings/_common/SipUri.h
  41. 1122
      bindings/_common/Xcap.cxx
  42. 334
      bindings/_common/Xcap.h
  43. 42
      bindings/_common/Xcap.i
  44. 146
      bindings/_common/tinyWRAP.i
  45. 144
      bindings/_common/tinyWRAP_config.h
  46. 0
      bindings/csharp/QoS.cs
  47. 0
      bindings/java/QoS.java
  48. 0
      bindings/java/android/QoS.java
  49. 0
      thirdparties/mac/include/srtp/config.h
  50. 0
      thirdparties/mac/lib/i386/libcrypto.a
  51. 0
      thirdparties/mac/lib/i386/libsrtp.a
  52. 0
      thirdparties/mac/lib/i386/libssl.a
  53. 0
      thirdparties/mac/lib/x86_64/libcrypto.a
  54. 0
      thirdparties/mac/lib/x86_64/libsrtp.a
  55. 0
      thirdparties/mac/lib/x86_64/libssl.a
  56. 6
      tinyDAV/src/video/tdav_session_video.c
  57. 4
      tinyNET/src/tnet_transport_cfsocket.c
  58. 0
      website/.htaccess

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

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

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

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

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

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

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

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