diff --git a/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp b/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp index b73f4ef7a..3fb4e80ae 100644 --- a/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp +++ b/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp @@ -356,6 +356,8 @@ int32_t DashSegmentDownloader::GetWaterLineAbove() } else { waterLineAbove = static_cast(DEFAULT_MIN_CACHE_TIME * realTimeBitBate_ / BYTES_TO_BIT); } + int32_t maxWaterLineAbove = static_cast(ringBufferCapcity_ / 2); + waterLineAbove = waterLineAbove > maxWaterLineAbove ? maxWaterLineAbove : waterLineAbove; int32_t minWaterLineAbove = 2 * PLAY_WATER_LINE; waterLineAbove = waterLineAbove < minWaterLineAbove ? minWaterLineAbove : waterLineAbove; } @@ -370,7 +372,7 @@ void DashSegmentDownloader::CalculateBitRate(size_t fragmentSize, double duratio return; } - realTimeBitBate_ = static_cast(fragmentSize * BYTES_TO_BIT) / duration; + realTimeBitBate_ = static_cast(fragmentSize * BYTES_TO_BIT * SECOND_TO_MILLIONSECOND) / duration; MEDIA_LOG_I("CalculateBitRate streamId: " PUBLIC_LOG_D32 " realTimeBitBate: " PUBLIC_LOG_D64, streamId_, realTimeBitBate_); } @@ -1015,12 +1017,6 @@ void DashSegmentDownloader::UpdateDownloadFinished(const std::string& url, const } else { downloadSpeed_ = 0; } - if (downloadRequest_ != nullptr) { - size_t fragmentSize = downloadRequest_->GetFileContentLength(); - double duration = downloadRequest_->GetDuration(); - CalculateBitRate(fragmentSize, duration); - downloadBiteRate_ = downloadRequest_->GetBitRate(); - } if (initSegment != nullptr && initSegment->writeState_ == INIT_SEGMENT_STATE_USING) { MEDIA_LOG_I("UpdateDownloadFinished:streamId:" PUBLIC_LOG_D32 ", writeState:" @@ -1038,6 +1034,12 @@ void DashSegmentDownloader::UpdateDownloadFinished(const std::string& url, const if (mediaSegment_->contentLength_ == 0 && downloadRequest_ != nullptr) { mediaSegment_->contentLength_ = downloadRequest_->GetFileContentLength(); } + if (downloadRequest_ != nullptr) { + size_t fragmentSize = mediaSegment_->contentLength_; + double duration = downloadRequest_->GetDuration(); + CalculateBitRate(fragmentSize, duration); + downloadBiteRate_ = downloadRequest_->GetBitRate(); + } mediaSegment_->isEos_ = true; if (mediaSegment_->isLast_) { MEDIA_LOG_I("AllSegmentFinish streamId: " PUBLIC_LOG_D32 " download complete", streamId_); diff --git a/services/media_engine/plugins/source/http_source/dash/include/utils/time_utils.h b/services/media_engine/plugins/source/http_source/dash/include/utils/time_utils.h index a55090a9b..d30fa69c8 100644 --- a/services/media_engine/plugins/source/http_source/dash/include/utils/time_utils.h +++ b/services/media_engine/plugins/source/http_source/dash/include/utils/time_utils.h @@ -43,16 +43,6 @@ constexpr int64_t MS_2_NS = MS_2_US * US_2_NS; constexpr int64_t S_2_NS = S_2_MS * MS_2_NS; constexpr int64_t MEDIA_PTS_UNSET = INT64_MIN + 1; - -class TimeUtils { -public: - static int64_t GetBootTimeMs(); - static int64_t GetBootTimeUs(); - static int64_t GetMonotonicTimeMs(); - static int64_t GetMonotonicTimeUs(); - static int64_t GetCurrentTimeMs(); -}; - } // namespace HttpPluginLite } // namespace Plugin } // namespace Media