diff --git a/daemon/call.c b/daemon/call.c index e4227b1df..63ba93bcb 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1848,7 +1848,7 @@ static void __update_media_protocol(struct call_media *media, struct call_media /* allow override of outgoing protocol even if we know it already */ /* but only if this is an RTP-based protocol */ if (flags->transport_protocol - && other_media->protocol && other_media->protocol->rtp) { + && proto_is_rtp(other_media->protocol)) { media->protocol = flags->transport_protocol; return; } @@ -2232,7 +2232,7 @@ void call_destroy(struct call *c) { STR_FMT(&md->type), \ md->protocol ? md->protocol->name : "(unknown)" - if (md->protocol && md->protocol->rtp) { + if (proto_is_rtp(md->protocol)) { rtp_pt = __rtp_stats_codec(md); if (!rtp_pt) ilog(LOG_INFO, MLL_PREFIX "unknown codec", MLL_COMMON); diff --git a/daemon/media_socket.c b/daemon/media_socket.c index d29b2b7df..e6ca24c88 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1119,7 +1119,7 @@ void kernelize(struct packet_stream *stream) { ZERO(stream->kernel_stats); - if (stream->media->protocol && stream->media->protocol->rtp) { + if (proto_is_rtp(stream->media->protocol)) { GList *values, *l; struct rtp_stats *rs; @@ -1416,9 +1416,7 @@ static void media_packet_rtp(struct packet_handler_ctx *phc) { phc->payload_type = -1; - if (G_UNLIKELY(!phc->mp.media->protocol)) - return; - if (G_UNLIKELY(!phc->mp.media->protocol->rtp)) + if (G_UNLIKELY(!proto_is_rtp(phc->mp.media->protocol))) return; if (G_LIKELY(!phc->rtcp && !rtp_payload(&phc->mp.rtp, &phc->mp.payload, &phc->s))) { diff --git a/daemon/sdp.c b/daemon/sdp.c index 931fe4877..23eef3385 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1114,7 +1114,7 @@ static int __rtp_payload_types(struct stream_params *sp, struct sdp_media *media struct sdp_attribute *attr; int ret = 0; - if (!sp->protocol || !sp->protocol->rtp) + if (!proto_is_rtp(sp->protocol)) return 0; /* first go through a=rtpmap and build a hash table of attrs */ @@ -1479,7 +1479,7 @@ static int replace_format_str(struct sdp_chopper *chop, static int replace_codec_list(struct sdp_chopper *chop, struct sdp_media *media, struct call_media *cm) { - if (cm->protocol && !cm->protocol->rtp) + if (proto_is_not_rtp(cm->protocol)) return replace_format_str(chop, media, cm); if (cm->codecs_prefs_recv.length == 0) @@ -2140,7 +2140,7 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu chopper_append_c(chop, "a=inactive\r\n"); } - if (call_media->protocol && call_media->protocol->rtp) { + if (proto_is_rtp(call_media->protocol)) { if (MEDIA_ISSET(call_media, RTCP_MUX) && (flags->opmode == OP_ANSWER || (flags->opmode == OP_OFFER diff --git a/include/media_socket.h b/include/media_socket.h index 6e42aee14..5ab3e8827 100644 --- a/include/media_socket.h +++ b/include/media_socket.h @@ -190,5 +190,18 @@ INLINE struct local_intf *get_interface_from_address(const struct logical_intf * } */ +INLINE int proto_is_rtp(const struct transport_protocol *protocol) { + // known to be RTP? therefore unknown is not RTP + if (!protocol) + return 0; + return protocol->rtp ? 1 : 0; +} +INLINE int proto_is_not_rtp(const struct transport_protocol *protocol) { + // known not to be RTP? therefore unknown might be RTP + if (!protocol) + return 0; + return protocol->rtp ? 0 : 1; +} + #endif