Skip to content

Commit

Permalink
Add rtcCreateOffer() and rtcCreateAnswer()
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Jan 16, 2025
1 parent 00ffc07 commit 7d491b8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/rtc/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ RTC_C_EXPORT int rtcSetIceStateChangeCallback(int pc, rtcIceStateChangeCallbackF
RTC_C_EXPORT int rtcSetGatheringStateChangeCallback(int pc, rtcGatheringStateCallbackFunc cb);
RTC_C_EXPORT int rtcSetSignalingStateChangeCallback(int pc, rtcSignalingStateCallbackFunc cb);

RTC_C_EXPORT int rtcSetLocalDescription(int pc, const char *type);
RTC_C_EXPORT int rtcSetLocalDescription(int pc, const char *type); // type may be NULL
RTC_C_EXPORT int rtcSetRemoteDescription(int pc, const char *sdp, const char *type);
RTC_C_EXPORT int rtcAddRemoteCandidate(int pc, const char *cand, const char *mid);

Expand All @@ -221,6 +221,10 @@ RTC_C_EXPORT int rtcGetRemoteDescription(int pc, char *buffer, int size);
RTC_C_EXPORT int rtcGetLocalDescriptionType(int pc, char *buffer, int size);
RTC_C_EXPORT int rtcGetRemoteDescriptionType(int pc, char *buffer, int size);

// For specific use cases only
RTC_C_EXPORT int rtcCreateOffer(int pc, char *buffer, int size);
RTC_C_EXPORT int rtcAnswerOffer(int pc, char *buffer, int size);

RTC_C_EXPORT int rtcGetLocalAddress(int pc, char *buffer, int size);
RTC_C_EXPORT int rtcGetRemoteAddress(int pc, char *buffer, int size);

Expand Down
18 changes: 18 additions & 0 deletions src/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,24 @@ int rtcGetRemoteDescriptionType(int pc, char *buffer, int size) {
});
}

int rtcCreateOffer(int pc, char *buffer, int size) {
return wrap([&] {
auto peerConnection = getPeerConnection(pc);

auto desc = peerConnection->createOffer();
return copyAndReturn(string(desc), buffer, size);
});
}

int rtcCreateAnswer(int pc, char *buffer, int size) {
return wrap([&] {
auto peerConnection = getPeerConnection(pc);

auto desc = peerConnection->createAnswer();
return copyAndReturn(string(desc), buffer, size);
});
}

int rtcGetLocalAddress(int pc, char *buffer, int size) {
return wrap([&] {
auto peerConnection = getPeerConnection(pc);
Expand Down

0 comments on commit 7d491b8

Please sign in to comment.