Skip to content

Commit bab9544

Browse files
Add rtcCreateOffer() and rtcCreateAnswer()
1 parent 00ffc07 commit bab9544

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

include/rtc/rtc.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ RTC_C_EXPORT int rtcSetIceStateChangeCallback(int pc, rtcIceStateChangeCallbackF
211211
RTC_C_EXPORT int rtcSetGatheringStateChangeCallback(int pc, rtcGatheringStateCallbackFunc cb);
212212
RTC_C_EXPORT int rtcSetSignalingStateChangeCallback(int pc, rtcSignalingStateCallbackFunc cb);
213213

214-
RTC_C_EXPORT int rtcSetLocalDescription(int pc, const char *type);
214+
RTC_C_EXPORT int rtcSetLocalDescription(int pc, const char *type); // type may be NULL
215215
RTC_C_EXPORT int rtcSetRemoteDescription(int pc, const char *sdp, const char *type);
216216
RTC_C_EXPORT int rtcAddRemoteCandidate(int pc, const char *cand, const char *mid);
217217

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

224+
// For specific use cases only
225+
RTC_C_EXPORT int rtcCreateOffer(int pc, char *buffer, int size);
226+
RTC_C_EXPORT int rtcCreateAnswer(int pc, char *buffer, int size);
227+
224228
RTC_C_EXPORT int rtcGetLocalAddress(int pc, char *buffer, int size);
225229
RTC_C_EXPORT int rtcGetRemoteAddress(int pc, char *buffer, int size);
226230

src/capi.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,24 @@ int rtcGetRemoteDescriptionType(int pc, char *buffer, int size) {
631631
});
632632
}
633633

634+
int rtcCreateOffer(int pc, char *buffer, int size) {
635+
return wrap([&] {
636+
auto peerConnection = getPeerConnection(pc);
637+
638+
auto desc = peerConnection->createOffer();
639+
return copyAndReturn(string(desc), buffer, size);
640+
});
641+
}
642+
643+
int rtcCreateAnswer(int pc, char *buffer, int size) {
644+
return wrap([&] {
645+
auto peerConnection = getPeerConnection(pc);
646+
647+
auto desc = peerConnection->createAnswer();
648+
return copyAndReturn(string(desc), buffer, size);
649+
});
650+
}
651+
634652
int rtcGetLocalAddress(int pc, char *buffer, int size) {
635653
return wrap([&] {
636654
auto peerConnection = getPeerConnection(pc);

0 commit comments

Comments
 (0)