| 1074 | |
| 1075 | |
| 1076 | int pv_set_sdp_stream(struct sip_msg *msg, pv_param_t *param, |
| 1077 | int op, pv_value_t *val) |
| 1078 | { |
| 1079 | struct sdp_pv_param *pvp = (struct sdp_pv_param *)param->pvn.u.dname; |
| 1080 | struct sip_msg_body *sbody; |
| 1081 | struct sdp_body_part_ops *ops; |
| 1082 | struct body_part *body_part; |
| 1083 | str body, dup_line, src_line; |
| 1084 | int idx, insert = 0; |
| 1085 | |
| 1086 | if (!msg) |
| 1087 | return -1; |
| 1088 | |
| 1089 | if (val && !(val->flags & PV_VAL_STR)) { |
| 1090 | LM_ERR("refusing to set SDP line to non-string value (val flags: %d)\n", |
| 1091 | val->flags); |
| 1092 | return -1; |
| 1093 | } |
| 1094 | |
| 1095 | if (msg->body_lumps) { |
| 1096 | /* TODO: rebuild SDP body, clear the body lumps; assert lines_sz == 0 */ |
| 1097 | } |
| 1098 | |
| 1099 | if (!have_sdp_ops(msg) || msg->sdp_ops->lines_sz == 0) { |
| 1100 | if (parse_sip_body(msg)<0 || !(sbody=msg->body)) { |
| 1101 | LM_ERR("current SIP message has no SDP body!\n"); |
| 1102 | return -1; |
| 1103 | } |
| 1104 | |
| 1105 | first_part_by_mime( &sbody->first, body_part, (TYPE_APPLICATION<<16)+SUBTYPE_SDP ); |
| 1106 | if (!body_part) { |
| 1107 | LM_ERR("current SIP message has a body, but no SDP part!\n"); |
| 1108 | return -1; |
| 1109 | } |
| 1110 | |
| 1111 | ops = msg->sdp_ops; |
| 1112 | /* first time working with SDP ops => allocate DS */ |
| 1113 | if (!ops && !(ops = msg->sdp_ops = mk_sdp_ops())) { |
| 1114 | LM_ERR("oom\n"); |
| 1115 | return -1; |
| 1116 | } |
| 1117 | |
| 1118 | body = body_part->body; |
| 1119 | if (ops->lines_sz == 0 && sdp_ops_parse_lines(ops, &body) != 0) { |
| 1120 | LM_ERR("oom\n"); |
| 1121 | return -1; |
| 1122 | } |
| 1123 | } else { |
| 1124 | ops = msg->sdp_ops; |
| 1125 | } |
| 1126 | |
| 1127 | idx = IDX(msg, &pvp->match_line.idx); |
| 1128 | switch (param->pvi.type) { |
| 1129 | case SDP_PV_IDX_INSERT: |
| 1130 | insert = 1; |
| 1131 | break; |
| 1132 | |
| 1133 | case SDP_PV_IDX_AINSERT: |
nothing calls this directly
no test coverage detected