PassengerStatistics/Main/VideoInput.h

34 lines
723 B
C
Raw Normal View History

2024-03-13 11:40:55 +08:00
#ifndef __VIDEOINPUT_H__
#define __VIDEOINPUT_H__
#include <functional>
#include <string>
#include <thread>
class VideoInput {
public:
using PacketHandler = std::function<void(const uint8_t *, uint32_t)>;
VideoInput(int32_t width, int32_t height);
~VideoInput();
bool start();
void stop();
bool isStarted() const;
bool startEncode();
void setPacketHandler(const PacketHandler &hanlder);
protected:
void run();
void encodeRun();
private:
int32_t m_width;
int32_t m_height;
int32_t m_vid = -1;
int32_t m_encodeChannel = -1;
bool m_exit = true;
std::thread m_thread;
std::thread m_encodeThread;
PacketHandler m_handler;
};
#endif // __VIDEOINPUT_H__