Update test files to match the C API callback update with adding an ID parameter.

This commit is contained in:
Hanseul Jun
2020-10-04 11:32:52 -07:00
parent c38edd089b
commit 44eaaf038a
2 changed files with 15 additions and 15 deletions

View File

@ -42,33 +42,33 @@ typedef struct {
static Peer *peer1 = NULL; static Peer *peer1 = NULL;
static Peer *peer2 = NULL; static Peer *peer2 = NULL;
static void descriptionCallback(const char *sdp, const char *type, void *ptr) { static void descriptionCallback(int pc, const char *sdp, const char *type, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
printf("Description %d:\n%s\n", peer == peer1 ? 1 : 2, sdp); printf("Description %d:\n%s\n", peer == peer1 ? 1 : 2, sdp);
Peer *other = peer == peer1 ? peer2 : peer1; Peer *other = peer == peer1 ? peer2 : peer1;
rtcSetRemoteDescription(other->pc, sdp, type); rtcSetRemoteDescription(other->pc, sdp, type);
} }
static void candidateCallback(const char *cand, const char *mid, void *ptr) { static void candidateCallback(int pc, const char *cand, const char *mid, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
printf("Candidate %d: %s\n", peer == peer1 ? 1 : 2, cand); printf("Candidate %d: %s\n", peer == peer1 ? 1 : 2, cand);
Peer *other = peer == peer1 ? peer2 : peer1; Peer *other = peer == peer1 ? peer2 : peer1;
rtcAddRemoteCandidate(other->pc, cand, mid); rtcAddRemoteCandidate(other->pc, cand, mid);
} }
static void stateChangeCallback(rtcState state, void *ptr) { static void stateChangeCallback(int pc, rtcState state, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->state = state; peer->state = state;
printf("State %d: %d\n", peer == peer1 ? 1 : 2, (int)state); printf("State %d: %d\n", peer == peer1 ? 1 : 2, (int)state);
} }
static void gatheringStateCallback(rtcGatheringState state, void *ptr) { static void gatheringStateCallback(int pc, rtcGatheringState state, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->gatheringState = state; peer->gatheringState = state;
printf("Gathering state %d: %d\n", peer == peer1 ? 1 : 2, (int)state); printf("Gathering state %d: %d\n", peer == peer1 ? 1 : 2, (int)state);
} }
static void openCallback(void *ptr) { static void openCallback(int id, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->connected = true; peer->connected = true;
printf("DataChannel %d: Open\n", peer == peer1 ? 1 : 2); printf("DataChannel %d: Open\n", peer == peer1 ? 1 : 2);
@ -77,12 +77,12 @@ static void openCallback(void *ptr) {
rtcSendMessage(peer->dc, message, -1); // negative size indicates a null-terminated string rtcSendMessage(peer->dc, message, -1); // negative size indicates a null-terminated string
} }
static void closedCallback(void *ptr) { static void closedCallback(int id, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->connected = false; peer->connected = false;
} }
static void messageCallback(const char *message, int size, void *ptr) { static void messageCallback(int id, const char *message, int size, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
if (size < 0) { // negative size indicates a null-terminated string if (size < 0) { // negative size indicates a null-terminated string
printf("Message %d: %s\n", peer == peer1 ? 1 : 2, message); printf("Message %d: %s\n", peer == peer1 ? 1 : 2, message);
@ -91,7 +91,7 @@ static void messageCallback(const char *message, int size, void *ptr) {
} }
} }
static void dataChannelCallback(int dc, void *ptr) { static void dataChannelCallback(int pc, int dc, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->dc = dc; peer->dc = dc;
peer->connected = true; peer->connected = true;

View File

@ -43,44 +43,44 @@ static Peer *peer2 = NULL;
static const char *mediaDescription = "video 9 UDP/TLS/RTP/SAVPF\r\n" static const char *mediaDescription = "video 9 UDP/TLS/RTP/SAVPF\r\n"
"a=mid:video\r\n"; "a=mid:video\r\n";
static void descriptionCallback(const char *sdp, const char *type, void *ptr) { static void descriptionCallback(int pc, const char *sdp, const char *type, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
printf("Description %d:\n%s\n", peer == peer1 ? 1 : 2, sdp); printf("Description %d:\n%s\n", peer == peer1 ? 1 : 2, sdp);
Peer *other = peer == peer1 ? peer2 : peer1; Peer *other = peer == peer1 ? peer2 : peer1;
rtcSetRemoteDescription(other->pc, sdp, type); rtcSetRemoteDescription(other->pc, sdp, type);
} }
static void candidateCallback(const char *cand, const char *mid, void *ptr) { static void candidateCallback(int pc, const char *cand, const char *mid, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
printf("Candidate %d: %s\n", peer == peer1 ? 1 : 2, cand); printf("Candidate %d: %s\n", peer == peer1 ? 1 : 2, cand);
Peer *other = peer == peer1 ? peer2 : peer1; Peer *other = peer == peer1 ? peer2 : peer1;
rtcAddRemoteCandidate(other->pc, cand, mid); rtcAddRemoteCandidate(other->pc, cand, mid);
} }
static void stateChangeCallback(rtcState state, void *ptr) { static void stateChangeCallback(int pc, rtcState state, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->state = state; peer->state = state;
printf("State %d: %d\n", peer == peer1 ? 1 : 2, (int)state); printf("State %d: %d\n", peer == peer1 ? 1 : 2, (int)state);
} }
static void gatheringStateCallback(rtcGatheringState state, void *ptr) { static void gatheringStateCallback(int pc, rtcGatheringState state, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->gatheringState = state; peer->gatheringState = state;
printf("Gathering state %d: %d\n", peer == peer1 ? 1 : 2, (int)state); printf("Gathering state %d: %d\n", peer == peer1 ? 1 : 2, (int)state);
} }
static void openCallback(void *ptr) { static void openCallback(int id, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->connected = true; peer->connected = true;
printf("Track %d: Open\n", peer == peer1 ? 1 : 2); printf("Track %d: Open\n", peer == peer1 ? 1 : 2);
} }
static void closedCallback(void *ptr) { static void closedCallback(int id, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->connected = false; peer->connected = false;
} }
static void trackCallback(int tr, void *ptr) { static void trackCallback(int pc, int tr, void *ptr) {
Peer *peer = (Peer *)ptr; Peer *peer = (Peer *)ptr;
peer->tr = tr; peer->tr = tr;
peer->connected = true; peer->connected = true;