• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HDR_MUXER_H
16 #define HDR_MUXER_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 class MuxerSample {
31 public:
32     MuxerSample() = default;
33     ~MuxerSample();
34     void Configure();
35     void Start();
36     void WaitForEOS();
37     void Stop();
38     void WriteAudioTrack();
39     void WriteVideoTrack();
40     bool InitMuxerDeMuxer(const char *mp4File);
41     void RunHdrMuxer(const uint8_t *data, size_t size, const char *mp4File);
42     OH_AVDemuxer *demuxer = nullptr;
43     OH_AVMuxer *muxer = nullptr;
44     const uint8_t *fuzzData = nullptr;
45     size_t fuzzSize;
46     uint32_t videoTrackID = -1;
47     uint32_t audioTrackID = -1;
48     std::condition_variable waitCond;
49     std::atomic<bool> isAudioFinish;
50     std::atomic<bool> isVideoFinish;
51     uint32_t frameDuration = 0;
52     std::unique_ptr<std::thread> audioThread;
53     std::unique_ptr<std::thread> videoThread;
54 private:
55     OH_AVSource *inSource = nullptr;
56     int32_t trackCount = 0;
57     int32_t fd;
58     int32_t outFd;
59 };
60 } // namespace MediaAVCodec
61 } // namespace OHOS
62 
63 #endif