mirror of
https://github.com/niellun/FastCarPlay.git
synced 2026-06-07 09:38:25 +02:00
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#ifndef SRC_PROTOCOL
|
|
#define SRC_PROTOCOL
|
|
|
|
#include "struct/atomic_queue.h"
|
|
#include "struct/message.h"
|
|
#include "helper/iprotocol.h"
|
|
#include "settings.h"
|
|
#include "connector.h"
|
|
|
|
class Protocol : public IProtocol
|
|
{
|
|
|
|
public:
|
|
Protocol(uint16_t width, uint16_t height, uint16_t fps, uint16_t padding);
|
|
~Protocol();
|
|
|
|
Protocol(const Protocol &) = delete;
|
|
Protocol &operator=(const Protocol &) = delete;
|
|
|
|
static const char *cmdString(int cmd);
|
|
|
|
void start(StatusCallback onStatus);
|
|
void stop();
|
|
|
|
void sendKey(int key);
|
|
void sendInit(int width, int height, int fps);
|
|
void sendFile(const char *filename, const uint8_t *data, uint32_t length);
|
|
void sendFile(const char *filename, const char *value);
|
|
void sendFile(const char *filename, int value);
|
|
void sendClick(float x, float y, bool down);
|
|
void sendMove(float dx, float dy);
|
|
|
|
Connector connector;
|
|
AtomicQueue<Message> videoData;
|
|
AtomicQueue<Message> audioStream0;
|
|
AtomicQueue<Message> audioStream1;
|
|
AtomicQueue<Message> audioStream2;
|
|
bool phoneConnected;
|
|
|
|
private:
|
|
void sendInt(uint32_t cmd, uint32_t value, bool encryption = true);
|
|
void sendEncryption();
|
|
|
|
void onStatus(const char *status) override;
|
|
void onDevice(bool connected) override;
|
|
void onData(uint32_t cmd, uint32_t length, uint8_t *data) override;
|
|
|
|
void onPhone(bool connected);
|
|
|
|
uint16_t _width;
|
|
uint16_t _height;
|
|
uint16_t _fps;
|
|
|
|
StatusCallback _statusCallback = nullptr;
|
|
};
|
|
|
|
#endif /* SRC_PROTOCOL */
|