Commit 01735a67 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Allocate an ICE check list for each audio and video stream.

parent 90df40e6
......@@ -30,12 +30,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef enum {
HostCandidate,
ServerReflexiveCandidate,
PeerReflexiveCandidate,
RelayedCandidate
ICT_HostCandidate,
ICT_ServerReflexiveCandidate,
ICT_PeerReflexiveCandidate,
ICT_RelayedCandidate
} IceCandidateType;
typedef enum {
ICP_Waiting,
ICP_InProgress,
ICP_Succeeded,
ICP_Failed,
ICP_Frozen
} IceCandidatePairState;
typedef enum {
ICL_Running,
ICL_Completed,
ICL_Failed
} IceCheckListState;
typedef struct {
char ip[64];
int port;
......@@ -51,16 +65,17 @@ typedef struct {
typedef struct {
IceCandidate *local;
IceCandidate *remote;
IceCandidatePairState state;
bool_t is_default;
bool_t is_valid;
bool_t is_nominated;
// TODO: state
} IceCandidatePair;
typedef struct {
IceCandidate local_candidates[ICE_MAX_NB_CANDIDATES];
IceCandidate remote_candidates[ICE_MAX_NB_CANDIDATES];
IceCandidatePair pairs[ICE_MAX_NB_CANDIDATE_PAIRS];
IceCheckListState state;
} IceCheckList;
......@@ -68,7 +83,13 @@ typedef struct {
extern "C"{
#endif
void ice_handle_STUN_packet(RtpSession *session, mblk_t *m);
IceCheckList * ice_check_list_new(void);
void ice_check_list_destroy(IceCheckList *cl);
IceCheckListState ice_check_list_state(IceCheckList *cl);
void ice_handle_stun_packet(IceCheckList *cl, RtpSession *session, mblk_t *m);
#ifdef __cplusplus
}
......
......@@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <mediastreamer2/msvideo.h>
#include <mediastreamer2/bitratecontrol.h>
#include <mediastreamer2/qualityindicator.h>
#include <mediastreamer2/ice.h>
#include <ortp/ortp.h>
#include <ortp/event.h>
#include <ortp/zrtp.h>
......@@ -48,6 +49,7 @@ struct _AudioStream
{
MSTicker *ticker;
RtpSession *session;
IceCheckList *ice_check_list;
MSFilter *soundread;
MSFilter *soundwrite;
MSFilter *encoder;
......@@ -288,6 +290,7 @@ struct _VideoStream
{
MSTicker *ticker;
RtpSession *session;
IceCheckList *ice_check_list;
MSFilter *source;
MSFilter *pixconv;
MSFilter *sizeconv;
......
......@@ -55,6 +55,7 @@ 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);
......@@ -223,6 +224,8 @@ void audio_stream_iterate(AudioStream *stream){
/*we choose to update the quality indicator when the oRTP stack decides to emit a RTCP report */
ms_quality_indicator_update_local(stream->qi);
ms_message("audio_stream_iterate(): local statistics available\n\tLocal's current jitter buffer size:%f ms",rtp_session_get_jitter_stats(stream->session)->jitter_buffer_size_ms);
}else if (evt==ORTP_EVENT_STUN_PACKET_RECEIVED){
ice_handle_stun_packet(stream->ice_check_list,stream->session,ortp_event_get_data(ev)->packet);
}
ortp_event_destroy(ev);
}
......@@ -674,6 +677,8 @@ AudioStream *audio_stream_new(int locport, bool_t 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();
if (ec_desc!=NULL)
stream->ec=ms_filter_new_from_desc(ec_desc);
else
......
......@@ -30,7 +30,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/ice.h"
void ice_handle_STUN_packet(RtpSession *session, mblk_t *m)
static void ice_check_list_init(IceCheckList *cl)
{
cl->state = ICL_Running;
}
IceCheckList * ice_check_list_new(void)
{
IceCheckList *cl = ms_new0(IceCheckList, 1);
if (cl == NULL) {
ms_error("ice_check_list_new: Memory allocation failed");
return NULL;
}
ice_check_list_init(cl);
return cl;
}
void ice_check_list_destroy(IceCheckList *cl)
{
ms_free(cl);
}
IceCheckListState ice_check_list_state(IceCheckList *cl)
{
return cl->state;
}
void ice_handle_stun_packet(IceCheckList *cl, RtpSession* session, mblk_t* m)
{
//TODO
}
......@@ -45,6 +45,8 @@ 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)
......@@ -168,6 +170,8 @@ void video_stream_iterate(VideoStream *stream){
if (evt == ORTP_EVENT_RTCP_PACKET_RECEIVED){
OrtpEventData *evd=ortp_event_get_data(ev);
video_steam_process_rtcp(stream,evd->packet);
}else if (evt == ORTP_EVENT_STUN_PACKET_RECEIVED){
ice_handle_stun_packet(stream->ice_check_list,stream->session,ortp_event_get_data(ev)->packet);
}
ortp_event_destroy(ev);
}
......@@ -203,6 +207,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();
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;
......
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