From 7335107743bd44f5ecc9a2c023a1179e486bd534 Mon Sep 17 00:00:00 2001 From: c00489537 Date: Sat, 29 Apr 2023 03:47:04 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4include?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: c00489537 --- services/engine/codec/video/include/fcodec.h | 169 ------------------- 1 file changed, 169 deletions(-) delete mode 100755 services/engine/codec/video/include/fcodec.h diff --git a/services/engine/codec/video/include/fcodec.h b/services/engine/codec/video/include/fcodec.h deleted file mode 100755 index 3871d72b7..000000000 --- a/services/engine/codec/video/include/fcodec.h +++ /dev/null @@ -1,169 +0,0 @@ -#ifndef FCODEC_H -#define FCODEC_H - -#include -#include -#include -#include -#include -#include -#include "codecbase.h" -#include "avcodec_errors.h" //Errorcode -#include "avcodec_common.h" //AVCodecBufferInfo & callback -#include "plugin_buffer.h" //buffer -#include "surface_memory.h" //SurfaceMemory surface_allocator -#include "ffmpeg_utils.h" -#include "task_thread.h" -#include "share_memory.h" -#include "codec_utils.h" -// #include "AVCodecBase.h" - -extern "C" { -#include "libavcodec/avcodec.h" -#include "libswscale/swscale.h" -#include "libavutil/imgutils.h" -}; - -// using namespace OHOS::Media::Codec; -namespace OHOS { namespace Media { namespace Codec { - -class FCodec : public CodecBase { -public: - FCodec() = default; - ~FCodec() override = default; - static std::shared_ptr Create(const std::string &name); - static std::shared_ptr Create(bool isEncoder, const std::string &mime); - - int32_t Configure(const Format &format) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Flush() override; - int32_t Reset() override; - int32_t Release() override; - int32_t SetParameter(const Format &format) override; - int32_t GetOutputFormat(Format &format) override; - std::shared_ptr GetInputBuffer(size_t index) override; - int32_t QueueInputBuffer(size_t index, const AVCodecBufferInfo &info, AVCodecBufferFlag &flag) override; - std::shared_ptr GetOutputBuffer(size_t index) override; - int32_t ReleaseOutputBuffer(size_t index) override; - int32_t SetCallback(const std::shared_ptr &callback) override; - int32_t SetOutputSurface(sptr surface) override; - int32_t RenderOutputBuffer(size_t index) override; - int32_t Pause() override; - int32_t Resume() override; - int32_t NotifyEos() override; - sptr CreateInputSurface() override; - int32_t SignalRequestIDRFrame() override; - - struct BufferInfo - { - public: - BufferInfo(size_t index, uint32_t flag, int32_t offset, int32_t size, int64_t pts) : - index_(index), flag_(flag), offset_(offset), size_(size), pts_(pts){}; - ~BufferInfo() = default; - - size_t index_; - uint32_t flag_; - int32_t offset_; - int32_t size_; - int64_t pts_; - }; - - struct AVBuffer - { - public: - AVBuffer() = default; - ~AVBuffer() = default; - - enum status { - OWNED_BY_CODEC, - OWNED_BY_USER, - OWNED_BY_SURFACE, - }; - // std::vector> shabuffer_ {}; - std::shared_ptr shabuffer_; - std::shared_ptr buffer_; - std::atomic owner_; - uint64_t flag_; - int64_t pts_; - }; - -private: - int32_t Init(const std::string &name); - std::shared_ptr GetBuffer(size_t index, uint32_t port); - - enum struct State : int32_t { - Uninitialized, - Initialized, - Configured, - Running, - Flushing, - Flushed, - Stopping, - Releasing, - EOS, - Error, - }; - - template - void GetParameter(Tag tag, T &val); - bool IsActive() const; - void ResetContext(bool isFlush=false); - std::tuple CalculateBufferSize(); - int32_t AllocateBuffers(); - int32_t ReleaseBuffers(bool isFlush=false); - void sendFrame(); - void receiveFrame(); - void renderFrame(); - int32_t FillFrameBuffer(const std::shared_ptr &frameBuffer); - int32_t UpdateSurfaceMemory(std::shared_ptr &surfaceMemory, int64_t pts); - - std::string codecName_; - std::atomic state_{State::Uninitialized}; - uint32_t width_{0}; - uint32_t height_{0}; - std::map decParams_; - bool isUpTodate_{false}; - // INIT - std::shared_ptr avCodec_{nullptr}; - // Config - std::shared_ptr avCodecContext_{nullptr}; - // Start - std::shared_ptr avPacket_{nullptr}; - std::shared_ptr cachedFrame_{nullptr}; - // std::shared_ptr shaAlloc_{nullptr}; - std::shared_ptr sfAlloc_{nullptr}; - // Receive frame - uint8_t *scaleData_[AV_NUM_DATA_POINTERS]; - int32_t scaleLineSize_[AV_NUM_DATA_POINTERS]; - std::shared_ptr scale_{nullptr}; - bool isConverted_{false}; - // Running - std::vector> buffers_[2]; - std::list codecAvailBuffers_; // 保留 - std::list renderBuffers_; - std::list> inBufQue_; - uint32_t inBufferCnt_; // 输入buffer个数,默认8个 - uint32_t outBufferCnt_; // 输入buffer个数,默认8个 - uint32_t outBufferSize_; - sptr surface_{nullptr}; - VideoPixelFormat outputPixelFmt_{VideoPixelFormat::RGBA}; - VideoScaleType scalingType_ {VideoScaleType::VIDEO_SCALE_TYPE_FIT}; - SurfaceRotation surfaceRotate_{SurfaceRotation::SURFACE_ROTATION_0}; - - std::shared_ptr sendTask_{nullptr}; - std::shared_ptr receiveTask_{nullptr}; - std::shared_ptr renderTask_{nullptr}; - std::shared_mutex inputMutex_; - std::mutex outputMutex_; - std::mutex sendMutex_; - std::mutex syncMutex_; - std::condition_variable outputCv_; - std::condition_variable sendCv_; - std::shared_ptr callback_; - bool isSendWait_ = false; -}; - -}}} // namespace OHOS::Media::Codec - -#endif // FCODEC_H