43 lines
974 B
C++
43 lines
974 B
C++
#ifndef __VIDEOINPUT_H__
|
|
#define __VIDEOINPUT_H__
|
|
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
class VideoInputPrivate;
|
|
|
|
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();
|
|
bool startFileInput(const std::string &path, int32_t width, int32_t height);
|
|
void setPacketHandler(const PacketHandler &hanlder);
|
|
|
|
protected:
|
|
void run();
|
|
void fakeRun();
|
|
void encodeRun();
|
|
|
|
private:
|
|
VideoInputPrivate *m_d = nullptr;
|
|
int32_t m_width;
|
|
int32_t m_height;
|
|
|
|
std::string m_path;
|
|
std::shared_ptr<std::ifstream> m_ifs;
|
|
|
|
int32_t m_vid = -1;
|
|
int32_t m_decodeChannel = -1;
|
|
bool m_exit = true;
|
|
std::thread m_thread;
|
|
std::thread m_encodeThread;
|
|
PacketHandler m_handler;
|
|
};
|
|
#endif // __VIDEOINPUT_H__
|