Commit 3b02ef66 authored by Ghislain MARY's avatar Ghislain MARY

API change to be able to specify remote RTCP address for audio and video streams.

parent a954810f
......@@ -501,14 +501,15 @@ void ice_handle_stun_packet(IceCheckList* cl, RtpSession* rtp_session, const Ort
* Get the remote address, RTP port and RTCP port to use to send the stream once the ICE process has finished successfully.
*
* @param cl A pointer to a check list
* @param addr A pointer to the buffer to use to store the remote address
* @param addr_len The size of the buffer to use to store the remote address
* @param rtp_addr A pointer to the buffer to use to store the remote RTP address
* @param rtp_port A pointer to the location to store the RTP port to
* @param rtcp_aadr A pointer to the buffer to use to store the remote RTCP address
* @param rtcp_port A pointer to the location to store the RTCP port to
* @param addr_len The size of the buffer to use to store the remote addresses
*
* This function will usually be called from within the success callback defined while creating the ICE check list with ice_check_list_new().
*/
MS2_PUBLIC void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList* cl, char* addr, int addr_len, int* rtp_port, int* rtcp_port);
MS2_PUBLIC void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *rtp_addr, int *rtp_port, char *rtcp_addr, int *rtcp_port, int addr_len);
/**
* Print the route used to send the stream if the ICE process has finished successfully.
......
......@@ -132,8 +132,9 @@ MS2_PUBLIC int audio_stream_start_with_files (AudioStream * stream, RtpProfile *
*
* @param stream an AudioStream previously created with audio_stream_new().
* @param prof a RtpProfile containing all PayloadType possible during the audio session.
* @param remip remote IP address where to send the encoded audio.
* @param remport remote IP port where to send the encoded audio
* @param rem_rtp_ip remote IP address where to send the encoded audio.
* @param rem_rtp_port remote IP port where to send the encoded audio.
* @param rem_rtcp_ip remote IP address for RTCP.
* @param rem_rtcp_port remote port for RTCP.
* @param payload_type payload type index to use for the sending stream. This index must point to a valid PayloadType in the RtpProfile.
* @param jitt_comp Nominal jitter buffer size in milliseconds.
......@@ -144,8 +145,8 @@ MS2_PUBLIC int audio_stream_start_with_files (AudioStream * stream, RtpProfile *
* @param echo_cancel whether echo cancellation is to be performed.
* @returns 0 if sucessful, -1 otherwise.
**/
MS2_PUBLIC int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *remip,int remport,
int rem_rtcp_port, int payload,int jitt_comp, const char *infile, const char *outfile,
MS2_PUBLIC int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *rem_rtp_ip,int rem_rtp_port,
const char *rem_rtcp_ip, int rem_rtcp_port, int payload,int jitt_comp, const char *infile, const char *outfile,
MSSndCard *playcard, MSSndCard *captcard, bool_t use_ec);
MS2_PUBLIC void audio_stream_play(AudioStream *st, const char *name);
......@@ -336,7 +337,7 @@ MS2_PUBLIC void video_stream_enable_adaptive_bitrate_control(VideoStream *s, boo
MS2_PUBLIC void video_stream_set_render_callback(VideoStream *s, VideoStreamRenderCallback cb, void *user_pointer);
MS2_PUBLIC void video_stream_set_event_callback(VideoStream *s, VideoStreamEventCallback cb, void *user_pointer);
MS2_PUBLIC void video_stream_set_display_filter_name(VideoStream *s, const char *fname);
MS2_PUBLIC int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport, int rem_rtcp_port,
MS2_PUBLIC int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *rem_rtp_ip, int rem_rtp_port, const char *rem_rtcp_ip, int rem_rtcp_port,
int payload, int jitt_comp, MSWebCam *device);
......
......@@ -151,6 +151,7 @@ MS2_PUBLIC void ms_audio_conference_destroy(MSAudioConference *obj);
* audio_stream_start_full(st, conf->local_dummy_profile,
* "127.0.0.1",
* 65000,
* "127.0.0.1",
* 65001,
* 0,
* 40,
......
......@@ -208,15 +208,17 @@ static void audio_stream_process_rtcp(AudioStream *stream, mblk_t *m){
}
static void audio_stream_set_remote_from_ice(AudioStream *st){
char addr[64];
char rtp_addr[64];
char rtcp_addr[64];
int rtp_port = 0;
int rtcp_port = 0;
if (st->ice_check_list == NULL) return;
memset(addr, '\0', sizeof(addr));
ice_get_remote_addr_and_ports_from_valid_pairs(st->ice_check_list, addr, sizeof(addr), &rtp_port, &rtcp_port);
ms_message("audio_stream_set_remote_from_ice: addr=%s rtp_port=%u rtcp_port=%u", addr, rtp_port, rtcp_port);
rtp_session_set_remote_addr_full(st->session, addr, rtp_port, rtcp_port);
memset(rtp_addr, '\0', sizeof(rtp_addr));
memset(rtcp_addr, '\0', sizeof(rtcp_addr));
ice_get_remote_addr_and_ports_from_valid_pairs(st->ice_check_list, rtp_addr, &rtp_port, rtcp_addr, &rtcp_port, sizeof(rtp_addr));
ms_message("audio_stream_set_remote_from_ice: rtp_addr=%s rtp_port=%u rtcp_addr=%s rtcp_port=%u", rtp_addr, rtp_port, rtcp_addr, rtcp_port);
rtp_session_set_remote_addr_full(st->session, rtp_addr, rtp_port, rtcp_addr, rtcp_port);
}
void audio_stream_iterate(AudioStream *stream){
......@@ -349,8 +351,8 @@ void audio_stream_unprepare_sound(AudioStream *stream){
#endif
}
int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *remip,int remport,
int rem_rtcp_port, int payload,int jitt_comp, const char *infile, const char *outfile,
int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *rem_rtp_ip,int rem_rtp_port,
const char *rem_rtcp_ip, int rem_rtcp_port, int payload,int jitt_comp, const char *infile, const char *outfile,
MSSndCard *playcard, MSSndCard *captcard, bool_t use_ec)
{
RtpSession *rtps=stream->session;
......@@ -361,14 +363,14 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
MSRtpPayloadPickerContext picker_context;
rtp_session_set_profile(rtps,profile);
if (remport>0) rtp_session_set_remote_addr_full(rtps,remip,remport,rem_rtcp_port);
if (rem_rtp_port>0) rtp_session_set_remote_addr_full(rtps,rem_rtp_ip,rem_rtp_port,rem_rtcp_ip,rem_rtcp_port);
if (rem_rtcp_port<=0){
rtp_session_enable_rtcp(rtps,FALSE);
}
rtp_session_set_payload_type(rtps,payload);
rtp_session_set_jitter_compensation(rtps,jitt_comp);
if (remport>0)
if (rem_rtp_port>0)
ms_filter_call_method(stream->rtpsend,MS_RTP_SEND_SET_SESSION,rtps);
stream->rtprecv=ms_filter_new(MS_RTP_RECV_ID);
ms_filter_call_method(stream->rtprecv,MS_RTP_RECV_SET_SESSION,rtps);
......@@ -599,7 +601,7 @@ void audio_stream_enable_adaptive_bitrate_control(AudioStream *st, bool_t enable
int audio_stream_start_with_files(AudioStream *stream, RtpProfile *prof,const char *remip, int remport,
int rem_rtcp_port, int pt,int jitt_comp, const char *infile, const char * outfile)
{
return audio_stream_start_full(stream,prof,remip,remport,rem_rtcp_port,pt,jitt_comp,infile,outfile,NULL,NULL,FALSE);
return audio_stream_start_full(stream,prof,remip,remport,remip,rem_rtcp_port,pt,jitt_comp,infile,outfile,NULL,NULL,FALSE);
}
AudioStream * audio_stream_start(RtpProfile *prof,int locport,const char *remip,int remport,int profile,int jitt_comp,bool_t use_ec)
......@@ -612,7 +614,7 @@ AudioStream * audio_stream_start(RtpProfile *prof,int locport,const char *remip,
if (sndcard_capture==NULL || sndcard_playback==NULL)
return NULL;
stream=audio_stream_new(locport, locport+1, ms_is_ipv6(remip));
if (audio_stream_start_full(stream,prof,remip,remport,remport+1,profile,jitt_comp,NULL,NULL,sndcard_playback,sndcard_capture,use_ec)==0) return stream;
if (audio_stream_start_full(stream,prof,remip,remport,remip,remport+1,profile,jitt_comp,NULL,NULL,sndcard_playback,sndcard_capture,use_ec)==0) return stream;
audio_stream_free(stream);
return NULL;
}
......@@ -629,7 +631,7 @@ AudioStream *audio_stream_start_with_sndcards(RtpProfile *prof,int locport,const
return NULL;
}
stream=audio_stream_new(locport, locport+1, ms_is_ipv6(remip));
if (audio_stream_start_full(stream,prof,remip,remport,remport+1,profile,jitt_comp,NULL,NULL,playcard,captcard,use_ec)==0) return stream;
if (audio_stream_start_full(stream,prof,remip,remport,remip,remport+1,profile,jitt_comp,NULL,NULL,playcard,captcard,use_ec)==0) return stream;
audio_stream_free(stream);
return NULL;
}
......@@ -712,7 +714,7 @@ void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno){
}
int audio_stream_start_now(AudioStream *stream, RtpProfile * prof, const char *remip, int remport, int rem_rtcp_port, int payload_type, int jitt_comp, MSSndCard *playcard, MSSndCard *captcard, bool_t use_ec){
return audio_stream_start_full(stream,prof,remip,remport,rem_rtcp_port,
return audio_stream_start_full(stream,prof,remip,remport,remip,rem_rtcp_port,
payload_type,jitt_comp,NULL,NULL,playcard,captcard,use_ec);
}
......
......@@ -84,7 +84,8 @@ typedef struct _LocalCandidate_RemoteCandidate {
} LocalCandidate_RemoteCandidate;
typedef struct _Addr_Ports {
char *addr;
char *rtp_addr;
char *rtcp_addr;
int addr_len;
int *rtp_port;
int *rtcp_port;
......@@ -2063,18 +2064,20 @@ static MSList * ice_get_valid_pairs(const IceCheckList *cl)
static void ice_get_remote_addr_and_ports_from_valid_pair(const IceCandidatePair *pair, Addr_Ports *addr_ports)
{
if (pair->local->componentID == 1) {
strncpy(addr_ports->addr, pair->remote->taddr.ip, addr_ports->addr_len);
strncpy(addr_ports->rtp_addr, pair->remote->taddr.ip, addr_ports->addr_len);
*(addr_ports->rtp_port) = pair->remote->taddr.port;
} else if (pair->local->componentID == 2) {
strncpy(addr_ports->rtcp_addr, pair->remote->taddr.ip, addr_ports->addr_len);
*(addr_ports->rtcp_port) = pair->remote->taddr.port;
}
}
void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *addr, int addr_len, int *rtp_port, int *rtcp_port)
void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *rtp_addr, int *rtp_port, char *rtcp_addr, int *rtcp_port, int addr_len)
{
Addr_Ports addr_ports;
MSList *ice_pairs = ice_get_valid_pairs(cl);
addr_ports.addr = addr;
addr_ports.rtp_addr = rtp_addr;
addr_ports.rtcp_addr = rtcp_addr;
addr_ports.addr_len = addr_len;
addr_ports.rtp_port = rtp_port;
addr_ports.rtcp_port = rtcp_port;
......@@ -2085,18 +2088,20 @@ void ice_get_remote_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char
static void ice_get_local_addr_and_ports_from_valid_pair(const IceCandidatePair *pair, Addr_Ports *addr_ports)
{
if (pair->local->componentID == 1) {
strncpy(addr_ports->addr, pair->local->taddr.ip, addr_ports->addr_len);
strncpy(addr_ports->rtp_addr, pair->local->taddr.ip, addr_ports->addr_len);
*(addr_ports->rtp_port) = pair->local->taddr.port;
} else if (pair->local->componentID == 2) {
strncpy(addr_ports->rtcp_addr, pair->local->taddr.ip, addr_ports->addr_len);
*(addr_ports->rtcp_port) = pair->local->taddr.port;
}
}
static void ice_get_local_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *addr, int addr_len, int *rtp_port, int *rtcp_port)
static void ice_get_local_addr_and_ports_from_valid_pairs(const IceCheckList *cl, char *rtp_addr, int *rtp_port, char *rtcp_addr, int *rtcp_port, int addr_len)
{
Addr_Ports addr_ports;
MSList *ice_pairs = ice_get_valid_pairs(cl);
addr_ports.addr = addr;
addr_ports.rtp_addr = rtp_addr;
addr_ports.rtcp_addr = rtcp_addr;
addr_ports.addr_len = addr_len;
addr_ports.rtp_port = rtp_port;
addr_ports.rtcp_port = rtcp_port;
......@@ -2106,18 +2111,20 @@ static void ice_get_local_addr_and_ports_from_valid_pairs(const IceCheckList *cl
void ice_check_list_print_route(const IceCheckList *cl, const char *message)
{
char local_addr[64];
char remote_addr[64];
char local_rtp_addr[64], local_rtcp_addr[64];
char remote_rtp_addr[64], remote_rtcp_addr[64];
int local_rtp_port, local_rtcp_port;
int remote_rtp_port, remote_rtcp_port;
if (cl->state == ICL_Completed) {
memset(local_addr, '\0', sizeof(local_addr));
memset(remote_addr, '\0', sizeof(remote_addr));
ice_get_remote_addr_and_ports_from_valid_pairs(cl, remote_addr, sizeof(remote_addr), &remote_rtp_port, &remote_rtcp_port);
ice_get_local_addr_and_ports_from_valid_pairs(cl, local_addr, sizeof(local_addr), &local_rtp_port, &local_rtcp_port);
memset(local_rtp_addr, '\0', sizeof(local_rtp_addr));
memset(local_rtcp_addr, '\0', sizeof(local_rtcp_addr));
memset(remote_rtp_addr, '\0', sizeof(remote_rtp_addr));
memset(remote_rtcp_addr, '\0', sizeof(remote_rtcp_addr));
ice_get_remote_addr_and_ports_from_valid_pairs(cl, remote_rtp_addr, &remote_rtp_port, remote_rtcp_addr, &remote_rtcp_port, sizeof(remote_rtp_addr));
ice_get_local_addr_and_ports_from_valid_pairs(cl, local_rtp_addr, &local_rtp_port, local_rtcp_addr, &local_rtcp_port, sizeof(local_rtp_addr));
ms_message("%s", message);
ms_message("\tRTP: %s:%u --> %s:%u", local_addr, local_rtp_port, remote_addr, remote_rtp_port);
ms_message("\tRTCP: %s:%u --> %s:%u", local_addr, local_rtcp_port, remote_addr, remote_rtcp_port);
ms_message("\tRTP: %s:%u --> %s:%u", local_rtp_addr, local_rtp_port, remote_rtp_addr, remote_rtp_port);
ms_message("\tRTCP: %s:%u --> %s:%u", local_rtcp_addr, local_rtcp_port, remote_rtcp_addr, remote_rtcp_port);
}
}
......
......@@ -156,15 +156,17 @@ static void video_steam_process_rtcp(VideoStream *stream, mblk_t *m){
}
static void video_stream_set_remote_from_ice(VideoStream *stream){
char addr[64];
char rtp_addr[64];
char rtcp_addr[64];
int rtp_port = 0;
int rtcp_port = 0;
if (stream->ice_check_list == NULL) return;
memset(addr, '\0', sizeof(addr));
ice_get_remote_addr_and_ports_from_valid_pairs(stream->ice_check_list, addr, sizeof(addr), &rtp_port, &rtcp_port);
ms_message("video_stream_set_remote_from_ice: addr=%s rtp_port=%u rtcp_port=%u", addr, rtp_port, rtcp_port);
rtp_session_set_remote_addr_full(stream->session, addr, rtp_port, rtcp_port);
memset(rtp_addr, '\0', sizeof(rtp_addr));
memset(rtcp_addr, '\0', sizeof(rtcp_addr));
ice_get_remote_addr_and_ports_from_valid_pairs(stream->ice_check_list, rtp_addr, &rtp_port, rtcp_addr, &rtcp_port, sizeof(rtp_addr));
ms_message("video_stream_set_remote_from_ice: rtp_addr=%s rtp_port=%u rtcp_addr=%s rtcp_port=%u", rtp_addr, rtp_port, rtcp_addr, rtcp_port);
rtp_session_set_remote_addr_full(stream->session, rtp_addr, rtp_port, rtcp_addr, rtcp_port);
}
void video_stream_iterate(VideoStream *stream){
......@@ -367,8 +369,8 @@ static void configure_video_source(VideoStream *stream){
}
}
int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *remip, int remport,
int rem_rtcp_port, int payload, int jitt_comp, MSWebCam *cam){
int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *rem_rtp_ip, int rem_rtp_port,
const char *rem_rtcp_ip, int rem_rtcp_port, int payload, int jitt_comp, MSWebCam *cam){
PayloadType *pt;
RtpSession *rtps=stream->session;
MSPixFmt format;
......@@ -389,7 +391,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
}
rtp_session_set_profile(rtps,profile);
if (remport>0) rtp_session_set_remote_addr_full(rtps,remip,remport,rem_rtcp_port);
if (rem_rtp_port>0) rtp_session_set_remote_addr_full(rtps,rem_rtp_ip,rem_rtp_port,rem_rtcp_ip,rem_rtcp_port);
rtp_session_set_payload_type(rtps,payload);
rtp_session_set_jitter_compensation(rtps,jitt_comp);
......@@ -405,7 +407,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
if (stream->dir==VideoStreamSendRecv || stream->dir==VideoStreamSendOnly){
/*plumb the outgoing stream */
if (remport>0) ms_filter_call_method(stream->rtpsend,MS_RTP_SEND_SET_SESSION,stream->session);
if (rem_rtp_port>0) ms_filter_call_method(stream->rtpsend,MS_RTP_SEND_SET_SESSION,stream->session);
stream->encoder=ms_filter_create_encoder(pt->mime_type);
if ((stream->encoder==NULL) ){
/* big problem: we don't have a registered codec for this payload...*/
......@@ -755,14 +757,14 @@ void video_preview_stop(VideoStream *stream){
int video_stream_recv_only_start(VideoStream *videostream, RtpProfile *profile, const char *addr, int port, int used_pt, int jitt_comp){
video_stream_set_direction(videostream,VideoStreamRecvOnly);
return video_stream_start(videostream,profile,addr,port,port+1,used_pt,jitt_comp,NULL);
return video_stream_start(videostream,profile,addr,port,addr,port+1,used_pt,jitt_comp,NULL);
}
int video_stream_send_only_start(VideoStream *videostream,
RtpProfile *profile, const char *addr, int port, int rtcp_port,
int used_pt, int jitt_comp, MSWebCam *device){
video_stream_set_direction (videostream,VideoStreamSendOnly);
return video_stream_start(videostream,profile,addr,port,rtcp_port,used_pt,jitt_comp,device);
return video_stream_start(videostream,profile,addr,port,addr,rtcp_port,used_pt,jitt_comp,device);
}
......
......@@ -134,6 +134,7 @@ int init_bench(struct bench_config *bench)
rtp_session_set_remote_addr_full(ts->rtps,
bench->ip_destination,
bench->port_destination+pos*2,
bench->ip_destination,
bench->port_destination+1+pos*2);
ts->fplayer = ms_filter_new(MS_FILE_PLAYER_ID);
......
......@@ -601,7 +601,7 @@ void setup_media_streams(MediastreamDatas* args) {
audio_stream_enable_adaptive_bitrate_control(args->audio,args->use_rc);
printf("Starting audio stream.\n");
audio_stream_start_full(args->audio,args->profile,args->ip,args->remoteport,args->remoteport+1, args->payload, args->jitter,args->infile,args->outfile,
audio_stream_start_full(args->audio,args->profile,args->ip,args->remoteport,args->ip,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) {
......@@ -701,8 +701,8 @@ void setup_media_streams(MediastreamDatas* args) {
if (cam==NULL)
cam=ms_web_cam_manager_get_default_cam(ms_web_cam_manager_get());
video_stream_start(args->video,args->profile,
args->ip,
args->remoteport,args->remoteport+1,
args->ip,args->remoteport,
args->ip,args->remoteport+1,
args->payload,
args->jitter,cam
);
......
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