1 /* 2 * Copyright (c) 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 #ifndef AV_CODEC_PROXY_H 16 #define AV_CODEC_PROXY_H 17 #include "av_codec_interface.h" 18 #include "camera_dynamic_loader.h" 19 20 namespace OHOS { 21 namespace CameraStandard { 22 class AVCodecProxy : public AVCodecIntf { 23 public: 24 explicit AVCodecProxy( 25 std::shared_ptr<Dynamiclib> avcodecLib, std::shared_ptr<AVCodecIntf> avcodecIntf); 26 static std::shared_ptr<AVCodecProxy> CreateAVCodecProxy(); 27 ~AVCodecProxy() override; 28 static void Release(); 29 int32_t CreateAVMuxer(int32_t fd, OutputFormat format) override; 30 int32_t CreateAVCodecVideoEncoder(const std::string& codecMime) override; 31 int32_t AVMuxerSetParameter(const std::shared_ptr<Meta>& param) override; 32 int32_t AVMuxerSetUserMeta(const std::shared_ptr<Meta>& userMeta) override; 33 int32_t AVMuxerAddTrack(int32_t& trackIndex, const std::shared_ptr<Meta>& trackDesc) override; 34 int32_t AVMuxerStart() override; 35 int32_t AVMuxerWriteSample(uint32_t trackIndex, const std::shared_ptr<AVBuffer>& sample) override; 36 int32_t AVMuxerStop() override; 37 int32_t AVCodecVideoEncoderPrepare() override; 38 int32_t AVCodecVideoEncoderStart() override; 39 int32_t AVCodecVideoEncoderStop() override; 40 int32_t AVCodecVideoEncoderRelease() override; 41 bool IsVideoEncoderExisted() override; 42 sptr<Surface> CreateInputSurface() override; 43 int32_t QueueInputBuffer(uint32_t index) override; 44 int32_t AVCodecVideoEncoderNotifyEos() override; 45 int32_t ReleaseOutputBuffer(uint32_t index) override; 46 int32_t AVCodecVideoEncoderSetParameter(const Format& format) override; 47 int32_t AVCodecVideoEncoderSetCallback(const std::shared_ptr<MediaCodecCallback>& callback) override; 48 int32_t AVCodecVideoEncoderConfigure(const Format& format) override; 49 void CreateAVSource(int32_t fd, int64_t offset, int64_t size) override; 50 int32_t AVSourceGetSourceFormat(Format& format) override; 51 int32_t AVSourceGetUserMeta(Format& format) override; 52 int32_t AVSourceGetTrackFormat(Format& format, uint32_t trackIndex) override; 53 void CreateAVDemuxer(std::shared_ptr<AVSource> source) override; 54 int32_t ReadSampleBuffer(uint32_t trackIndex, std::shared_ptr<AVBuffer> sample) override; 55 int32_t AVDemuxerSeekToTime(int64_t millisecond, SeekMode mode) override; 56 int32_t AVDemuxerSelectTrackByID(uint32_t trackIndex) override; 57 private: 58 std::shared_ptr<Dynamiclib> avcodecLib_ = {nullptr}; 59 std::shared_ptr<AVCodecIntf> avcodecIntf_ = {nullptr}; 60 }; 61 } // namespace CameraStandard 62 } // namespace OHOS 63 #endif // AV_CODEC_PROXY_H