Skip to content

Commit

Permalink
Renamed packetizer functions in C API
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Jan 20, 2024
1 parent 0484b45 commit 7ea19e9
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 43 deletions.
99 changes: 61 additions & 38 deletions include/rtc/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>

#ifdef RTC_STATIC
#define RTC_C_EXPORT
#else // dynamic library
Expand All @@ -27,16 +30,6 @@ extern "C" {
#endif
#endif

#ifdef _WIN32
#ifdef CAPI_STDCALL
#define RTC_API __stdcall
#else
#define RTC_API
#endif
#else // not WIN32
#define RTC_API
#endif

#ifndef RTC_ENABLE_WEBSOCKET
#define RTC_ENABLE_WEBSOCKET 1
#endif
Expand All @@ -53,8 +46,23 @@ extern "C" {
#define RTC_DEFAULT_MAXIMUM_PACKET_COUNT_FOR_NACK_CACHE ((unsigned)512)
#endif

#include <stdbool.h>
#include <stdint.h>
#ifdef _WIN32
#ifdef CAPI_STDCALL
#define RTC_API __stdcall
#else
#define RTC_API
#endif
#else // not WIN32
#define RTC_API
#endif

#if defined(__GNUC__) || defined(__clang__)
#define RTC_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define RTC_DEPRECATED __declspec(deprecated)
#else
#define DEPRECATED
#endif

// libdatachannel C API

Expand Down Expand Up @@ -320,16 +328,19 @@ typedef struct {
uint16_t sequenceNumber;
uint32_t timestamp;

// H264, H265, AV1
uint16_t maxFragmentSize; // Maximum fragment size, 0 means default

// H264/H265 only
rtcNalUnitSeparator nalSeparator; // NAL unit separator

// H264, H265, AV1
uint16_t maxFragmentSize; // Maximum fragment size

// AV1 only
rtcObuPacketization obuPacketization; // OBU paketization for AV1 samples

} rtcPacketizationHandlerInit;
} rtcPacketizerInit;

// Deprecated, do not use
typedef rtcPacketizerInit rtcPacketizationHandlerInit;

typedef struct {
uint32_t ssrc;
Expand All @@ -338,8 +349,6 @@ typedef struct {
const char *trackId; // optional, track ID used in MSID
} rtcSsrcForTypeInit;

// Opaque message

// Opaque type used (via rtcMessage*) to reference an rtc::Message
typedef void *rtcMessage;

Expand All @@ -349,34 +358,48 @@ typedef void *rtcMessage;
RTC_C_EXPORT rtcMessage *rtcCreateOpaqueMessage(void *data, int size);
RTC_C_EXPORT void rtcDeleteOpaqueMessage(rtcMessage *msg);

// Set MediaInterceptor for peer connection
// Set MediaInterceptor on peer connection
RTC_C_EXPORT int rtcSetMediaInterceptorCallback(int id, rtcInterceptorCallbackFunc cb);

// Set H264PacketizationHandler for track
RTC_C_EXPORT int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);

// Set H265PacketizationHandler for track
RTC_C_EXPORT int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);

// Set AV1PacketizationHandler for track
RTC_C_EXPORT int rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);

// Set OpusPacketizationHandler for track
RTC_C_EXPORT int rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);

// Set AACPacketizationHandler for track
RTC_C_EXPORT int rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);

// Set RtcpReceivingSession for track
// Set a packetizer on track
RTC_C_EXPORT int rtcSetH264Packetizer(int tr, const rtcPacketizerInit *init);
RTC_C_EXPORT int rtcSetH265Packetizer(int tr, const rtcPacketizerInit *init);
RTC_C_EXPORT int rtcSetAV1Packetizer(int tr, const rtcPacketizerInit *init);
RTC_C_EXPORT int rtcSetOpusPacketizer(int tr, const rtcPacketizerInit *init);
RTC_C_EXPORT int rtcSetAACPacketizer(int tr, const rtcPacketizerInit *init);

// Deprecated, do not use
RTC_DEPRECATED static inline int
rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
return rtcSetH264Packetizer(tr, init);
}
RTC_DEPRECATED static inline int
rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
return rtcSetH265Packetizer(tr, init);
}
RTC_DEPRECATED static inline int
rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
return rtcSetAV1Packetizer(tr, init);
}
RTC_DEPRECATED static inline int
rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
return rtcSetOpusPacketizer(tr, init);
}
RTC_DEPRECATED static inline int
rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
return rtcSetAACPacketizer(tr, init);
}

// Chain RtcpReceivingSession on track
RTC_C_EXPORT int rtcChainRtcpReceivingSession(int tr);

// Chain RtcpSrReporter to handler chain for given track
// Chain RtcpSrReporter on track
RTC_C_EXPORT int rtcChainRtcpSrReporter(int tr);

// Chain RtcpNackResponder to handler chain for given track
// Chain RtcpNackResponder on track
RTC_C_EXPORT int rtcChainRtcpNackResponder(int tr, unsigned int maxStoredPacketsCount);

// Chain PliHandler to handler chain for given track
// Chain PliHandler on track
RTC_C_EXPORT int rtcChainPliHandler(int tr, rtcPliHandlerCallbackFunc cb);

// Transform seconds to timestamp using track's clock rate, result is written to timestamp
Expand Down
10 changes: 5 additions & 5 deletions src/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ int rtcSetMediaInterceptorCallback(int pc, rtcInterceptorCallbackFunc cb) {
});
}

int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
int rtcSetH264Packetizer(int tr, const rtcPacketizerInit *init) {
return wrap([&] {
auto track = getTrack(tr);
// create RTP configuration
Expand All @@ -1228,7 +1228,7 @@ int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
});
}

int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
int rtcSetH265Packetizer(int tr, const rtcPacketizerInit *init) {
return wrap([&] {
auto track = getTrack(tr);
// create RTP configuration
Expand All @@ -1244,7 +1244,7 @@ int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
});
}

int rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
int rtcSetAV1Packetizer(int tr, const rtcPacketizerInit *init) {
return wrap([&] {
auto track = getTrack(tr);
// create RTP configuration
Expand All @@ -1262,7 +1262,7 @@ int rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *ini
});
}

int rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
int rtcSetOpusPacketizer(int tr, const rtcPacketizerInit *init) {
return wrap([&] {
auto track = getTrack(tr);
// create RTP configuration
Expand All @@ -1275,7 +1275,7 @@ int rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
});
}

int rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
int rtcSetAACPacketizer(int tr, const rtcPacketizerInit *init) {
return wrap([&] {
auto track = getTrack(tr);
// create RTP configuration
Expand Down

0 comments on commit 7ea19e9

Please sign in to comment.