55 lines
1.6 KiB
C
55 lines
1.6 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <deque>
|
||
|
|
#include <mutex>
|
||
|
|
#include <string>
|
||
|
|
#include <vector>
|
||
|
|
|
||
|
|
enum class RtcEventType {
|
||
|
|
LocalDescription, // id=pc, s1=sdp, s2=type
|
||
|
|
LocalCandidate, // id=pc, s1=cand, s2=mid
|
||
|
|
StateChange, // id=pc, arg=rtcState
|
||
|
|
GatheringState, // id=pc, arg=rtcGatheringState
|
||
|
|
DataChannel, // id=pc, arg=new dc id
|
||
|
|
Open, // id=dc
|
||
|
|
Closed, // id=dc
|
||
|
|
Error, // id=dc, s1=error
|
||
|
|
Message // id=dc, data=payload, isString=text frame
|
||
|
|
};
|
||
|
|
|
||
|
|
struct RtcEvent {
|
||
|
|
RtcEventType type;
|
||
|
|
int id;
|
||
|
|
int arg = 0;
|
||
|
|
std::string s1;
|
||
|
|
std::string s2;
|
||
|
|
std::vector<char> data;
|
||
|
|
bool isString = false;
|
||
|
|
};
|
||
|
|
|
||
|
|
int runt_rtc_init();
|
||
|
|
void runt_rtc_cleanup();
|
||
|
|
|
||
|
|
int runt_rtc_create_peer_connection(const std::vector<std::string> &iceServers);
|
||
|
|
void runt_rtc_close_peer_connection(int pc);
|
||
|
|
void runt_rtc_delete_peer_connection(int pc);
|
||
|
|
void runt_rtc_set_local_description(int pc, const char *type);
|
||
|
|
int runt_rtc_set_remote_description(int pc, const char *sdp, const char *type);
|
||
|
|
int runt_rtc_add_remote_candidate(int pc, const char *cand, const char *mid);
|
||
|
|
std::string runt_rtc_get_local_description(int pc);
|
||
|
|
std::string runt_rtc_get_local_description_type(int pc);
|
||
|
|
|
||
|
|
int runt_rtc_create_data_channel(int pc, const char *label, bool unordered,
|
||
|
|
int maxRetransmits);
|
||
|
|
void runt_rtc_delete_data_channel(int dc);
|
||
|
|
|
||
|
|
int runt_rtc_send_message(int id, const char *data, int size);
|
||
|
|
void runt_rtc_close(int id);
|
||
|
|
void runt_rtc_delete(int id);
|
||
|
|
bool runt_rtc_is_open(int id);
|
||
|
|
int runt_rtc_get_buffered_amount(int id);
|
||
|
|
|
||
|
|
bool runt_rtc_random_bytes(char *out, int len);
|
||
|
|
|
||
|
|
bool runt_rtc_poll_event(RtcEvent &out);
|