31 lines
619 B
C++
31 lines
619 B
C++
#pragma once
|
|
|
|
#include <winsock2.h>
|
|
#include <ws2tcpip.h>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
#pragma comment(lib, "ws2_32.lib")
|
|
|
|
struct PacketHeader {
|
|
uint64_t timestamp;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t frameType; // 0=I, 1=P
|
|
uint32_t dataSize;
|
|
};
|
|
|
|
class NetworkSender {
|
|
public:
|
|
NetworkSender();
|
|
~NetworkSender();
|
|
|
|
bool Initialize(const std::string& ip, int port);
|
|
bool SendFrame(const std::vector<uint8_t>& data, uint64_t timestamp, int width, int height, bool isKeyFrame);
|
|
|
|
private:
|
|
SOCKET socket_ = INVALID_SOCKET;
|
|
sockaddr_in destAddr_;
|
|
};
|