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 #ifndef AVCODEC_E2E_DEMO_API10_H 16 #define AVCODEC_E2E_DEMO_API10_H 17 18 #include <condition_variable> 19 #include <atomic> 20 #include <thread> 21 22 #include "native_avcodec_base.h" 23 #include "native_avdemuxer.h" 24 #include "native_avmuxer.h" 25 #include "native_avsource.h" 26 #include "native_avformat.h" 27 28 namespace OHOS { 29 namespace MediaAVCodec { 30 namespace E2EDemo { 31 class AVCodecE2EDemoAPI10 { 32 public: 33 explicit AVCodecE2EDemoAPI10(const char *file); 34 ~AVCodecE2EDemoAPI10(); 35 void Configure(); 36 void Start(); 37 void WaitForEOS(); 38 void Stop(); 39 void WriteAudioTrack(); 40 OH_AVDemuxer *demuxer = nullptr; 41 OH_AVMuxer *muxer = nullptr; 42 uint32_t videoTrackID = -1; 43 uint32_t audioTrackID = -1; 44 OH_AVCodec *dec = nullptr; 45 OH_AVCodec *enc = nullptr; 46 std::condition_variable waitCond; 47 std::atomic<bool> isFinish; 48 uint32_t frameDuration = 0; 49 std::unique_ptr<std::thread> audioThread; 50 private: 51 OH_AVSource *inSource = nullptr; 52 int32_t trackCount = 0; 53 int32_t fd; 54 int32_t outFd; 55 }; 56 } 57 } 58 } 59 60 #endif 61