• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MUXER_H
17 #define OH_VEF_VIDEO_MUXER_H
18 
19 #include <native_avcodec_base.h>
20 #include <native_avmuxer.h>
21 #include "video_editor.h"
22 #include "ffrt.h"
23 #include "codec/video_encoder_engine.h"
24 
25 namespace OHOS {
26 namespace Media {
27 class VideoMuxer {
28 public:
29     VideoMuxer(uint64_t id);
30     ~VideoMuxer();
31 
32     VEFError Init(const VideoMuxerParam& muxerParam);
33     VEFError AddVideoTrack(OH_AVFormat* format);
34     VEFError AddAudioTrack(OH_AVFormat* format);
35     VEFError Start();
36     VEFError Stop();
37     VEFError WriteVideoData(OH_AVMemory* data, OH_AVCodecBufferAttr* attr);
38     VEFError WriteAudioData(OH_AVMemory* data, OH_AVCodecBufferAttr* attr);
39 
40 private:
41     std::string logTag_ = "";
42     int32_t videoTrackId_ = -1;
43     int32_t audioTrackId_ = -1;
44     OH_AVMuxer* muxer_ = nullptr;
45     ffrt::mutex writeFrameMutex_;
46 };
47 } // namespace Media
48 } // namespace OHOS
49 
50 #endif // OH_VEF_VIDEO_MUXER_H
51