!3997 HLS代码告警整改以及解决偶先crash

Merge pull request !3997 from 李烨/master
This commit is contained in:
openharmony_ci 2024-11-22 08:45:47 +00:00 committed by Gitee
commit 847198f168
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 10 additions and 2 deletions

View File

@ -1088,6 +1088,11 @@ size_t DashMediaDownloader::GetBufferSize() const
return segmentDownloader->GetBufferSize();
}
bool DashMediaDownloader::GetPlayable()
{
return GetBufferSize() > 0;
}
void DashMediaDownloader::SetAppUid(int32_t appUid)
{
for (size_t i = 0; i < segmentDownloaders_.size(); i++) {

View File

@ -67,6 +67,7 @@ public:
void SetDemuxerState(int32_t streamId) override;
void GetPlaybackInfo(PlaybackInfo& playbackInfo) override;
size_t GetBufferSize() const override;
bool GetPlayable() override;
void SetAppUid(int32_t appUid) override;
bool GetBufferingTimeOut() override;

View File

@ -1501,8 +1501,10 @@ void HlsMediaDownloader::CalculateBitRate(size_t fragmentSize, double duration)
if (fragmentSize == 0 || duration == 0) {
return;
}
int32_t calculateBitRate = static_cast<int32_t>(static_cast<int32_t>(fragmentSize * BYTES_TO_BIT) / duration);
double divisorFragmentSize = (static_cast<double>(fragmentSize) / static_cast<double>(ONE_SECONDS))
* static_cast<double>(BYTES_TO_BIT);
double dividendDuration = static_cast<double>(duration) / static_cast<double>(ONE_SECONDS);
int32_t calculateBitRate = static_cast<int32_t>(divisorFragmentSize / dividendDuration);
currentBitRate_ = (calculateBitRate >> 1) + (currentBitRate_ >> 1) + ((calculateBitRate | currentBitRate_) & 1);
MEDIA_LOG_I("HLS Calculate avgBitRate: " PUBLIC_LOG_D32, currentBitRate_);
}