1 /* 2 * Copyright (C) 2024 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 OH_VEF_VIDEO_ENCODER_ENGINE_H 17 #define OH_VEF_VIDEO_ENCODER_ENGINE_H 18 19 #include "codec/common/codec_common.h" 20 #include <memory> 21 #include "video_editor.h" 22 #include "native_avcodec_base.h" 23 #include "codec/audio/pcm_buffer_queue.h" 24 25 namespace OHOS { 26 namespace Media { 27 28 class VideoEncodeCallback { 29 public: 30 virtual void OnEncodeFrame(uint64_t pts) = 0; 31 virtual void OnEncodeResult(CodecResult result) = 0; 32 }; 33 34 struct VideoMuxerParam { 35 int targetFileFd { -1 }; 36 OH_AVOutputFormat avOutputFormat = AV_OUTPUT_FORMAT_MPEG_4; 37 int32_t rotation = 0; 38 }; 39 40 struct VideoEncodeParam { 41 VideoMuxerParam muxerParam; 42 OH_AVFormat* videoTrunkFormat = nullptr; 43 OH_AVFormat* audioTrunkFormat = nullptr; 44 }; 45 46 class IVideoEncoderEngine { 47 public: 48 static std::shared_ptr<IVideoEncoderEngine> Create(const VideoEncodeParam& encodeParam, VideoEncodeCallback* cb); 49 50 virtual VEFError Init(const VideoEncodeParam& encodeParam) = 0; 51 virtual uint64_t GetId() const = 0; 52 virtual VEFError StartEncode() = 0; 53 virtual VEFError StopEncode() = 0; 54 virtual VEFError SendEos() = 0; 55 virtual VEFError Flush() = 0; 56 virtual OHNativeWindow* GetVideoInputWindow() = 0; 57 virtual std::shared_ptr<PcmBufferQueue> GetAudioInputBufferQueue() const = 0; 58 }; 59 60 } // namespace Media 61 } // namespace OHOS 62 63 #endif // OH_VEF_VIDEO_ENCODER_ENGINE_H