コード例 #1
0
ファイル: network_client.c プロジェクト: waycom/h6
int32_t
network_client_send_msg(network_client *nc, msg_t *m, uint32_t seq,
	uint32_t flags)
{
	int32_t err = -EKILLED;
	proto_watch *pw = NULL;

	pthread_mutex_lock(nc->lock);
	if (!__network_client_killed(nc))
	{
		pw = proto_watch_ref(nc->proto_watch);
	}
	pthread_mutex_unlock(nc->lock);

	if (pw)
	{
		err = proto_watch_write(pw, m, seq, flags);
		proto_watch_unref(pw);
	}
	else
	{
		msg_unref(m);
	}

	return err;
}
コード例 #2
0
ファイル: rtp_sinker.c プロジェクト: dulton/nampu
static int32_t
rtp_sinker_consume(network_sinker *ns, proto_watch *pw,
                   int32_t stm_i, msg *m, uint32_t seq)
{
    int32_t ret = -ENOMEM;
    media_sinker *sinker = (media_sinker*)ns;
    rtp_sinker *rs = (rtp_sinker*)ns;
    media_sinker *ms = (media_sinker*)ns;
    mem_block *mb;
    network_client *nc = (network_client*)rs->interleaved;

    if (rs->trans_mode == RTP_OVER_UDP)
    {
        BUG_ON(!pw);
        proto_watch_ref(pw);
        RELEASE_LOCK(sinker->lock);

        msg_ref(m);
        ret = proto_watch_write(pw, m, seq, 0);
        proto_watch_unref(pw);

        AQUIRE_LOCK(sinker->lock);
        return ret;
    }

    mb = rtp_msg_to_interleaved_mb(m, ns->stms[stm_i].interleaved);
    if (mb)
    {
        MEMBLOCK_SET_SEQ(mb, seq);
        if (rs->trans_mode == RTP_OVER_TCP)
        {
            BUG_ON(!pw);
            proto_watch_ref(pw);
            RELEASE_LOCK(sinker->lock);

            msg_ref(m);
            ret = proto_watch_write_mb(pw, mb, 0);
            proto_watch_unref(pw);

            AQUIRE_LOCK(sinker->lock);
        }
        else
        {
            BUG_ON(!nc);
            RELEASE_LOCK(ms->lock);

            msg_ref(m);
            ret = network_client_send_mb(nc, mb, 0);

            AQUIRE_LOCK(ms->lock);
        }
    }

    return ret;
}