MT#60476 Move offer/answer model to sdp_create

Move the SDP offer/answer model to the sdp_create
approach instead of using the sdp_replace one.

This assumes the SDP body including session level
attributes (s=, o=, t= etc.), as well as the media
attributes, are formatted using currently given
session context.

In other words, rtpengine collects all possible
information during all of the offer/answer exchanges
within the dialog, which in its turn affects each
monologue's context, from which each new SDP message
will be built up.

This approach replaces the older one, which instead
used to go through the currenty processed SDP and
just replace those attributes, that rtpengine
is required to affect, leaving the rest untouched.

Additionally: all of the existing offer/asnwer model
tests were fixed to comply with the currect change.
Most of it is just an offset of attributes, which are
stored a bit higher/lower within the same media or global
SDP session.

Also a good part of unit test fixes targets a move of
`c=` line from the session level to the media one (so
each media has from now on its own `c=` attribute). This
does discontinue a support for session level connection
information.

Change-Id: Iecb4739683d23c4f9341e8a34b71f8ca2070956c
pull/1870/head
Donat Zenichev 7 months ago
parent c865c492af
commit d5890ee388

@ -2144,6 +2144,7 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, enum call_opmode
g_auto(sdp_ng_flags) flags;
parser_arg output = ctx->resp;
const ng_parser_t *parser = ctx->parser_ctx.parser;
g_auto(str) sdp_out = STR_NULL;
call_ng_process_flags(&flags, ctx, opmode);
@ -2230,8 +2231,6 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, enum call_opmode
from_ml->tagtype = TO_TAG;
}
struct sdp_chopper *chopper = ctx->ngbuf->chopper = sdp_chopper_new(&sdp);
if (flags.drop_traffic_start) {
CALL_SET(call, DROP_TRAFFIC);
}
@ -2245,9 +2244,17 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, enum call_opmode
/* offer/answer model processing */
if ((ret = monologue_offer_answer(monologues, &streams, &flags)) == 0) {
/* if all fine, prepare an outer sdp and save it */
if ((ret = sdp_replace(chopper, &parsed, to_ml, &flags)) == 0) {
if ((ret = sdp_create(&sdp_out, to_ml, &flags)) == 0) {
/* TODO: should we save sdp_out? */
save_last_sdp(from_ml, &sdp, &parsed, &streams);
}
/* place return output SDP */
if (sdp_out.len) {
ctx->ngbuf->sdp_out = sdp_out.s;
ctx->parser_ctx.parser->dict_add_str(output, "sdp", &sdp_out);
sdp_out = STR_NULL; /* ownership passed to output */
}
}
update_metadata_monologue(from_ml, &flags);
@ -2256,8 +2263,7 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, enum call_opmode
struct recording *recording = call->recording;
if (recording != NULL) {
meta_write_sdp_before(recording, &sdp, from_ml, opmode);
meta_write_sdp_after(recording, chopper->output,
from_ml, opmode);
meta_write_sdp_after(recording, &sdp_out, from_ml, opmode);
recording_response(recording, ctx->parser_ctx.parser, output);
}
@ -2286,9 +2292,6 @@ static const char *call_offer_answer_ng(ng_command_ctx_t *ctx, enum call_opmode
if (ret)
goto out;
if (chopper->output->len)
ctx->parser_ctx.parser->dict_add_str(output, "sdp", &STR_LEN(chopper->output->str, chopper->output->len));
errstr = NULL;
out:
return errstr;

@ -45,7 +45,7 @@ static int vappend_meta_chunk(struct recording *recording, const char *buf, unsi
// all methods
static int create_spool_dir_all(const char *spoolpath);
static void init_all(call_t *call);
static void sdp_after_all(struct recording *recording, GString *str, struct call_monologue *ml,
static void sdp_after_all(struct recording *recording, const str *str, struct call_monologue *ml,
enum call_opmode opmode);
static void dump_packet_all(struct media_packet *mp, const str *s);
static void finish_all(call_t *call, bool discard);
@ -53,7 +53,7 @@ static void finish_all(call_t *call, bool discard);
// pcap methods
static int rec_pcap_create_spool_dir(const char *dirpath);
static void rec_pcap_init(call_t *);
static void sdp_after_pcap(struct recording *, GString *str, struct call_monologue *, enum call_opmode opmode);
static void sdp_after_pcap(struct recording *, const str *str, struct call_monologue *, enum call_opmode opmode);
static void dump_packet_pcap(struct media_packet *mp, const str *s);
static void finish_pcap(call_t *, bool discard);
static void response_pcap(struct recording *, const ng_parser_t *, parser_arg);
@ -61,7 +61,7 @@ static void response_pcap(struct recording *, const ng_parser_t *, parser_arg);
// proc methods
static void proc_init(call_t *);
static void sdp_before_proc(struct recording *, const str *, struct call_monologue *, enum call_opmode);
static void sdp_after_proc(struct recording *, GString *str, struct call_monologue *, enum call_opmode opmode);
static void sdp_after_proc(struct recording *, const str *sdp, struct call_monologue *, enum call_opmode opmode);
static void meta_chunk_proc(struct recording *, const char *, const str *);
static void update_flags_proc(call_t *call, bool streams);
static void finish_proc(call_t *, bool discard);
@ -525,7 +525,7 @@ static char *meta_setup_file(struct recording *recording, const str *meta_prefix
/**
* Write out a block of SDP to the metadata file.
*/
static void sdp_after_pcap(struct recording *recording, GString *s, struct call_monologue *ml,
static void sdp_after_pcap(struct recording *recording, const str *s, struct call_monologue *ml,
enum call_opmode opmode)
{
FILE *meta_fp = recording->pcap.meta_fp;
@ -545,7 +545,7 @@ static void sdp_after_pcap(struct recording *recording, GString *s, struct call_
fprintf(meta_fp, "%s", get_opmode_text(opmode));
fprintf(meta_fp, "\nSDP before RTP packet: %" PRIu64 "\n\n", recording->pcap.packet_num);
fflush(meta_fp);
if (write(meta_fd, s->str, s->len) <= 0)
if (write(meta_fd, s->s, s->len) <= 0)
ilog(LOG_WARN, "Error writing SDP body to metadata file: %s", strerror(errno));
}
@ -883,10 +883,10 @@ static void sdp_before_proc(struct recording *recording, const str *sdp, struct
"SDP from %u before %s", ml->unique_id, get_opmode_text(opmode));
}
static void sdp_after_proc(struct recording *recording, GString *s, struct call_monologue *ml,
static void sdp_after_proc(struct recording *recording, const str *sdp, struct call_monologue *ml,
enum call_opmode opmode)
{
append_meta_chunk(recording, s->str, s->len,
append_meta_chunk_str(recording, sdp,
"SDP from %u after %s", ml->unique_id, get_opmode_text(opmode));
}
@ -1073,7 +1073,7 @@ static void init_all(call_t *call) {
proc_init(call);
}
static void sdp_after_all(struct recording *recording, GString *s, struct call_monologue *ml,
static void sdp_after_all(struct recording *recording, const str *s, struct call_monologue *ml,
enum call_opmode opmode)
{
sdp_after_pcap(recording, s, ml, opmode);

@ -63,7 +63,7 @@ struct recording_method {
void (*init_struct)(call_t *);
void (*sdp_before)(struct recording *, const str *, struct call_monologue *, enum call_opmode);
void (*sdp_after)(struct recording *, GString *, struct call_monologue *,
void (*sdp_after)(struct recording *, const str *, struct call_monologue *,
enum call_opmode);
void (*meta_chunk)(struct recording *, const char *, const str *);
void (*update_flags)(call_t *call, bool streams);

@ -169,7 +169,7 @@ a=rtcp:PORT
SDP
new_call;
offer('intfs selection alias', { direction => [qw(blah baz)] }, <<SDP);
v=0

@ -146,9 +146,9 @@ m=audio 16478 RTP/AVP 8
v=0
o=- 1545997027 1 IN IP4 198.51.101.40
s=tester
c=IN IP4 203.0.113.1
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendonly
a=rtcp:PORT
@ -300,8 +300,8 @@ v=0
o=- 1545997027 1 IN IP4 203.0.113.1
s=tester
t=0 0
c=IN IP4 203.0.113.1
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=inactive
a=rtcp:PORT
@ -324,8 +324,8 @@ v=0
o=- 1545997027 1 IN IP4 203.0.113.1
s=tester
t=0 0
c=IN IP4 203.0.113.1
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=inactive
a=rtcp:PORT

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save