RTP_session * rtp_session_new(RTSP_Client *client, RTSP_session *rtsp_s, RTP_transport *transport, GstRTSPUrl *uri, Track *tr) { RTP_session *rtp_s = g_new0(RTP_session, 1); rtp_s->ref_count = 1; rtp_s->playing = FALSE; rtp_s->uri = gst_rtsp_url_get_request_uri(uri); memcpy(&rtp_s->transport, transport, sizeof(RTP_transport)); memset(transport, 0, sizeof(RTP_transport)); rtp_s->start_rtptime = g_random_int(); rtp_s->start_seq = g_random_int_range(0, G_MAXUINT16); rtp_s->seq_no = rtp_s->start_seq - 1; rtp_s->track = tr; if (tr->properties.media_type == MP_video) rtp_s->consumer = bq_consumer_new(tr->producer); rtp_s->ssrc = g_random_int(); rtp_s->client = client; #ifdef HAVE_METADATA rtp_s->metadata = rtsp_s->resource->metadata; #endif rtsp_s->rtp_sessions = g_slist_append(rtsp_s->rtp_sessions, rtp_s); rtp_s->rtsp = rtsp_s; rtsp_session_ref(rtsp_s); return rtp_s; }
/** * @brief Create a new RTP session object. * * @param rtsp The buffer for which to generate the session * @param rtsp_s The RTSP session * @param uri The URI for the current RTP session * @param transport The transport used by the session * @param tr The track that will be sent over the session * * @return A pointer to a newly-allocated RTP_session, that needs to * be freed with @ref rtp_session_free. * * @see rtp_session_free */ RTP_session *rtp_session_new(RTSP_Client *rtsp, RTSP_session *rtsp_s, RTP_transport *transport, const char *uri, Track *tr) { feng *srv = rtsp->srv; RTP_session *rtp_s = g_slice_new0(RTP_session); ev_io *io = &rtp_s->transport.rtcp_reader; ev_periodic *periodic = &rtp_s->transport.rtp_writer; /* Make sure we start paused since we have to wait for parameters * given by @ref rtp_session_resume. */ rtp_s->uri = g_strdup(uri); memcpy(&rtp_s->transport, transport, sizeof(RTP_transport)); rtp_s->start_rtptime = g_random_int(); rtp_s->start_seq = g_random_int_range(0, G_MAXUINT16); rtp_s->seq_no = rtp_s->start_seq - 1; /* Set up the track selector and get a consumer for the track */ rtp_s->track = tr; rtp_s->consumer = bq_consumer_new(tr->producer); rtp_s->srv = srv; rtp_s->ssrc = g_random_int(); rtp_s->client = rtsp; #ifdef HAVE_METADATA rtp_s->metadata = rtsp_s->resource->metadata; #endif periodic->data = rtp_s; ev_periodic_init(periodic, rtp_write_cb, 0, 0, NULL); io->data = rtp_s; ev_io_init(io, rtcp_read_cb, Sock_fd(rtp_s->transport.rtcp_sock), EV_READ); // Setup the RTP session rtsp_s->rtp_sessions = g_slist_append(rtsp_s->rtp_sessions, rtp_s); return rtp_s; }