Skip to content

Commit 7ea19e9

Browse files
Renamed packetizer functions in C API
1 parent 0484b45 commit 7ea19e9

File tree

2 files changed

+66
-43
lines changed

2 files changed

+66
-43
lines changed

include/rtc/rtc.h

+61-38
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
extern "C" {
1414
#endif
1515

16+
#include <stdbool.h>
17+
#include <stdint.h>
18+
1619
#ifdef RTC_STATIC
1720
#define RTC_C_EXPORT
1821
#else // dynamic library
@@ -27,16 +30,6 @@ extern "C" {
2730
#endif
2831
#endif
2932

30-
#ifdef _WIN32
31-
#ifdef CAPI_STDCALL
32-
#define RTC_API __stdcall
33-
#else
34-
#define RTC_API
35-
#endif
36-
#else // not WIN32
37-
#define RTC_API
38-
#endif
39-
4033
#ifndef RTC_ENABLE_WEBSOCKET
4134
#define RTC_ENABLE_WEBSOCKET 1
4235
#endif
@@ -53,8 +46,23 @@ extern "C" {
5346
#define RTC_DEFAULT_MAXIMUM_PACKET_COUNT_FOR_NACK_CACHE ((unsigned)512)
5447
#endif
5548

56-
#include <stdbool.h>
57-
#include <stdint.h>
49+
#ifdef _WIN32
50+
#ifdef CAPI_STDCALL
51+
#define RTC_API __stdcall
52+
#else
53+
#define RTC_API
54+
#endif
55+
#else // not WIN32
56+
#define RTC_API
57+
#endif
58+
59+
#if defined(__GNUC__) || defined(__clang__)
60+
#define RTC_DEPRECATED __attribute__((deprecated))
61+
#elif defined(_MSC_VER)
62+
#define RTC_DEPRECATED __declspec(deprecated)
63+
#else
64+
#define DEPRECATED
65+
#endif
5866

5967
// libdatachannel C API
6068

@@ -320,16 +328,19 @@ typedef struct {
320328
uint16_t sequenceNumber;
321329
uint32_t timestamp;
322330

331+
// H264, H265, AV1
332+
uint16_t maxFragmentSize; // Maximum fragment size, 0 means default
333+
323334
// H264/H265 only
324335
rtcNalUnitSeparator nalSeparator; // NAL unit separator
325336

326-
// H264, H265, AV1
327-
uint16_t maxFragmentSize; // Maximum fragment size
328-
329337
// AV1 only
330338
rtcObuPacketization obuPacketization; // OBU paketization for AV1 samples
331339

332-
} rtcPacketizationHandlerInit;
340+
} rtcPacketizerInit;
341+
342+
// Deprecated, do not use
343+
typedef rtcPacketizerInit rtcPacketizationHandlerInit;
333344

334345
typedef struct {
335346
uint32_t ssrc;
@@ -338,8 +349,6 @@ typedef struct {
338349
const char *trackId; // optional, track ID used in MSID
339350
} rtcSsrcForTypeInit;
340351

341-
// Opaque message
342-
343352
// Opaque type used (via rtcMessage*) to reference an rtc::Message
344353
typedef void *rtcMessage;
345354

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

352-
// Set MediaInterceptor for peer connection
361+
// Set MediaInterceptor on peer connection
353362
RTC_C_EXPORT int rtcSetMediaInterceptorCallback(int id, rtcInterceptorCallbackFunc cb);
354363

355-
// Set H264PacketizationHandler for track
356-
RTC_C_EXPORT int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);
357-
358-
// Set H265PacketizationHandler for track
359-
RTC_C_EXPORT int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);
360-
361-
// Set AV1PacketizationHandler for track
362-
RTC_C_EXPORT int rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);
363-
364-
// Set OpusPacketizationHandler for track
365-
RTC_C_EXPORT int rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);
366-
367-
// Set AACPacketizationHandler for track
368-
RTC_C_EXPORT int rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init);
369-
370-
// Set RtcpReceivingSession for track
364+
// Set a packetizer on track
365+
RTC_C_EXPORT int rtcSetH264Packetizer(int tr, const rtcPacketizerInit *init);
366+
RTC_C_EXPORT int rtcSetH265Packetizer(int tr, const rtcPacketizerInit *init);
367+
RTC_C_EXPORT int rtcSetAV1Packetizer(int tr, const rtcPacketizerInit *init);
368+
RTC_C_EXPORT int rtcSetOpusPacketizer(int tr, const rtcPacketizerInit *init);
369+
RTC_C_EXPORT int rtcSetAACPacketizer(int tr, const rtcPacketizerInit *init);
370+
371+
// Deprecated, do not use
372+
RTC_DEPRECATED static inline int
373+
rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
374+
return rtcSetH264Packetizer(tr, init);
375+
}
376+
RTC_DEPRECATED static inline int
377+
rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
378+
return rtcSetH265Packetizer(tr, init);
379+
}
380+
RTC_DEPRECATED static inline int
381+
rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
382+
return rtcSetAV1Packetizer(tr, init);
383+
}
384+
RTC_DEPRECATED static inline int
385+
rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
386+
return rtcSetOpusPacketizer(tr, init);
387+
}
388+
RTC_DEPRECATED static inline int
389+
rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
390+
return rtcSetAACPacketizer(tr, init);
391+
}
392+
393+
// Chain RtcpReceivingSession on track
371394
RTC_C_EXPORT int rtcChainRtcpReceivingSession(int tr);
372395

373-
// Chain RtcpSrReporter to handler chain for given track
396+
// Chain RtcpSrReporter on track
374397
RTC_C_EXPORT int rtcChainRtcpSrReporter(int tr);
375398

376-
// Chain RtcpNackResponder to handler chain for given track
399+
// Chain RtcpNackResponder on track
377400
RTC_C_EXPORT int rtcChainRtcpNackResponder(int tr, unsigned int maxStoredPacketsCount);
378401

379-
// Chain PliHandler to handler chain for given track
402+
// Chain PliHandler on track
380403
RTC_C_EXPORT int rtcChainPliHandler(int tr, rtcPliHandlerCallbackFunc cb);
381404

382405
// Transform seconds to timestamp using track's clock rate, result is written to timestamp

src/capi.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ int rtcSetMediaInterceptorCallback(int pc, rtcInterceptorCallbackFunc cb) {
12111211
});
12121212
}
12131213

1214-
int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
1214+
int rtcSetH264Packetizer(int tr, const rtcPacketizerInit *init) {
12151215
return wrap([&] {
12161216
auto track = getTrack(tr);
12171217
// create RTP configuration
@@ -1228,7 +1228,7 @@ int rtcSetH264PacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
12281228
});
12291229
}
12301230

1231-
int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
1231+
int rtcSetH265Packetizer(int tr, const rtcPacketizerInit *init) {
12321232
return wrap([&] {
12331233
auto track = getTrack(tr);
12341234
// create RTP configuration
@@ -1244,7 +1244,7 @@ int rtcSetH265PacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
12441244
});
12451245
}
12461246

1247-
int rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
1247+
int rtcSetAV1Packetizer(int tr, const rtcPacketizerInit *init) {
12481248
return wrap([&] {
12491249
auto track = getTrack(tr);
12501250
// create RTP configuration
@@ -1262,7 +1262,7 @@ int rtcSetAV1PacketizationHandler(int tr, const rtcPacketizationHandlerInit *ini
12621262
});
12631263
}
12641264

1265-
int rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
1265+
int rtcSetOpusPacketizer(int tr, const rtcPacketizerInit *init) {
12661266
return wrap([&] {
12671267
auto track = getTrack(tr);
12681268
// create RTP configuration
@@ -1275,7 +1275,7 @@ int rtcSetOpusPacketizationHandler(int tr, const rtcPacketizationHandlerInit *in
12751275
});
12761276
}
12771277

1278-
int rtcSetAACPacketizationHandler(int tr, const rtcPacketizationHandlerInit *init) {
1278+
int rtcSetAACPacketizer(int tr, const rtcPacketizerInit *init) {
12791279
return wrap([&] {
12801280
auto track = getTrack(tr);
12811281
// create RTP configuration

0 commit comments

Comments
 (0)