Exemplo n.º 1
0
static void receiver_process(MSFilter * f)
{
	ReceiverData *d = (ReceiverData *) f->data;
	mblk_t *m;
	uint32_t timestamp;
	if (d->session == NULL)
		return;
	
	if (d->reset_jb){
		ms_message("Reseting jitter buffer");
		rtp_session_resync(d->session);
		d->reset_jb=FALSE;
	}

	if (d->starting){
		PayloadType *pt=rtp_profile_get_payload(
			rtp_session_get_profile(d->session),
			rtp_session_get_recv_payload_type(d->session));
		if (pt && pt->type!=PAYLOAD_VIDEO)
			rtp_session_flush_sockets(d->session);
		d->starting=FALSE;
	}

	timestamp = (uint32_t) (f->ticker->time * (d->rate/1000));
	while ((m = rtp_session_recvm_with_ts(d->session, timestamp)) != NULL) {
		mblk_set_timestamp_info(m, rtp_get_timestamp(m));
		mblk_set_marker_info(m, rtp_get_markbit(m));
		mblk_set_cseq(m, rtp_get_seqnumber(m));
		rtp_get_payload(m,&m->b_rptr);		
		ms_queue_put(f->outputs[0], m);
	}
}
Exemplo n.º 2
0
static void receiver_process(MSFilter * f)
{
	ReceiverData *d = (ReceiverData *) f->data;
	mblk_t *m;
	uint32_t timestamp;

	if (d->session == NULL)
		return;

	timestamp = (uint32_t) (f->ticker->time * (d->rate/1000));
	while ((m = rtp_session_recvm_with_ts(d->session, timestamp)) != NULL) {
		mblk_set_timestamp_info(m, rtp_get_timestamp(m));
		mblk_set_marker_info(m, rtp_get_markbit(m));
		mblk_set_payload_type(m, rtp_get_payload_type(m));
		rtp_get_payload(m,&m->b_rptr);
		ms_queue_put(f->outputs[0], m);
	}
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
    MastTool* tool = NULL;
    mblk_t* packet = NULL;
    mblk_t* body = NULL;
    PayloadType* pt = NULL;
    int payload_size = 0;


    // Create an RTP session
    tool = new MastTool( MAST_TOOL_NAME, RTP_SESSION_RECVONLY );
    if (tool==NULL) return -1;

    // Parse the command line arguments
    // and configure the session
    parse_cmd_line( argc, argv, tool->get_session() );



    // Setup signal handlers
    mast_setup_signals();

    // Recieve a single packet
    packet = tool->wait_for_rtp_packet();
    if (packet == NULL) MAST_FATAL("Failed to receive a packet");
    body = packet->b_cont;
    payload_size = (body->b_wptr - body->b_rptr);


    // Display information about the packet received
    printf("\n");
    printf("RTP Header\n");
    printf("==========\n");
    printf("Payload type    : %u\n", rtp_get_payload_type( packet ) );
    printf("Payload size    : %u bytes\n", payload_size );
    printf("Sequence Number : %u\n", rtp_get_seqnumber( packet ) );
    printf("Timestamp       : %u\n", rtp_get_timestamp( packet ) );
    printf("SSRC Identifier : %x\n", rtp_get_ssrc( packet ) );
    printf("Marker Bit      : %s\n", rtp_get_markbit( packet ) ? "Set" : "Not Set");
    printf("\n");


    // Lookup the payload type
    pt = rtp_profile_get_payload( tool->get_profile(), rtp_get_payload_type( packet ) );
    if (pt == NULL) {
        MAST_WARNING( "Payload type %u isn't registered with oRTP", rtp_get_payload_type( packet ) );
    } else {
        const char* mime_major = "?";

        printf("Payload Details\n");
        printf("===============\n");

        if (pt->type==PAYLOAD_AUDIO_CONTINUOUS) mime_major = "audio";
        else if (pt->type==PAYLOAD_AUDIO_PACKETIZED) mime_major = "audio";
        else if (pt->type==PAYLOAD_VIDEO) mime_major = "video";
        printf("Mime Type       : %s/%s\n", mime_major, pt->mime_type);

        if (pt->clock_rate)			printf("Clock Rate      : %u Hz\n", pt->clock_rate);
        if (pt->channels)			printf("Channels        : %u\n", pt->channels);
        if (pt->bits_per_sample)	printf("Bits per Sample : %u\n", pt->bits_per_sample);
        if (pt->normal_bitrate) {
            printf("Normal Bitrate  : %u kbps\n", (pt->normal_bitrate/1000));
            printf("Packet duration : %u ms\n", (payload_size*1000)/(pt->normal_bitrate/8) );
        }
        if (pt->recv_fmtp)			printf("Recieve FMTP    : %s\n", pt->recv_fmtp);
        if (pt->send_fmtp)			printf("Send FMTP       : %s\n", pt->send_fmtp);
        printf("\n");


    }


    // Parse the MPEG Audio header
    if (rtp_get_payload_type( packet ) == RTP_MPEG_AUDIO_PT) {
        /* FIXME: check fragment offset header (see rfc2250) */
        unsigned char* mpa_ptr = body->b_rptr + 4;
        MPA_Header mh;

        printf("MPEG Audio Header\n");
        printf("=================\n");

        if (!mh.parse( mpa_ptr )) {
            MAST_WARNING("Failed to parse MPEG Audio header");
        } else {
            mh.debug( stdout );
        }
    }


    // Close RTP session
    delete tool;


    // Success !
    return 0;
}