Commit de2b7706 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added an OutputMedia

parent 4fbc0258
#include "OutputMedia.h"
OutputMedia::OutputMedia() : m_pixelBuffer( NULL )
{
char const *vlc_argv[] =
{
"-verbose",
"3",
"--codec", "invmem",
//"--snapshot-format", "jpg",
//"--plugin-path", VLC_TREE "/modules",
//"--ignore-config", /* Don't use VLC's config files */
};
int vlc_argc = sizeof( vlc_argv ) / sizeof( *vlc_argv );
m_instance = new LibVLCpp::Instance( vlc_argc, vlc_argv );
m_vlcMedia = new LibVLCpp::Media( m_instance, "fake://" );
m_dataCtx = new OutputMedia::DataCtx;
m_dataCtx->mutex = new QMutex;
m_dataCtx->outputMedia = this;
char width[64], height[64], lock[64], unlock[64], data[64];
sprintf( width, ":invmem-width=%i", VIDEOWIDTH );
sprintf( height, ":invmem-height=%i", VIDEOHEIGHT );
sprintf( lock, ":invmem-lock: %lld", (long long int)(intptr_t)&OutputMedia::lock );
sprintf( unlock, ":invmem-unlock: %lld", (long long int)(intptr_t)&OutputMedia::unlock );
sprintf( data, ":invmem-data: %lld", (long long int)(intptr_t)m_dataCtx );
m_vlcMedia->addOption( width );
m_vlcMedia->addOption( height );
m_vlcMedia->addOption( lock );
m_vlcMedia->addOption( unlock );
m_vlcMedia->addOption( data );
m_vlcMediaPlayer = new LibVLCpp::MediaPlayer(m_vlcMedia);
}
uchar* OutputMedia::lock( OutputMedia::DataCtx* dataCtx )
{
dataCtx->mutex->lock();
return dataCtx->outputMedia->m_pixelBuffer;
}
void OutputMedia::unlock( OutputMedia::DataCtx* dataCtx )
{
//FIXME: use class Image to avoid alloc/free...
delete dataCtx->outputMedia->m_pixelBuffer;
dataCtx->mutex->unlock();
}
void OutputMedia::setVmem( uchar* pixelBuffer )
{
m_dataCtx->mutex->lock();
m_pixelBuffer = pixelBuffer;
m_dataCtx->mutex->unlock();
}
/*****************************************************************************
* OutputMedia.h: Class for outpouting a media from a VMEM
*****************************************************************************
* 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.
*****************************************************************************/
#ifndef OUTPUTMEDIA_H
#define OUTPUTMEDIA_H
#include "VLCMedia.h"
#include "VLCInstance.h"
#include "VLCMediaPlayer.h"
class OutputMedia
{
public:
struct DataCtx
{
~DataCtx();
QMutex* mutex;
OutputMedia* outputMedia;
};
OutputMedia();
static uchar* lock( OutputMedia::DataCtx* dataCtx );
static void unlock( OutputMedia::DataCtx* dataCtx );
void setVmem( uchar* pixelBuffer );
private:
LibVLCpp::Media* m_vlcMedia;
LibVLCpp::MediaPlayer* m_vlcMediaPlayer;
LibVLCpp::Instance* m_instance;
OutputMedia::DataCtx* m_dataCtx;
uchar* m_pixelBuffer;
};
#endif // OUTPUTMEDIA_H
......@@ -27,8 +27,8 @@ SOURCES += src/main.cpp \
src/gui/Preferences.cpp \
src/gui/ListViewMediaItem.cpp \
src/gui/MediaListWidget.cpp \
src/Media.cpp
src/Media.cpp \
src/OutputMedia.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -48,16 +48,14 @@ HEADERS += src/gui/MainWindow.h \
src/gui/ListViewMediaItem.h \
src/Media.h \
src/Image.h \
src/gui/MediaListWidget.h
src/gui/MediaListWidget.h \
src/OutputMedia.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
src/gui/ui/Timeline.ui \
src/gui/ui/LibraryWidget.ui
FORMS +=
FORMS +=
RESOURCES +=
INCLUDEPATH += src/LibVLCpp
LIBS = -L/usr/local/lib \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment