Esempio n. 1
0
/**
 * Starts decoding and playing the FLI/FLC file
 */
void FlcPlayer::play(bool skipLastFrame)
{
	_playingState = PLAYING;

	// Vertically center the video
	_dy = (_mainScreen->h - _headerHeight) / 2;

	_offset = _dy * _mainScreen->pitch + _mainScreen->format->BytesPerPixel * _dx;

	// Skip file header
	_videoFrameData = _fileBuf + 128;
	_audioFrameData = _videoFrameData;

	while (!shouldQuit())
	{
		if (_frameCallBack)
			(*_frameCallBack)();
		else // TODO: support both, in the case the callback is not some audio?
			decodeAudio(2);

		if (!shouldQuit())
			decodeVideo(skipLastFrame);

		if(!shouldQuit())
			SDLPolling();
	}
	
}
Esempio n. 2
0
AVFrame *FFMpegDecoder::getFrameAtSec(double sec)
{
	if (videoStream < 0)
	{
		errinfo("no video stream!");
		return NULL;
	}

	AVFrame *pic = NULL;
	seekToSec(sec);
	while (true)
	{
		AVPacket *pkt = readPacket();
		if (pkt == NULL)
			break;

		if (pkt->stream_index != videoStream)
			continue;

		pic = decodeVideo();
		if (pic != NULL)
			break;
	}
	return pic;
}
Esempio n. 3
0
void FPVDrone::updateCycle()
{
    // Retrieve and process video packets
    bool newFrame = decodeVideo(_frame);
    if(newFrame)
    {
        notifyVideoFrameAvailable(_frame);
    }
}
Esempio n. 4
0
Frame *DataSource::readFrame() {
    AVPacket packet;

    //DPRINT("%d, %d", m_formatCtx->streams[m_videoStream]->time_base.num, m_formatCtx->streams[m_videoStream]->time_base.den);
    while (av_read_frame(m_formatCtx, &packet) >= 0) {
        if (packet.stream_index == m_videoStream) {
            //DPRINT("video packet pts %lld", packet.pts);
            if (packet.pts != AV_NOPTS_VALUE) {
                //DPRINT("video set pts %lld", packet.pts);
                if (packet.pts > m_currentVideoPts) {
                    m_currentVideoPts = packet.pts;
                }
            }

            AVFrame *f = decodeVideo(m_formatCtx->streams[m_videoStream]->codec, &packet);

            if (f != NULL) {
                //DPRINT("video pts: %lf, %lf", videoTimeBase, m_currentPts * videoTimeBase);
                Frame *ret = new VideoFrame(f,
                                            m_currentVideoPts,
                                            Frame::VideoFrame);
                av_free_packet(&packet);
                return ret;
            }
        }
        else if (packet.stream_index == m_audioStream) {
            //DPRINT("audio packet pts %lld", packet.pts);
            if (packet.pts != AV_NOPTS_VALUE) {
                //DPRINT("audio set pts %lld", packet.pts);
                if (packet.pts > m_currentAudioPts) {
                    m_currentAudioPts = packet.pts;
                }
            }
            int size = 0;
            uint8_t *buf = decodeAudio(m_formatCtx->streams[m_audioStream]->codec,
                                       &packet,
                                       &size);

            if (buf != NULL) {
                Frame *ret = new AudioFrame(buf, size, m_currentAudioPts, Frame::AudioFrame);
                return ret;
            }
        }

        av_free_packet(&packet);
    }

    return NULL;
}
Esempio n. 5
0
AVFrame* FFMpegDecoder::decodeVideo()
{
	return decodeVideo(&encodedPacket);
}