Commit 15b6353e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Started rework of streams' indexes for RTT

parent e141a5ea
......@@ -739,6 +739,8 @@ static SalStreamDescription * sdp_to_stream_description(SalMediaDescription *md,
stream->type=SalAudio;
} else if ( strcasecmp ( "video", mtype ) == 0 ) {
stream->type=SalVideo;
} else if ( strcasecmp ( "text", mtype ) == 0 ) {
stream->type=SalText;
} else {
stream->type=SalOther;
strncpy ( stream->typeother,mtype,sizeof ( stream->typeother )-1 );
......
This diff is collapsed.
......@@ -1027,6 +1027,15 @@ static void rtp_config_read(LinphoneCore *lc)
linphone_core_set_video_port(lc, min_port);
}
if (lp_config_get_range(lc->config, "rtp", "text_rtp_port", &min_port, &max_port, 11078, 11078) == TRUE) {
if (min_port <= 0) min_port = 1;
if (max_port > 65535) max_port = 65535;
linphone_core_set_text_port_range(lc, min_port, max_port);
} else {
min_port = lp_config_get_int(lc->config, "rtp", "text_rtp_port", 11078);
linphone_core_set_text_port(lc, min_port);
}
jitt_comp=lp_config_get_int(lc->config,"rtp","audio_jitt_comp",60);
linphone_core_set_audio_jittcomp(lc,jitt_comp);
jitt_comp=lp_config_get_int(lc->config,"rtp","video_jitt_comp",60);
......@@ -1121,7 +1130,7 @@ static bool_t get_codec(LinphoneCore *lc, SalStreamType type, int index, Payload
LpConfig *config=lc->config;
*ret=NULL;
snprintf(codeckey,50,"%s_codec_%i",type==SalAudio ? "audio" : "video", index);
snprintf(codeckey,50,"%s_codec_%i",type == SalAudio ? "audio" : type == SalVideo ? "video" : "text", index);
mime=lp_config_get_string(config,codeckey,"mime",NULL);
if (mime==NULL || strlen(mime)==0 ) return FALSE;
......@@ -1133,15 +1142,17 @@ static bool_t get_codec(LinphoneCore *lc, SalStreamType type, int index, Payload
ms_warning("Codec %s/%i read from conf is not supported by mediastreamer2, ignored.",mime,rate);
return TRUE;
}
pt=find_payload(type==SalAudio ? lc->default_audio_codecs : lc->default_video_codecs,mime,rate,channels,fmtp);
pt = find_payload(type == SalAudio ? lc->default_audio_codecs : type == SalVideo ? lc->default_video_codecs : lc->default_text_codecs ,mime,rate,channels,fmtp);
if (!pt){
MSList **default_list=(type==SalAudio) ? &lc->default_audio_codecs : &lc->default_video_codecs;
if (type==SalAudio)
MSList **default_list = (type==SalAudio) ? &lc->default_audio_codecs : type == SalVideo ? &lc->default_video_codecs : &lc->default_text_codecs;
if (type == SalAudio)
ms_warning("Codec %s/%i/%i read from conf is not in the default list.",mime,rate,channels);
else
else if (type == SalVideo)
ms_warning("Codec %s/%i read from conf is not in the default list.",mime,rate);
else
ms_warning("Codec %s read from conf is not in the default list.",mime);
pt=payload_type_new();
pt->type=(type==SalAudio) ? PAYLOAD_AUDIO_PACKETIZED : PAYLOAD_VIDEO;
pt->type=(type==SalAudio) ? PAYLOAD_AUDIO_PACKETIZED : type == SalVideo ? PAYLOAD_VIDEO : PAYLOAD_TEXT;
pt->mime_type=ortp_strdup(mime);
pt->clock_rate=rate;
pt->channels=channels;
......@@ -1199,6 +1210,7 @@ static void codecs_config_read(LinphoneCore *lc)
PayloadType *pt;
MSList *audio_codecs=NULL;
MSList *video_codecs=NULL;
MSList *text_codecs=NULL;
lc->codecs_conf.dyn_pt=96;
lc->codecs_conf.telephone_event_pt=lp_config_get_int(lc->config,"misc","telephone_event_pt",101);
......@@ -1220,8 +1232,17 @@ static void codecs_config_read(LinphoneCore *lc)
if( lp_config_get_int(lc->config, "misc", "add_missing_video_codecs", 1) == 1 ){
video_codecs=add_missing_codecs(lc->default_video_codecs,video_codecs);
}
for (i=0;get_codec(lc,SalText,i,&pt);i++){
if (pt){
text_codecs=codec_append_if_new(text_codecs, pt);
}
}
text_codecs = add_missing_codecs(lc->default_text_codecs, text_codecs);
linphone_core_set_audio_codecs(lc,audio_codecs);
linphone_core_set_video_codecs(lc,video_codecs);
linphone_core_set_text_codecs(lc, text_codecs);
linphone_core_update_allocated_audio_bandwidth(lc);
}
......@@ -1402,7 +1423,7 @@ const char * linphone_core_get_version(void){
static void linphone_core_register_payload_type(LinphoneCore *lc, const PayloadType *const_pt, const char *recv_fmtp, bool_t enabled){
MSList **codec_list=const_pt->type==PAYLOAD_VIDEO ? &lc->default_video_codecs : &lc->default_audio_codecs;
if (linphone_core_codec_supported(lc, (const_pt->type == PAYLOAD_VIDEO) ? SalVideo : SalAudio, const_pt->mime_type)){
if (linphone_core_codec_supported(lc, (const_pt->type == PAYLOAD_VIDEO) ? SalVideo : const_pt->type == PAYLOAD_TEXT ? SalText : SalAudio, const_pt->mime_type)){
PayloadType *pt=payload_type_clone(const_pt);
int number=-1;
payload_type_set_enable(pt,enabled);
......@@ -1428,8 +1449,8 @@ static void linphone_core_register_static_payloads(LinphoneCore *lc){
if (pt->type==PAYLOAD_VIDEO) continue;
#endif
if (find_payload_type_from_list(
pt->mime_type, pt->clock_rate, pt->type!=PAYLOAD_VIDEO ? pt->channels : LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS,
pt->type==PAYLOAD_VIDEO ? lc->default_video_codecs : lc->default_audio_codecs)==NULL){
pt->mime_type, pt->clock_rate, pt->type == PAYLOAD_VIDEO || pt->type == PAYLOAD_TEXT ? LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS : pt->channels,
pt->type == PAYLOAD_VIDEO ? lc->default_video_codecs : pt->type == PAYLOAD_TEXT ? lc->default_text_codecs : lc->default_audio_codecs)==NULL){
linphone_core_register_payload_type(lc,pt,NULL,FALSE);
}
}
......@@ -1569,7 +1590,8 @@ static void linphone_core_register_default_codecs(LinphoneCore *lc){
linphone_core_register_payload_type(lc,&payload_type_aal2_g726_40,NULL,FALSE);
linphone_core_register_payload_type(lc,&payload_type_codec2,NULL,FALSE);
linphone_core_register_payload_type(lc,&payload_type_t140,NULL,TRUE);
linphone_core_register_payload_type(lc,&payload_type_t140_red,NULL,TRUE);
#ifdef VIDEO_ENABLED
......@@ -1659,6 +1681,11 @@ const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc)
return lc->codecs_conf.video_codecs;
}
const MSList *linphone_core_get_text_codecs(const LinphoneCore *lc)
{
return lc->codecs_conf.text_codecs;
}
int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact)
{
LinphoneAddress *ctt;
......@@ -1788,6 +1815,15 @@ int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs){
return 0;
}
int linphone_core_set_text_codecs(LinphoneCore *lc, MSList *codecs) {
if (lc->codecs_conf.text_codecs != NULL)
ms_list_free(lc->codecs_conf.text_codecs);
lc->codecs_conf.text_codecs = codecs;
_linphone_core_codec_config_write(lc);
return 0;
}
/**
* Enable RFC3389 generic confort noise algorithm (CN payload type).
* It is disabled by default, because this algorithm is only relevant for legacy codecs (PCMU, PCMA, G722).
......@@ -1893,6 +1929,24 @@ void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, i
*max_port = lc->rtp_conf.video_rtp_max_port;
}
/**
* Returns the UDP port used for text streaming.
*
* @ingroup network_parameters
**/
int linphone_core_get_text_port(const LinphoneCore *lc) {
return lc->rtp_conf.text_rtp_min_port;
}
/**
* Get the video port range from which is randomly chosen the UDP port used for text streaming.
*
* @ingroup network_parameters
*/
void linphone_core_get_text_port_range(const LinphoneCore *lc, int *min_port, int *max_port) {
*min_port = lc->rtp_conf.text_rtp_min_port;
*max_port = lc->rtp_conf.text_rtp_max_port;
}
/**
* Returns the value in seconds of the no-rtp timeout.
......@@ -1992,6 +2046,26 @@ void linphone_core_set_video_port_range(LinphoneCore *lc, int min_port, int max_
lc->rtp_conf.video_rtp_min_port=min_port;
lc->rtp_conf.video_rtp_max_port=max_port;
}
/**
* Sets the UDP port used for text streaming.
* A value if -1 will request the system to allocate the local port randomly.
* This is recommended in order to avoid firewall warnings.
*
* @ingroup network_parameters
**/
void linphone_core_set_text_port(LinphoneCore *lc, int port) {
lc->rtp_conf.text_rtp_min_port = lc->rtp_conf.text_rtp_max_port = port;
}
/**
* Sets the UDP port range from which to randomly select the port used for text streaming.
* @ingroup media_parameters
*/
void linphone_core_set_text_port_range(LinphoneCore *lc, int min_port, int max_port) {
lc->rtp_conf.text_rtp_min_port = min_port;
lc->rtp_conf.text_rtp_max_port = max_port;
}
/**
* Sets the no-rtp timeout value in seconds.
......@@ -3843,7 +3917,7 @@ int _linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call){
}
lc->current_call=NULL;
linphone_core_notify_display_status(lc,_("Pausing the current call..."));
if (call->audiostream || call->videostream)
if (call->audiostream || call->videostream || call->textstream)
linphone_call_stop_media_streams (call);
call->paused_by_app=FALSE;
return 0;
......@@ -6850,6 +6924,7 @@ void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *para
params->has_video=linphone_core_video_enabled(lc) && lc->video_policy.automatically_initiate;
params->media_encryption=linphone_core_get_media_encryption(lc);
params->in_conference=FALSE;
params->realtimetext_enabled = linphone_core_realtime_text_enabled(lc);
params->privacy=LinphonePrivacyDefault;
params->avpf_enabled=FALSE;
params->audio_dir=LinphoneMediaDirectionSendRecv;
......@@ -7184,3 +7259,7 @@ LINPHONE_PUBLIC const char *linphone_core_log_collection_upload_state_to_string(
}
return "UNKNOWN";
}
bool_t linphone_core_realtime_text_enabled(LinphoneCore *lc) {
return lc->text_conf.enabled;
}
......@@ -469,6 +469,7 @@ typedef struct _LinphoneVideoPolicy LinphoneVideoPolicy;
#define LINPHONE_CALL_STATS_AUDIO 0
#define LINPHONE_CALL_STATS_VIDEO 1
#define LINPHONE_CALL_STATS_TEXT 2
/**
* Enum describing ICE states.
......@@ -2683,6 +2684,22 @@ LINPHONE_PUBLIC const MSList *linphone_core_get_video_codecs(const LinphoneCore
LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs);
/**
* Returns the list of available text codecs.
* @param[in] lc The LinphoneCore object
* @return \mslist{PayloadType}
*
* This list is unmodifiable. The ->data field of the MSList points a PayloadType
* structure holding the codec information.
* It is possible to make copy of the list with ms_list_copy() in order to modify it
* (such as the order of codecs).
* @ingroup media_parameters
**/
LINPHONE_PUBLIC const MSList *linphone_core_get_text_codecs(const LinphoneCore *lc);
LINPHONE_PUBLIC int linphone_core_set_text_codecs(LinphoneCore *lc, MSList *codecs);
LINPHONE_PUBLIC void linphone_core_enable_generic_confort_noise(LinphoneCore *lc, bool_t enabled);
LINPHONE_PUBLIC bool_t linphone_core_generic_confort_noise_enabled(const LinphoneCore *lc);
......@@ -2931,6 +2948,10 @@ LINPHONE_PUBLIC int linphone_core_get_video_port(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, int *max_port);
LINPHONE_PUBLIC int linphone_core_get_text_port(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_get_text_port_range(const LinphoneCore *lc, int *min_port, int *max_port);
LINPHONE_PUBLIC int linphone_core_get_nortp_timeout(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_set_audio_port(LinphoneCore *lc, int port);
......@@ -2941,6 +2962,10 @@ LINPHONE_PUBLIC void linphone_core_set_video_port(LinphoneCore *lc, int port);
LINPHONE_PUBLIC void linphone_core_set_video_port_range(LinphoneCore *lc, int min_port, int max_port);
LINPHONE_PUBLIC void linphone_core_set_text_port(LinphoneCore *lc, int port);
LINPHONE_PUBLIC void linphone_core_set_text_port_range(LinphoneCore *lc, int min_port, int max_port);
LINPHONE_PUBLIC void linphone_core_set_nortp_timeout(LinphoneCore *lc, int port);
LINPHONE_PUBLIC void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc, bool_t use_info);
......@@ -4092,6 +4117,13 @@ LINPHONE_PUBLIC void linphone_core_set_video_preset(LinphoneCore *lc, const char
*/
LINPHONE_PUBLIC const char * linphone_core_get_video_preset(const LinphoneCore *lc);
/**
* Gets if realtime text is enabled or not
* @param[in] lc LinphoneCore object
* @return true if realtime text is enabled, false otherwise
*/
LINPHONE_PUBLIC bool_t linphone_core_realtime_text_enabled(LinphoneCore *lc);
#ifdef __cplusplus
}
#endif
......
......@@ -62,7 +62,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void clear_ice_check_list(LinphoneCall *call, IceCheckList *removed);
bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const LinphonePayloadType *pt){
if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt)){
if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || ms_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){
return payload_type_enabled(pt);
}
ms_error("Getting enablement status of codec not in audio or video list of PayloadType !");
......@@ -75,7 +75,7 @@ bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayload
}
int linphone_core_enable_payload_type(LinphoneCore *lc, LinphonePayloadType *pt, bool_t enabled){
if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){
if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt) || ms_list_find(lc->codecs_conf.text_codecs,pt)){
payload_type_set_enable(pt,enabled);
_linphone_core_codec_config_write(lc);
linphone_core_update_allocated_audio_bandwidth(lc);
......@@ -106,7 +106,7 @@ const char *linphone_core_get_payload_type_description(LinphoneCore *lc, Payload
}
void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, LinphonePayloadType *pt, int bitrate){
if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt)){
if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || ms_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){
if (pt->type==PAYLOAD_VIDEO || pt->flags & PAYLOAD_TYPE_IS_VBR){
pt->normal_bitrate=bitrate*1000;
pt->flags|=PAYLOAD_TYPE_BITRATE_OVERRIDE;
......
......@@ -117,6 +117,7 @@ struct _LinphoneCallParams{
LinphoneMediaEncryption media_encryption;
PayloadType *audio_codec; /*audio codec currently in use */
PayloadType *video_codec; /*video codec currently in use */
PayloadType *text_codec; /*text codec currently in use */
MSVideoSize sent_vsize; /* Size of the video currently being sent */
MSVideoSize recv_vsize; /* Size of the video currently being received */
float received_fps,sent_fps;
......@@ -251,6 +252,7 @@ struct _LinphoneCall{
SalMediaDescription *resultdesc;
struct _RtpProfile *audio_profile;
struct _RtpProfile *video_profile;
struct _RtpProfile *text_profile;
struct _RtpProfile *rtp_io_audio_profile;
struct _RtpProfile *rtp_io_video_profile;
struct _LinphoneCallLog *log;
......@@ -262,11 +264,13 @@ struct _LinphoneCall{
LinphoneCallState prevstate;
LinphoneCallState transfer_state; /*idle if no transfer*/
LinphoneProxyConfig *dest_proxy;
PortConfig media_ports[2];
MSMediaStreamSessions sessions[2]; /*the rtp, srtp, zrtp contexts for each stream*/
StunCandidate ac,vc; /*audio video ip/port discovered by STUN*/
int main_audio_stream_index, main_video_stream_index, main_text_stream_index;
PortConfig media_ports[SAL_MEDIA_DESCRIPTION_MAX_STREAMS];
MSMediaStreamSessions sessions[SAL_MEDIA_DESCRIPTION_MAX_STREAMS]; /*the rtp, srtp, zrtp contexts for each stream*/
StunCandidate ac, vc, tc; /*audio video text ip/port discovered by STUN*/
struct _AudioStream *audiostream; /**/
struct _VideoStream *videostream;
struct _TextStream *textstream;
void *video_window_id;
MSAudioEndpoint *endpoint; /*used for conferencing*/
char *refer_to;
......@@ -278,8 +282,9 @@ struct _LinphoneCall{
OrtpEvQueue *audiostream_app_evq;
char *auth_token;
OrtpEvQueue *videostream_app_evq;
OrtpEvQueue *textstream_app_evq;
CallCallbackObj nextVideoFrameDecoded;
LinphoneCallStats stats[2];
LinphoneCallStats stats[3]; /* audio, video, text */
#ifdef BUILD_UPNP
UpnpSession *upnp_session;
#endif //BUILD_UPNP
......@@ -453,6 +458,7 @@ void linphone_call_init_stats(LinphoneCallStats *stats, int type);
void linphone_call_fix_call_parameters(LinphoneCall *call);
void linphone_call_init_audio_stream(LinphoneCall *call);
void linphone_call_init_video_stream(LinphoneCall *call);
void linphone_call_init_text_stream(LinphoneCall *call);
void linphone_call_init_media_streams(LinphoneCall *call);
void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState target_state);
void linphone_call_start_media_streams_for_ice_gathering(LinphoneCall *call);
......@@ -656,6 +662,8 @@ typedef struct rtp_config
char* video_multicast_addr;
int video_multicast_ttl;
bool_t video_multicast_enabled;
int text_rtp_min_port;
int text_rtp_max_port;
}rtp_config_t;
......@@ -701,6 +709,7 @@ typedef struct codecs_config
{
MSList *audio_codecs; /* list of audio codecs in order of preference*/
MSList *video_codecs;
MSList *text_codecs;
int dyn_pt;
int telephone_event_pt;
}codecs_config_t;
......@@ -718,6 +727,10 @@ typedef struct video_config{
bool_t reuse_preview_source;
}video_config_t;
typedef struct text_config{
bool_t enabled;
}text_config_t;
typedef struct ui_config
{
int is_daemon;
......@@ -781,11 +794,13 @@ struct _LinphoneCore
struct _LpConfig *config;
MSList *default_audio_codecs;
MSList *default_video_codecs;
MSList *default_text_codecs;
net_config_t net_conf;
sip_config_t sip_conf;
rtp_config_t rtp_conf;
sound_config_t sound_conf;
video_config_t video_conf;
text_config_t text_conf;
codecs_config_t codecs_conf;
ui_config_t ui_conf;
autoreplier_config_t autoreplier_conf;
......
......@@ -617,8 +617,9 @@ void sal_auth_info_delete(SalAuthInfo* auth_info) {
const char* sal_stream_type_to_string(SalStreamType type) {
switch (type) {
case SalAudio:return "audio";
case SalVideo:return "video";
case SalAudio: return "audio";
case SalVideo: return "video";
case SalText: return "text";
default: return "other";
}
}
......
......@@ -126,6 +126,7 @@ void *sal_get_user_pointer(const Sal *sal);
typedef enum {
SalAudio,
SalVideo,
SalText,
SalOther
} SalStreamType;
const char* sal_stream_type_to_string(SalStreamType type);
......
mediastreamer2 @ 2df92791
Subproject commit 93cf916ac44dea93db7744b1d66ea3655c8345d9
Subproject commit 2df927914113b54610e9174d6c1f8615d22cb304
oRTP @ c3b24c49
Subproject commit bb95930a77e8a1432e5c31dc170f05ecd15518e5
Subproject commit c3b24c490a1f1f22dda6a88d2d2e428ff610b915
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment