RenderPreviewWidget.cpp 3.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*****************************************************************************
 * RenderPreviewWidget.cpp: Allow a current workflow preview
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

23
#include <QtDebug>
24 25 26 27

#include "RenderPreviewWidget.h"

RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget ) :
28
            GenericPreviewWidget( renderWidget ), m_mainWorkflow( mainWorkflow )
29
{
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    m_media = new LibVLCpp::Media( "fake://" );
//      --invmem-width <integer>   Width
//      --invmem-height <integer>  Height
//      --invmem-lock <string>     Lock function
//      --invmem-unlock <string>   Unlock function
//      --invmem-data <string>     Callback data
    char        buffer[64];

    sprintf( buffer, ":invmem-width=%i", VIDEOWIDTH );
    m_media->addOption( ":codec=invmem" );
    m_media->addOption( buffer );
    sprintf( buffer, ":invmem-height=%i", VIDEOHEIGHT );
    m_media->addOption( buffer );
    sprintf( buffer, ":invmem-lock=%lld", (qint64)RenderPreviewWidget::lock );
    m_media->addOption( buffer );
    sprintf( buffer, ":invmem-unlock=%lld", (qint64)RenderPreviewWidget::unlock );
    m_media->addOption( buffer );
    sprintf( buffer, ":invmem-data=%lld", (qint64)this );
    m_media->addOption( buffer );
    m_mediaPlayer->setMedia( m_media );
50 51
}

52

53 54
RenderPreviewWidget::~RenderPreviewWidget()
{
55 56 57 58 59
    delete m_media;
}

void*   RenderPreviewWidget::lock( void* datas )
{
60
//    qDebug() << "Locking invmem";
61
    RenderPreviewWidget* self = reinterpret_cast<RenderPreviewWidget*>( datas);
62 63 64 65
    void* ret = self->m_mainWorkflow->getOutput();
    if ( ret == NULL )
        self->m_mediaPlayer->stop();
    return ret;
66 67 68 69
}

void    RenderPreviewWidget::unlock( void*  )
{
70
//    qDebug() << "Unlocking invmem";
71 72
}

73 74
void        RenderPreviewWidget::startPreview( Media* )
{
75
    qDebug() << "Starting render preview";
76 77
    m_mainWorkflow->startRender();
    m_mediaPlayer->play();
78 79
}

80
void        RenderPreviewWidget::setPosition( float /*newPos*/ )
81 82 83
{
}

84
void        RenderPreviewWidget::togglePlayPause( bool /*forcePause*/ )
85
{
86
    startPreview( NULL );
87
}
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////

void        RenderPreviewWidget::__endReached()
{
    qDebug() << "RenderPreviewWidget::__endReached : unimplemented";
}

void        RenderPreviewWidget::__positionChanged()
{
    qDebug() << "RenderPreviewWidget::__positionChanged: Unimplemented";
}

void        RenderPreviewWidget::__videoPaused()
{
    qDebug() << "RenderPreviewWidget::__videoPaused: Unimplemented";
}

void        RenderPreviewWidget::__videoPlaying()
{
    qDebug() << "RenderPreviewWidget::__videoPlaying: Unimplemented";
}