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_CODEC_ENCODER_H 17 #define OH_VEF_CODEC_ENCODER_H 18 19 #include <string> 20 #include "codec/common/codec_common.h" 21 22 namespace OHOS { 23 namespace Media { 24 25 class CodecEncoder { 26 public: 27 CodecEncoder() = delete; 28 CodecEncoder(uint64_t id, std::string logTag); 29 virtual ~CodecEncoder(); 30 31 virtual VEFError Init(OH_AVFormat* format) = 0; 32 virtual VEFError Start() = 0; 33 virtual VEFError Stop() = 0; 34 virtual VEFError Flush() = 0; 35 36 protected: 37 OH_AVCodecAsyncCallback GetAVCodecAsyncCallback(); 38 virtual void CodecOnErrorInner(OH_AVCodec* codec, int32_t errorCode) = 0; 39 40 uint64_t id_ { 0 }; 41 std::string logTag_; 42 OH_AVCodec* encoder_ { nullptr }; 43 std::string codecMime_; 44 CodecState state_ { CodecState::INIT }; 45 46 private: 47 virtual void CodecOnStreamChangedInner(OH_AVFormat* format) = 0; 48 virtual void CodecOnNeedInputDataInner(OH_AVCodec* codec, uint32_t index, OH_AVMemory* data) = 0; 49 virtual void CodecOnNewOutputDataInner(OH_AVCodec* codec, uint32_t index, OH_AVMemory* data, 50 OH_AVCodecBufferAttr* attr) = 0; 51 }; 52 } // namespace Media 53 } // namespace OHOS 54 55 #endif // OH_VEF_CODEC_ENCODER_H