1 Star 0 Fork 46

刘杰/third_party_glib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
player_framework.patch 6.04 KB
一键复制 编辑 原始数据 按行查看 历史
刘杰 提交于 2024-02-07 10:53 . fix initial playing blink black frame
diff --git a/services/engine/histreamer/player/hiplayer_callback_looper.cpp b/services/engine/histreamer/player/hiplayer_callback_looper.cpp
index 5d70e1cb..168fa52c 100755
--- a/services/engine/histreamer/player/hiplayer_callback_looper.cpp
+++ b/services/engine/histreamer/player/hiplayer_callback_looper.cpp
@@ -154,6 +154,13 @@ void HiPlayerCallbackLooper::DoReportError(const Any &error)
}
}
+void HiPlayerCallbackLooper::OnInfoDelay(PlayerOnInfoType type, int32_t extra, const Format &infoBody, long delayMs)
+{
+ eventQueue_.Enqueue(std::make_shared<HiPlayerCallbackLooper::Event>(WHAT_INFO, SteadyClock::GetCurrentTimeMs() + delayMs,
+ std::make_tuple(type, extra, infoBody)));
+}
+
+
void HiPlayerCallbackLooper::OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody)
{
eventQueue_.Enqueue(std::make_shared<HiPlayerCallbackLooper::Event>(WHAT_INFO, SteadyClock::GetCurrentTimeMs(),
diff --git a/services/engine/histreamer/player/hiplayer_callback_looper.h b/services/engine/histreamer/player/hiplayer_callback_looper.h
index 1dcdbd76..d6ae3d83 100755
--- a/services/engine/histreamer/player/hiplayer_callback_looper.h
+++ b/services/engine/histreamer/player/hiplayer_callback_looper.h
@@ -50,6 +50,8 @@ public:
void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody) override;
+ void OnInfoDelay(PlayerOnInfoType type, int32_t extra, const Format &infoBody, long delayMs);
+
void DoReportCompletedTime();
private:
diff --git a/services/engine/histreamer/player/hiplayer_impl.cpp b/services/engine/histreamer/player/hiplayer_impl.cpp
index f790eafb..e1413a52 100644
--- a/services/engine/histreamer/player/hiplayer_impl.cpp
+++ b/services/engine/histreamer/player/hiplayer_impl.cpp
@@ -308,7 +308,11 @@ int32_t HiPlayerImpl::Play()
}
}
if (ret == MSERR_OK) {
- OnStateChanged(PlayerStateId::PLAYING);
+ if (!isInitialPlay_) {
+ OnStateChanged(PlayerStateId::PLAYING);
+ } else {
+ MEDIA_LOG_I("InitialPlay, pending to change state of playing.");
+ }
}
return ret;
}
@@ -916,7 +920,7 @@ int32_t HiPlayerImpl::GetVideoHeight()
int32_t HiPlayerImpl::SetVideoScaleType(OHOS::Media::VideoScaleType videoScaleType)
{
- MEDIA_LOG_I("SetVideoScaleType entered.");
+ MEDIA_LOG_I("SetVideoScaleType entered. VIDEO_SCALE_TYPE: " PUBLIC_LOG_D32, videoScaleType);
#ifdef SUPPORT_VIDEO
auto meta = std::make_shared<Meta>();
meta->Set<Tag::VIDEO_SCALE_TYPE>(static_cast<int32_t>(videoScaleType));
@@ -981,7 +985,9 @@ void HiPlayerImpl::OnEvent(const Event &event)
break;
}
case EventType::EVENT_AUDIO_FIRST_FRAME: {
+ MEDIA_LOG_I("audio first frame reneder received");
NotifyAudioFirstFrame(event);
+ HandleInitialPlayingStateChange(event.type);
break;
}
case EventType::EVENT_DRM_INFO_UPDATED: {
@@ -989,8 +995,10 @@ void HiPlayerImpl::OnEvent(const Event &event)
break;
}
case EventType::EVENT_VIDEO_RENDERING_START: {
+ MEDIA_LOG_I("video first frame reneder received");
Format format;
callbackLooper_.OnInfo(INFO_TYPE_MESSAGE, PlayerMessageType::PLAYER_INFO_VIDEO_RENDERING_START, format);
+ HandleInitialPlayingStateChange(event.type);
break;
}
case EventType::EVENT_AUDIO_DEVICE_CHANGE : {
@@ -1006,6 +1014,26 @@ void HiPlayerImpl::OnEvent(const Event &event)
}
}
+void HiPlayerImpl::HandleInitialPlayingStateChange(const EventType& eventType)
+{
+ for (std::pair<EventType, bool>& item : initialAVStates_) {
+ if (item.first == eventType) {
+ item.second = true;
+ }
+ }
+ for (auto item : initialAVStates_) {
+ if (item.second == false) {
+ return;
+ }
+ }
+
+ MEDIA_LOG_I("av first frame reneder all received");
+
+ isInitialPlay_ = false;
+ OnStateChanged(PlayerStateId::PLAYING);
+
+}
+
Status HiPlayerImpl::DoSetSource(const std::shared_ptr<MediaSource> source)
{
demuxer_ = FilterFactory::Instance().CreateFilter<DemuxerFilter>("builtin.player.demuxer",
@@ -1359,6 +1387,7 @@ Status HiPlayerImpl::LinkAudioSinkFilter(const std::shared_ptr<Filter>& preFilte
audioSink_->SetSyncCenter(syncManager_);
}
completeState_.emplace_back(std::make_pair("AudioSink", false));
+ initialAVStates_.emplace_back(std::make_pair(EventType::EVENT_AUDIO_FIRST_FRAME, false));
return pipeline_->LinkFilters(preFilter, {audioSink_}, type);
}
@@ -1394,6 +1423,7 @@ Status HiPlayerImpl::LinkVideoDecoderFilter(const std::shared_ptr<Filter>& preFi
}
}
completeState_.emplace_back(std::make_pair("VideoSink", false));
+ initialAVStates_.emplace_back(std::make_pair(EventType::EVENT_VIDEO_RENDERING_START, false));
return pipeline_->LinkFilters(preFilter, {videoDecoder_}, type);
}
#endif
diff --git a/services/engine/histreamer/player/hiplayer_impl.h b/services/engine/histreamer/player/hiplayer_impl.h
index ddc75d75..1ea42d7f 100644
--- a/services/engine/histreamer/player/hiplayer_impl.h
+++ b/services/engine/histreamer/player/hiplayer_impl.h
@@ -97,6 +97,7 @@ private:
Status DoSetSource(const std::shared_ptr<MediaSource> source);
Status Resume();
void HandleCompleteEvent(const Event& event);
+ void HandleInitialPlayingStateChange(const EventType& eventType);
void HandleDrmInfoUpdatedEvent(const Event& event);
void HandleIsLiveStreamEvent(bool isLiveStream);
void HandleErrorEvent(int32_t errorCode);
@@ -181,6 +182,9 @@ private:
bool stopWaitingDrmConfig_ = false;
sptr<DrmStandard::IMediaKeySessionService> keySessionServiceProxy_{nullptr};
int32_t svpMode_ = HiplayerSvpMode::SVP_CLEAR;
+
+ bool isInitialPlay_ = true;
+ std::vector<std::pair<EventType, bool>> initialAVStates_;
std::vector<std::pair<std::string, bool>> completeState_;
};
} // namespace Media
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jaygome/third_party_glib.git
git@gitee.com:jaygome/third_party_glib.git
jaygome
third_party_glib
third_party_glib
master

搜索帮助