1 /* 2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HI_PLAYER_IMPL_H 17 #define HI_PLAYER_IMPL_H 18 19 #include <memory> 20 #include <unordered_map> 21 #include <queue> 22 #include <chrono> 23 24 #include "audio_info.h" 25 #include "audio_decoder_filter.h" 26 #include "audio_sink_filter.h" 27 #include "common/status.h" 28 #include "demuxer_filter.h" 29 #include "filter/filter.h" 30 #include "filter/filter_factory.h" 31 #include "hiplayer_callback_looper.h" 32 #include "live_controller.h" 33 #include "media_utils.h" 34 #include "i_player_engine.h" 35 #include "media_sync_manager.h" 36 #include "pipeline/pipeline.h" 37 #include "seek_agent.h" 38 #include "dfx_agent.h" 39 #include "subtitle_sink_filter.h" 40 #include "meta/meta.h" 41 #include "dragging_player_agent.h" 42 #include "interrupt_monitor.h" 43 #include "plugin/plugin_time.h" 44 #ifdef SUPPORT_VIDEO 45 #include "decoder_surface_filter.h" 46 #include "sei_parser_filter.h" 47 #endif 48 #include "common/fdsan_fd.h" 49 50 namespace OHOS { 51 namespace Media { 52 using namespace Pipeline; 53 struct PlayStatisticalInfo { 54 int32_t errCode {0}; 55 std::string errMsg {}; 56 int32_t playDuration {0}; 57 int32_t sourceType {0}; 58 std::string sourceUrl {}; 59 int32_t avgDownloadRate {0}; 60 std::string containerMime {}; 61 std::string videoMime {}; 62 std::string videoResolution {}; 63 float videoFrameRate {0.0}; 64 int8_t videoBitdepth {0}; 65 int32_t videoBitrate {0}; 66 int8_t hdrType {0}; 67 std::string audioMime {}; 68 int32_t audioSampleRate {0}; 69 int32_t audioChannelCount {0}; 70 int32_t audioBitrate {0}; 71 std::string subtitleMime {}; 72 std::string subtitleLang {}; 73 bool isDrmProtected {false}; 74 int32_t startLatency {0}; 75 int32_t avgDownloadSpeed {0}; 76 int32_t maxSeekLatency {0}; 77 int32_t maxAccurateSeekLatency {0}; 78 int32_t lagTimes {0}; 79 int32_t maxLagDuration {0}; 80 int32_t avgLagDuration {0}; 81 int32_t maxSurfaceSwapLatency {0}; 82 uint64_t totalDownLoadBits {0}; 83 bool isTimeOut {false}; 84 }; 85 86 enum VideoHdrType : int32_t { 87 /** 88 * This option is used to mark none HDR type. 89 */ 90 VIDEO_HDR_TYPE_NONE, 91 /** 92 * This option is used to mark HDR Vivid type. 93 */ 94 VIDEO_HDR_TYPE_VIVID, 95 }; 96 97 98 class HiPlayerImpl : public IPlayerEngine, public std::enable_shared_from_this<HiPlayerImpl> { 99 public: 100 HiPlayerImpl(int32_t appUid, int32_t appPid, uint32_t appTokenId, uint64_t appFullTokenId); 101 ~HiPlayerImpl() override; 102 HiPlayerImpl(const HiPlayerImpl& other) = delete; 103 HiPlayerImpl& operator=(const HiPlayerImpl& other) = delete; 104 Status Init(); 105 // interface from PlayerInterface 106 int32_t SetSource(const std::string& uri) override; 107 int32_t SetSource(const std::shared_ptr<IMediaDataSource>& dataSrc) override; 108 int32_t AddSubSource(const std::string &url) override; 109 int32_t Prepare() override; 110 int32_t SetRenderFirstFrame(bool display) override; 111 int32_t SetPlayRange(int64_t start, int64_t end) override; 112 int32_t SetPlayRangeWithMode(int64_t start, int64_t end, PlayerSeekMode mode) override; 113 int32_t SetIsCalledBySystemApp(bool isCalledBySystemApp) override; 114 int32_t PrepareAsync() override; 115 int32_t Play() override; 116 int32_t Pause(bool isSystemOperation) override; 117 int32_t Stop() override; 118 int32_t Reset() override; 119 int32_t Freeze(bool &isNoNeedToFreeze) override; 120 int32_t UnFreeze() override; 121 int32_t PauseSourceDownload() override; 122 int32_t ResumeSourceDownload() override; 123 int32_t Seek(int32_t mSeconds, PlayerSeekMode mode) override; 124 int32_t SetVolume(float leftVolume, float rightVolume) override; 125 int32_t SetVolumeMode(int32_t mode) override; 126 int32_t SetVideoSurface(sptr<Surface> surface) override; 127 int32_t SetDecryptConfig(const sptr<OHOS::DrmStandard::IMediaKeySessionService> &keySessionProxy, 128 bool svp) override; 129 int32_t SetLooping(bool loop) override; 130 int32_t SetParameter(const Format& params) override; 131 int32_t SetObs(const std::weak_ptr<IPlayerEngineObs>& obs) override; 132 int32_t GetCurrentTime(int32_t& currentPositionMs) override; 133 int32_t GetPlaybackPosition(int32_t& playbackPositionMs) override; 134 int32_t GetDuration(int32_t& durationMs) override; 135 int32_t SetPlaybackSpeed(PlaybackRateMode mode) override; 136 int32_t SetPlaybackRate(float rate) override; 137 int32_t SetMediaSource(const std::shared_ptr<AVMediaSource> &mediaSource, AVPlayStrategy strategy) override; 138 int32_t GetPlaybackSpeed(PlaybackRateMode& mode) override; 139 int32_t SelectBitRate(uint32_t bitRate, bool isAutoSelect) override; 140 int32_t GetAudioEffectMode(int32_t &effectMode) override; 141 int32_t SetAudioEffectMode(int32_t effectMode) override; 142 143 int32_t GetCurrentTrack(int32_t trackType, int32_t &index) override; 144 int32_t SelectTrack(int32_t trackId, PlayerSwitchMode mode) override; 145 int32_t DeselectTrack(int32_t trackId) override; 146 int32_t GetVideoTrackInfo(std::vector<Format>& videoTrack) override; 147 int32_t GetPlaybackInfo(Format& playbackInfo) override; 148 int32_t GetAudioTrackInfo(std::vector<Format>& audioTrack) override; 149 int32_t GetSubtitleTrackInfo(std::vector<Format>& subtitleTrack) override; 150 int32_t GetVideoWidth() override; 151 int32_t GetVideoHeight() override; 152 int32_t SetVideoScaleType(VideoScaleType videoScaleType) override; 153 int32_t SetAudioRendererInfo(const int32_t contentType, const int32_t streamUsage, 154 const int32_t rendererFlag, const int32_t volumeMode) override; 155 int32_t SetAudioInterruptMode(const int32_t interruptMode) override; 156 int32_t SeekToCurrentTime(int32_t mSeconds, PlayerSeekMode mode) override; 157 int32_t SetStartFrameRateOptEnabled(bool enabled) override; 158 void SetInterruptState(bool isInterruptNeeded) override; 159 void OnDumpInfo(int32_t fd) override; 160 void SetInstancdId(uint64_t instanceId) override; 161 void SetApiVersion(int32_t apiVersion) override; 162 int64_t GetPlayRangeStartTime() override; 163 int64_t GetPlayRangeEndTime() override; 164 int32_t GetPlayRangeSeekMode() override; 165 bool IsNeedChangePlaySpeed(PlaybackRateMode &mode, bool &isXSpeedPlay) override; 166 bool IsPauseForTooLong(int64_t pauseTime) override; 167 bool IsLivingMaxDelayTimeValid() override; 168 bool IsFlvLive() override; 169 void DoRestartLiveLink() override; 170 171 // internal interfaces 172 void EnableStartFrameRateOpt(Format &videoTrack); 173 void OnEvent(const Event &event); 174 void OnEventContinue(const Event &event); 175 void OnEventSub(const Event &event); 176 void OnEventSubTrackChange(const Event &event); 177 void HandleDfxEvent(const DfxEvent &event); 178 void HandleMemoryUsageEvent(const DfxEvent &event); 179 void OnStateChanged(PlayerStateId state, bool isSystemOperation = false); 180 Status OnCallback(std::shared_ptr<Filter> filter, const FilterCallBackCommand cmd, StreamType outType); 181 int32_t SeekContinous(int32_t mSeconds, int64_t seekContinousBatchNo) override; 182 int32_t ExitSeekContinous(bool align, int64_t seekContinousBatchNo) override; 183 int32_t PauseDemuxer() override; 184 int32_t ResumeDemuxer() override; 185 int32_t SetPlaybackStrategy(AVPlayStrategy playbackStrategy) override; 186 int32_t SetMediaMuted(OHOS::Media::MediaType mediaType, bool isMuted) override; 187 int32_t SetSuperResolution(bool enabled) override; 188 int32_t SetVideoWindowSize(int32_t width, int32_t height) override; 189 float GetMaxAmplitude() override; 190 int32_t SetMaxAmplitudeCbStatus(bool status) override; 191 int32_t IsSeekContinuousSupported(bool &isSeekContinuousSupported) override; 192 int32_t SetSeiMessageCbStatus(bool status, const std::vector<int32_t> &payloadTypes) override; 193 void SetPerfRecEnabled(bool isPerfRecEnabled) override; 194 int32_t SetReopenFd(int32_t fd) override; 195 int32_t EnableCameraPostprocessing() override; 196 int32_t SetCameraPostprocessing(bool isOpen) override; 197 int32_t EnableReportMediaProgress(bool enable) override; 198 int32_t ForceLoadVideo(bool status) override; 199 int32_t NotifyMemoryExchange(bool status) override; 200 void SetEosInLoopForFrozen(bool status) override; 201 202 private: 203 enum HiplayerSvpMode : int32_t { 204 SVP_CLEAR = -1, /* it's not a protection video */ 205 SVP_FALSE, /* it's a protection video but not need secure decoder */ 206 SVP_TRUE, /* it's a protection video and need secure decoder */ 207 }; 208 209 Status DoSetSource(const std::shared_ptr<MediaSource> source); 210 void DoSetPlayStrategy(const std::shared_ptr<MediaSource> source); 211 void DoSetPlayMediaStream(const std::shared_ptr<MediaSource>& source); 212 Status Resume(); 213 void GetDumpFlag(); 214 void HandleCompleteEvent(const Event& event); 215 void HandleInitialPlayingStateChange(const EventType& eventType); 216 void HandleDrmInfoUpdatedEvent(const Event& event); 217 void HandleIsLiveStreamEvent(bool isLiveStream); 218 void HandleErrorEvent(int32_t errorCode); 219 void HandleResolutionChangeEvent(const Event& event); 220 void HandleBitrateStartEvent(const Event& event); 221 void HandleAudioTrackChangeEvent(const Event& event); 222 void HandleVideoTrackChangeEvent(const Event& event); 223 void HandleSubtitleTrackChangeEvent(const Event& event); 224 void HandleFlvAutoSelectBitRate(uint32_t bitRate); 225 void HandleSeiInfoEvent(const Event &event); 226 void NotifyBufferingStart(int32_t param); 227 void NotifyBufferingEnd(int32_t param); 228 void NotifyCachedDuration(int32_t param); 229 void UpdateStateNoLock(PlayerStates newState, bool notifyUpward = true, bool isSystemOperation = false); 230 void NotifyBufferingUpdate(const std::string_view& type, int32_t param); 231 void NotifyDurationUpdate(const std::string_view& type, int32_t param); 232 void NotifySeekDone(int32_t seekPos); 233 void NotifyAudioInterrupt(const Event& event); 234 void NotifyAudioDeviceChange(const Event& event); 235 void NotifyAudioServiceDied(); 236 void NotifyAudioFirstFrame(const Event& event); 237 void NotifyResolutionChange(); 238 void NotifyPositionUpdate(); 239 void NotifySuperResolutionChanged(const Event& event); 240 Status LinkAudioDecoderFilter(const std::shared_ptr<Filter>& preFilter, StreamType type); 241 Status LinkAudioSinkFilter(const std::shared_ptr<Filter>& preFilter, StreamType type); 242 Status LinkSubtitleSinkFilter(const std::shared_ptr<Filter>& preFilter, StreamType type); 243 void SetAudioRendererParameter(); 244 void NotifySubtitleUpdate(const Event& event); 245 void NotifyDecoderErrorFrame(int64_t pts); 246 void DoInitializeForHttp(); 247 bool EnableBufferingBySysParam() const; 248 bool IsFileUrl(const std::string &url) const; 249 bool IsNetworkUrl(const std::string &url) const; 250 bool IsValidPlayRange(int64_t start, int64_t end) const; 251 int32_t GetRealPath(const std::string &url, std::string &realUrlPath) const; 252 int32_t HandleErrorRet(Status ret, const std::string& errMsg); 253 void SetDefaultAudioRenderInfo(const std::vector<std::shared_ptr<Meta>> &trackInfos); 254 void AppendPlayerMediaInfo(); 255 int64_t GetCurrentMillisecond(); 256 void UpdatePlayStatistics(); 257 void DoSetMediaSource(Status& ret); 258 void UpdatePlayerStateAndNotify(); 259 void UpdateMediaFirstPts(); 260 void UpdateMaxSeekLatency(PlayerSeekMode mode, int64_t seekStartTime); 261 #ifdef SUPPORT_VIDEO 262 Status LinkVideoDecoderFilter(const std::shared_ptr<Filter>& preFilter, StreamType type); 263 Status LinkSeiDecoder(const std::shared_ptr<Filter>& preFilter, StreamType type); 264 bool IsVideoMime(const std::string& mime); 265 Status InitVideoDecoder(); 266 #endif 267 bool IsAudioMime(const std::string& mime); 268 bool IsSubtitleMime(const std::string& mime); 269 bool IsNeedAudioSinkChangeTrack(std::vector<std::shared_ptr<Meta>>& metaInfo, int32_t newAudioTrackId); 270 Status Seek(int64_t mSeconds, PlayerSeekMode mode, bool notifySeekDone, bool isUnFreezeSeek = false); 271 Status HandleSeek(int64_t seekPos, PlayerSeekMode mode, bool isUnFreezeSeek = false); 272 273 Status doPreparedSeek(int64_t seekPos, PlayerSeekMode mode); 274 Status doStartedSeek(int64_t seekPos, PlayerSeekMode mode); 275 Status doPausedSeek(int64_t seekPos, PlayerSeekMode mode); 276 Status doFrozenSeek(int64_t seekPos, PlayerSeekMode mode, bool isUnFreezeSeek = false); 277 Status doCompletedSeek(int64_t seekPos, PlayerSeekMode mode); 278 Status doSeek(int64_t seekPos, PlayerSeekMode mode); 279 Status doSetPlaybackSpeed(float speed); 280 Status HandleSeekClosest(int64_t seekPos, int64_t seekTimeUs); 281 void NotifySeek(Status rtv, bool flag, int64_t seekPos); 282 void ResetIfSourceExisted(); 283 void ReleaseInner(); 284 int32_t InitDuration(); 285 int32_t InitVideoWidthAndHeight(); 286 int32_t SetFrameRateForSeekPerformance(double frameRate); 287 void SetBundleName(std::string bundleName); 288 Status InitAudioDefaultTrackIndex(); 289 Status InitVideoDefaultTrackIndex(); 290 Status InitSubtitleDefaultTrackIndex(); 291 void DoPausedPlay(int32_t &ret); 292 bool BreakIfInterruptted(); 293 void CollectionErrorInfo(int32_t errCode, const std::string& errMsg); 294 void NotifyUpdateTrackInfo(); 295 Status SelectSeekType(int64_t seekPos, PlayerSeekMode mode); 296 Status DoSetPlayRange(); 297 void ResetPlayRangeParameter(); 298 bool IsInValidSeekTime(int32_t seekPos); 299 int64_t GetPlayStartTime(); 300 Status StartSeekContinous(); 301 void FlushVideoEOS(); 302 int32_t InnerSelectTrack(std::string mime, int32_t trackId, PlayerSwitchMode mode); 303 bool NeedSeekClosest(); 304 bool HandleEosFlagState(const Event& event); 305 int32_t GetSarVideoWidth(std::shared_ptr<Meta> trackInfo); 306 int32_t GetSarVideoHeight(std::shared_ptr<Meta> trackInfo); 307 bool IsLiveStream(); 308 Status SetSeiMessageListener(); 309 void UpdatePlayTotalDuration(); 310 inline bool IsStatisticalInfoValid(); 311 void ReportAudioInterruptEvent(); 312 int32_t AdjustCachedDuration(int32_t cachedDuration); 313 bool IsLivingMaxDelyTimeValid(); 314 void SetFlvObs(); 315 void StartFlvCheckLiveDelayTime(); 316 void StopFlvCheckLiveDelayTime(); 317 void UpdateFlvLiveParams(); 318 void SetFlvLiveParams(AVPlayStrategy playbackStrategy); 319 void SetPostProcessor(); 320 void ResetEnableCameraPostProcess(); 321 int32_t SetAudioHapticsSyncId(int32_t syncId); 322 void ApplyAudioHapticsSyncId(); 323 void DoInitDemuxer(); 324 void ReleaseVideoDecoderOnMuted(); 325 326 bool isNetWorkPlay_ = false; 327 bool isDump_ = false; 328 int32_t appUid_{0}; 329 int32_t appPid_{0}; 330 int32_t appTokenId_{0}; 331 int64_t appFullTokenId_{0}; 332 OHOS::Media::Mutex stateMutex_{}; 333 OHOS::Media::Mutex initialPlayingEventMutex_{}; 334 OHOS::Media::ConditionVariable cond_{}; 335 std::atomic<bool> renderFirstFrame_ {false}; 336 std::atomic<bool> singleLoop_ {false}; 337 std::atomic<bool> isSeek_ {false}; 338 std::atomic<bool> isSeekClosest_ {false}; 339 std::atomic<PlaybackRateMode> playbackRateMode_ {PlaybackRateMode::SPEED_FORWARD_1_00_X}; 340 std::atomic<float> playbackRate_ {1.0f}; 341 342 std::shared_ptr<EventReceiver> playerEventReceiver_; 343 std::shared_ptr<FilterCallback> playerFilterCallback_; 344 std::vector<std::weak_ptr<Meta>> streamMeta_{}; 345 std::atomic<PlayerStates> pipelineStates_ {PlayerStates::PLAYER_IDLE}; // only update in UpdateStateNoLock() 346 std::queue<PlayerStates> pendingStates_ {}; 347 std::shared_ptr<OHOS::Media::Pipeline::Pipeline> pipeline_; 348 std::shared_ptr<DemuxerFilter> demuxer_; 349 std::shared_ptr<AudioDecoderFilter> audioDecoder_; 350 std::shared_ptr<AudioSinkFilter> audioSink_; 351 std::shared_ptr<SubtitleSinkFilter> subtitleSink_; 352 std::shared_ptr<InterruptMonitor> interruptMonitor_; 353 #ifdef SUPPORT_VIDEO 354 std::shared_ptr<DecoderSurfaceFilter> videoDecoder_; 355 std::shared_ptr<SeiParserFilter> seiDecoder_; 356 #endif 357 std::shared_ptr<MediaSyncManager> syncManager_; 358 std::atomic<PlayerStateId> curState_; 359 HiPlayerCallbackLooper callbackLooper_{}; 360 LiveController liveController_ {}; 361 std::weak_ptr<IPlayerEngineObs> playerEngineObs_{}; 362 sptr<Surface> surface_ {nullptr}; 363 std::string url_; 364 std::string subUrl_; 365 bool hasExtSub_ {false}; 366 std::atomic<int32_t> durationMs_{-1}; 367 int64_t mediaStartPts_{0}; 368 std::shared_ptr<IMediaDataSource> dataSrc_{nullptr}; 369 std::shared_ptr<IMediaSourceLoader> sourceLoader_{nullptr}; 370 std::atomic<int32_t> videoWidth_{0}; 371 std::atomic<int32_t> videoHeight_{0}; 372 std::atomic<bool> needSwapWH_{false}; 373 std::atomic<bool> isInterruptNeeded_{false}; 374 bool isEnableStartFrameRateOpt_ {true}; 375 std::atomic<bool> isBufferingEnd_{false}; 376 377 std::shared_ptr<Meta> audioRenderInfo_{nullptr}; 378 std::shared_ptr<Meta> audioInterruptMode_{nullptr}; 379 int32_t volumeMode_ = 0; 380 bool isStreaming_{false}; 381 382 int32_t rotation90 = 90; 383 int32_t rotation270 = 270; 384 385 std::shared_ptr<SeekAgent> seekAgent_; 386 387 std::mutex drmMutex_; 388 std::mutex flvLiveMutex_; 389 std::condition_variable drmConfigCond_; 390 std::condition_variable flvLiveCond_; 391 bool isDrmProtected_ = false; 392 bool isDrmPrepared_ = false; 393 bool stopWaitingDrmConfig_ = false; 394 #ifdef SUPPORT_AVPLAYER_DRM 395 sptr<DrmStandard::IMediaKeySessionService> keySessionServiceProxy_{nullptr}; 396 #endif 397 int32_t svpMode_ = HiplayerSvpMode::SVP_CLEAR; 398 399 bool isInitialPlay_ = true; 400 std::vector<std::pair<EventType, bool>> initialAVStates_; 401 std::vector<std::pair<std::string, bool>> completeState_; 402 std::mutex seekMutex_; 403 std::string bundleName_ {}; 404 405 std::map<std::string, std::string> header_; 406 uint32_t preferedWidth_ = 0; 407 uint32_t preferedHeight_ = 0; 408 uint32_t bufferDuration_ = 0; 409 double bufferDurationForPlaying_ = 0; 410 double maxLivingDelayTime_ = -1; 411 bool isSetBufferDurationForPlaying_ {false}; 412 bool isFlvLive_ {false}; 413 bool preferHDR_ = false; 414 OHOS::Media::MediaType mutedMediaType_ = OHOS::Media::MediaType::MEDIA_TYPE_MAX_COUNT; 415 std::string audioLanguage_; 416 std::string subtitleLanguage_; 417 std::vector<AVPlayMediaStream> playMediaStreamVec_; 418 419 std::string playerId_; 420 std::string mimeType_; 421 int32_t currentAudioTrackId_ = -1; 422 int32_t defaultAudioTrackId_ = -1; 423 int32_t currentVideoTrackId_ = -1; 424 int32_t defaultVideoTrackId_ = -1; 425 int32_t currentSubtitleTrackId_ = -1; 426 int32_t defaultSubtitleTrackId_ = -1; 427 PlayStatisticalInfo playStatisticalInfo_; 428 std::atomic<int64_t> startTime_ = 0; 429 int64_t maxSeekLatency_ = 0; 430 int64_t maxAccurateSeekLatency_ = 0; 431 uint64_t instanceId_ = 0; 432 int32_t apiVersion_ = 0; 433 int64_t maxSurfaceSwapLatency_ = 0; 434 int64_t playTotalDuration_ = 0; 435 bool inEosSeek_ = false; 436 std::atomic<bool> isDoCompletedSeek_{false}; 437 OHOS::Media::Mutex stateChangeMutex_{}; 438 int64_t playRangeStartTime_ = -1; 439 int64_t playRangeEndTime_ = -1; 440 bool isSetPlayRange_ = false; 441 int64_t startTimeWithMode_ = -1; 442 int64_t endTimeWithMode_ = -1; 443 PlayerSeekMode playRangeSeekMode_ = PlayerSeekMode::SEEK_PREVIOUS_SYNC; 444 445 std::mutex seekContinousMutex_; 446 std::atomic<int64_t> seekContinousBatchNo_ {-1}; 447 std::shared_ptr<DraggingPlayerAgent> draggingPlayerAgent_ {nullptr}; 448 int64_t lastSeekContinousPos_ {-1}; 449 bool inEosPlayingSeekContinuous_ = false; 450 std::atomic<bool> needUpdateSubtitle_ {true}; 451 std::shared_ptr<DfxAgent> dfxAgent_{}; 452 bool maxAmplitudeCbStatus_ {false}; 453 OHOS::Media::Mutex handleCompleteMutex_{}; 454 int64_t playStartTime_ = 0; 455 std::atomic<bool> isBufferingStartNotified_ {false}; 456 std::atomic<bool> needUpdateSei_ {true}; 457 bool seiMessageCbStatus_ {false}; 458 std::vector<int32_t> payloadTypes_{}; 459 bool isPerfRecEnabled_ { false }; 460 OHOS::Media::Mutex interruptMutex_{}; 461 bool isHintPauseReceived_ { false }; 462 std::atomic<bool> interruptNotifyPlay_ {false}; 463 std::atomic<bool> isSaveInterruptEventNeeded_ {true}; 464 OHOS::AudioStandard::InterruptEvent interruptEvent_ = OHOS::AudioStandard::InterruptEvent( 465 OHOS::AudioStandard::INTERRUPT_TYPE_END, 466 OHOS::AudioStandard::INTERRUPT_SHARE, 467 OHOS::AudioStandard::INTERRUPT_HINT_RESUME); 468 bool isCalledBySystemApp_ { false }; 469 470 std::atomic<bool> isOnlyAudio_ {false}; 471 472 // post processor 473 static constexpr int32_t MAX_TARGET_WIDTH = 1920; 474 static constexpr int32_t MAX_TARGET_HEIGHT = 1080; 475 static constexpr int32_t MIN_TARGET_WIDTH = 320; 476 static constexpr int32_t MIN_TARGET_HEIGHT = 320; 477 static constexpr int32_t DEFAULT_SYNC_ID = 0; 478 int32_t audioHapticsSyncId_ {DEFAULT_SYNC_ID}; 479 int32_t postProcessorTargetWidth_ = MAX_TARGET_WIDTH; 480 int32_t postProcessorTargetHeight_ = MAX_TARGET_HEIGHT; 481 VideoPostProcessorType videoPostProcessorType_ {VideoPostProcessorType::NONE}; 482 std::atomic<bool> isPostProcessorOn_ {false}; 483 // memory usage 484 std::unordered_map<std::string, uint32_t> memoryUsageInfo_ {}; 485 std::mutex memoryReportMutex_; 486 std::mutex fdMutex_ {}; 487 std::unique_ptr<FdsanFd> fdsanFd_ = nullptr; 488 std::atomic<bool> enableCameraPostprocessing_ {false}; 489 bool isForzenSeekRecv_ = false; 490 bool eosInLoopForFrozen_ = false; 491 int64_t frozenSeekTime_ = 0; 492 PlayerSeekMode frozenSeekMode_ = PlayerSeekMode::SEEK_NEXT_SYNC; 493 bool isDownloadPaused_ = false; 494 std::mutex freezeMutex_; 495 bool isForceLoadVideo_ {false}; 496 bool keepDecodingOnMute_ = false; 497 bool isVideoMuted_ = false; 498 bool isVideoDecoderInited_ = false; 499 }; 500 } // namespace Media 501 } // namespace OHOS 502 #endif // HI_PLAYER_IMPL_H 503