Skip to content

Commit

Permalink
Pass track profile for any codec in C API
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Sep 6, 2023
1 parent 51a6d6a commit 4b70bfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
5 changes: 1 addition & 4 deletions include/rtc/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,7 @@ typedef struct {
const char *name; // optional
const char *msid; // optional
const char *trackId; // optional, track ID used in MSID

//indicate the coder capability and configuration
//e.g: aac latm streammuxconfig
const char *profile;
const char *profile; // optional, codec profile
} rtcTrackInit;

RTC_C_EXPORT int rtcSetTrackCallback(int pc, rtcTrackCallbackFunc cb);
Expand Down
24 changes: 14 additions & 10 deletions src/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,12 @@ int rtcAddTrackEx(int pc, const rtcTrackInit *init) {
}
}

int pt = init->payloadType;

optional<string> profile;
if (init->profile)
profile.emplace(string(init->profile));

optional<Description::Media> optDescription = nullopt;

switch (init->codec) {
Expand All @@ -1046,16 +1052,16 @@ int rtcAddTrackEx(int pc, const rtcTrackInit *init) {
auto desc = Description::Video(mid, direction);
switch (init->codec) {
case RTC_CODEC_H264:
desc.addH264Codec(init->payloadType);
desc.addH264Codec(pt, profile);
break;
case RTC_CODEC_H265:
desc.addH265Codec(init->payloadType);
desc.addH265Codec(pt, profile);
break;
case RTC_CODEC_VP8:
desc.addVP8Codec(init->payloadType);
desc.addVP8Codec(pt, profile);
break;
case RTC_CODEC_VP9:
desc.addVP9Codec(init->payloadType);
desc.addVP9Codec(pt, profile);
break;
default:
break;
Expand All @@ -1070,18 +1076,16 @@ int rtcAddTrackEx(int pc, const rtcTrackInit *init) {
auto desc = Description::Audio(mid, direction);
switch (init->codec) {
case RTC_CODEC_OPUS:
desc.addOpusCodec(init->payloadType);
desc.addOpusCodec(pt, profile);
break;
case RTC_CODEC_PCMU:
desc.addPCMUCodec(init->payloadType);
desc.addPCMUCodec(pt, profile);
break;
case RTC_CODEC_PCMA:
desc.addPCMACodec(init->payloadType);
desc.addPCMACodec(pt, profile);
break;
case RTC_CODEC_AAC:
desc.addAacCodec(init->payloadType, init->profile
? std::make_optional(string(init->profile))
: nullopt);
desc.addAacCodec(pt, profile);
break;
default:
break;
Expand Down

0 comments on commit 4b70bfe

Please sign in to comment.