Commit fc9a7518 authored by Ghislain MARY's avatar Ghislain MARY

Use audio_stream_prepare_sound() to gather ICE candidates so that ICE should work on IOS.

parent d5f95918
......@@ -150,7 +150,6 @@ MS2_PUBLIC int audio_stream_start_full(AudioStream *stream, RtpProfile *profile,
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_start_ice_gathering(AudioStream *stream);
MS2_PUBLIC void audio_stream_play(AudioStream *st, const char *name);
MS2_PUBLIC void audio_stream_record(AudioStream *st, const char *name);
......@@ -343,7 +342,8 @@ MS2_PUBLIC void video_stream_set_event_callback(VideoStream *s, VideoStreamEvent
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 *rem_rtp_ip, int rem_rtp_port, const char *rem_rtcp_ip, int rem_rtcp_port,
int payload, int jitt_comp, MSWebCam *device);
MS2_PUBLIC void video_stream_start_ice_gathering(VideoStream *stream);
MS2_PUBLIC void video_stream_prepare_video(VideoStream *stream);
MS2_PUBLIC void video_stream_unprepare_video(VideoStream *stream);
MS2_PUBLIC void video_stream_set_relay_session_id(VideoStream *stream, const char *relay_session_id);
......
......@@ -318,46 +318,56 @@ static void start_ticker(AudioStream *stream){
static void stop_preload_graph(AudioStream *stream){
ms_ticker_detach(stream->ticker,stream->dummy);
ms_filter_unlink(stream->dummy,0,stream->soundwrite,0);
if (stream->soundwrite) {
ms_filter_unlink(stream->dummy,0,stream->soundwrite,0);
}
if (stream->voidsink) {
ms_filter_unlink(stream->dummy,0,stream->voidsink,0);
ms_filter_destroy(stream->voidsink);
stream->voidsink=NULL;
}
ms_filter_destroy(stream->dummy);
stream->dummy=NULL;
}
static void stop_ice_gathering_graph(AudioStream *stream){
ms_ticker_detach(stream->ticker,stream->voidsink);
ms_filter_unlink(stream->rtprecv,0,stream->voidsink,0);
ms_filter_destroy(stream->voidsink);
ms_filter_destroy(stream->rtprecv);
stream->voidsink=stream->rtprecv=NULL;
}
bool_t audio_stream_started(AudioStream *stream){
return stream->start_time!=0;
}
/* This function is used either on IOS to workaround the long time to initialize the Audio Unit or for ICE candidates gathering. */
void audio_stream_prepare_sound(AudioStream *stream, MSSndCard *playcard, MSSndCard *captcard){
#ifdef __ios
audio_stream_unprepare_sound(stream);
stream->dummy=ms_filter_new(MS_RTP_RECV_ID);
rtp_session_set_payload_type(stream->session,0);
ms_filter_call_method(stream->dummy,MS_RTP_RECV_SET_SESSION,stream->session);
if (captcard && playcard){
#ifdef __ios
stream->soundread=ms_snd_card_create_reader(captcard);
stream->soundwrite=ms_snd_card_create_writer(playcard);
stream->dummy=ms_filter_new(MS_FILE_PLAYER_ID);
ms_filter_link(stream->dummy,0,stream->soundwrite,0);
start_ticker(stream);
ms_ticker_attach(stream->ticker,stream->dummy);
}
#else
stream->voidsink=ms_filter_new(MS_VOID_SINK_ID);
ms_filter_link(stream->dummy,0,stream->voidsink,0);
#endif
} else {
stream->voidsink=ms_filter_new(MS_VOID_SINK_ID);
ms_filter_link(stream->dummy,0,stream->voidsink,0);
}
start_ticker(stream);
ms_ticker_attach(stream->ticker,stream->dummy);
}
void audio_stream_unprepare_sound(AudioStream *stream){
#ifdef __ios
if (stream->dummy){
stop_preload_graph(stream);
#ifdef __ios
ms_filter_destroy(stream->soundread);
stream->soundread=NULL;
ms_filter_destroy(stream->soundwrite);
stream->soundwrite=NULL;
}
#endif
}
}
int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *rem_rtp_ip,int rem_rtp_port,
......@@ -727,17 +737,6 @@ int audio_stream_start_now(AudioStream *stream, RtpProfile * prof, const char *
payload_type,jitt_comp,NULL,NULL,playcard,captcard,use_ec);
}
void audio_stream_start_ice_gathering(AudioStream *stream)
{
if (stream->ticker==NULL) start_ticker(stream);
stream->voidsink=ms_filter_new(MS_VOID_SINK_ID);
stream->rtprecv=ms_filter_new(MS_RTP_RECV_ID);
rtp_session_set_payload_type(stream->session,0);
ms_filter_call_method(stream->rtprecv,MS_RTP_RECV_SET_SESSION,stream->session);
ms_filter_link(stream->rtprecv,0,stream->voidsink,0);
ms_ticker_attach(stream->ticker,stream->rtprecv);
}
void audio_stream_set_relay_session_id(AudioStream *stream, const char *id){
ms_filter_call_method(stream->rtpsend, MS_RTP_SEND_SET_RELAY_SESSION_ID,(void*)id);
}
......@@ -814,8 +813,6 @@ void audio_stream_stop(AudioStream * stream)
if (stream->dummy){
stop_preload_graph(stream);
}else if (stream->voidsink){
stop_ice_gathering_graph(stream);
}else if (stream->start_time!=0){
ms_ticker_detach(stream->ticker,stream->soundread);
......
......@@ -157,8 +157,8 @@ static void video_steam_process_rtcp(VideoStream *stream, mblk_t *m){
}while(rtcp_next_packet(m));
}
static void stop_ice_gathering_graph(VideoStream *stream){
ms_ticker_detach(stream->ticker,stream->voidsink);
static void stop_preload_graph(VideoStream *stream){
ms_ticker_detach(stream->ticker,stream->rtprecv);
ms_filter_unlink(stream->rtprecv,0,stream->voidsink,0);
ms_filter_destroy(stream->voidsink);
ms_filter_destroy(stream->rtprecv);
......@@ -541,7 +541,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
}
/* create the ticker */
start_ticker(stream);
if (stream->ticker==NULL) start_ticker(stream);
/* attach the graphs */
if (stream->source)
......@@ -551,16 +551,23 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
return 0;
}
void video_stream_start_ice_gathering(VideoStream *stream){
if (stream->ticker==NULL) start_ticker(stream);
stream->voidsink=ms_filter_new(MS_VOID_SINK_ID);
void video_stream_prepare_video(VideoStream *stream){
video_stream_unprepare_video(stream);
stream->rtprecv=ms_filter_new(MS_RTP_RECV_ID);
rtp_session_set_payload_type(stream->session,0);
ms_filter_call_method(stream->rtprecv,MS_RTP_RECV_SET_SESSION,stream->session);
stream->voidsink=ms_filter_new(MS_VOID_SINK_ID);
ms_filter_link(stream->rtprecv,0,stream->voidsink,0);
start_ticker(stream);
ms_ticker_attach(stream->ticker,stream->rtprecv);
}
void video_stream_unprepare_video(VideoStream *stream){
if (stream->voidsink) {
stop_preload_graph(stream);
}
}
void video_stream_update_video_params(VideoStream *stream){
/*calling video_stream_change_camera() does the job of unplumbing/replumbing and configuring the new graph*/
video_stream_change_camera(stream,stream->cam);
......@@ -618,7 +625,7 @@ video_stream_stop (VideoStream * stream)
stream->event_pointer = NULL;
if (stream->ticker){
if (stream->voidsink) {
stop_ice_gathering_graph(stream);
stop_preload_graph(stream);
} else {
if (stream->source)
ms_ticker_detach(stream->ticker,stream->source);
......
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