| 38 | #include "rtpproxy_vcmd.h" |
| 39 | |
| 40 | static int |
| 41 | rtpproxy_stream(struct sip_msg* msg, str *pname, int count, |
| 42 | nh_set_param_t *setid, pv_spec_t *var, int stream2uac) |
| 43 | { |
| 44 | int nitems, ret = -1; |
| 45 | str callid, from_tag, to_tag; |
| 46 | struct rtpp_node *node; |
| 47 | struct rtpp_set *set; |
| 48 | char cbuf[16]; |
| 49 | struct rtpproxy_vcmd vstream; |
| 50 | |
| 51 | RTPP_VCMD_INIT(vstream, 10, |
| 52 | {cbuf, 0}, /*.vu[0] P<count> */ |
| 53 | {" ", 1}, |
| 54 | {NULL, 0}, /*.vu[2] callid */ |
| 55 | {" ", 1}, |
| 56 | {NULL, 0}, /*.vu[4] pname */ |
| 57 | {" session ", 9}, |
| 58 | {NULL, 0}, /*.vu[6] from tag */ |
| 59 | {";1 ", 3}, |
| 60 | {NULL, 0}, /*.vu[8] to tag */ |
| 61 | {";1", 2} |
| 62 | ); |
| 63 | |
| 64 | if (get_callid(msg, &callid) == -1 || callid.len == 0) { |
| 65 | LM_ERR("can't get Call-Id field\n"); |
| 66 | return -1; |
| 67 | } |
| 68 | if (get_to_tag(msg, &to_tag) == -1) { |
| 69 | LM_ERR("can't get To tag\n"); |
| 70 | return -1; |
| 71 | } |
| 72 | if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) { |
| 73 | LM_ERR("can't get From tag\n"); |
| 74 | return -1; |
| 75 | } |
| 76 | vstream.vu[0].iov_len = sprintf(cbuf, "P%d", count); |
| 77 | STR2IOVEC(callid, vstream.vu[2]); |
| 78 | STR2IOVEC(*pname, vstream.vu[4]); |
| 79 | |
| 80 | nitems = vstream.useritems; |
| 81 | if (stream2uac == 0) { |
| 82 | if (to_tag.len == 0) |
| 83 | return -1; |
| 84 | STR2IOVEC(to_tag, vstream.vu[6]); |
| 85 | STR2IOVEC(from_tag, vstream.vu[8]); |
| 86 | } else { |
| 87 | STR2IOVEC(from_tag, vstream.vu[6]); |
| 88 | STR2IOVEC(to_tag, vstream.vu[8]); |
| 89 | if (to_tag.len <= 0) |
| 90 | nitems -= 2; |
| 91 | } |
| 92 | if (nh_lock) { |
| 93 | lock_start_read( nh_lock ); |
| 94 | } |
| 95 | |
| 96 | set = get_rtpp_set(setid); |
| 97 | if (!set) { |
no test coverage detected