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