/* * Copyright (C) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef AVMETADATAHELPER_HST_IMPL_H #define AVMETADATAHELPER_HST_IMPL_H #include #include #include "avmetadata_collector.h" #include "av_thumbnail_generator.h" #include "buffer/avsharedmemorybase.h" #include "common/status.h" #include "i_avmetadatahelper_engine.h" #include "i_avmetadatahelper_service.h" #include "media_demuxer.h" #include "nocopyable.h" namespace OHOS { namespace Media { class TimeAndIndexConversion; class AVMetadataHelperImpl : public IAVMetadataHelperEngine, public std::enable_shared_from_this, public NoCopyable { public: AVMetadataHelperImpl(); ~AVMetadataHelperImpl(); void OnError(MediaAVCodec::AVCodecErrorType errorType, int32_t errorCode); int32_t SetSource(const std::string &uri, int32_t usage) override; int32_t SetSource(const std::shared_ptr &dataSrc) override; std::string ResolveMetadata(int32_t key) override; std::unordered_map ResolveMetadata() override; std::shared_ptr GetAVMetadata() override; std::shared_ptr FetchFrameAtTime( int64_t timeUs, int32_t option, const OutputConfiguration ¶m) override; std::shared_ptr FetchFrameYuv( int64_t timeUs, int32_t option, const OutputConfiguration ¶m) override; std::shared_ptr FetchArtPicture() override; int32_t GetTimeByFrameIndex(uint32_t index, uint64_t &time) override; int32_t GetFrameIndexByTime(uint64_t time, uint32_t &index) override; void SetInterruptState(bool isInterruptNeeded) override; private: std::shared_ptr mediaDemuxer_; std::shared_ptr metadataCollector_; std::shared_ptr thumbnailGenerator_; std::unordered_map collectedMeta_; std::shared_ptr collectedArtPicture_; std::shared_ptr fetchedFrameAtTime_; std::shared_ptr conversion_ { nullptr }; std::atomic_bool stopProcessing_{ false }; std::atomic_bool isForFrameConvert_{ false }; Status SetSourceInternel(const std::string &uri, bool isForFrameConvert); Status SetSourceInternel(const std::shared_ptr &dataSrc); Status SetSourceForFrameConvert(const std::string &uri); Status InitMetadataCollector(); Status InitThumbnailGenerator(); int32_t GetTimeForFrameConvert(uint32_t index, uint64_t &time); int32_t GetIndexForFrameConvert(uint64_t time, uint32_t &index); void Reset(); void Destroy(); std::string groupId_; std::atomic isInterruptNeeded_ = false; }; } // namespace Media } // namespace OHOS #endif // AVMETADATAHELPER_HST_IMPL_H