Пример #1
0
struct rtpp_log *
rtpp_log_ctor(struct rtpp_cfg_stable *cfs, const char *app,
  const char *call_id, int flags)
{
    struct rtpp_log_priv *pvt;
    struct rtpp_refcnt *rcnt;

    pvt = rtpp_rzmalloc(sizeof(struct rtpp_log_priv), &rcnt);
    if (pvt == NULL) {
        return (NULL);
    }
    pvt->pub.rcnt = rcnt;
    pvt->log = rtpp_log_open(cfs, app, call_id, flags);
    rtpp_gen_uid(&pvt->pub.lguid);
    pvt->pub.setlevel = &rtpp_log_obj_setlevel;
    pvt->pub.write = rtpp_log_obj_write;
    pvt->pub.ewrite = rtpp_log_obj_ewrite;
    CALL_SMETHOD(pvt->pub.rcnt, attach, (rtpp_refcnt_dtor_t)&rtpp_log_obj_dtor,
      pvt);
    return (&pvt->pub);
}
Пример #2
0
struct rtpp_stream *
rtpp_stream_ctor(struct rtpp_log *log, struct rtpp_weakref_obj *servers_wrt,
  struct rtpp_stats *rtpp_stats, enum rtpp_stream_side side,
  int session_type, uint64_t seuid)
{
    struct rtpp_stream_priv *pvt;
    struct rtpp_refcnt *rcnt;

    pvt = rtpp_rzmalloc(sizeof(struct rtpp_stream_priv), &rcnt);
    if (pvt == NULL) {
        goto e0;
    }
    pvt->pub.rcnt = rcnt;
    if (pthread_mutex_init(&pvt->lock, NULL) != 0) {
        goto e1;
    }
    if (session_type == SESS_RTP) {
        pvt->pub.analyzer = rtpp_analyzer_ctor(log);
        if (pvt->pub.analyzer == NULL) {
            goto e3;
        }
    }
    pvt->pub.pcnt_strm = rtpp_pcnt_strm_ctor();
    if (pvt->pub.pcnt_strm == NULL) {
        goto e4;
    }
    pvt->servers_wrt = servers_wrt;
    pvt->rtpp_stats = rtpp_stats;
    pvt->pub.log = log;
    CALL_METHOD(log->rcnt, incref);
    pvt->side = side;
    pvt->pub.session_type = session_type;
    pvt->pub.handle_play = &rtpp_stream_handle_play;
    pvt->pub.handle_noplay = &rtpp_stream_handle_noplay;
    pvt->pub.isplayer_active = &rtpp_stream_isplayer_active;
    pvt->pub.finish_playback = &rtpp_stream_finish_playback;
    pvt->pub.get_actor = &rtpp_stream_get_actor;
    pvt->pub.get_proto = &rtpp_stream_get_proto;
    pvt->pub.latch = &rtpp_stream_latch;
    pvt->pub.check_latch_override = &rtpp_stream_check_latch_override;
    pvt->pub.fill_addr = &rtpp_stream_fill_addr;
    pvt->pub.prefill_addr = &rtpp_stream_prefill_addr;
    pvt->pub.get_rtps = &rtpp_stream_get_rtps;
    pvt->pub.replace_rtps = &rtpp_stream_replace_rtps;
    if (session_type == SESS_RTCP) {
        pvt->pub.guess_addr = &rtpp_stream_guess_addr;
    }
    rtpp_gen_uid(&pvt->pub.stuid);
    pvt->pub.seuid = seuid;
    CALL_METHOD(pvt->pub.rcnt, attach, (rtpp_refcnt_dtor_t)&rtpp_stream_dtor,
      pvt);
    return (&pvt->pub);

e4:
    if (session_type == SESS_RTP) {
         CALL_METHOD(pvt->pub.analyzer->rcnt, decref);
    }
e3:
    pthread_mutex_destroy(&pvt->lock);
e1:
    CALL_METHOD(pvt->pub.rcnt, decref);
    free(pvt);
e0:
    return (NULL);
}