Skip to content

Commit

Permalink
add support for nack/rtx
Browse files Browse the repository at this point in the history
  • Loading branch information
z-dule committed Jul 19, 2024
1 parent dbcdda8 commit fa71897
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/peerflow/peerflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,8 @@ class SdpObserver : public webrtc::CreateSessionDescriptionObserver {

switch(type) {
case webrtc::SdpType::kOffer:
info("SDP-fromPC: %s\n", sdp_str.c_str());

err = sdp_dup(&sess, pf_->conv_type,
sdp_str.c_str(), true);
if (err) {
Expand All @@ -1655,8 +1657,8 @@ class SdpObserver : public webrtc::CreateSessionDescriptionObserver {
pf_->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
pf_->audio.local_cbr);

info("SDP-fromPC: %s\n", sdp);
info("SDP-moded: %s\n", sdp);

imod_sdp = sdp_interface(sdp, webrtc::SdpType::kOffer);
pf_->peerConn->SetLocalDescription(
pf_->offerObserver,
Expand Down
49 changes: 38 additions & 11 deletions src/sdp/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

enum {
AUDIO_GROUP_BANDWIDTH = 32,
VIDEO_GROUP_BANDWIDTH = 600,
VIDEO_GROUP_BANDWIDTH = 800,
};


Expand Down Expand Up @@ -76,9 +76,16 @@ static bool cand_handler(const char *name, const char *value, void *arg)
}


struct fmt_mod {
struct sdp_media *sdpm;
char *vid;
};

static bool fmt_handler(struct sdp_format *fmt, void *arg)
{
struct sdp_media *sdpm = (struct sdp_media *)arg;
struct fmt_mod *fmtm = arg;
struct sdp_media *sdpm = fmtm->sdpm;
bool use_fmt = false;

if (streq(sdp_media_name(sdpm), "audio")) {
if (streq(fmt->name, "opus")) {
Expand All @@ -89,7 +96,24 @@ static bool fmt_handler(struct sdp_format *fmt, void *arg)
}
}
else if (streq(sdp_media_name(sdpm), "video")) {
char aptid[16];

if (strcaseeq(fmt->name, "vp8")) {
use_fmt = true;
if (fmtm->vid == NULL) {
str_dup(&fmtm->vid, fmt->id);
}
}
if (strcaseeq(fmt->name, "rtx")) {
int n;

n = sscanf(fmt->params, "apt=%15s", aptid);
if (n == 1) {
if (strcaseeq(aptid, fmtm->vid))
use_fmt = true;
}
}
if (use_fmt) {
sdp_format_add(NULL, sdpm, false,
fmt->id, fmt->name, fmt->srate, fmt->ch,
NULL, NULL, NULL, false,
Expand Down Expand Up @@ -262,6 +286,7 @@ static int sdp_dup_int(struct sdp_session **sessp,
enum sdp_dir rdir;
int rport;
struct conv_sdp csdp;
struct fmt_mod fmtm;

rport = sdp_media_rport(sdpm);
sdp_media_add(NULL, sess, mname,
Expand All @@ -271,8 +296,11 @@ static int sdp_dup_int(struct sdp_session **sessp,
sdp_media_set_laddr(sdpm, sdp_media_raddr(sdpm));
sdp_media_set_lport(sdpm, rport);

fmtm.sdpm = sdpm;
fmtm.vid = NULL;
sdp_media_format_apply(sdpm, false, NULL, -1, NULL,
-1, -1, fmt_handler, sdpm);
-1, -1, fmt_handler, &fmtm);
mem_deref(fmtm.vid);

csdp.sdpm = sdpm;
csdp.conv_type = conv_type;
Expand Down Expand Up @@ -344,9 +372,9 @@ const char *sdp_modify_offer(struct sdp_session *sess,

struct sdp_media *sdpm = (struct sdp_media *)le->data;

if (conv_type != ICALL_CONV_TYPE_ONEONONE) {
sdp_set_bandwidth(sdpm, screenshare);
}
if (conv_type != ICALL_CONV_TYPE_ONEONONE) {
sdp_set_bandwidth(sdpm, screenshare);
}

if (streq(sdp_media_name(sdpm), "audio")) {
debug("sdp_modify_offer: audio_cbr=%d\n", audio_cbr);
Expand All @@ -360,7 +388,6 @@ const char *sdp_modify_offer(struct sdp_session *sess,
char *params;

str_dup(&params, fmt->params);

sdp_format_set_params(fmt, "%s;cbr=1", params);
mem_deref(params);
}
Expand Down Expand Up @@ -401,13 +428,13 @@ const char *sdp_modify_answer(struct sdp_session *sess,

struct sdp_media *sdpm = (struct sdp_media *)le->data;

if (conv_type != ICALL_CONV_TYPE_ONEONONE) {
sdp_set_bandwidth(sdpm, screenshare);
}
if (conv_type != ICALL_CONV_TYPE_ONEONONE) {
sdp_set_bandwidth(sdpm, screenshare);
}

if (streq(sdp_media_name(sdpm), "audio")) {
if (conv_type != ICALL_CONV_TYPE_ONEONONE) {
const struct list *fmtl;
const struct list *fmtl;
struct le *fle;

fmtl = sdp_media_format_lst(sdpm, true);
Expand Down

0 comments on commit fa71897

Please sign in to comment.