diff --git a/StreamingKit/StreamingKit/STKAudioPlayer.m b/StreamingKit/StreamingKit/STKAudioPlayer.m index 75c34b0..cb444ba 100644 --- a/StreamingKit/StreamingKit/STKAudioPlayer.m +++ b/StreamingKit/StreamingKit/STKAudioPlayer.m @@ -54,7 +54,7 @@ #define STK_DEFAULT_PCM_BUFFER_SIZE_IN_SECONDS (10) #define STK_DEFAULT_SECONDS_REQUIRED_TO_START_PLAYING (1) #define STK_DEFAULT_SECONDS_REQUIRED_TO_START_PLAYING_AFTER_BUFFER_UNDERRUN (7.5) -#define STK_MAX_COMPRESSED_PACKETS_FOR_BITRATE_CALCULATION (2048) +#define STK_MAX_COMPRESSED_PACKETS_FOR_BITRATE_CALCULATION (4096) #define STK_DEFAULT_READ_BUFFER_SIZE (64 * 1024) #define STK_DEFAULT_PACKET_BUFFER_SIZE (2048) diff --git a/StreamingKit/StreamingKit/STKQueueEntry.m b/StreamingKit/StreamingKit/STKQueueEntry.m index 0b7ab29..d4e4cbd 100644 --- a/StreamingKit/StreamingKit/STKQueueEntry.m +++ b/StreamingKit/StreamingKit/STKQueueEntry.m @@ -9,8 +9,8 @@ #import "STKQueueEntry.h" #import "STKDataSource.h" -#define STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MIN (4) -#define STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MAX (64) +#define STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MIN (2) +#define STK_BIT_RATE_ESTIMATION_MIN_PACKETS_PREFERRED (64) @implementation STKQueueEntry @@ -39,15 +39,16 @@ { double retval; - if (packetDuration && - (processedPacketsCount > STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MAX || (audioStreamBasicDescription.mBytesPerFrame == 0 - && processedPacketsCount > STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MIN))) + if (packetDuration > 0) { - double averagePacketByteSize = processedPacketsSizeTotal / processedPacketsCount; - - retval = averagePacketByteSize / packetDuration * 8; - - return retval; + if (processedPacketsCount > STK_BIT_RATE_ESTIMATION_MIN_PACKETS_PREFERRED || (audioStreamBasicDescription.mBytesPerFrame == 0 && processedPacketsCount > STK_BIT_RATE_ESTIMATION_MIN_PACKETS_MIN)) + { + double averagePacketByteSize = processedPacketsSizeTotal / processedPacketsCount; + + retval = averagePacketByteSize / packetDuration * 8; + + return retval; + } } retval = (audioStreamBasicDescription.mBytesPerFrame * audioStreamBasicDescription.mSampleRate) * 8;