| 5834 | } |
| 5835 | |
| 5836 | static int rtpproxy_handle_recording(struct rtpproxy_copy_ctx *ctx, |
| 5837 | struct rtpp_args *args, str *flags, str *body) |
| 5838 | { |
| 5839 | int ret = -1, len; |
| 5840 | sdp_info_t sdp; |
| 5841 | sdp_stream_cell_t *stream; |
| 5842 | unsigned int leg; |
| 5843 | str *from_tag, *to_tag; |
| 5844 | str destination; |
| 5845 | struct list_head *it; |
| 5846 | struct rtpproxy_copy_stream *rtp_stream; |
| 5847 | |
| 5848 | memset(&sdp, 0, sizeof sdp); |
| 5849 | |
| 5850 | if (parse_sdp_session(body, 0, NULL, &sdp)<0) { |
| 5851 | LM_ERR("failed to parse SDP for body\n"); |
| 5852 | return -1; |
| 5853 | }; |
| 5854 | |
| 5855 | for (stream = sdp.sessions->streams; stream; stream = stream->next) { |
| 5856 | if (!(ctx->streams_mask & (1 << stream->stream_num))) |
| 5857 | continue; |
| 5858 | rtp_stream = rtpproxy_get_stream_index(ctx, &leg, stream); |
| 5859 | if (!rtp_stream) { |
| 5860 | LM_WARN("could not find associated stream %d\n", |
| 5861 | stream->stream_num); |
| 5862 | continue; |
| 5863 | } |
| 5864 | if (leg == RTP_RELAY_CALLER) { |
| 5865 | from_tag = &args->from_tag; |
| 5866 | to_tag = &args->to_tag; |
| 5867 | } else { |
| 5868 | from_tag = &args->to_tag; |
| 5869 | to_tag = &args->from_tag; |
| 5870 | } |
| 5871 | if (!stream->is_on_hold && !(ctx->flags & RTP_COPY_MODE_DISABLE) && |
| 5872 | !(rtp_stream->flags & RTPPROXY_COPY_STREAM_INACTIVE)) { |
| 5873 | |
| 5874 | if (rtp_stream->flags & RTPPROXY_COPY_STREAM_STARTED) { |
| 5875 | ret++; |
| 5876 | continue; /* stream already started */ |
| 5877 | } |
| 5878 | |
| 5879 | len = 4/* udp: */; |
| 5880 | /* if there is an IP in the stream, use it, otherwise use the |
| 5881 | * SDP session IP */ |
| 5882 | if (stream->ip_addr.len) |
| 5883 | len += stream->ip_addr.len; |
| 5884 | else |
| 5885 | len += sdp.sessions->ip_addr.len; |
| 5886 | len += 1/* : */ + stream->port.len; |
| 5887 | |
| 5888 | /* build the socket to stream to */ |
| 5889 | destination.s = pkg_malloc(len); |
| 5890 | if (!destination.s) { |
| 5891 | LM_ERR("cannot allocate destination buffer!\n"); |
| 5892 | return -1; |
| 5893 | } |
no test coverage detected