Commit ad054592 authored by Ghislain MARY's avatar Ghislain MARY

Slightly change ICE API to ease integration in Linphone.

parent 33411cef
......@@ -208,13 +208,19 @@ MS2_PUBLIC void ice_session_destroy(IceSession *session);
/**
* Allocate a new ICE check list.
*
* @param success_cb Pointer to a callback function to be called when the processing of the check list is successful
* @param stream_ptr Pointer to the media stream to be passed as a parameter to the callback function
* @return Pointer to the allocated check list
*
* A check list must be allocated for each media stream of a media session and be added to an ICE session using the ice_session_add_check_list() function.
*/
MS2_PUBLIC IceCheckList * ice_check_list_new(ice_check_list_success_cb success_cb, void *stream_ptr);
MS2_PUBLIC IceCheckList * ice_check_list_new(void);
/**
* Register the callback function to be called when the processing of the check list is successful
*
* @param success_cb Pointer to a callback function to be called when the processing of the check list is successful
* @param stream_ptr Pointer to the media stream to be passed as a parameter to the callback function
*/
MS2_PUBLIC void ice_check_list_register_success_cb(IceCheckList *cl, ice_check_list_success_cb success_cb, void *stream_ptr);
/**
* Destroy a previously allocated ICE check list.
......
......@@ -271,6 +271,9 @@ MS2_PUBLIC void audio_stream_enable_zrtp(AudioStream *stream, OrtpZrtpParams *pa
/* enable SRTP on the audio stream */
MS2_PUBLIC bool_t audio_stream_enable_strp(AudioStream* stream, enum ortp_srtp_crypto_suite_t suite, const char* snd_key, const char* rcv_key);
/* set the remote address to send the audio stream to according to an ICE check list */
MS2_PUBLIC void audio_stream_set_remote_from_ice(void *stream, IceCheckList *cl);
/*****************
Video Support
*****************/
......@@ -375,6 +378,9 @@ MS2_PUBLIC bool_t video_stream_enable_strp(VideoStream* stream, enum ortp_srtp_c
/* if enabled, the display filter will internaly rotate the video, according to the device orientation */
MS2_PUBLIC void video_stream_enable_display_filter_auto_rotate(VideoStream* stream, bool_t enable);
/* set the remote address to send the video stream to according to an ICE check list */
void video_stream_set_remote_from_ice(void *stream, IceCheckList *cl);
/**
* Small API to display a local preview window.
**/
......
......@@ -55,7 +55,6 @@ void audio_stream_free(AudioStream *stream)
rtp_session_destroy(stream->session);
}
if (stream->ice_check_list!=NULL) ice_check_list_destroy(stream->ice_check_list);
if (stream->evq) ortp_ev_queue_destroy(stream->evq);
if (stream->rtpsend!=NULL) ms_filter_destroy(stream->rtpsend);
if (stream->rtprecv!=NULL) ms_filter_destroy(stream->rtprecv);
......@@ -667,7 +666,7 @@ void audio_stream_set_features(AudioStream *st, uint32_t features){
st->features = features;
}
static void audio_stream_set_remote_from_ice(void *stream, IceCheckList *cl){
void audio_stream_set_remote_from_ice(void *stream, IceCheckList *cl){
char addr[64];
int rtp_port = 0;
int rtcp_port = 0;
......@@ -689,8 +688,7 @@ AudioStream *audio_stream_new(int locport, bool_t ipv6){
stream->session=create_duplex_rtpsession(locport,ipv6);
/*some filters are created right now to allow configuration by the application before start() */
stream->rtpsend=ms_filter_new(MS_RTP_SEND_ID);
stream->ice_check_list=ice_check_list_new(audio_stream_set_remote_from_ice, stream);
stream->ice_check_list=NULL;
if (ec_desc!=NULL)
stream->ec=ms_filter_new_from_desc(ec_desc);
......
......@@ -206,7 +206,7 @@ static void ice_check_list_init(IceCheckList *cl)
cl->foundation_generator = 1;
}
IceCheckList * ice_check_list_new(ice_check_list_success_cb success_cb, void *stream_ptr)
IceCheckList * ice_check_list_new(void)
{
IceCheckList *cl = ms_new(IceCheckList, 1);
if (cl == NULL) {
......@@ -214,9 +214,13 @@ IceCheckList * ice_check_list_new(ice_check_list_success_cb success_cb, void *st
return NULL;
}
ice_check_list_init(cl);
return cl;
}
void ice_check_list_register_success_cb(IceCheckList *cl, ice_check_list_success_cb success_cb, void *stream_ptr)
{
cl->success_cb = success_cb;
cl->stream_ptr = stream_ptr;
return cl;
}
static void ice_compute_pair_priority(IceCandidatePair *pair, IceRole *role)
......
......@@ -45,8 +45,6 @@ void video_stream_free (VideoStream * stream)
rtp_session_unregister_event_queue(stream->session,stream->evq);
rtp_session_destroy(stream->session);
}
if (stream->ice_check_list != NULL)
ice_check_list_destroy(stream->ice_check_list);
if (stream->rtprecv != NULL)
ms_filter_destroy (stream->rtprecv);
if (stream->rtpsend!=NULL)
......@@ -203,7 +201,7 @@ static void choose_display_name(VideoStream *stream){
#endif
}
static void video_stream_set_remote_from_ice(void *stream, IceCheckList *cl){
void video_stream_set_remote_from_ice(void *stream, IceCheckList *cl){
char addr[64];
int rtp_port = 0;
int rtcp_port = 0;
......@@ -220,7 +218,7 @@ VideoStream *video_stream_new(int locport, bool_t use_ipv6){
stream->session=create_duplex_rtpsession(locport,use_ipv6);
stream->evq=ortp_ev_queue_new();
stream->rtpsend=ms_filter_new(MS_RTP_SEND_ID);
stream->ice_check_list=ice_check_list_new(video_stream_set_remote_from_ice, stream);
stream->ice_check_list=NULL;
rtp_session_register_event_queue(stream->session,stream->evq);
stream->sent_vsize.width=MS_VIDEO_SIZE_CIF_W;
stream->sent_vsize.height=MS_VIDEO_SIZE_CIF_H;
......
......@@ -604,6 +604,12 @@ void setup_media_streams(MediastreamDatas* args) {
audio_stream_start_full(args->audio,args->profile,args->ip,args->remoteport,args->remoteport+1, args->payload, args->jitter,args->infile,args->outfile,
args->outfile==NULL ? play : NULL ,args->infile==NULL ? capt : NULL,args->infile!=NULL ? FALSE: args->ec);
if (args->ice_local_candidates_nb || args->ice_remote_candidates_nb) {
args->audio->ice_check_list = ice_check_list_new();
ice_check_list_register_success_cb(args->audio->ice_check_list, audio_stream_set_remote_from_ice, args->audio);
rtp_session_set_pktinfo(args->audio->session,TRUE);
ice_session_add_check_list(args->ice_session, args->audio->ice_check_list);
}
if (args->ice_local_candidates_nb) {
MediastreamIceCandidate *candidate;
int c;
......@@ -625,7 +631,6 @@ void setup_media_streams(MediastreamDatas* args) {
ice_add_remote_candidate(args->audio->ice_check_list,candidate->type,candidate->ip,candidate->port+1,2,0,foundation);
}
}
ice_session_add_check_list(args->ice_session, args->audio->ice_check_list);
if (args->audio) {
if (args->el) {
......@@ -720,7 +725,6 @@ void setup_media_streams(MediastreamDatas* args) {
printf("Error: video support not compiled.\n");
#endif
}
rtp_session_set_pktinfo(args->session, TRUE);
ice_session_set_base_for_srflx_candidates(args->ice_session);
ice_session_compute_candidates_foundations(args->ice_session);
ice_session_choose_default_candidates(args->ice_session);
......@@ -824,9 +828,13 @@ void clear_mediastreams(MediastreamDatas* args) {
ms_message("stopping all...\n");
ms_message("Average quality indicator: %f",args->audio ? audio_stream_get_average_quality_rating(args->audio) : -1);
if (args->audio) audio_stream_stop(args->audio);
if (args->audio) {
if (args->audio->ice_check_list) ice_check_list_destroy(args->audio->ice_check_list);
audio_stream_stop(args->audio);
}
#ifdef VIDEO_ENABLED
if (args->video) {
if (args->video->ice_check_list) ice_check_list_destroy(args->video->ice_check_list);
video_stream_stop(args->video);
ms_filter_log_statistics();
}
......
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