• 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 <thread>
19 #include "native_avcodec_base.h"
20 #include "native_avdemuxer.h"
21 #include "native_avmuxer.h"
22 #include "native_avsource.h"
23 #include "native_avformat.h"
24 
25 namespace OHOS {
26 namespace MediaAVCodec {
27 class MuxerSample {
28 public:
29     MuxerSample() = default;
30     ~MuxerSample();
31     void Configure();
32     void Start();
33     void WaitForEOS();
34     void Stop();
35     void WriteAudioTrack();
36     void WriteVideoTrack();
37     bool InitMuxerDeMuxer(const char *mp4File);
38     void RunHdrMuxer(const uint8_t *data, size_t size, const char *mp4File);
39     OH_AVDemuxer *demuxer = nullptr;
40     OH_AVMuxer *muxer = nullptr;
41     const uint8_t *fuzzData = nullptr;
42     size_t fuzzSize;
43     uint32_t videoTrackID = -1;
44     uint32_t audioTrackID = -1;
45     uint32_t frameDuration = 0;
46     std::unique_ptr<std::thread> audioThread;
47     std::unique_ptr<std::thread> videoThread;
48 private:
49     OH_AVSource *inSource = nullptr;
50     int32_t trackCount = 0;
51     int32_t fd;
52     int32_t outFd;
53 };
54 } // namespace MediaAVCodec
55 } // namespace OHOS
56 
57 #endif