Commit d5014c8d authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Merge branch 'dev_ice'

parents 0a55eafa 539893ee
......@@ -7,7 +7,6 @@ extern MSFilterDesc ms_ulaw_enc_desc;
extern MSFilterDesc ms_rtp_send_desc;
extern MSFilterDesc ms_rtp_recv_desc;
extern MSFilterDesc ms_dtmf_gen_desc;
extern MSFilterDesc ms_ice_desc;
extern MSFilterDesc ms_tee_desc;
extern MSFilterDesc ms_conf_desc;
extern MSFilterDesc ms_join_desc;
......@@ -51,7 +50,6 @@ MSFilterDesc * ms_filter_descs[]={
&ms_rtp_send_desc,
&ms_rtp_recv_desc,
&ms_dtmf_gen_desc,
&ms_ice_desc,
&ms_tee_desc,
&ms_conf_desc,
&ms_join_desc,
......
......@@ -7,7 +7,6 @@ extern MSFilterDesc ms_ulaw_enc_desc;
extern MSFilterDesc ms_rtp_send_desc;
extern MSFilterDesc ms_rtp_recv_desc;
extern MSFilterDesc ms_dtmf_gen_desc;
extern MSFilterDesc ms_ice_desc;
extern MSFilterDesc ms_tee_desc;
extern MSFilterDesc ms_conf_desc;
extern MSFilterDesc ms_join_desc;
......@@ -59,7 +58,6 @@ MSFilterDesc * ms_filter_descs[]={
&ms_rtp_send_desc,
&ms_rtp_recv_desc,
&ms_dtmf_gen_desc,
&ms_ice_desc,
&ms_tee_desc,
&ms_conf_desc,
&ms_join_desc,
......
......@@ -29,7 +29,6 @@ extern MSFilterDesc ms_conf_desc;
extern MSFilterDesc ms_join_desc;
extern MSFilterDesc ms_resample_desc;
extern MSFilterDesc ms_volume_desc;
extern MSFilterDesc ms_ice_desc;
extern MSFilterDesc ms_equalizer_desc;
MSFilterDesc * ms_filter_descs[]={
&ms_alaw_dec_desc,
......@@ -63,7 +62,6 @@ MSFilterDesc * ms_filter_descs[]={
&ms_resample_desc,
#endif
&ms_volume_desc,
&ms_ice_desc,
&ms_equalizer_desc,
NULL
};
......
......@@ -40,7 +40,6 @@ extern MSFilterDesc ms_volume_desc;
extern MSFilterDesc ms_static_image_desc;
extern MSFilterDesc ms_mire_desc;
extern MSFilterDesc ms_vfw_desc;
extern MSFilterDesc ms_ice_desc;
extern MSFilterDesc ms_equalizer_desc;
extern MSFilterDesc ms_dd_display_desc;
extern MSFilterDesc ms_itc_source_desc;
......@@ -96,7 +95,6 @@ MSFilterDesc * ms_filter_descs[]={
&ms_volume_desc,
&ms_static_image_desc,
&ms_mire_desc,
&ms_ice_desc,
&ms_equalizer_desc,
&ms_dd_display_desc,
&ms_itc_source_desc,
......
......@@ -29,7 +29,6 @@ extern MSFilterDesc ms_conf_desc;
extern MSFilterDesc ms_join_desc;
extern MSFilterDesc ms_resample_desc;
extern MSFilterDesc ms_volume_desc;
extern MSFilterDesc ms_ice_desc;
extern MSFilterDesc ms_void_sink_desc;
MSFilterDesc * ms_filter_descs[]={
&ms_alaw_dec_desc,
......@@ -61,7 +60,6 @@ MSFilterDesc * ms_filter_descs[]={
&ms_join_desc,
&ms_resample_desc,
&ms_volume_desc,
&ms_ice_desc,
&ms_void_sink_desc,
NULL
};
......
......@@ -29,7 +29,6 @@ extern MSFilterDesc ms_conf_desc;
extern MSFilterDesc ms_join_desc;
extern MSFilterDesc ms_resample_desc;
extern MSFilterDesc ms_volume_desc;
extern MSFilterDesc ms_ice_desc;
extern MSFilterDesc ms_void_sink_desc;
MSFilterDesc * ms_filter_descs[]={
&ms_alaw_dec_desc,
......@@ -61,7 +60,6 @@ MSFilterDesc * ms_filter_descs[]={
&ms_join_desc,
&ms_resample_desc,
&ms_volume_desc,
&ms_ice_desc,
&ms_void_sink_desc,
NULL
};
......
......@@ -12,7 +12,7 @@ MEDIASTREAMER_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
MEDIASTREAMER_MICRO_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f3)
MEDIASTREAMER_EXTRA_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f4)
LIBMEDIASTREAMER_SO_CURRENT=1 dnl increment this number when you add/change/remove an interface
LIBMEDIASTREAMER_SO_CURRENT=2 dnl increment this number when you add/change/remove an interface
LIBMEDIASTREAMER_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
LIBMEDIASTREAMER_SO_AGE=0 dnl increment this number when you add an interface, set to 0 if you remove an interface
......
......@@ -81,7 +81,6 @@ typedef enum MSFilterId{
MS_H263_OLD_ENC_ID,
MS_MIRE_ID,
MS_VFW_ID,
MS_ICE_ID,
MS_VOID_SINK_ID,
MS_DSCAP_ID,
MS_AQ_READ_ID,
......
This diff is collapsed.
......@@ -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;
......@@ -63,6 +65,7 @@ struct _AudioStream
MSFilter *write_resampler;
MSFilter *equalizer;
MSFilter *dummy;
MSFilter *voidsink;
uint64_t last_packet_count;
time_t last_packet_time;
EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/
......@@ -130,8 +133,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.
......@@ -142,10 +146,11 @@ 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);
MS2_PUBLIC void audio_stream_record(AudioStream *st, const char *name);
......@@ -155,11 +160,12 @@ MS2_PUBLIC void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno);
/**
* Creates an AudioStream object listening on a RTP port.
* @param locport the local UDP port to listen for RTP packets.
* @param loc_rtp_port the local UDP port to listen for RTP packets.
* @param loc_rtcp_port the local UDP port to listen for RTCP packets
* @param ipv6 TRUE if ipv6 must be used.
* @returns a new AudioStream.
**/
MS2_PUBLIC AudioStream *audio_stream_new(int locport, bool_t ipv6);
MS2_PUBLIC AudioStream *audio_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6);
#define AUDIO_STREAM_FEATURE_PLC (1 << 0)
#define AUDIO_STREAM_FEATURE_EC (1 << 1)
......@@ -288,6 +294,7 @@ struct _VideoStream
{
MSTicker *ticker;
RtpSession *session;
IceCheckList *ice_check_list;
MSFilter *source;
MSFilter *pixconv;
MSFilter *sizeconv;
......@@ -300,6 +307,7 @@ struct _VideoStream
MSFilter *tee2;
MSFilter *jpegwriter;
MSFilter *output2;
MSFilter *voidsink;
OrtpEvQueue *evq;
MSVideoSize sent_vsize;
int corner; /*for selfview*/
......@@ -326,14 +334,16 @@ typedef struct _VideoStream VideoStream;
MS2_PUBLIC VideoStream *video_stream_new(int locport, bool_t use_ipv6);
MS2_PUBLIC VideoStream *video_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t use_ipv6);
MS2_PUBLIC void video_stream_set_direction(VideoStream *vs, VideoStreamDir dir);
MS2_PUBLIC void video_stream_enable_adaptive_bitrate_control(VideoStream *s, bool_t yesno);
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);
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);
......
......@@ -147,10 +147,11 @@ MS2_PUBLIC void ms_audio_conference_destroy(MSAudioConference *obj);
* with the audiostream and is_remote=FALSE.<br>
* For example:<br>
* <PRE>
* AudioStream *st=audio_stream_new(65000,FALSE);
* AudioStream *st=audio_stream_new(65000,65001,FALSE);
* audio_stream_start_full(st, conf->local_dummy_profile,
* "127.0.0.1",
* 65000,
* "127.0.0.1",
* 65001,
* 0,
* 40,
......
......@@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define msrtp_hh
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/ice.h>
#include <ortp/ortp.h>
#define MS_RTP_RECV_SET_SESSION MS_FILTER_METHOD(MS_RTP_RECV_ID,0,RtpSession*)
......
......@@ -33,7 +33,7 @@ libmediastreamer_la_SOURCES= mscommon.c $(GITVERSION_FILE) \
mssndcard.c \
msrtp.c \
dtmfgen.c \
ice.c \
ice.c \
tee.c \
msconf.c \
msjoin.c \
......
......@@ -73,6 +73,7 @@ void audio_stream_free(AudioStream *stream)
if (stream->write_resampler!=NULL) ms_filter_destroy(stream->write_resampler);
if (stream->dtmfgen_rtp!=NULL) ms_filter_destroy(stream->dtmfgen_rtp);
if (stream->dummy) ms_filter_destroy(stream->dummy);
if (stream->voidsink) ms_filter_destroy(stream->voidsink);
if (stream->rc) ms_bitrate_controller_destroy(stream->rc);
if (stream->qi) ms_quality_indicator_destroy(stream->qi);
ms_free(stream);
......@@ -154,7 +155,7 @@ MSTickerPrio __ms_get_default_prio(bool_t is_video){
#endif
}
RtpSession * create_duplex_rtpsession( int locport, bool_t ipv6){
RtpSession * create_duplex_rtpsession( int loc_rtp_port, int loc_rtcp_port, bool_t ipv6){
RtpSession *rtpr;
rtpr=rtp_session_new(RTP_SESSION_SENDRECV);
rtp_session_set_recv_buf_size(rtpr,MAX_RTP_SIZE);
......@@ -162,7 +163,7 @@ RtpSession * create_duplex_rtpsession( int locport, bool_t ipv6){
rtp_session_set_blocking_mode(rtpr,0);
rtp_session_enable_adaptive_jitter_compensation(rtpr,TRUE);
rtp_session_set_symmetric_rtp(rtpr,TRUE);
rtp_session_set_local_addr(rtpr,ipv6 ? "::" : "0.0.0.0",locport);
rtp_session_set_local_addr(rtpr,ipv6 ? "::" : "0.0.0.0",loc_rtp_port,loc_rtcp_port);
rtp_session_signal_connect(rtpr,"timestamp_jump",(RtpCallback)rtp_session_resync,(long)NULL);
rtp_session_signal_connect(rtpr,"ssrc_changed",(RtpCallback)rtp_session_resync,(long)NULL);
rtp_session_set_ssrc_changed_threshold(rtpr,0);
......@@ -223,10 +224,13 @@ 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)&&(stream->ice_check_list)){
ice_handle_stun_packet(stream->ice_check_list,stream->session,ortp_event_get_data(ev));
}
ortp_event_destroy(ev);
}
}
if (stream->ice_check_list) ice_check_list_process(stream->ice_check_list,stream->session);
}
bool_t audio_stream_alive(AudioStream * stream, int timeout){
......@@ -298,7 +302,14 @@ 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;
}
......@@ -307,33 +318,44 @@ 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 *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;
......@@ -344,14 +366,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);
......@@ -523,7 +545,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
if (stream->ticker==NULL) start_ticker(stream);
else{
/*we were using the dummy preload graph, destroy it*/
stop_preload_graph(stream);
if (stream->dummy) stop_preload_graph(stream);
}
/* and then connect all */
......@@ -580,7 +602,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)
......@@ -592,8 +614,8 @@ AudioStream * audio_stream_start(RtpProfile *prof,int locport,const char *remip,
sndcard_playback=ms_snd_card_manager_get_default_playback_card(ms_snd_card_manager_get());
if (sndcard_capture==NULL || sndcard_playback==NULL)
return NULL;
stream=audio_stream_new(locport, 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;
stream=audio_stream_new(locport, locport+1, ms_is_ipv6(remip));
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;
}
......@@ -609,8 +631,8 @@ AudioStream *audio_stream_start_with_sndcards(RtpProfile *prof,int locport,const
ms_error("No capture card.");
return NULL;
}
stream=audio_stream_new(locport, 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;
stream=audio_stream_new(locport, locport+1, ms_is_ipv6(remip));
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;
}
......@@ -661,17 +683,18 @@ void audio_stream_set_features(AudioStream *st, uint32_t features){
st->features = features;
}
AudioStream *audio_stream_new(int locport, bool_t ipv6){
AudioStream *audio_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6){
AudioStream *stream=(AudioStream *)ms_new0(AudioStream,1);
MSFilterDesc *ec_desc=ms_filter_lookup_by_name("MSOslec");
ms_filter_enable_statistics(TRUE);
ms_filter_reset_statistics();
stream->session=create_duplex_rtpsession(locport,ipv6);
stream->session=create_duplex_rtpsession(loc_rtp_port,loc_rtcp_port,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=NULL;
if (ec_desc!=NULL)
stream->ec=ms_filter_new_from_desc(ec_desc);
else
......@@ -692,7 +715,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);
}
......@@ -777,6 +800,7 @@ void audio_stream_stop(AudioStream * stream)
ms_ticker_detach(stream->ticker,stream->soundread);
ms_ticker_detach(stream->ticker,stream->rtprecv);
if (stream->ice_check_list != NULL) ice_check_list_print_route(stream->ice_check_list, "Audio session's route");
rtp_stats_display(rtp_session_get_stats(stream->session),"Audio session's RTP statistics");
/*dismantle the outgoing graph*/
......
This diff is collapsed.
......@@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern RtpSession * create_duplex_rtpsession( int locport, bool_t ipv6);
extern RtpSession * create_duplex_rtpsession( int loc_rtp_port, int loc_rtcp_port, bool_t ipv6);
#define MAX_RTP_SIZE UDP_MAX_SIZE
......@@ -69,6 +69,8 @@ void video_stream_free (VideoStream * stream)
ms_filter_destroy(stream->jpegwriter);
if (stream->output2!=NULL)
ms_filter_destroy(stream->output2);
if (stream->voidsink!=NULL)
ms_filter_destroy(stream->voidsink);
if (stream->ticker != NULL)
ms_ticker_destroy (stream->ticker);
if (stream->evq!=NULL)
......@@ -155,6 +157,14 @@ static void video_steam_process_rtcp(VideoStream *stream, mblk_t *m){
}while(rtcp_next_packet(m));
}
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);
stream->voidsink=stream->rtprecv=NULL;
}
void video_stream_iterate(VideoStream *stream){
/*
if (stream->output!=NULL)
......@@ -168,10 +178,13 @@ 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) && (stream->ice_check_list)) {
ice_handle_stun_packet(stream->ice_check_list,stream->session,ortp_event_get_data(ev));
}
ortp_event_destroy(ev);
}
}
if (stream->ice_check_list) ice_check_list_process(stream->ice_check_list,stream->session);
}
static void payload_type_changed(RtpSession *session, unsigned long data){
......@@ -198,11 +211,12 @@ static void choose_display_name(VideoStream *stream){
#endif
}
VideoStream *video_stream_new(int locport, bool_t use_ipv6){
VideoStream *video_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t use_ipv6){
VideoStream *stream = (VideoStream *)ms_new0 (VideoStream, 1);
stream->session=create_duplex_rtpsession(locport,use_ipv6);
stream->session=create_duplex_rtpsession(loc_rtp_port,loc_rtcp_port,use_ipv6);
stream->evq=ortp_ev_queue_new();
stream->rtpsend=ms_filter_new(MS_RTP_SEND_ID);
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;
......@@ -349,8 +363,19 @@ 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){
static void start_ticker(VideoStream *stream){
MSTickerParams params={0};
params.name="Video MSTicker";
#ifdef __ios
params.prio=MS_TICKER_PRIO_HIGH;
#else
params.prio=MS_TICKER_PRIO_NORMAL;
#endif
stream->ticker = ms_ticker_new_with_params(&params);
}
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;
......@@ -371,7 +396,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);
......@@ -387,7 +412,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...*/
......@@ -500,14 +525,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
}
/* create the ticker */
MSTickerParams params={0};
params.name="Video MSTicker";
#ifdef __ios
params.prio=MS_TICKER_PRIO_HIGH;
#else
params.prio=MS_TICKER_PRIO_NORMAL;
#endif
stream->ticker = ms_ticker_new_with_params(&params);
if (stream->ticker==NULL) start_ticker(stream);
/* attach the graphs */
if (stream->source)
......@@ -517,6 +535,23 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
return 0;
}
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);
......@@ -573,36 +608,41 @@ video_stream_stop (VideoStream * stream)
stream->eventcb = NULL;
stream->event_pointer = NULL;
if (stream->ticker){
if (stream->source)
ms_ticker_detach(stream->ticker,stream->source);
if (stream->rtprecv)
ms_ticker_detach(stream->ticker,stream->rtprecv);
rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics");
if (stream->source){
ms_filter_unlink(stream->source,0,stream->pixconv,0);
ms_filter_unlink (stream->pixconv, 0, stream->sizeconv, 0);
ms_filter_unlink (stream->sizeconv, 0, stream->tee, 0);
ms_filter_unlink(stream->tee,0,stream->encoder,0);
ms_filter_unlink(stream->encoder, 0, stream->rtpsend,0);
if (stream->output2){
ms_filter_unlink(stream->tee,1,stream->output2,0);
if (stream->voidsink) {
stop_preload_graph(stream);
} else {
if (stream->source)
ms_ticker_detach(stream->ticker,stream->source); </