예제 #1
0
/**
 * @brief Send an interleaved RTCP packet down to the RTCP handler
 *
 * @param rtsp The RTSP client where the handler can be found
 * @param channel The channel index where the package arrived
 * @param data The pointer to the data to send
 * @param len The length of the data to send
 *
 * This function is used to send data down to the actual RTCP handler
 * after it has been received from an interleaved transport (TCP or
 * SCTP alike).
 */
void interleaved_rtcp_send(RTSP_Client *rtsp, int channel,
                           void *data, size_t len)
{
    RTSP_interleaved *intlvd = NULL;
    GSList *intlvd_iter = g_slist_find_custom(rtsp->interleaved,
                                              GINT_TO_POINTER(channel),
                                              interleaved_rtcp_find_compare);

    /* We have to check if the value returned by g_slist_find_custom
     * is valid before derefencing it.
     */
    if ( intlvd_iter == NULL ) {
        fnc_log(FNC_LOG_DEBUG,
                "Interleaved RTCP packet arrived for unknown channel (%d)... discarding.\n",
                channel);
        return;
    }

    intlvd = (RTSP_interleaved *)intlvd_iter->data;

    /* We should be pretty sure this is not NULL */
    g_assert(intlvd != NULL);

    /* Write the actual data */
    Sock_write(intlvd->rtcp.local, data, len, NULL, MSG_DONTWAIT | MSG_EOR);
}
예제 #2
0
파일: rtp.c 프로젝트: dulton/hm-platform
static __inline__ gint
__rtp_pkt_send(RTP_session *session, RTP_transport *transport, 
	RTP_packet *packet, gsize packet_size)
{
	switch (transport->trans_mode)
	{
	case RTP_OVER_UDP:
		return Sock_write(transport->rtp_sock, packet, packet_size,
			NULL, MSG_DONTWAIT | MSG_EOR);

	case RTP_OVER_TCP:
		return __rtp_pkt_send_rot(session, transport, packet, packet_size);

	case RTP_OVER_RTSP:
		return __rtp_pkt_send_ror(session, transport, packet, packet_size);
	}

	return -1;
}
예제 #3
0
파일: Rsock.c 프로젝트: radfordneal/pqR
void in_Rsockwrite(int *sockp, char **buf, int *start, int *end, int *len)
{
    ssize_t n;
    if (*end > *len)
	*end = *len;
    if (*start < 0)
	*start = 0;
    if (*end < *start) {
	*len = -1;
	return;
    }
    check_init();
#ifdef DEBUG
    printf("writing %s to %d", *buf, *sockp);
#endif
    perr.error = 0;
    n = Sock_write(*sockp, *buf + *start, *end - *start, &perr);
    *len = (int) n;
    if(perr.error) REprintf("socket error: %s\n", strerror(perr.error));
}
예제 #4
0
파일: rtp.c 프로젝트: phully/feng_build
/**
 * @brief Send the actual buffer as an RTP packet to the client
 *
 * @param session The RTP session to send the packet for
 * @param buffer The data for the packet to be sent
 *
 * @return The number of frames sent to the client.
 * @retval -1 Error during writing.
 */
static void rtp_packet_send(RTP_session *session, MParserBuffer *buffer)
{
    const size_t packet_size = sizeof(RTP_packet) + buffer->data_size;
    RTP_packet *packet = g_malloc0(packet_size);
    Track *tr = session->track;
    const uint32_t timestamp = RTP_calc_rtptime(session,
                               tr->properties.clock_rate,
                               buffer);

    packet->version = 2;
    packet->padding = 0;
    packet->extension = 0;
    packet->csrc_len = 0;
    packet->marker = buffer->marker & 0x1;
    packet->payload = tr->properties.payload_type & 0x7f;
    packet->seq_no = htons(++session->seq_no);
    packet->timestamp = htonl(timestamp);
    packet->ssrc = htonl(session->ssrc);

    fnc_log(FNC_LOG_VERBOSE, "[RTP] Timestamp: %u", ntohl(timestamp));

    memcpy(packet->data, buffer->data, buffer->data_size);

    if (Sock_write(session->transport.rtp_sock, packet,
                   packet_size, NULL, MSG_DONTWAIT
                   | MSG_EOR) < 0) {
        fnc_log(FNC_LOG_DEBUG, "RTP Packet Lost\n");
    } else {
        session->last_timestamp = buffer->timestamp;
        session->pkt_count++;
        session->octet_count += buffer->data_size;

        session->last_packet_send_time = time(NULL);
    }
    g_free(packet);
}