1 /*
2  * Copyright (c) 2021-2021 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 HISTREAMER_PLUGIN_CORE_MUXER_H
17 #define HISTREAMER_PLUGIN_CORE_MUXER_H
18 
19 #include "plugin/common/plugin_buffer.h"
20 #include "plugin/core/base.h"
21 
22 namespace OHOS {
23 namespace Media {
24 namespace Plugin {
25 struct MuxerPlugin;
26 struct DataSinkHelper {
27     virtual ~DataSinkHelper() = default;
28     virtual Status WriteAt(int64_t offset, const std::shared_ptr<Buffer>& buffer) = 0;
29 };
30 class Muxer : public Base {
31 public:
32     Muxer(const Muxer &) = delete;
33     Muxer operator=(const Muxer &) = delete;
34     ~Muxer() override = default;
35     Status SetTrackParameter(uint32_t trackId, Plugin::Tag tag, const Plugin::ValueType& value);
36     Status GetTrackParameter(uint32_t trackId, Plugin::Tag tag, Plugin::ValueType& value);
37     Status AddTrack(uint32_t& trackId);
38     Status SetDataSink(const std::shared_ptr<DataSinkHelper>& dataSink);
39     Status WriteHeader();
40     Status WriteFrame(const std::shared_ptr<Buffer>& buffer);
41     Status WriteTrailer();
42 private:
43     friend class PluginManager;
44 
45     Muxer(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr<MuxerPlugin> plugin);
46 
47 private:
48     std::shared_ptr<MuxerPlugin> muxer_;
49 };
50 } // namespace Plugin
51 } // namespace Media
52 } // namespace OHOS
53 #endif // HISTREAMER_PLUGIN_CORE_MUXER_H
54