static void init_video_streams(video_stream_tester_t *vst1, video_stream_tester_t *vst2, bool_t avpf, bool_t one_way, OrtpNetworkSimulatorParams *params, int payload_type) { PayloadType *pt; create_video_stream(vst1, payload_type); create_video_stream(vst2, payload_type); /* Enable/disable avpf. */ pt = rtp_profile_get_payload(&rtp_profile, payload_type); CU_ASSERT_PTR_NOT_NULL_FATAL(pt); if (avpf == TRUE) { payload_type_set_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); } else { payload_type_unset_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); } /* Configure network simulator. */ if ((params != NULL) && (params->enabled == TRUE)) { rtp_session_enable_network_simulation(vst1->vs->ms.sessions.rtp_session, params); rtp_session_enable_network_simulation(vst2->vs->ms.sessions.rtp_session, params); } if (one_way == TRUE) { video_stream_set_direction(vst1->vs, VideoStreamRecvOnly); } CU_ASSERT_EQUAL(video_stream_start(vst1->vs, &rtp_profile, vst2->local_ip, vst2->local_rtp, vst2->local_ip, vst2->local_rtcp, payload_type, 50, vst1->cam), 0); CU_ASSERT_EQUAL(video_stream_start(vst2->vs, &rtp_profile, vst1->local_ip, vst1->local_rtp, vst1->local_ip, vst1->local_rtcp, payload_type, 50, vst2->cam), 0); }
static void start_adaptive_stream(StreamType type, stream_manager_t ** pmarielle, stream_manager_t ** pmargaux, int payload, int initial_bitrate, int target_bw, float loss_rate, int latency, float dup_ratio) { OrtpNetworkSimulatorParams params={0}; params.enabled=TRUE; params.loss_rate=loss_rate; params.max_bandwidth=target_bw; params.latency=latency; int pause_time=0; MediaStream *marielle_ms,*margaux_ms; #if VIDEO_ENABLED MSWebCam * marielle_webcam=ms_web_cam_manager_get_default_cam (ms_web_cam_manager_get()); #endif stream_manager_t *marielle=*pmarielle=stream_manager_new(type); stream_manager_t *margaux=*pmargaux=stream_manager_new(type); if (type == AudioStreamType){ marielle_ms=&marielle->audio_stream->ms; margaux_ms=&margaux->audio_stream->ms; }else{ marielle_ms=&marielle->video_stream->ms; margaux_ms=&margaux->video_stream->ms; } /* Disable avpf. */ PayloadType* pt = rtp_profile_get_payload(&rtp_profile, VP8_PAYLOAD_TYPE); CU_ASSERT_PTR_NOT_NULL_FATAL(pt); payload_type_unset_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); media_stream_enable_adaptive_bitrate_control(marielle_ms,TRUE); rtp_session_set_duplication_ratio(marielle_ms->sessions.rtp_session, dup_ratio); if (marielle->type == AudioStreamType){ audio_manager_start(marielle,payload,margaux->local_rtp,initial_bitrate,HELLO_16K_1S_FILE,NULL); ms_filter_call_method(marielle->audio_stream->soundread,MS_FILE_PLAYER_LOOP,&pause_time); audio_manager_start(margaux,payload,marielle->local_rtp,0,NULL,RECORDED_16K_1S_FILE); }else{ #if VIDEO_ENABLED video_manager_start(marielle,payload,margaux->local_rtp,0,marielle_webcam); video_stream_set_direction(margaux->video_stream,VideoStreamRecvOnly); video_manager_start(margaux,payload,marielle->local_rtp,0,NULL); #else ms_fatal("Unsupported stream type [%s]",ms_stream_type_to_string(marielle->type)); #endif } rtp_session_enable_network_simulation(margaux_ms->sessions.rtp_session,¶ms); }
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,addr,rtcp_port,used_pt,jitt_comp,device); }
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,addr,port+1,used_pt,jitt_comp,NULL); }
void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, stream_manager_t ** pmargaux, int payload, int initial_bitrate, int max_bw, float loss_rate, int latency, float dup_ratio) { int pause_time=0; PayloadType* pt; MediaStream *marielle_ms,*margaux_ms; OrtpNetworkSimulatorParams params={0}; #if VIDEO_ENABLED MSWebCam * marielle_webcam=ms_web_cam_manager_get_default_cam (ms_web_cam_manager_get()); #endif stream_manager_t *marielle=*pmarielle=stream_manager_new(type); stream_manager_t *margaux=*pmargaux=stream_manager_new(type); char* file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_file_root(), HELLO_16K_1S_FILE); char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_16K_1S_FILE); marielle->user_data = recorded_file; params.enabled=TRUE; params.loss_rate=loss_rate; params.max_bandwidth=max_bw; params.latency=latency; if (type == MSAudio){ marielle_ms=&marielle->audio_stream->ms; margaux_ms=&margaux->audio_stream->ms; }else{ marielle_ms=&marielle->video_stream->ms; margaux_ms=&margaux->video_stream->ms; } /* Disable avpf. */ pt = rtp_profile_get_payload(&rtp_profile, VP8_PAYLOAD_TYPE); CU_ASSERT_PTR_NOT_NULL_FATAL(pt); payload_type_unset_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); media_stream_enable_adaptive_bitrate_control(marielle_ms,TRUE); media_stream_set_adaptive_bitrate_algorithm(marielle_ms, MSQosAnalyzerAlgorithmStateful); rtp_session_set_duplication_ratio(marielle_ms->sessions.rtp_session, dup_ratio); if (marielle->type == MSAudio){ audio_manager_start(marielle,payload,margaux->local_rtp,initial_bitrate,file,NULL); ms_filter_call_method(marielle->audio_stream->soundread,MS_FILE_PLAYER_LOOP,&pause_time); audio_manager_start(margaux,payload,marielle->local_rtp,0,NULL,recorded_file); }else{ #if VIDEO_ENABLED video_manager_start(marielle,payload,margaux->local_rtp,0,marielle_webcam); video_stream_set_direction(margaux->video_stream,VideoStreamRecvOnly); video_manager_start(margaux,payload,marielle->local_rtp,0,NULL); #else ms_fatal("Unsupported stream type [%s]",ms_format_type_to_string(marielle->type)); #endif } ms_qos_analyzer_set_on_action_suggested(ms_bitrate_controller_get_qos_analyzer(marielle_ms->rc), qos_analyzer_on_action_suggested, *pmarielle); rtp_session_enable_network_simulation(margaux_ms->sessions.rtp_session,¶ms); ms_free(recorded_file); ms_free(file); }
void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone){ LinphoneCore *lc=call->core; LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc); const char *tool="linphone-" LINPHONE_VERSION; char *cname; int used_pt=-1; #ifdef VIDEO_ENABLED const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpAvp,SalVideo); #endif bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc); if(call->audiostream == NULL) { ms_fatal("start_media_stream() called without prior init !"); return; } call->current_params = call->params; /* adjust rtp jitter compensation. It must be at least the latency of the sound card */ int jitt_comp=MAX(lc->sound_conf.latency,lc->rtp_conf.audio_jitt_comp); if (call->media_start_time==0) call->media_start_time=time(NULL); cname=linphone_address_as_string_uri_only(me); { const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpAvp,SalAudio); if (stream && stream->dir!=SalStreamInactive && stream->port!=0){ MSSndCard *playcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard; MSSndCard *captcard=lc->sound_conf.capt_sndcard; const char *playfile=lc->play_file; const char *recfile=lc->rec_file; call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt); bool_t use_ec,use_arc_audio=use_arc; if (used_pt!=-1){ if (playcard==NULL) { ms_warning("No card defined for playback !"); } if (captcard==NULL) { ms_warning("No card defined for capture !"); } /*Replace soundcard filters by inactive file players or recorders when placed in recvonly or sendonly mode*/ if (stream->port==0 || stream->dir==SalStreamRecvOnly){ captcard=NULL; playfile=NULL; }else if (stream->dir==SalStreamSendOnly){ playcard=NULL; captcard=NULL; recfile=NULL; /*And we will eventually play "playfile" if set by the user*/ /*playfile=NULL;*/ } if (send_ringbacktone){ captcard=NULL; playfile=NULL;/* it is setup later*/ } /*if playfile are supplied don't use soundcards*/ if (lc->use_files) { captcard=NULL; playcard=NULL; } use_ec=captcard==NULL ? FALSE : linphone_core_echo_cancellation_enabled(lc); #if defined(VIDEO_ENABLED) if (vstream && vstream->dir!=SalStreamInactive && vstream->payloads!=NULL){ /*when video is used, do not make adaptive rate control on audio, it is stupid.*/ use_arc_audio=FALSE; #if defined(ANDROID) /*On android we have to disable the echo canceller to preserve CPU for video codecs */ use_ec=FALSE; #endif } #endif audio_stream_enable_adaptive_bitrate_control(call->audiostream,use_arc_audio); audio_stream_start_full( call->audiostream, call->audio_profile, stream->addr[0]!='\0' ? stream->addr : call->resultdesc->addr, stream->port, stream->port+1, used_pt, jitt_comp, playfile, recfile, playcard, captcard, use_ec ); post_configure_audio_streams(call); if (all_inputs_muted && !send_ringbacktone){ audio_stream_set_mic_gain(call->audiostream,0); } if (stream->dir==SalStreamSendOnly && playfile!=NULL){ int pause_time=500; ms_filter_call_method(call->audiostream->soundread,MS_FILE_PLAYER_LOOP,&pause_time); } if (send_ringbacktone){ setup_ring_player(lc,call); } audio_stream_set_rtcp_information(call->audiostream, cname, tool); }else ms_warning("No audio stream accepted ?"); } } #ifdef VIDEO_ENABLED { used_pt=-1; /* shutdown preview */ if (lc->previewstream!=NULL) { video_preview_stop(lc->previewstream); lc->previewstream=NULL; } call->current_params.has_video=FALSE; if (vstream && vstream->dir!=SalStreamInactive && vstream->port!=0) { const char *addr=vstream->addr[0]!='\0' ? vstream->addr : call->resultdesc->addr; call->video_profile=make_profile(call,call->resultdesc,vstream,&used_pt); if (used_pt!=-1){ VideoStreamDir dir=VideoStreamSendRecv; MSWebCam *cam=lc->video_conf.device; bool_t is_inactive=FALSE; call->current_params.has_video=TRUE; video_stream_set_sent_video_size(call->videostream,linphone_core_get_preferred_video_size(lc)); video_stream_enable_self_view(call->videostream,lc->video_conf.selfview); if (lc->video_window_id!=0) video_stream_set_native_window_id(call->videostream,lc->video_window_id); if (lc->preview_window_id!=0) video_stream_set_native_preview_window_id (call->videostream,lc->preview_window_id); video_stream_use_preview_video_window (call->videostream,lc->use_preview_window); if (vstream->dir==SalStreamSendOnly && lc->video_conf.capture ){ cam=get_nowebcam_device(); dir=VideoStreamSendOnly; }else if (vstream->dir==SalStreamRecvOnly && lc->video_conf.display ){ dir=VideoStreamRecvOnly; }else if (vstream->dir==SalStreamSendRecv){ if (lc->video_conf.display && lc->video_conf.capture) dir=VideoStreamSendRecv; else if (lc->video_conf.display) dir=VideoStreamRecvOnly; else dir=VideoStreamSendOnly; }else{ ms_warning("video stream is inactive."); /*either inactive or incompatible with local capabilities*/ is_inactive=TRUE; } if (call->camera_active==FALSE || all_inputs_muted){ cam=get_nowebcam_device(); } if (!is_inactive){ video_stream_set_direction (call->videostream, dir); video_stream_start(call->videostream, call->video_profile, addr, vstream->port, vstream->port+1, used_pt, jitt_comp, cam); video_stream_set_rtcp_information(call->videostream, cname,tool); } }else ms_warning("No video stream accepted."); }else{ ms_warning("No valid video stream defined."); } } #endif call->all_muted=all_inputs_muted; call->playing_ringbacktone=send_ringbacktone; call->up_bw=linphone_core_get_upload_bandwidth(lc); if (ortp_zrtp_available()) { OrtpZrtpParams params; params.zid=get_hexa_zrtp_identifier(lc); params.zid_file=lc->zrtp_secrets_cache; audio_stream_enable_zrtp(call->audiostream,¶ms); } goto end; end: ms_free(cname); linphone_address_destroy(me); }