예제 #1
0
int RTPEndpoint::RunText()
{
        BYTE lost;
        TextCodec::Type codec;
        DWORD timestamp = 0;
        RTPPacket text(MediaFrame::Text,0,0);

        while(inited)
        {
		DWORD len = text.GetMaxMediaLength();
                //Get the packet
                if (!RTPSession::GetTextPacket(text.GetMediaData(),&len,&lost, &codec, &timestamp))
			continue;
		//Set length
		text.SetMediaLength(len);
                //Set codec
                text.SetCodec(codec);
                text.SetType(codec);
                //Set timestamp
                text.SetTimestamp(timestamp);
                //Multiplex
                Multiplex(text);
        }

        return 1;

}
예제 #2
0
int RTPEndpoint::RunAudio()
{
        BYTE lost;
        AudioCodec::Type codec;
        DWORD timestamp;
        RTPPacket audio(MediaFrame::Audio,0,0);

        while(inited)
        {
		DWORD len = audio.GetMaxMediaLength();
                //Get the packet
                if (!RTPSession::GetAudioPacket(audio.GetMediaData(), &len ,&lost, &codec, &timestamp))
			//Next
			continue;
		//Set length
		audio.SetMediaLength(len);
		//Set codec
		audio.SetCodec(codec);
		audio.SetType(codec);
		//Set timestamp
		audio.SetTimestamp(timestamp);
		//Multiplex
		Multiplex(audio);
        }

        return 1;
}
예제 #3
0
int RTPEndpoint::RunVideo()
{
        BYTE lost;
        BYTE last;
        VideoCodec::Type codec;
        DWORD timestamp = 0;
        RTPPacket video(MediaFrame::Video,0,0);

        while(inited)
        {
		DWORD len = video.GetMaxMediaLength();
                //Get the packet
                if (!RTPSession::GetVideoPacket(video.GetMediaData(),&len,&last,&lost, &codec, &timestamp))
			continue;
		//Set length
		video.SetMediaLength(len);
                //Set codec
                video.SetCodec(codec);
                video.SetType(codec);
                //Set mark
                video.SetMark(last);
                //Set timestamp
                video.SetTimestamp(timestamp);
                //Multiplex
                Multiplex(video);
        }

        return 1;
}
예제 #4
0
int RTPMultiplexerSmoother::Run()
{
	timeval prev;
	timespec wait;
	DWORD	sendingTime = 0;
	
	//Calculate first
	getUpdDifTime(&prev);

	Log(">RTPMultiplexerSmoother run\n");
	
	while(inited)
	{
		//Wait for new frame
		if (!queue.Wait(0))
			//Check again
			continue;

		//Get it
		RTPPacketSched *sched = queue.Pop();

		//Check it
		if (!sched)
			//Exit
			continue;

		//Multiplex
		Multiplex(*(RTPPacket*)sched);

		//Update sending time
		sendingTime = sched->GetSendingTime();

		//Lock
		pthread_mutex_lock(&mutex);

		//Calculate timeout
		calcAbsTimeout(&wait,&prev,sendingTime);

		//Wait next or stopped
		pthread_cond_timedwait(&cond,&mutex,&wait);

		//Unlock
		pthread_mutex_unlock(&mutex);

		//If it was last
		if (sched->GetMark())
			//Update time of the previous frame
			getUpdDifTime(&prev);

		//DElete it
		delete(sched);
	}

	Log("<RTPMultiplexerSmoother run\n");

	return 1;
}