Begin adding support for per-session video size

This commit is contained in:
bossiel 2015-02-27 00:57:31 +00:00
parent 6f2eafef1f
commit 24e1eba626
20 changed files with 175 additions and 1 deletions

View File

@ -533,6 +533,16 @@ bool CallSession::setVideoBandwidthDownloadMax(int32_t max)
TSIP_SSESSION_SET_NULL()) == 0);
}
bool CallSession::setVideoPrefSize(tmedia_pref_video_size_t pref_video_size)
{
return (tsip_ssession_set(m_pHandle,
TSIP_SSESSION_SET_MEDIA(
TSIP_MSESSION_SET_VIDEO_PREFSIZE(pref_video_size),
TSIP_MSESSION_SET_NULL()
),
TSIP_SSESSION_SET_NULL()) == 0);
}
bool CallSession::setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength)
{
return (tsip_ssession_set(m_pHandle,

View File

@ -201,6 +201,7 @@ public: /* Public functions */
bool setVideoFps(int32_t fps);
bool setVideoBandwidthUploadMax(int32_t max);
bool setVideoBandwidthDownloadMax(int32_t max);
bool setVideoPrefSize(tmedia_pref_video_size_t pref_video_size);
bool setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength);
bool hold(ActionConfig* config=tsk_null);
bool resume(ActionConfig* config=tsk_null);

View File

@ -193,6 +193,11 @@ public class CallSession : InviteSession {
return ret;
}
public bool setVideoPrefSize(tmedia_pref_video_size_t pref_video_size) {
bool ret = tinyWRAPPINVOKE.CallSession_setVideoPrefSize(swigCPtr, (int)pref_video_size);
return ret;
}
public bool setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength) {
bool ret = tinyWRAPPINVOKE.CallSession_setQoS(swigCPtr, (int)type, (int)strength);
return ret;

View File

@ -975,6 +975,9 @@ class tinyWRAPPINVOKE {
[DllImport("tinyWRAP", EntryPoint="CSharp_CallSession_setVideoBandwidthDownloadMax")]
public static extern bool CallSession_setVideoBandwidthDownloadMax(HandleRef jarg1, int jarg2);
[DllImport("tinyWRAP", EntryPoint="CSharp_CallSession_setVideoPrefSize")]
public static extern bool CallSession_setVideoPrefSize(HandleRef jarg1, int jarg2);
[DllImport("tinyWRAP", EntryPoint="CSharp_CallSession_setQoS")]
public static extern bool CallSession_setQoS(HandleRef jarg1, int jarg2, int jarg3);

View File

@ -4458,6 +4458,20 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_CallSession_setVideoBandwidthDownload
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_CallSession_setVideoPrefSize(void * jarg1, int jarg2) {
unsigned int jresult ;
CallSession *arg1 = (CallSession *) 0 ;
tmedia_pref_video_size_t arg2 ;
bool result;
arg1 = (CallSession *)jarg1;
arg2 = (tmedia_pref_video_size_t)jarg2;
result = (bool)(arg1)->setVideoPrefSize(arg2);
jresult = result;
return jresult;
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_CallSession_setQoS(void * jarg1, int jarg2, int jarg3) {
unsigned int jresult ;
CallSession *arg1 = (CallSession *) 0 ;

View File

@ -159,6 +159,10 @@ public class CallSession extends InviteSession {
return tinyWRAPJNI.CallSession_setVideoBandwidthDownloadMax(swigCPtr, this, max);
}
public boolean setVideoPrefSize(tmedia_pref_video_size_t pref_video_size) {
return tinyWRAPJNI.CallSession_setVideoPrefSize(swigCPtr, this, pref_video_size.swigValue());
}
public boolean setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength) {
return tinyWRAPJNI.CallSession_setQoS(swigCPtr, this, type.swigValue(), strength.swigValue());
}

View File

@ -159,6 +159,10 @@ public class CallSession extends InviteSession {
return tinyWRAPJNI.CallSession_setVideoBandwidthDownloadMax(swigCPtr, this, max);
}
public boolean setVideoPrefSize(tmedia_pref_video_size_t pref_video_size) {
return tinyWRAPJNI.CallSession_setVideoPrefSize(swigCPtr, this, pref_video_size.swigValue());
}
public boolean setQoS(tmedia_qos_stype_t type, tmedia_qos_strength_t strength) {
return tinyWRAPJNI.CallSession_setQoS(swigCPtr, this, type.swigValue(), strength.swigValue());
}

View File

@ -273,6 +273,7 @@ public class tinyWRAPJNI {
public final static native boolean CallSession_setVideoFps(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setVideoBandwidthUploadMax(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setVideoBandwidthDownloadMax(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setVideoPrefSize(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setQoS(long jarg1, CallSession jarg1_, int jarg2, int jarg3);
public final static native boolean CallSession_hold__SWIG_0(long jarg1, CallSession jarg1_, long jarg2, ActionConfig jarg2_);
public final static native boolean CallSession_hold__SWIG_1(long jarg1, CallSession jarg1_);

View File

@ -6310,6 +6310,23 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_CallSession_1
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_CallSession_1setVideoPrefSize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
jboolean jresult = 0 ;
CallSession *arg1 = (CallSession *) 0 ;
tmedia_pref_video_size_t arg2 ;
bool result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(CallSession **)&jarg1;
arg2 = (tmedia_pref_video_size_t)jarg2;
result = (bool)(arg1)->setVideoPrefSize(arg2);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_CallSession_1setQoS(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3) {
jboolean jresult = 0 ;
CallSession *arg1 = (CallSession *) 0 ;

View File

@ -273,6 +273,7 @@ public class tinyWRAPJNI {
public final static native boolean CallSession_setVideoFps(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setVideoBandwidthUploadMax(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setVideoBandwidthDownloadMax(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setVideoPrefSize(long jarg1, CallSession jarg1_, int jarg2);
public final static native boolean CallSession_setQoS(long jarg1, CallSession jarg1_, int jarg2, int jarg3);
public final static native boolean CallSession_hold__SWIG_0(long jarg1, CallSession jarg1_, long jarg2, ActionConfig jarg2_);
public final static native boolean CallSession_hold__SWIG_1(long jarg1, CallSession jarg1_);

View File

@ -6310,6 +6310,23 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_CallSession_1
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_CallSession_1setVideoPrefSize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
jboolean jresult = 0 ;
CallSession *arg1 = (CallSession *) 0 ;
tmedia_pref_video_size_t arg2 ;
bool result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(CallSession **)&jarg1;
arg2 = (tmedia_pref_video_size_t)jarg2;
result = (bool)(arg1)->setVideoPrefSize(arg2);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_CallSession_1setQoS(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3) {
jboolean jresult = 0 ;
CallSession *arg1 = (CallSession *) 0 ;

View File

@ -1067,6 +1067,7 @@ sub DESTROY {
*setVideoFps = *tinyWRAPc::CallSession_setVideoFps;
*setVideoBandwidthUploadMax = *tinyWRAPc::CallSession_setVideoBandwidthUploadMax;
*setVideoBandwidthDownloadMax = *tinyWRAPc::CallSession_setVideoBandwidthDownloadMax;
*setVideoPrefSize = *tinyWRAPc::CallSession_setVideoPrefSize;
*setQoS = *tinyWRAPc::CallSession_setQoS;
*hold = *tinyWRAPc::CallSession_hold;
*resume = *tinyWRAPc::CallSession_resume;

View File

@ -12532,6 +12532,44 @@ XS(_wrap_CallSession_setVideoBandwidthDownloadMax) {
}
XS(_wrap_CallSession_setVideoPrefSize) {
{
CallSession *arg1 = (CallSession *) 0 ;
tmedia_pref_video_size_t arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
int ecode2 = 0 ;
int argvi = 0;
bool result;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: CallSession_setVideoPrefSize(self,pref_video_size);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CallSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CallSession_setVideoPrefSize" "', argument " "1"" of type '" "CallSession *""'");
}
arg1 = reinterpret_cast< CallSession * >(argp1);
ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CallSession_setVideoPrefSize" "', argument " "2"" of type '" "tmedia_pref_video_size_t""'");
}
arg2 = static_cast< tmedia_pref_video_size_t >(val2);
result = (bool)(arg1)->setVideoPrefSize(arg2);
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_CallSession_setQoS) {
{
CallSession *arg1 = (CallSession *) 0 ;
@ -28089,6 +28127,7 @@ static swig_command_info swig_commands[] = {
{"tinyWRAPc::CallSession_setVideoFps", _wrap_CallSession_setVideoFps},
{"tinyWRAPc::CallSession_setVideoBandwidthUploadMax", _wrap_CallSession_setVideoBandwidthUploadMax},
{"tinyWRAPc::CallSession_setVideoBandwidthDownloadMax", _wrap_CallSession_setVideoBandwidthDownloadMax},
{"tinyWRAPc::CallSession_setVideoPrefSize", _wrap_CallSession_setVideoPrefSize},
{"tinyWRAPc::CallSession_setQoS", _wrap_CallSession_setQoS},
{"tinyWRAPc::CallSession_hold", _wrap_CallSession_hold},
{"tinyWRAPc::CallSession_resume", _wrap_CallSession_resume},

View File

@ -996,6 +996,7 @@ class CallSession(InviteSession):
def setVideoFps(self, *args): return _tinyWRAP.CallSession_setVideoFps(self, *args)
def setVideoBandwidthUploadMax(self, *args): return _tinyWRAP.CallSession_setVideoBandwidthUploadMax(self, *args)
def setVideoBandwidthDownloadMax(self, *args): return _tinyWRAP.CallSession_setVideoBandwidthDownloadMax(self, *args)
def setVideoPrefSize(self, *args): return _tinyWRAP.CallSession_setVideoPrefSize(self, *args)
def setQoS(self, *args): return _tinyWRAP.CallSession_setQoS(self, *args)
def hold(self, *args): return _tinyWRAP.CallSession_hold(self, *args)
def resume(self, *args): return _tinyWRAP.CallSession_resume(self, *args)

View File

@ -13722,6 +13722,37 @@ fail:
}
SWIGINTERN PyObject *_wrap_CallSession_setVideoPrefSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CallSession *arg1 = (CallSession *) 0 ;
tmedia_pref_video_size_t arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
bool result;
if (!PyArg_ParseTuple(args,(char *)"OO:CallSession_setVideoPrefSize",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CallSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CallSession_setVideoPrefSize" "', argument " "1"" of type '" "CallSession *""'");
}
arg1 = reinterpret_cast< CallSession * >(argp1);
ecode2 = SWIG_AsVal_int(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CallSession_setVideoPrefSize" "', argument " "2"" of type '" "tmedia_pref_video_size_t""'");
}
arg2 = static_cast< tmedia_pref_video_size_t >(val2);
result = (bool)(arg1)->setVideoPrefSize(arg2);
resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_CallSession_setQoS(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CallSession *arg1 = (CallSession *) 0 ;
@ -26477,6 +26508,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"CallSession_setVideoFps", _wrap_CallSession_setVideoFps, METH_VARARGS, NULL},
{ (char *)"CallSession_setVideoBandwidthUploadMax", _wrap_CallSession_setVideoBandwidthUploadMax, METH_VARARGS, NULL},
{ (char *)"CallSession_setVideoBandwidthDownloadMax", _wrap_CallSession_setVideoBandwidthDownloadMax, METH_VARARGS, NULL},
{ (char *)"CallSession_setVideoPrefSize", _wrap_CallSession_setVideoPrefSize, METH_VARARGS, NULL},
{ (char *)"CallSession_setQoS", _wrap_CallSession_setQoS, METH_VARARGS, NULL},
{ (char *)"CallSession_hold", _wrap_CallSession_hold, METH_VARARGS, NULL},
{ (char *)"CallSession_resume", _wrap_CallSession_resume, METH_VARARGS, NULL},

View File

@ -63,6 +63,7 @@ typedef struct tdav_session_av_s
int32_t bandwidth_max_download_kbps;
int32_t fps;
tsk_bool_t congestion_ctrl_enabled;
tmedia_pref_video_size_t pref_size; // output
/* sdp capabilities (RFC 5939) */
struct tdav_sdp_caps_s* sdp_caps;

View File

@ -226,6 +226,7 @@ int tdav_session_av_init(tdav_session_av_t* self, tmedia_type_t media_type)
self->use_rtcpmux = tmedia_defaults_get_rtcpmux_enabled();
self->avpf_mode_set = self->avpf_mode_neg = tmedia_defaults_get_avpf_mode();
self->fps = -1; // use what is negotiated by the codec unless overrided by the user
self->pref_size = tmedia_defaults_get_pref_video_size(); // for the encoder
self->bandwidth_max_upload_kbps = ((media_type & tmedia_video || (media_type & tmedia_bfcp_video) == tmedia_bfcp_video) ? tmedia_defaults_get_bandwidth_video_upload_max() : INT_MAX); // INT_MAX or <=0 means undefined
self->bandwidth_max_download_kbps = ((media_type & tmedia_video || (media_type & tmedia_bfcp_video) == tmedia_bfcp_video) ? tmedia_defaults_get_bandwidth_video_download_max() : INT_MAX); // INT_MAX or <=0 means undefined
self->congestion_ctrl_enabled = tmedia_defaults_get_congestion_ctrl_enabled(); // whether to enable draft-alvestrand-rtcweb-congestion-03 and draft-alvestrand-rmcat-remb-01
@ -358,6 +359,10 @@ tsk_bool_t tdav_session_av_set(tdav_session_av_t* self, const tmedia_param_t* pa
self->fps = TSK_TO_INT32((uint8_t*)param->value);
return tsk_true;
}
else if (tsk_striequals(param->key, "pref-size")) {
self->pref_size = (tmedia_pref_video_size_t)TSK_TO_INT32((uint8_t*)param->value);
return tsk_true;
}
}
else if(param->value_type == tmedia_pvt_pobject){
if(tsk_striequals(param->key, "natt-ctx")){
@ -436,10 +441,18 @@ int tdav_session_av_init_encoder(tdav_session_av_t* self, struct tmedia_codec_s*
encoder->bandwidth_max_upload = self->bandwidth_max_upload_kbps;
encoder->bandwidth_max_download = self->bandwidth_max_download_kbps;
if ((encoder->type & tmedia_video) || (encoder->type & tmedia_bfcp_video)) {
tmedia_codec_video_t* video = TMEDIA_CODEC_VIDEO(encoder);
if (self->fps > 0) {
tmedia_codec_video_t* video = TMEDIA_CODEC_VIDEO(encoder);
video->out.fps = self->fps;
}
if (self->pref_size != video->pref_size) {
unsigned width, height;
if (tmedia_video_get_size(self->pref_size, &width, &height) == 0){
video->pref_size = self->pref_size;
video->out.width = width;
video->out.height = height;
}
}
}
return 0;
}

View File

@ -125,6 +125,7 @@ typedef enum tsip_msession_param_type_e
mstype_set_video_fps,
mstype_set_video_bw_up,
mstype_set_video_bw_down,
mstype_set_video_prefsize,
mstype_set_qos,
mstype_unset_qos,
@ -159,6 +160,7 @@ tsip_msession_param_type_t;
#define TSIP_MSESSION_SET_VIDEO_FPS(FPS_INT) mstype_set_video_fps, (int32_t)FPS_INT
#define TSIP_MSESSION_SET_VIDEO_BW_UP(BW_INT) mstype_set_video_bw_up, (int32_t)(BW_INT)
#define TSIP_MSESSION_SET_VIDEO_BW_DOWN(BW_INT) mstype_set_video_bw_down, (int32_t)(BW_INT)
#define TSIP_MSESSION_SET_VIDEO_PREFSIZE(PREFSIZE_ENUM) mstype_set_video_prefsize, (int32_t)(PREFSIZE_ENUM)
#define TSIP_MSESSION_SET_TIMERS(TIMEOUT_UINT, REFRESHER_STR) mstype_set_timers, (unsigned)TIMEOUT_UINT, (const char*)REFRESHER_STR
#define TSIP_MSESSION_UNSET_TIMERS() mstype_unset_timers
#define TSIP_MSESSION_SET_CODECS(CODECS_INT) mstype_set_codecs, (signed)CODECS_INT
@ -227,6 +229,7 @@ typedef struct tsip_ssession_s
int32_t video_fps;
int32_t video_bw_up;
int32_t video_bw_down;
tmedia_pref_video_size_t video_pref_size;
/* RTP*/
struct{

View File

@ -1106,6 +1106,7 @@ int tsip_dialog_invite_msession_configure(tsip_dialog_invite_t *self)
TMEDIA_SESSION_SET_INT32(tmedia_video, "fps", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_fps),
TMEDIA_SESSION_SET_INT32(tmedia_video, "bandwidth-max-upload", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_bw_up),
TMEDIA_SESSION_SET_INT32(tmedia_video, "bandwidth-max-download", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_bw_down),
TMEDIA_SESSION_SET_INT32(tmedia_video, "pref-size", ((tsip_ssession_t*)TSIP_DIALOG(self)->ss)->media.video_pref_size),
tsk_null);
}

View File

@ -383,6 +383,11 @@ int __tsip_ssession_set(tsip_ssession_t *self, va_list *app)
self->media.video_bw_down = va_arg(*app, signed);
break;
}
case mstype_set_video_prefsize:
{/* (tmedia_pref_video_size_t)PREFSIZE_ENUM */
self->media.video_pref_size = va_arg(*app, tmedia_pref_video_size_t);
break;
}
default:{
/* va_list will be unsafe => exit */
TSK_DEBUG_ERROR("%d NOT a valid MEDIA pname", mscurr);
@ -701,6 +706,7 @@ static tsk_object_t* tsip_ssession_ctor(tsk_object_t * self, va_list * app)
ss->media.video_fps = tmedia_defaults_get_video_fps();
ss->media.video_bw_down = tmedia_defaults_get_bandwidth_video_download_max();
ss->media.video_bw_up = tmedia_defaults_get_bandwidth_video_upload_max();
ss->media.video_pref_size = tmedia_defaults_get_pref_video_size();
{
const char *stun_hostname, *stun_username, *stun_password;
uint16_t stun_port;