Browse Source

TT#78307 add helper functions for SSRC contexts

Change-Id: I32470c03c19c8bb889900ca277b73713ee66c485
changes/42/38942/2
Richard Fuchs 6 years ago
parent
commit
1d514a063c
4 changed files with 30 additions and 29 deletions
  1. +2
    -4
      daemon/call.c
  2. +1
    -3
      daemon/media_player.c
  3. +10
    -22
      daemon/media_socket.c
  4. +17
    -0
      include/ssrc.h

+ 2
- 4
daemon/call.c View File

@ -2490,10 +2490,8 @@ static void __call_free(void *p) {
crypto_cleanup(&ps->crypto);
g_queue_clear(&ps->sfds);
g_hash_table_destroy(ps->rtp_stats);
if (ps->ssrc_in)
obj_put(&ps->ssrc_in->parent->h);
if (ps->ssrc_out)
obj_put(&ps->ssrc_out->parent->h);
ssrc_ctx_put(&ps->ssrc_in);
ssrc_ctx_put(&ps->ssrc_out);
g_slice_free1(sizeof(*ps), ps);
}


+ 1
- 3
daemon/media_player.c View File

@ -92,9 +92,7 @@ static void __media_player_free(void *p) {
ilog(LOG_DEBUG, "freeing media_player");
media_player_shutdown(mp);
if (mp->ssrc_out)
obj_put(&mp->ssrc_out->parent->h);
mp->ssrc_out = NULL;
ssrc_ctx_put(&mp->ssrc_out);
mutex_destroy(&mp->lock);
obj_put(mp->call);
}


+ 10
- 22
daemon/media_socket.c View File

@ -1285,17 +1285,14 @@ static void __stream_ssrc(struct packet_stream *in_srtp, struct packet_stream *o
mutex_lock(&in_srtp->in_lock);
(*ssrc_in_p) = in_srtp->ssrc_in;
if (*ssrc_in_p)
obj_hold(&(*ssrc_in_p)->parent->h);
ssrc_ctx_hold(*ssrc_in_p);
if (G_UNLIKELY(!(*ssrc_in_p) || (*ssrc_in_p)->parent->h.ssrc != in_ssrc)) {
// SSRC mismatch - get the new entry
if (*ssrc_in_p)
obj_put(&(*ssrc_in_p)->parent->h);
if (in_srtp->ssrc_in)
obj_put(&in_srtp->ssrc_in->parent->h);
ssrc_ctx_put(ssrc_in_p);
ssrc_ctx_put(&in_srtp->ssrc_in);
(*ssrc_in_p) = in_srtp->ssrc_in =
get_ssrc_ctx(in_ssrc, ssrc_hash, SSRC_DIR_INPUT);
obj_hold(&in_srtp->ssrc_in->parent->h);
ssrc_ctx_hold(in_srtp->ssrc_in);
// might have created a new entry, which would have a new random
// ssrc_map_out. we don't need this if we're not transcoding
@ -1310,17 +1307,14 @@ static void __stream_ssrc(struct packet_stream *in_srtp, struct packet_stream *o
mutex_lock(&out_srtp->out_lock);
(*ssrc_out_p) = out_srtp->ssrc_out;
if (*ssrc_out_p)
obj_hold(&(*ssrc_out_p)->parent->h);
ssrc_ctx_hold(*ssrc_out_p);
if (G_UNLIKELY(!(*ssrc_out_p) || (*ssrc_out_p)->parent->h.ssrc != out_ssrc)) {
// SSRC mismatch - get the new entry
if (*ssrc_out_p)
obj_put(&(*ssrc_out_p)->parent->h);
if (out_srtp->ssrc_out)
obj_put(&out_srtp->ssrc_out->parent->h);
ssrc_ctx_put(ssrc_out_p);
ssrc_ctx_put(&out_srtp->ssrc_out);
(*ssrc_out_p) = out_srtp->ssrc_out =
get_ssrc_ctx(out_ssrc, ssrc_hash, SSRC_DIR_OUTPUT);
obj_hold(&out_srtp->ssrc_out->parent->h);
ssrc_ctx_hold(out_srtp->ssrc_out);
// reverse SSRC mapping
(*ssrc_out_p)->ssrc_map_out = in_ssrc;
@ -1904,14 +1898,8 @@ out:
g_queue_clear_full(&phc->mp.packets_out, codec_packet_free);
if (phc->mp.ssrc_in) {
obj_put(&phc->mp.ssrc_in->parent->h);
phc->mp.ssrc_in = NULL;
}
if (phc->mp.ssrc_out) {
obj_put(&phc->mp.ssrc_out->parent->h);
phc->mp.ssrc_out = NULL;
}
ssrc_ctx_put(&phc->mp.ssrc_in);
ssrc_ctx_put(&phc->mp.ssrc_out);
return ret;
}


+ 17
- 0
include/ssrc.h View File

@ -204,5 +204,22 @@ void payload_tracker_init(struct payload_tracker *t);
void payload_tracker_add(struct payload_tracker *, int);
INLINE void ssrc_ctx_put(struct ssrc_ctx **c) {
if (!c || !*c)
return;
obj_put(&(*c)->parent->h);
*c = NULL;
}
INLINE struct ssrc_ctx *ssrc_ctx_get(struct ssrc_ctx *c) {
if (!c)
return NULL;
obj_hold(&c->parent->h);
return c;
}
INLINE void ssrc_ctx_hold(struct ssrc_ctx *c) {
ssrc_ctx_get(c);
}
#endif

Loading…
Cancel
Save