Skip to content

Commit

Permalink
Feature/screenshare bw (#74)
Browse files Browse the repository at this point in the history
* screenshare: don't add AS SDP-parameter for bandwidth reastrction when running screenshare

* Remove bitrate limit also for the one to one call and double it in group call

* Reset bandwidth limit to original value

* fix: remove duplicated code

* fix: logging right methode name

---------

Co-authored-by: Dusan Stevanovic <[email protected]>
  • Loading branch information
EnricoSchw and z-dule committed Jul 29, 2024
1 parent a9a24c9 commit cd23911
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
2 changes: 2 additions & 0 deletions include/avs_sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ const char *sdp_sess2str(struct sdp_session *sess);

const char *sdp_modify_offer(struct sdp_session *sess,
enum icall_conv_type conv_type,
bool screenshare,
bool audio_cbr);
const char *sdp_modify_answer(struct sdp_session *sess,
enum icall_conv_type conv_type,
bool screenshare,
bool audio_cbr);

int sdp_strip_video(char **sdp, enum icall_conv_type conv_type,
Expand Down
12 changes: 10 additions & 2 deletions src/jsflow/jsflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,13 @@ static int jsflow_generate_offer_answer(struct iflow *flow,
if (isoffer) {
sdp_modify_offer(sess,
jsflow->conv_type,
jsflow->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
jsflow->audio.req_local_cbr);
}
else {
sdp_modify_answer(sess,
jsflow->conv_type,
jsflow->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
jsflow->audio.req_local_cbr);
}

Expand Down Expand Up @@ -1449,11 +1451,17 @@ void pc_local_sdp_handler(int self, int err,
/* Modify SDP here */
if (isoffer) {
sdp_dup(&sess, flow->conv_type, sdp, true);
modsdp = sdp_modify_offer(sess, flow->conv_type, flow->audio.req_local_cbr);
modsdp = sdp_modify_offer(sess,
flow->conv_type,
flow->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
flow->audio.req_local_cbr);
}
else if (streq(type, "answer")) {
sdp_dup(&sess, flow->conv_type, sdp, false);
modsdp = sdp_modify_answer(sess, flow->conv_type, flow->audio.req_local_cbr);
modsdp = sdp_modify_answer(sess,
flow->conv_type,
flow->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
flow->audio.req_local_cbr);
}
else {
str_dup((char **)&modsdp, sdp);
Expand Down
10 changes: 8 additions & 2 deletions src/peerflow/peerflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,10 @@ class SdpObserver : public webrtc::CreateSessionDescriptionObserver {
}

sdp_check(sdp_str.c_str(), true, true, NULL, pf_norelay_handler, NULL, pf_);
sdp = sdp_modify_offer(sess, pf_->conv_type, pf_->audio.local_cbr);
sdp = sdp_modify_offer(sess,
pf_->conv_type,
pf_->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
pf_->audio.local_cbr);

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

Expand All @@ -1670,7 +1673,10 @@ class SdpObserver : public webrtc::CreateSessionDescriptionObserver {

sdp_check(sdp_str.c_str(), true, false, NULL, pf_norelay_handler, NULL, pf_);

sdp = sdp_modify_answer(sess, pf_->conv_type, pf_->audio.local_cbr);
sdp = sdp_modify_answer(sess,
pf_->conv_type,
pf_->vstate == ICALL_VIDEO_STATE_SCREENSHARE,
pf_->audio.local_cbr);
imod_sdp = sdp_interface(sdp, webrtc::SdpType::kAnswer);
pf_->peerConn->SetLocalDescription(
pf_->answerObserver,
Expand Down
54 changes: 23 additions & 31 deletions src/sdp/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
#define MAX_NET_ID 5

enum {
AUDIO_ONEONE_BANDWIDTH = 50,
AUDIO_GROUP_BANDWIDTH = 32,
VIDEO_ONEONE_BANDWIDTH = 800,
VIDEO_GROUP_BANDWIDTH = 600,
};

Expand Down Expand Up @@ -318,9 +316,21 @@ int sdp_dup(struct sdp_session **sessp,
return sdp_dup_int(sessp, conv_type, sdp, offer, false);
}

static void sdp_set_bandwidth(struct sdp_media *sdpm, bool screenshare)
{
if (streq(sdp_media_name(sdpm), "video") && !screenshare) {
sdp_media_set_lbandwidth(sdpm, SDP_BANDWIDTH_AS, VIDEO_GROUP_BANDWIDTH);
}
else if (streq(sdp_media_name(sdpm), "audio")){
sdp_media_set_lbandwidth(sdpm, SDP_BANDWIDTH_AS, AUDIO_GROUP_BANDWIDTH);
info("sdp_set_bandwidth: group mode, setting ptime\n");
sdp_media_set_lattr(sdpm, true, "ptime", "40");
}
}

const char *sdp_modify_offer(struct sdp_session *sess,
enum icall_conv_type conv_type,
bool screenshare,
bool audio_cbr)
{
char *sdpres = NULL;
Expand All @@ -334,24 +344,11 @@ const char *sdp_modify_offer(struct sdp_session *sess,

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

if (streq(sdp_media_name(sdpm), "video")) {
uint32_t bw = conv_type == ICALL_CONV_TYPE_ONEONONE ?
VIDEO_ONEONE_BANDWIDTH : VIDEO_GROUP_BANDWIDTH;

sdp_media_set_lbandwidth(sdpm, SDP_BANDWIDTH_AS, bw);
}
else if (streq(sdp_media_name(sdpm), "audio")) {
uint32_t bw = conv_type == ICALL_CONV_TYPE_ONEONONE ?
AUDIO_ONEONE_BANDWIDTH : AUDIO_GROUP_BANDWIDTH;
sdp_media_set_lbandwidth(sdpm, SDP_BANDWIDTH_AS, bw);

if (conv_type != ICALL_CONV_TYPE_ONEONONE) {

info("sdp_modify_offer: group mode, "
"setting ptime\n");
sdp_media_set_lattr(sdpm, true, "ptime", "40");
}
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);
if (audio_cbr) {
const struct list *fmtl;
Expand Down Expand Up @@ -393,6 +390,7 @@ const char *sdp_sess2str(struct sdp_session *sess)

const char *sdp_modify_answer(struct sdp_session *sess,
enum icall_conv_type conv_type,
bool screenshare,
bool audio_cbr)
{
const struct list *medial;
Expand All @@ -402,22 +400,16 @@ const char *sdp_modify_answer(struct sdp_session *sess,
for(le = medial->head; le; le = le->next) {

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

if (streq(sdp_media_name(sdpm), "video")) {
uint32_t bw = conv_type == ICALL_CONV_TYPE_ONEONONE ?
VIDEO_ONEONE_BANDWIDTH : VIDEO_GROUP_BANDWIDTH;
sdp_media_set_lbandwidth(sdpm, SDP_BANDWIDTH_AS, bw);
}
else if (streq(sdp_media_name(sdpm), "audio")) {
uint32_t bw = conv_type == ICALL_CONV_TYPE_ONEONONE ?
AUDIO_ONEONE_BANDWIDTH : AUDIO_GROUP_BANDWIDTH;
sdp_media_set_lbandwidth(sdpm, SDP_BANDWIDTH_AS, bw);

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;

sdp_media_set_lattr(sdpm, true, "ptime", "40");
fmtl = sdp_media_format_lst(sdpm, true);

LIST_FOREACH(fmtl, fle) {
Expand Down

0 comments on commit cd23911

Please sign in to comment.