diff --git a/daemon/call.c b/daemon/call.c index ce20215d5..cdf898363 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1019,6 +1019,9 @@ static int setup_peer(struct peer *p, struct stream_input *s, const str *tag) { b->peer.port++; a->peer_advertised = a->peer; b->peer_advertised = b->peer; + a->rtcp = s->is_rtcp; + b->rtcp = 1; + p->protocol = s->protocol; for (i = 0; i < 2; i++) { switch (s->direction[i]) { diff --git a/daemon/call.h b/daemon/call.h index f7e8fd4d4..b6ef096d9 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -47,6 +47,14 @@ enum call_opmode { OP_OTHER, }; +enum transport_protocol { + PROTO_UNKNOWN = 0, + PROTO_RTP_AVP, + PROTO_RTP_SAVP, + PROTO_RTP_AVPF, + PROTO_RTP_SAVPF, +}; + struct stats { u_int64_t packets; u_int64_t bytes; @@ -62,7 +70,9 @@ struct stream_input { struct stream stream; enum stream_direction direction[2]; int consecutive_num; + enum transport_protocol protocol; int has_rtcp:1; + int is_rtcp:1; }; struct udp_fd { int fd; @@ -80,6 +90,7 @@ struct streamrelay { struct stats kstats; time_t last; int stun:1; + int rtcp:1; }; struct relays_cache { struct udp_fd relays_A[16]; @@ -97,6 +108,7 @@ struct peer { int desired_family; str ice_ufrag; str ice_pwd; + enum transport_protocol protocol; int kernelized:1; int filled:1; int confirmed:1; diff --git a/daemon/sdp.c b/daemon/sdp.c index 80970b48c..fad1ef9d6 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -557,6 +557,26 @@ static int fill_stream_rtcp(struct stream_input *si, struct sdp_media *media, in return 0; } +static enum transport_protocol transport_protocol(str *s) { + switch (s->len) { + case 7: + if (!str_cmp(s, "RTP/AVP")) + return PROTO_RTP_AVP; + break; + case 8: + if (!str_cmp(s, "RTP/SAVP")) + return PROTO_RTP_SAVP; + if (!str_cmp(s, "RTP/AVPF")) + return PROTO_RTP_AVPF; + break; + case 9: + if (!str_cmp(s, "RTP/SAVPF")) + return PROTO_RTP_SAVPF; + break; + } + return PROTO_UNKNOWN; +} + int sdp_streams(const GQueue *sessions, GQueue *streams, GHashTable *streamhash, struct sdp_ng_flags *flags) { struct sdp_session *session; struct sdp_media *media; @@ -566,6 +586,7 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, GHashTable *streamhash, int i, num; str s; struct sdp_attribute *attr; + enum transport_protocol tp; num = 0; for (l = sessions->head; l; l = l->next) { @@ -573,6 +594,7 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, GHashTable *streamhash, for (k = session->media_streams.head; k; k = k->next) { media = k->data; + tp = transport_protocol(&media->transport); si = NULL; for (i = 0; i < media->port_count; i++) { @@ -589,6 +611,7 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, GHashTable *streamhash, si->stream.num = ++num; si->consecutive_num = (i == 0) ? media->port_count : 1; + si->protocol = tp; g_hash_table_insert(streamhash, si, si); g_queue_push_tail(streams, si); @@ -610,6 +633,8 @@ int sdp_streams(const GQueue *sessions, GQueue *streams, GHashTable *streamhash, goto error; si->stream.num = ++num; si->consecutive_num = 1; + si->is_rtcp = 1; + si->protocol = tp; g_hash_table_insert(streamhash, si, si); g_queue_push_tail(streams, si);