1/*
2 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
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 STREAM_PLUGIN_H
17#define STREAM_PLUGIN_H
18
19#include "logging.h"
20#include "plugin_module_api.h"
21#include "stream_plugin_config.pb.h"
22#include "stream_plugin_result.pb.h"
23
24#include <atomic>
25#include <mutex>
26#include <thread>
27#include <vector>
28
29class StreamPlugin {
30public:
31    StreamPlugin();
32    ~StreamPlugin();
33    int Start(const uint8_t* configData, uint32_t configSize);
34    int Stop();
35
36    int SetWriter(WriterStruct* writer);
37    void Loop(void);
38
39private:
40    StreamConfig protoConfig_;
41    std::vector<char> buffer_;
42    WriterStruct* resultWriter_ = nullptr;
43
44    std::mutex mutex_;
45    std::thread writeThread_;
46    std::atomic<bool> running_ = true;
47};
48
49#endif // STREAM_PLUGIN_H