| 5216 | } |
| 5217 | |
| 5218 | static void rtpengine_copy_streams(bencode_item_t *streams, struct rtp_relay_streams *ret) |
| 5219 | { |
| 5220 | bencode_item_t *item, *medias; |
| 5221 | str tmp = STR_NULL; |
| 5222 | struct dlg_cell *dlg; |
| 5223 | int leg = RTP_RELAY_CALLER, medianum, label, s; |
| 5224 | if (!ret || !streams) |
| 5225 | return; |
| 5226 | ret->count = 0; |
| 5227 | dlg = dlgb.get_dlg(); |
| 5228 | if (!dlg) |
| 5229 | LM_WARN("could not fetch dialog - legs might not match\n"); |
| 5230 | s = 0; |
| 5231 | for (item = streams->child; item; item = item->sibling) { |
| 5232 | if (dlg) { |
| 5233 | tmp.s = bencode_dictionary_get_string(item, "tag", &tmp.len); |
| 5234 | if (!tmp.s) |
| 5235 | LM_WARN("could not retrieve tag - placing to %s\n", |
| 5236 | (leg == RTP_RELAY_CALLER?"caller":"callee")); |
| 5237 | else if (!str_match(&tmp, &dlg->legs[DLG_CALLER_LEG].tag)) |
| 5238 | leg = RTP_RELAY_CALLEE; |
| 5239 | else |
| 5240 | leg = RTP_RELAY_CALLER; |
| 5241 | } else if (leg == RTP_RELAY_CALLER) { |
| 5242 | /* first try caller, then callee */ |
| 5243 | leg = RTP_RELAY_CALLEE; |
| 5244 | } |
| 5245 | medias = bencode_dictionary_get_expect(item, "medias", BENCODE_LIST); |
| 5246 | if (!medias) |
| 5247 | continue; |
| 5248 | for (medias = medias->child; medias; medias = medias->sibling) { |
| 5249 | s = ret->count; |
| 5250 | if (s == RTP_COPY_MAX_STREAMS) { |
| 5251 | LM_WARN("maximum amount of streams %d reached!\n", |
| 5252 | RTP_COPY_MAX_STREAMS); |
| 5253 | return; |
| 5254 | } |
| 5255 | medianum = bencode_dictionary_get_integer(item, "index", 0); |
| 5256 | tmp.s = bencode_dictionary_get_string(medias, "label", &tmp.len); |
| 5257 | if (str2sint(&tmp, &label) < 0) { |
| 5258 | LM_WARN("invalid label %.*s - not integer - skipping\n", |
| 5259 | tmp.len, tmp.s); |
| 5260 | continue; |
| 5261 | } |
| 5262 | ret->streams[s].leg = leg; |
| 5263 | ret->streams[s].label = label; |
| 5264 | ret->streams[s].medianum = medianum; |
| 5265 | ret->count++; |
| 5266 | } |
| 5267 | } |
| 5268 | } |
| 5269 | |
| 5270 | static int rtpengine_api_copy_offer(struct rtp_relay_session *sess, |
| 5271 | struct rtp_relay_server *server, void **_ctx, str *flags, |
no test coverage detected