Commit 7b45f03f authored by jehan's avatar jehan

msiounit no longer check ratio between asked bytes and bytes in bufferinzer to...

msiounit no longer check ratio between asked bytes and bytes in bufferinzer to decide to flush bufferizer. 
It fix a bug with iPhone 6s. 
parent f8b158d8
......@@ -165,6 +165,7 @@ struct au_filter_write_data{
ms_mutex_t mutex;
MSBufferizer *bufferizer;
unsigned int n_lost_frame;
bool first_frame_wrote;
};
......@@ -384,10 +385,15 @@ static OSStatus au_write_cb (
if (d!=NULL){
ms_mutex_lock(&d->mutex);
if (!d->first_frame_wrote) {
ms_bufferizer_flush(d->bufferizer); /*to avoid keeping delay from first start which can be around 100ms becasue io unit takes time to start*/
d->first_frame_wrote=true;
}
if(ms_bufferizer_get_avail(d->bufferizer) >= inNumberFrames*d->base.card->bits/8) {
ms_bufferizer_read(d->bufferizer, ioData->mBuffers[0].mData, inNumberFrames*d->base.card->bits/8);
if (ms_bufferizer_get_avail(d->bufferizer) >10*inNumberFrames*d->base.card->bits/8) {
ms_debug("we are late, bufferizer sise is %i bytes in framezize is %lu bytes"
/*basic algo, can be enhanced with a more advanced bufferizer computing average value*/
if (ms_bufferizer_get_avail(d->bufferizer) > card->rate* (card->nchannels * card->bits / 8)/5 ) {
ms_warning("we are at least 200ms late, bufferizer sise is %i bytes in framezize is %lu bytes"
,ms_bufferizer_get_avail(d->bufferizer)
,inNumberFrames*d->base.card->bits/8);
ms_bufferizer_flush(d->bufferizer);
......
......@@ -148,6 +148,7 @@ typedef struct _MediastreamDatas {
int ice_remote_candidates_nb;
char * video_display_filter;
FILE * logfile;
bool_t enable_speaker;
} MediastreamDatas;
......@@ -222,6 +223,9 @@ const char *usage="mediastream --local <port>\n"
"[ --width <pixels> ]\n"
"[ --zoom zoom factor ]\n"
"[ --zrtp <secrets file> (enable zrtp) ]\n"
#if TARGET_OS_IPHONE
"[ --speaker route audio to speaker ]\n"
#endif
;
#if TARGET_OS_IPHONE
......@@ -622,6 +626,8 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
out->logfile = fopen(argv[i], "a+");
} else if (strcmp(argv[i], "--freeze-on-error") == 0) {
out->freeze_on_error=TRUE;
} else if (strcmp(argv[i], "--speaker") == 0) {
out->enable_speaker=TRUE;
} else {
ms_error("Unknown option '%s'\n", argv[i]);
return FALSE;
......@@ -789,7 +795,10 @@ void setup_media_streams(MediastreamDatas* args) {
audio_stream_set_echo_canceller_params(args->audio,args->ec_len_ms,args->ec_delay_ms,args->ec_framesize);
audio_stream_enable_echo_limiter(args->audio,args->el);
audio_stream_enable_adaptive_bitrate_control(args->audio,args->use_rc);
if (capt)
ms_snd_card_set_preferred_sample_rate(capt,rtp_profile_get_payload(args->profile, args->payload)->clock_rate);
if (play)
ms_snd_card_set_preferred_sample_rate(play,rtp_profile_get_payload(args->profile, args->payload)->clock_rate);
ms_message("Starting audio stream.\n");
audio_stream_start_full(args->audio,args->profile,args->ip,args->remoteport,args->ip,args->enable_rtcp?args->remoteport+1:-1, args->payload, args->jitter,args->infile,args->outfile,
......@@ -847,13 +856,12 @@ void setup_media_streams(MediastreamDatas* args) {
}
}
#ifndef TARGET_OS_IPHONE
if (args->zrtp_secrets != NULL) {
MSZrtpParams params;
params.zid_file=args->zrtp_secrets;
audio_stream_enable_zrtp(args->audio,&params);
}
#endif
args->session=args->audio->ms.sessions.rtp_session;
}
......@@ -866,6 +874,17 @@ void setup_media_streams(MediastreamDatas* args) {
args->srtp_local_master_key,
args->srtp_remote_master_key));
}
#if TARGET_OS_IPHONE
if (args->enable_speaker) {
ms_message("Setting audio route to spaker");
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
if (AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride),&audioRouteOverride) != kAudioSessionNoError) {
ms_error("Cannot set route to speaker");
};
}
#endif
}else{
#ifdef VIDEO_ENABLED
float zoom[] = {
......
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