MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / rtpengine_api_copy_op

Function rtpengine_api_copy_op

modules/rtpengine/rtpengine.c:5145–5205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5143}
5144
5145static bencode_item_t *rtpengine_api_copy_op(struct rtp_relay_session *sess,
5146 int op, struct rtp_relay_server *server, void *copy_ctx,
5147 str *flags, unsigned int copy_flags, str *body)
5148{
5149 static bencode_buffer_t bencbuf;
5150 bencode_item_t *dict, *list = NULL;
5151 bencode_item_t *ret;
5152 struct sip_msg *msg;
5153 struct rtpe_set* rset;
5154 str viabranch;
5155 char viabranch_buf[2/* br */ + INT2STR_MAX_LEN];
5156
5157 RTPE_START_READ();
5158 rset = select_rtpe_set(server->set);
5159 rtpe_ctx_set_fill( rset );
5160 RTPE_STOP_READ();
5161
5162 if (bencode_buffer_init(&bencbuf)) {
5163 LM_ERR("could not initialize bencode_buffer_t\n");
5164 return NULL;
5165 }
5166 dict = bencode_dictionary(&bencbuf);
5167
5168 if (sess->callid)
5169 bencode_dictionary_add_str(dict, "call-id", sess->callid);
5170 if (sess->branch != RTP_RELAY_ALL_BRANCHES) {
5171 viabranch.s = int2bstr(sess->branch, viabranch_buf, &viabranch.len);
5172 viabranch.s -= 2;
5173 viabranch.len += 2;
5174 memcpy(viabranch.s, "br", 2);
5175 bencode_dictionary_add_str(dict, "via-branch", &viabranch);
5176 }
5177 if (copy_ctx && ((str *)copy_ctx)->len)
5178 bencode_dictionary_add_str(dict, "to-tag", copy_ctx);
5179 if (copy_flags & RTP_COPY_MODE_SIPREC) {
5180 list = bencode_list(&bencbuf);
5181 bencode_list_add_string(list, "all");
5182 bencode_list_add_string(list, "siprec");
5183 } else if ((copy_flags & RTP_COPY_LEG_BOTH) == RTP_COPY_LEG_BOTH) {
5184 list = bencode_list(&bencbuf);
5185 bencode_list_add_string(list, "all");
5186 } else if (copy_flags & RTP_COPY_LEG_CALLER && sess->from_tag) {
5187 bencode_dictionary_add_str(dict, "from-tag", sess->from_tag);
5188 } else if (sess->to_tag && sess->to_tag->len) {
5189 bencode_dictionary_add_str(dict, "from-tag", sess->to_tag);
5190 }
5191 if (copy_flags & RTP_COPY_MODE_DISABLE) {
5192 if (!list)
5193 list = bencode_list(&bencbuf);
5194 bencode_list_add_string(list, "inactive");
5195 }
5196 if (list)
5197 bencode_dictionary_add(dict, "flags", list);
5198 msg = (sess->msg?sess->msg:get_dummy_sip_msg());
5199 ret = rtpe_function_call_ok(&bencbuf, msg, op, flags, body,
5200 NULL, rset, &server->node, dict);
5201 if (is_dummy_sip_msg(msg) == 0)
5202 release_dummy_sip_msg(msg);

Callers 3

rtpengine_api_copy_offerFunction · 0.85

Calls 13

select_rtpe_setFunction · 0.85
rtpe_ctx_set_fillFunction · 0.85
bencode_buffer_initFunction · 0.85
bencode_dictionaryFunction · 0.85
int2bstrFunction · 0.85
bencode_listFunction · 0.85
bencode_list_add_stringFunction · 0.85
bencode_dictionary_addFunction · 0.85
get_dummy_sip_msgFunction · 0.85
rtpe_function_call_okFunction · 0.85
is_dummy_sip_msgFunction · 0.85

Tested by

no test coverage detected