Skip to content

Commit 9b44a8c

Browse files
committed
Handle RTCP sender reports separately for each track, the way it should always have been
1 parent 060a538 commit 9b44a8c

File tree

4 files changed

+37
-29
lines changed

4 files changed

+37
-29
lines changed

src/rtsp/rtcp.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
* DECLARATIONS
1212
******************************************************************************/
1313

14-
static inline int __rtcp_send_sr(struct connection_item_t *con);
14+
static inline int __rtcp_send_sr(struct connection_item_t *con, int track_id);
1515

1616

1717
/******************************************************************************
1818
* INLINE FUNCTIONS
1919
******************************************************************************/
20-
static inline int __rtcp_send_sr(struct connection_item_t *con)
20+
static inline int __rtcp_send_sr(struct connection_item_t *con, int track_id)
2121
{
2222
struct timeval tv;
2323
unsigned int ts_h;
2424
unsigned int ts_l;
2525
int send_bytes;
2626
struct sockaddr_in to_addr;
27+
transport_t *t;
28+
29+
ASSERT(track_id >= 0 &&
30+
track_id < (int)(sizeof(con->trans) / sizeof(con->trans[0])),
31+
return FAILURE);
32+
t = &con->trans[track_id];
2733

2834
ASSERT(gettimeofday(&tv,NULL) == 0, return FAILURE);
2935

@@ -34,21 +40,21 @@ static inline int __rtcp_send_sr(struct connection_item_t *con)
3440
r: { sr: { ssrc: htonl(con->ssrc),
3541
ntp_sec: htonl(ts_h),
3642
ntp_frac: htonl(ts_l),
37-
rtp_ts: htonl(con->trans[con->track_id].rtp_timestamp),
38-
psent: htonl(con->trans[con->track_id].rtcp_packet_cnt),
39-
osent: htonl(con->trans[con->track_id].rtcp_octet)}}};
43+
rtp_ts: htonl(t->rtp_timestamp),
44+
psent: htonl(t->rtcp_packet_cnt),
45+
osent: htonl(t->rtcp_octet)}}};
4046

4147
to_addr = con->addr;
42-
to_addr.sin_port = con->trans[con->track_id].client_port_rtcp;
48+
to_addr.sin_port = t->client_port_rtcp;
4349

44-
ASSERT((send_bytes = send(con->trans[con->track_id].server_rtcp_fd,
50+
ASSERT((send_bytes = send(t->server_rtcp_fd,
4551
&(rtcp),36,0)) == 36, ({
4652
ERR("send:%d:%s¥n",send_bytes,strerror(errno));
4753
return FAILURE;}));
4854

49-
con->trans[con->track_id].rtcp_packet_cnt = 0;
50-
con->trans[con->track_id].rtcp_octet = 0;
51-
con->trans[con->track_id].rtcp_tick = con->trans[con->track_id].rtcp_tick_org;
55+
t->rtcp_packet_cnt = 0;
56+
t->rtcp_octet = 0;
57+
t->rtcp_tick = t->rtcp_tick_org;
5258

5359
return SUCCESS;
5460
}

src/rtsp/rtp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static inline int __rtcp_poll(struct list_t *e, void *v)
350350
MUST(con = trans->con, return FAILURE);
351351

352352
if ((con->trans[*track_id].rtcp_tick)-- == 0) {
353-
ASSERT(__rtcp_send_sr(con) == SUCCESS, return FAILURE);
353+
ASSERT(__rtcp_send_sr(con, *track_id) == SUCCESS, return FAILURE);
354354

355355
/* postcondition check */
356356
DASSERT(con->trans[*track_id].rtcp_tick ==

src/rtsp/rtsp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ static void __method_play(struct connection_item_t *p, rtsp_handle h)
306306
p->trans[p->track_id].rtcp_packet_cnt = 0;
307307
p->trans[p->track_id].rtcp_tick_org = 150; // TODO: must be variant
308308
p->trans[p->track_id].rtcp_tick = p->trans[p->track_id].rtcp_tick_org;
309+
310+
ASSERT(__rtcp_send_sr(p, p->track_id) == SUCCESS, return);
309311
}
310312

311313
p->con_state = __CON_S_PLAYING;
312314

313-
ASSERT(__rtcp_send_sr(p) == SUCCESS, return);
314-
315315
request_idr();
316316
}
317317

src/rtsp/rtsp.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ struct __time_stat_t {
7575
unsigned int ts_offset;
7676
};
7777

78+
typedef struct {
79+
int server_rtcp_fd;
80+
int server_rtp_fd;
81+
unsigned int client_port_rtp;
82+
unsigned int client_port_rtcp;
83+
unsigned int server_port_rtp;
84+
unsigned int server_port_rtcp;
85+
unsigned int range_start;
86+
unsigned int range_end;
87+
unsigned int rtcp_octet;
88+
unsigned int rtcp_packet_cnt;
89+
int rtcp_tick;
90+
int rtcp_tick_org;
91+
unsigned short rtp_seq;
92+
unsigned int rtp_timestamp;
93+
} transport_t;
94+
7895
struct connection_item_t {
7996
struct sockaddr_in addr;
8097
FILE *fp_tcp_read;
@@ -83,22 +100,7 @@ struct connection_item_t {
83100
int track_id;
84101
int cseq;
85102

86-
struct {
87-
int server_rtcp_fd;
88-
int server_rtp_fd;
89-
unsigned int client_port_rtp;
90-
unsigned int client_port_rtcp;
91-
unsigned int server_port_rtp;
92-
unsigned int server_port_rtcp;
93-
unsigned int range_start;
94-
unsigned int range_end;
95-
unsigned int rtcp_octet;
96-
unsigned int rtcp_packet_cnt;
97-
int rtcp_tick;
98-
int rtcp_tick_org;
99-
unsigned short rtp_seq;
100-
unsigned int rtp_timestamp;
101-
} trans[2];
103+
transport_t trans[2];
102104

103105
enum __connection_state_e con_state;
104106
enum __parser_state_e parser_state;

0 commit comments

Comments
 (0)