Skip to content

Commit

Permalink
Remove some unused variables and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
atoppi committed May 2, 2024
1 parent c04d583 commit d2e74fd
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 55 deletions.
2 changes: 0 additions & 2 deletions src/janus.c
Expand Up @@ -1591,7 +1591,6 @@ int janus_process_incoming_request(janus_request *request) {
}
janus_request_ice_handle_answer(handle, jsep_sdp);
/* Check if the answer does contain the mid/abs-send-time/twcc extmaps */
int mindex = 0;
gboolean do_mid = FALSE, do_twcc = FALSE, do_dd = FALSE, do_abs_send_time = FALSE, do_abs_capture_time = FALSE;
GList *temp = parsed_sdp->m_lines;
while(temp) {
Expand Down Expand Up @@ -1620,7 +1619,6 @@ int janus_process_incoming_request(janus_request *request) {
do_dd = do_dd || have_dd;
do_abs_send_time = do_abs_send_time || have_abs_send_time;
do_abs_capture_time = do_abs_capture_time || have_abs_capture_time;
mindex++;
temp = temp->next;
}
if(!do_mid && handle->pc)
Expand Down
6 changes: 1 addition & 5 deletions src/plugins/janus_videoroom.c
Expand Up @@ -2395,9 +2395,6 @@ static void janus_videoroom_publisher_stream_unref(janus_videoroom_publisher_str
if(ps)
janus_refcount_decrease(&ps->ref);
}
static void janus_videoroom_publisher_stream_dereference_void(void *ps) {
janus_videoroom_publisher_stream_unref((janus_videoroom_publisher_stream *)ps);
}

static void janus_videoroom_publisher_stream_free(const janus_refcount *ps_ref) {
janus_videoroom_publisher_stream *ps = janus_refcount_containerof(ps_ref, janus_videoroom_publisher_stream, ref);
Expand Down Expand Up @@ -12868,13 +12865,12 @@ static void janus_videoroom_rtp_forwarder_rtcp_receive(janus_rtp_forwarder *rf,
* which publisher video stream we should send the PLI to */
uint32_t ssrc = 0;
janus_rtcp_header *rtcp = (janus_rtcp_header *)buffer;
int pno = 0, total = len;
int total = len;
while(rtcp && ssrc == 0) {
if(!janus_rtcp_check_len(rtcp, total))
return; /* Invalid RTCP packet */
if(rtcp->version != 2)
return; /* Invalid RTCP packet */
pno++;
switch(rtcp->type) {
case RTCP_PSFB: {
gint fmt = rtcp->rc;
Expand Down
3 changes: 1 addition & 2 deletions src/postprocessing/pp-g711.c
Expand Up @@ -163,7 +163,7 @@ int janus_pp_g711_process(FILE *file, janus_pp_frame_packet *list, int *working)
return -1;
janus_pp_frame_packet *tmp = list;
long int offset = 0;
int bytes = 0, len = 0, steps = 0, last_seq = 0;
int bytes = 0, len = 0, last_seq = 0;
uint8_t *buffer = g_malloc0(1500);
int16_t samples[1500];
memset(samples, 0, sizeof(samples));
Expand Down Expand Up @@ -216,7 +216,6 @@ int janus_pp_g711_process(FILE *file, janus_pp_frame_packet *list, int *working)
last_seq = tmp->seq;
if(tmp->seq < last_seq) {
last_seq = tmp->seq;
steps++;
}
JANUS_LOG(LOG_VERB, "Writing %d bytes out of %d (seq=%"SCNu16", step=%"SCNu16", ts=%"SCNu64", time=%"SCNu64"s)\n",
bytes, tmp->len, tmp->seq, diff, tmp->ts, (tmp->ts-list->ts)/8000);
Expand Down
3 changes: 1 addition & 2 deletions src/postprocessing/pp-g722.c
Expand Up @@ -119,7 +119,7 @@ int janus_pp_g722_process(FILE *file, janus_pp_frame_packet *list, int *working)
return -1;
janus_pp_frame_packet *tmp = list;
long int offset = 0;
int bytes = 0, len = 0, steps = 0, last_seq = 0;
int bytes = 0, len = 0, last_seq = 0;
uint8_t *buffer = g_malloc0(1500);
int16_t samples[1500];
memset(samples, 0, sizeof(samples));
Expand Down Expand Up @@ -172,7 +172,6 @@ int janus_pp_g722_process(FILE *file, janus_pp_frame_packet *list, int *working)
last_seq = tmp->seq;
if(tmp->seq < last_seq) {
last_seq = tmp->seq;
steps++;
}
JANUS_LOG(LOG_VERB, "Writing %d bytes out of %d (seq=%"SCNu16", step=%"SCNu16", ts=%"SCNu64", time=%"SCNu64"s)\n",
bytes, tmp->len, tmp->seq, diff, tmp->ts, (tmp->ts-list->ts)/8000);
Expand Down
3 changes: 1 addition & 2 deletions src/postprocessing/pp-l16.c
Expand Up @@ -95,7 +95,7 @@ int janus_pp_l16_process(FILE *file, janus_pp_frame_packet *list, int *working)
return -1;
janus_pp_frame_packet *tmp = list;
long int offset = 0;
int bytes = 0, len = 0, steps = 0, last_seq = 0;
int bytes = 0, len = 0, last_seq = 0;
uint8_t *buffer = g_malloc0(1500);
int16_t samples[1500];
memset(samples, 0, sizeof(samples));
Expand Down Expand Up @@ -149,7 +149,6 @@ int janus_pp_l16_process(FILE *file, janus_pp_frame_packet *list, int *working)
last_seq = tmp->seq;
if(tmp->seq < last_seq) {
last_seq = tmp->seq;
steps++;
}
JANUS_LOG(LOG_VERB, "Writing %d bytes out of %d (seq=%"SCNu16", step=%"SCNu16", ts=%"SCNu64", time=%"SCNu64"s)\n",
bytes, tmp->len, tmp->seq, diff, tmp->ts, (tmp->ts-list->ts)/samplerate);
Expand Down
3 changes: 1 addition & 2 deletions src/postprocessing/pp-opus.c
Expand Up @@ -106,7 +106,7 @@ int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, gboolean rest
return -1;
janus_pp_frame_packet *tmp = list;
long int offset = 0;
int bytes = 0, len = 0, steps = 0, last_seq = 0;
int bytes = 0, len = 0, last_seq = 0;
uint64_t pos = 0, nextPos = 0;
double ts = 0.0;
uint8_t *buffer = g_malloc0(1500);
Expand Down Expand Up @@ -320,7 +320,6 @@ int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, gboolean rest
last_seq = tmp->seq;
if(tmp->seq < last_seq) {
last_seq = tmp->seq;
steps++;
}
JANUS_LOG(LOG_VERB, "pos: %06"SCNu64", writing %d bytes out of %d (seq=%"SCNu16", step=%"SCNu16", ts=%"SCNu64", time=%"SCNu64"s)\n",
pos, bytes, tmp->len, tmp->seq, diff, tmp->ts, (tmp->ts-list->ts)/48000);
Expand Down
19 changes: 0 additions & 19 deletions src/postprocessing/pp-webm.c
Expand Up @@ -374,15 +374,13 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
/* VP8 depay */
/* https://tools.ietf.org/html/draft-ietf-payload-vp8 */
/* Read the first octet (VP8 Payload Descriptor) */
int skipped = 1;
len--;
uint8_t vp8pd = *buffer;
uint8_t xbit = (vp8pd & 0x80);
uint8_t sbit = (vp8pd & 0x10);

if (xbit) {
buffer++;
skipped++;
len--;

vp8pd = *buffer;
Expand All @@ -394,7 +392,6 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
/* Read the PictureID octet */
buffer++;
len--;
skipped++;
vp8pd = *buffer;
uint16_t picid = vp8pd, wholepicid = picid;
uint8_t mbit = (vp8pd & 0x80);
Expand All @@ -404,21 +401,18 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
picid = (wholepicid & 0x7FFF);
buffer++;
len--;
skipped++;
}
}
if(lbit) {
/* Read the TL0PICIDX octet */
buffer++;
len--;
skipped++;
vp8pd = *buffer;
}
if(tbit || kbit) {
/* Read the TID/KEYIDX octet */
buffer++;
len--;
skipped++;
vp8pd = *buffer;
}
}
Expand Down Expand Up @@ -457,7 +451,6 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
/* VP9 depay */
/* https://tools.ietf.org/html/draft-ietf-payload-vp9-02 */
/* Read the first octet (VP9 Payload Descriptor) */
int skipped = 0;
uint8_t vp9pd = *buffer;
uint8_t ibit = (vp9pd & 0x80);
uint8_t pbit = (vp9pd & 0x40);
Expand All @@ -467,7 +460,6 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
/* Move to the next octet and see what's there */
buffer++;
len--;
skipped++;
if(ibit) {
/* Read the PictureID octet */
vp9pd = *buffer;
Expand All @@ -476,25 +468,21 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
if(!mbit) {
buffer++;
len--;
skipped++;
} else {
memcpy(&picid, buffer, sizeof(uint16_t));
wholepicid = ntohs(picid);
picid = (wholepicid & 0x7FFF);
buffer += 2;
len -= 2;
skipped += 2;
}
}
if(lbit) {
buffer++;
len--;
skipped++;
if(!fbit) {
/* Non-flexible mode, skip TL0PICIDX */
buffer++;
len--;
skipped++;
}
}
if(fbit && pbit) {
Expand All @@ -505,7 +493,6 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
nbit = (vp9pd & 0x01);
buffer++;
len--;
skipped++;
}
}
if(vbit) {
Expand All @@ -520,13 +507,11 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
/* Iterate on all spatial layers and get resolution */
buffer++;
len--;
skipped++;
int i=0;
for(i=0; i<n_s; i++) {
/* Been there, done that: skip skip skip */
buffer += 4;
len -= 4;
skipped += 4;
}
/* Is this the first keyframe we find?
* (FIXME assuming this really means "keyframe...) */
Expand All @@ -539,12 +524,10 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
if(!ybit) {
buffer++;
len--;
skipped++;
}
uint8_t n_g = *buffer;
buffer++;
len--;
skipped++;
if(n_g > 0) {
uint i=0;
for(i=0; i<n_g; i++) {
Expand All @@ -555,11 +538,9 @@ int janus_pp_webm_process(FILE *file, janus_pp_frame_packet *list, gboolean vp8,
/* Skip reference indices */
buffer += r;
len -= r;
skipped += r;
}
buffer++;
len--;
skipped++;
}
}
}
Expand Down
21 changes: 7 additions & 14 deletions src/rtcp.c
Expand Up @@ -57,13 +57,12 @@ guint32 janus_rtcp_get_sender_ssrc(char *packet, int len) {
if(packet == NULL || len == 0)
return 0;
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len;
int total = len;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
break;
if(rtcp->version != 2)
break;
pno++;
switch(rtcp->type) {
case RTCP_SR: {
/* SR, sender report */
Expand Down Expand Up @@ -110,13 +109,12 @@ guint32 janus_rtcp_get_receiver_ssrc(char *packet, int len) {
if(packet == NULL || len == 0)
return 0;
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len;
int total = len;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
break;
if(rtcp->version != 2)
break;
pno++;
switch(rtcp->type) {
case RTCP_SR: {
/* SR, sender report */
Expand Down Expand Up @@ -165,13 +163,12 @@ void janus_rtcp_swap_report_blocks(char *packet, int len, uint32_t rtx_ssrc) {
if(packet == NULL || len == 0)
return;
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len;
int total = len;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
break;
if(rtcp->version != 2)
break;
pno++;
switch(rtcp->type) {
case RTCP_SR: {
/* SR, sender report */
Expand Down Expand Up @@ -1042,13 +1039,12 @@ int janus_rtcp_fix_report_data(char *packet, int len, uint32_t base_ts, uint32_t
return -1;
/* Parse RTCP compound packet */
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len, status = 0;
int total = len, status = 0;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
return -2;
if(rtcp->version != 2)
return -2;
pno++;
switch(rtcp->type) {
case RTCP_RR: {
if (!janus_rtcp_check_rr(rtcp, total))
Expand Down Expand Up @@ -1111,13 +1107,12 @@ int janus_rtcp_fix_report_data(char *packet, int len, uint32_t base_ts, uint32_t
gboolean janus_rtcp_has_bye(char *packet, int len) {
/* Parse RTCP compound packet */
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len;
int total = len;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
break;
if(rtcp->version != 2)
break;
pno++;
switch(rtcp->type) {
case RTCP_BYE:
return TRUE;
Expand All @@ -1139,13 +1134,12 @@ gboolean janus_rtcp_has_bye(char *packet, int len) {
gboolean janus_rtcp_has_fir(char *packet, int len) {
/* Parse RTCP compound packet */
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len;
int total = len;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
break;
if(rtcp->version != 2)
break;
pno++;
switch(rtcp->type) {
case RTCP_FIR:
return TRUE;
Expand All @@ -1167,13 +1161,12 @@ gboolean janus_rtcp_has_fir(char *packet, int len) {
gboolean janus_rtcp_has_pli(char *packet, int len) {
/* Parse RTCP compound packet */
janus_rtcp_header *rtcp = (janus_rtcp_header *)packet;
int pno = 0, total = len;
int total = len;
while(rtcp) {
if (!janus_rtcp_check_len(rtcp, total))
break;
if(rtcp->version != 2)
break;
pno++;
switch(rtcp->type) {
case RTCP_PSFB: {
gint fmt = rtcp->rc;
Expand Down
4 changes: 1 addition & 3 deletions src/sdp.c
Expand Up @@ -1315,7 +1315,7 @@ int janus_sdp_parse_ssrc(void *m, const char *ssrc_attr, int video) {
int janus_sdp_anonymize(janus_sdp *anon) {
if(anon == NULL)
return -1;
int audio = 0, video = 0, data = 0;
int data = 0;
/* o= */
if(anon->o_addr != NULL) {
g_free(anon->o_addr);
Expand Down Expand Up @@ -1348,10 +1348,8 @@ int janus_sdp_anonymize(janus_sdp *anon) {
while(temp) {
janus_sdp_mline *m = (janus_sdp_mline *)temp->data;
if(m->type == JANUS_SDP_AUDIO && m->port > 0) {
audio++;
m->port = 9;
} else if(m->type == JANUS_SDP_VIDEO && m->port > 0) {
video++;
m->port = 9;
} else if(m->type == JANUS_SDP_APPLICATION && m->port > 0) {
if(m->proto != NULL && (!strcasecmp(m->proto, "DTLS/SCTP") || !strcasecmp(m->proto, "UDP/DTLS/SCTP"))) {
Expand Down
4 changes: 0 additions & 4 deletions src/utils.c
Expand Up @@ -215,9 +215,7 @@ char *janus_string_replace(char *message, const char *old_string, const char *ne
if(strlen(old_string) == strlen(new_string)) { /* Just overwrite */
char *outgoing = message;
char *pos = strstr(outgoing, old_string), *tmp = NULL;
int i = 0;
while(pos) {
i++;
memcpy(pos, new_string, strlen(new_string));
pos += strlen(old_string);
tmp = strstr(pos, old_string);
Expand Down Expand Up @@ -1262,13 +1260,11 @@ GList *janus_red_parse_blocks(char *buffer, int len) {
}
/* Go through the blocks, iterating on the lengths to get a pointer to the data */
if(blocks != NULL) {
int tot_gens = gens;
gens = 0;
uint16_t length = 0;
GList *temp = blocks;
while(temp != NULL) {
gens++;
tot_gens--;
rb = (janus_red_block *)temp->data;
length = rb->length;
if(length > plen) {
Expand Down

0 comments on commit d2e74fd

Please sign in to comment.