fix payload type tracking for transcoding situations

closes #476

Change-Id: I6a038136e22b23efe422eb40caa0f3e10359e5d1
changes/64/19464/1
Richard Fuchs 8 years ago
parent 2ebe76d535
commit 0db5e226e5

@ -428,6 +428,8 @@ void codec_add_raw_packet(struct media_packet *mp) {
struct codec_packet *p = g_slice_alloc(sizeof(*p));
p->s = mp->raw;
p->free_func = NULL;
if (mp->rtp)
mp->ssrc_out->payload_type = mp->rtp->m_pt & 0x7f;
g_queue_push_tail(&mp->packets_out, p);
}
static int handler_func_passthrough(struct codec_handler *h, struct call_media *media,
@ -677,6 +679,7 @@ static int __packet_encoded(encoder_t *enc, void *u1, void *u2) {
struct codec_packet *p = g_slice_alloc(sizeof(*p));
p->s.s = buf;
p->s.len = inout.len + sizeof(struct rtp_header);
mp->ssrc_out->payload_type = ch->handler->dest_pt.payload_type;
p->free_func = free;
g_queue_push_tail(&mp->packets_out, p);

@ -1301,7 +1301,7 @@ static void media_packet_rtp(struct packet_handler_ctx *phc)
// XXX redundant between SSRC handling and codec_handler stuff -> combine
phc->payload_type = (phc->mp.rtp->m_pt & 0x7f);
if (G_LIKELY(phc->mp.ssrc_in))
phc->mp.ssrc_in->parent->payload_type = phc->payload_type;
phc->mp.ssrc_in->payload_type = phc->payload_type;
// XXX yet another hash table per payload type -> combine
struct rtp_stats *rtp_s = g_atomic_pointer_get(&phc->mp.stream->rtp_stats_cache);

@ -1475,9 +1475,10 @@ static int json_build_ssrc(struct call *c, JsonReader *root_reader) {
struct ssrc_entry_call *se = get_ssrc(ssrc, c->ssrc_hash);
se->input_ctx.srtp_index = json_reader_get_ll(root_reader, "in_srtp_index");
se->input_ctx.srtcp_index = json_reader_get_ll(root_reader, "in_srtcp_index");
se->input_ctx.payload_type = json_reader_get_ll(root_reader, "in_payload_type");
se->output_ctx.srtp_index = json_reader_get_ll(root_reader, "out_srtp_index");
se->output_ctx.srtcp_index = json_reader_get_ll(root_reader, "out_srtcp_index");
se->payload_type = json_reader_get_ll(root_reader, "payload_type");
se->output_ctx.payload_type = json_reader_get_ll(root_reader, "out_payload_type");
json_reader_end_element(root_reader);
}
@ -2087,9 +2088,10 @@ char* redis_encode_json(struct call *c) {
// XXX use function for in/out
JSON_SET_SIMPLE("in_srtp_index","%" PRIu64, se->input_ctx.srtp_index);
JSON_SET_SIMPLE("in_srtcp_index","%" PRIu64, se->input_ctx.srtcp_index);
JSON_SET_SIMPLE("in_payload_type","%i", se->input_ctx.payload_type);
JSON_SET_SIMPLE("out_srtp_index","%" PRIu64, se->output_ctx.srtp_index);
JSON_SET_SIMPLE("out_srtcp_index","%" PRIu64, se->output_ctx.srtcp_index);
JSON_SET_SIMPLE("payload_type","%i", se->payload_type);
JSON_SET_SIMPLE("out_payload_type","%i", se->output_ctx.payload_type);
// XXX add rest of info
json_builder_end_object (builder);

@ -273,20 +273,20 @@ static int parse_address(struct network_address *address) {
&address->address_type, &address->address);
}
#define EXTRACT_TOKEN(field) if (str_token_sep(&output->field, value_str, ' ')) return -1
#define EXTRACT_TOKEN(field) do { if (str_token_sep(&output->field, value_str, ' ')) return -1; } while (0)
#define EXTRACT_NETWORK_ADDRESS_NP(field) \
EXTRACT_TOKEN(field.network_type); \
do { EXTRACT_TOKEN(field.network_type); \
EXTRACT_TOKEN(field.address_type); \
EXTRACT_TOKEN(field.address)
EXTRACT_TOKEN(field.address); } while (0)
#define EXTRACT_NETWORK_ADDRESS(field) \
EXTRACT_NETWORK_ADDRESS_NP(field); \
if (parse_address(&output->field)) return -1
do { EXTRACT_NETWORK_ADDRESS_NP(field); \
if (parse_address(&output->field)) return -1; } while (0)
#define EXTRACT_NETWORK_ADDRESS_NF(field) \
EXTRACT_NETWORK_ADDRESS_NP(field); \
if (parse_address(&output->field)) do { \
do { EXTRACT_NETWORK_ADDRESS_NP(field); \
if (parse_address(&output->field)) { \
output->field.parsed.family = get_socket_family_enum(SF_IP4); \
output->field.parsed.u.ipv4.s_addr = 1; \
} while (0)
} } while (0)
#define PARSE_DECL str v_str, *value_str
#define PARSE_INIT v_str = output->value; value_str = &v_str

@ -8,6 +8,7 @@
static void init_ssrc_ctx(struct ssrc_ctx *c, struct ssrc_entry_call *parent) {
c->parent = parent;
c->payload_type = -1;
while (!c->ssrc_map_out)
c->ssrc_map_out = random();
}
@ -18,7 +19,6 @@ static void init_ssrc_entry(struct ssrc_entry *ent, u_int32_t ssrc) {
static struct ssrc_entry *create_ssrc_entry_call(void *uptr) {
struct ssrc_entry_call *ent;
ent = g_slice_alloc0(sizeof(*ent));
ent->payload_type = -1;
init_ssrc_ctx(&ent->input_ctx, ent);
init_ssrc_ctx(&ent->output_ctx, ent);
return &ent->h;
@ -213,7 +213,7 @@ static long long __calc_rtt(struct call *c, u_int32_t ssrc, u_int32_t ntp_middle
return 0;
if (pt_p)
*pt_p = e->payload_type;
*pt_p = e->output_ctx.payload_type;
struct ssrc_time_item *sti;
GQueue *q = (((void *) e) + reports_queue_offset);
@ -287,14 +287,11 @@ void ssrc_receiver_report(struct call_media *m, const struct ssrc_receiver_repor
// determine the clock rate for jitter values
if (pt < 0) {
pt = other_e->payload_type;
if (pt < 0) {
ilog(LOG_DEBUG, "No payload type known for RTCP RR, discarding");
goto out_nl;
}
ilog(LOG_DEBUG, "No payload type known for RTCP RR, discarding");
goto out_nl;
}
const struct rtp_payload_type *rpt = rtp_payload_type(pt, m->codecs_recv);
const struct rtp_payload_type *rpt = rtp_payload_type(pt, m->codecs_send);
if (!rpt) {
ilog(LOG_INFO, "Invalid RTP payload type %i, discarding RTCP RR", pt);
goto out_nl;

@ -36,6 +36,7 @@ struct ssrc_hash {
};
struct ssrc_ctx {
struct ssrc_entry_call *parent;
int payload_type; // to determine the clock rate for jitter calculations
// XXX lock this?
u_int64_t srtp_index,
srtcp_index;
@ -76,7 +77,6 @@ struct ssrc_entry_call {
struct ssrc_stats_block *lowest_mos,
*highest_mos,
average_mos; // contains a running tally of all stats blocks
int payload_type; // to determine the clock rate for jitter calculations
unsigned int last_rtt; // last calculated raw rtt without rtt from opposide side
};
enum ssrc_dir { // these values must not be used externally

Loading…
Cancel
Save