Files
screen_cast/include/screencast/network/transport.h
T

44 lines
1.0 KiB
C++

#pragma once
#include "screencast/network/rtp_packet.h"
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
namespace sc {
struct Endpoint {
std::string address;
uint16_t port = 0;
};
// UDP transport for RTP packets. Owned by the sender or receiver pipeline.
class RtpTransport {
public:
using ReceiveCallback = std::function<void(RtpPacket)>;
virtual ~RtpTransport() = default;
// Bind locally and start the receive loop. Callback is invoked on the
// transport's thread.
virtual bool start(const Endpoint& local_endpoint, ReceiveCallback on_receive) = 0;
// Send a packet to the configured peer.
virtual bool send(const RtpPacket& packet) = 0;
// Set the peer endpoint dynamically (e.g. after signaling).
virtual void set_peer(const Endpoint& peer) = 0;
// Stop the transport and close sockets.
virtual void stop() = 0;
};
class RtpTransportFactory {
public:
static std::unique_ptr<RtpTransport> create();
};
} // namespace sc