コード例 #1
0
bool FFmpegPlayer::handleCommand(const Command cmd)
{
    switch (cmd)
    {
    case CMD_PLAY:
        cmdPlay();
        return true;

    case CMD_PAUSE:
        cmdPause();
        return true;

    case CMD_REWIND:
        cmdRewind();
        return true;

    case CMD_SEEK:
        cmdSeek(m_seek_time);
        return true;

    case CMD_STOP:
        cmdPause();
        return false;

    case CMD_ACTOUTPUT:
        cmdActivateOutput();
        return true;

    default:
        //OSG_WARN << "FFmpegPlayer::handleCommand() Unsupported command" << std::endl;
        av_log(NULL, AV_LOG_WARNING, "FFmpegPlayer::handleCommand() Unsupported command");
        return false;
    }
}
コード例 #2
0
void FFmpegPlayer::cmdSeek(double time)
{
    cmdPause();
    //
    const unsigned long ul_time = time;
    m_streamer.seek(ul_time);
}
コード例 #3
0
ファイル: FFmpegImageStream.cpp プロジェクト: aalex/osg
bool FFmpegImageStream::handleCommand(const Command cmd)
{
    switch (cmd)
    {
    case CMD_PLAY:
        cmdPlay();
        return true;

    case CMD_PAUSE:
        cmdPause();
        return true;

    case CMD_REWIND:
        cmdRewind();
        return true;

    case CMD_SEEK:
        cmdSeek(m_seek_time);
        return true;

    case CMD_STOP:
        return false;

    default:
        assert(false);
        return false;
    }
}
コード例 #4
0
void FFmpegPlayer::run()
{
    av_log(NULL, AV_LOG_INFO, "Start FFmpegPlayer::run()");
    try
    {
        Mutex       lockMutex;
        ScopedLock  lock(lockMutex);

        bool done = false;

        while (! done)
        {
            if (_status == PLAYING)
            {
                bool no_cmd;
                const Command cmd = m_commands->timedPop(no_cmd, 1);

                if (no_cmd)
                {
                    m_commandQueue_cond.wait(& lockMutex);
                }
                else
                {
                    done = ! handleCommand(cmd);
                }
            }
            else
            {
                done = ! handleCommand(m_commands->pop());
            }
        }
    }

    catch (const std::exception & error)
    {
        //OSG_WARN << "FFmpegPlayer::run : " << error.what() << std::endl;
        av_log(NULL, AV_LOG_WARNING, "FFmpegPlayer::run : %s", error.what());
    }

    catch (...)
    {
        //OSG_WARN << "FFmpegPlayer::run : unhandled exception" << std::endl;
        av_log(NULL, AV_LOG_WARNING, "FFmpegPlayer::run : unhandled exception");
    }

    //OSG_NOTICE<<"Finished FFmpegPlayer::run()"<<std::endl;
    av_log(NULL, AV_LOG_INFO, "Finished FFmpegPlayer::run()");

    // Ensure that all threads are closed
    cmdPause();
    //
    // Because \open() starts thread, here we should call \close()
    close();
}
コード例 #5
0
// todo: it is strange, but here we need to init SDL in main thread, not in command-stack om shadow thread.
void FFmpegPlayer::activateOutput()
{
    const PlayingStatus prevStatus = get_status();

    if (prevStatus == PLAYING)
        cmdPause();

    //pushCommand(CMD_ACTOUTPUT);
    cmdActivateOutput();

    if (prevStatus == PLAYING)
        cmdPlay();
}