- Fix issue 56.

- simplify codec priority setting
This commit is contained in:
bossiel 2011-10-21 12:11:06 +00:00
parent 522506121d
commit 78be530041
22 changed files with 203 additions and 9 deletions

View File

@ -264,4 +264,9 @@ bool MediaSessionMgr::defaultsSetAudioGain(int32_t producer_gain, int32_t consum
bool MediaSessionMgr::defaultsSetRtpPortRange(uint16_t range_start, uint16_t range_stop){
return tmedia_defaults_set_rtp_port_range(range_start, range_stop) == 0;
}
}
bool MediaSessionMgr::defaultsSetMediaType(twrap_media_type_t media_type)
{
return (tmedia_defaults_set_media_type(_get_media_type(media_type)) == 0);
}

View File

@ -80,7 +80,7 @@ public:
static bool defaultsSetScreenSize(int32_t sx, int32_t sy);
static bool defaultsSetAudioGain(int32_t producer_gain, int32_t consumer_gain);
static bool defaultsSetRtpPortRange(uint16_t range_start, uint16_t range_stop);
static bool defaultsSetMediaType(twrap_media_type_t media_type);
private:
tmedia_session_mgr_t* m_pWrappedMgr;

View File

@ -191,6 +191,11 @@ public class MediaSessionMgr : IDisposable {
return ret;
}
public static bool defaultsSetMediaType(twrap_media_type_t media_type) {
bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetMediaType((int)media_type);
return ret;
}
}
}

View File

@ -347,6 +347,9 @@ class tinyWRAPPINVOKE {
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetRtpPortRange")]
public static extern bool MediaSessionMgr_defaultsSetRtpPortRange(ushort jarg1, ushort jarg2);
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetMediaType")]
public static extern bool MediaSessionMgr_defaultsSetMediaType(int jarg1);
[DllImport("tinyWRAP", EntryPoint="CSharp_delete_MediaContent")]
public static extern void delete_MediaContent(HandleRef jarg1);

View File

@ -1788,6 +1788,18 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetRtpPortRan
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetMediaType(int jarg1) {
unsigned int jresult ;
twrap_media_type_t arg1 ;
bool result;
arg1 = (twrap_media_type_t)jarg1;
result = (bool)MediaSessionMgr::defaultsSetMediaType(arg1);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_delete_MediaContent(void * jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;

View File

@ -155,4 +155,8 @@ public class MediaSessionMgr {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetRtpPortRange(range_start, range_stop);
}
public static boolean defaultsSetMediaType(twrap_media_type_t media_type) {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetMediaType(media_type.swigValue());
}
}

View File

@ -155,4 +155,8 @@ public class MediaSessionMgr {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetRtpPortRange(range_start, range_stop);
}
public static boolean defaultsSetMediaType(twrap_media_type_t media_type) {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetMediaType(media_type.swigValue());
}
}

View File

@ -65,6 +65,10 @@ public class MsrpMessage {
return tinyWRAPJNI.MsrpMessage_isFirstChunck(swigCPtr, this);
}
public boolean isSuccessReport() {
return tinyWRAPJNI.MsrpMessage_isSuccessReport(swigCPtr, this);
}
public String getMsrpHeaderValue(String name) {
return tinyWRAPJNI.MsrpMessage_getMsrpHeaderValue(swigCPtr, this, name);
}

View File

@ -64,6 +64,7 @@ class tinyWRAPJNI {
public final static native boolean MediaSessionMgr_defaultsSetScreenSize(int jarg1, int jarg2);
public final static native boolean MediaSessionMgr_defaultsSetAudioGain(int jarg1, int jarg2);
public final static native boolean MediaSessionMgr_defaultsSetRtpPortRange(int jarg1, int jarg2);
public final static native boolean MediaSessionMgr_defaultsSetMediaType(int jarg1);
public final static native void delete_MediaContent(long jarg1);
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);
@ -492,6 +493,7 @@ class tinyWRAPJNI {
public final static native void MsrpMessage_getByteRange(long jarg1, MsrpMessage jarg1_, long[] jarg2, long[] jarg3, long[] jarg4);
public final static native boolean MsrpMessage_isLastChunck(long jarg1, MsrpMessage jarg1_);
public final static native boolean MsrpMessage_isFirstChunck(long jarg1, MsrpMessage jarg1_);
public final static native boolean MsrpMessage_isSuccessReport(long jarg1, MsrpMessage jarg1_);
public final static native String MsrpMessage_getMsrpHeaderValue(long jarg1, MsrpMessage jarg1_, String jarg2);
public final static native String MsrpMessage_getMsrpHeaderParamValue(long jarg1, MsrpMessage jarg1_, String jarg2, String jarg3);
public final static native long MsrpMessage_getMsrpContentLength(long jarg1, MsrpMessage jarg1_);

View File

@ -2741,6 +2741,20 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionM
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetMediaType(JNIEnv *jenv, jclass jcls, jint jarg1) {
jboolean jresult = 0 ;
twrap_media_type_t arg1 ;
bool result;
(void)jenv;
(void)jcls;
arg1 = (twrap_media_type_t)jarg1;
result = (bool)MediaSessionMgr::defaultsSetMediaType(arg1);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;
@ -10515,6 +10529,21 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MsrpMessage_1
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MsrpMessage_1isSuccessReport(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jboolean jresult = 0 ;
MsrpMessage *arg1 = (MsrpMessage *) 0 ;
bool result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(MsrpMessage **)&jarg1;
result = (bool)(arg1)->isSuccessReport();
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jstring JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MsrpMessage_1getMsrpHeaderValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
jstring jresult = 0 ;
MsrpMessage *arg1 = (MsrpMessage *) 0 ;

View File

@ -64,6 +64,7 @@ class tinyWRAPJNI {
public final static native boolean MediaSessionMgr_defaultsSetScreenSize(int jarg1, int jarg2);
public final static native boolean MediaSessionMgr_defaultsSetAudioGain(int jarg1, int jarg2);
public final static native boolean MediaSessionMgr_defaultsSetRtpPortRange(int jarg1, int jarg2);
public final static native boolean MediaSessionMgr_defaultsSetMediaType(int jarg1);
public final static native void delete_MediaContent(long jarg1);
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);

View File

@ -2741,6 +2741,20 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionM
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetMediaType(JNIEnv *jenv, jclass jcls, jint jarg1) {
jboolean jresult = 0 ;
twrap_media_type_t arg1 ;
bool result;
(void)jenv;
(void)jcls;
arg1 = (twrap_media_type_t)jarg1;
result = (bool)MediaSessionMgr::defaultsSetMediaType(arg1);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;

View File

@ -221,6 +221,7 @@ sub DESTROY {
*defaultsSetScreenSize = *tinyWRAPc::MediaSessionMgr_defaultsSetScreenSize;
*defaultsSetAudioGain = *tinyWRAPc::MediaSessionMgr_defaultsSetAudioGain;
*defaultsSetRtpPortRange = *tinyWRAPc::MediaSessionMgr_defaultsSetRtpPortRange;
*defaultsSetMediaType = *tinyWRAPc::MediaSessionMgr_defaultsSetMediaType;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);

View File

@ -3957,6 +3957,34 @@ XS(_wrap_MediaSessionMgr_defaultsSetRtpPortRange) {
}
XS(_wrap_MediaSessionMgr_defaultsSetMediaType) {
{
twrap_media_type_t arg1 ;
int val1 ;
int ecode1 = 0 ;
int argvi = 0;
bool result;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: MediaSessionMgr_defaultsSetMediaType(media_type);");
}
ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetMediaType" "', argument " "1"" of type '" "twrap_media_type_t""'");
}
arg1 = static_cast< twrap_media_type_t >(val1);
result = (bool)MediaSessionMgr::defaultsSetMediaType(arg1);
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_delete_MediaContent) {
{
MediaContent *arg1 = (MediaContent *) 0 ;
@ -21644,6 +21672,7 @@ static swig_command_info swig_commands[] = {
{"tinyWRAPc::MediaSessionMgr_defaultsSetScreenSize", _wrap_MediaSessionMgr_defaultsSetScreenSize},
{"tinyWRAPc::MediaSessionMgr_defaultsSetAudioGain", _wrap_MediaSessionMgr_defaultsSetAudioGain},
{"tinyWRAPc::MediaSessionMgr_defaultsSetRtpPortRange", _wrap_MediaSessionMgr_defaultsSetRtpPortRange},
{"tinyWRAPc::MediaSessionMgr_defaultsSetMediaType", _wrap_MediaSessionMgr_defaultsSetMediaType},
{"tinyWRAPc::delete_MediaContent", _wrap_delete_MediaContent},
{"tinyWRAPc::MediaContent_getType", _wrap_MediaContent_getType},
{"tinyWRAPc::MediaContent_getDataLength", _wrap_MediaContent_getDataLength},

View File

@ -198,6 +198,8 @@ class MediaSessionMgr(_object):
if _newclass:defaultsSetAudioGain = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetAudioGain)
__swig_getmethods__["defaultsSetRtpPortRange"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetRtpPortRange
if _newclass:defaultsSetRtpPortRange = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetRtpPortRange)
__swig_getmethods__["defaultsSetMediaType"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetMediaType
if _newclass:defaultsSetMediaType = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetMediaType)
MediaSessionMgr_swigregister = _tinyWRAP.MediaSessionMgr_swigregister
MediaSessionMgr_swigregister(MediaSessionMgr)
@ -289,6 +291,10 @@ def MediaSessionMgr_defaultsSetRtpPortRange(*args):
return _tinyWRAP.MediaSessionMgr_defaultsSetRtpPortRange(*args)
MediaSessionMgr_defaultsSetRtpPortRange = _tinyWRAP.MediaSessionMgr_defaultsSetRtpPortRange
def MediaSessionMgr_defaultsSetMediaType(*args):
return _tinyWRAP.MediaSessionMgr_defaultsSetMediaType(*args)
MediaSessionMgr_defaultsSetMediaType = _tinyWRAP.MediaSessionMgr_defaultsSetMediaType
class MediaContent(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MediaContent, name, value)

View File

@ -6550,6 +6550,28 @@ fail:
}
SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetMediaType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
twrap_media_type_t arg1 ;
int val1 ;
int ecode1 = 0 ;
PyObject * obj0 = 0 ;
bool result;
if (!PyArg_ParseTuple(args,(char *)"O:MediaSessionMgr_defaultsSetMediaType",&obj0)) SWIG_fail;
ecode1 = SWIG_AsVal_int(obj0, &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetMediaType" "', argument " "1"" of type '" "twrap_media_type_t""'");
}
arg1 = static_cast< twrap_media_type_t >(val1);
result = (bool)MediaSessionMgr::defaultsSetMediaType(arg1);
resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *MediaSessionMgr_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
@ -21067,6 +21089,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"MediaSessionMgr_defaultsSetScreenSize", _wrap_MediaSessionMgr_defaultsSetScreenSize, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetAudioGain", _wrap_MediaSessionMgr_defaultsSetAudioGain, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetRtpPortRange", _wrap_MediaSessionMgr_defaultsSetRtpPortRange, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetMediaType", _wrap_MediaSessionMgr_defaultsSetMediaType, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_swigregister", MediaSessionMgr_swigregister, METH_VARARGS, NULL},
{ (char *)"delete_MediaContent", _wrap_delete_MediaContent, METH_VARARGS, NULL},
{ (char *)"MediaContent_getType", _wrap_MediaContent_getType, METH_VARARGS, NULL},

View File

@ -344,16 +344,17 @@ int tdav_codec_set_priority(tdav_codec_id_t codec_id, int priority)
for(i = 0; i<count; ++i){
if(__codecs[i].id == codec_id){
tdav_codec_decl_t codec_decl_1, codec_decl_2;
if(!tmedia_codec_plugin_is_registered(*__codecs[i].plugin)){
TSK_DEBUG_INFO("Codec not registered");
return 0;
}
priority = TSK_MIN(priority, count-1);
codec_decl_1 = __codecs[priority];
codec_decl_2 = __codecs[i];
__codecs[i] = codec_decl_1;
__codecs[priority] = codec_decl_2;
// change priority if already registered and supported
if(_tdav_codec_is_supported(codec_decl_2.id, *codec_decl_2.plugin) && tmedia_codec_plugin_is_registered(*codec_decl_2.plugin)){
return tmedia_codec_plugin_register_2(*codec_decl_2.plugin, priority);
}
return 0;
}
}
@ -365,11 +366,12 @@ int tdav_codec_set_priority(tdav_codec_id_t codec_id, int priority)
void tdav_set_codecs(tdav_codec_id_t codecs)
{
int i;
int prio;
for(i=0; i<sizeof(__codecs)/sizeof(tdav_codec_decl_t); ++i){
for(i=0,prio=0; i<sizeof(__codecs)/sizeof(tdav_codec_decl_t); ++i){
if((codecs & __codecs[i].id)){
if(_tdav_codec_is_supported(__codecs[i].id, *(__codecs[i].plugin))){
tmedia_codec_plugin_register(*(__codecs[i].plugin));
tmedia_codec_plugin_register_2(*(__codecs[i].plugin), prio++);
}
}
else{

View File

@ -213,6 +213,7 @@ TINYMEDIA_API int tmedia_codec_open(tmedia_codec_t* self);
TINYMEDIA_API int tmedia_codec_close(tmedia_codec_t* self);
TINYMEDIA_API int tmedia_codec_cmp(const tsk_object_t* codec1, const tsk_object_t* codec2);
TINYMEDIA_API int tmedia_codec_plugin_register(const tmedia_codec_plugin_def_t* plugin);
TINYMEDIA_API int tmedia_codec_plugin_register_2(const tmedia_codec_plugin_def_t* plugin, int prio);
TINYMEDIA_API tsk_bool_t tmedia_codec_plugin_is_registered(const tmedia_codec_plugin_def_t* plugin);
TINYMEDIA_API int tmedia_codec_plugin_unregister(const tmedia_codec_plugin_def_t* plugin);
TINYMEDIA_API tmedia_codec_t* tmedia_codec_create(const char* format);

View File

@ -64,6 +64,9 @@ TINYMEDIA_API int32_t tmedia_defaults_get_audio_consumer_gain();
TINYMEDIA_API uint16_t tmedia_defaults_get_rtp_port_range_start();
TINYMEDIA_API uint16_t tmedia_defaults_get_rtp_port_range_stop();
TINYMEDIA_API int tmedia_defaults_set_rtp_port_range(uint16_t start, uint16_t stop);
TINYMEDIA_API tmedia_type_t tmedia_defaults_get_media_type();
TINYMEDIA_API int tmedia_defaults_set_media_type(tmedia_type_t media_type);
TMEDIA_END_DECLS

View File

@ -213,6 +213,42 @@ int tmedia_codec_plugin_register(const tmedia_codec_plugin_def_t* plugin)
return -2;
}
int tmedia_codec_plugin_register_2(const tmedia_codec_plugin_def_t* plugin, int prio)
{
tsk_size_t count = 0;
tsk_bool_t already_registered = tsk_false;
const tmedia_codec_plugin_def_t* tmp;
if(!plugin || tsk_strnullORempty(plugin->name) || tsk_strnullORempty(plugin->format) || (prio + 1) >= TMED_CODEC_MAX_PLUGINS){
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
// count codecs and found if already registered
while(__tmedia_codec_plugins[count]){
if(__tmedia_codec_plugins[count] == plugin){
already_registered = tsk_true;
}
++count;
}
if(count >= TMED_CODEC_MAX_PLUGINS){
TSK_DEBUG_ERROR("No room");
return -1;
}
// unregister and compact
if(already_registered){
tmedia_codec_plugin_unregister(plugin);
--count;
}
tmp = __tmedia_codec_plugins[prio];
__tmedia_codec_plugins[prio] = plugin;
__tmedia_codec_plugins[count] = tmp;// put old codec add prio to the end of the list
return 0;
}
/**@ingroup tmedia_codec_group
* Checks whether a codec plugin is registered or not.
* @param plugin the definition of the plugin to check for availability.

View File

@ -60,6 +60,7 @@ static int32_t __audio_producer_gain = 0;
static int32_t __audio_consumer_gain = 0;
static uint16_t __rtp_port_range_start = 1024;
static uint16_t __rtp_port_range_stop = 65535;
static tmedia_type_t __media_type = tmedia_audio;
int tmedia_defaults_set_echo_tail(uint32_t echo_tail)
{
@ -202,3 +203,12 @@ int tmedia_defaults_set_rtp_port_range(uint16_t start, uint16_t stop){
__rtp_port_range_stop = stop;
return 0;
}
tmedia_type_t tmedia_defaults_get_media_type(){
return __media_type;
}
int tmedia_defaults_set_media_type(tmedia_type_t media_type){
__media_type = media_type;
return 0;
}

View File

@ -393,7 +393,7 @@ int tsip_dialog_invite_process_ro(tsip_dialog_invite_t *self, const tsip_message
}
else{
if(TSIP_DIALOG(self)->state == tsip_initial && TSIP_REQUEST_IS_INVITE(message)){ /* Bodiless initial INVITE */
TSIP_DIALOG_GET_SS(self)->media.type = tmedia_audio; // Default media for initial INVITE to send with the first reliable answer
TSIP_DIALOG_GET_SS(self)->media.type = tmedia_defaults_get_media_type(); // Default media for initial INVITE to send with the first reliable answer
}
else{
return 0;