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

Enhanced cpp binding, still buggy...

It will take some time to correct it -_-
parent 55693dc3
......@@ -4,26 +4,10 @@
using namespace LibVLCpp;
//void MediaPlayer::eventPlayingCallback(const EventManager::Event*, void* data)
//{
// //getting the event manager back...
// MediaPlayer* mp = static_cast<MediaPlayer*>(data);
// //...and removing this dirty callback.
// //mp->_evMgr->removeEvent(EventManager::MediaPlayingEvent, &eventPlayingCallback, reinterpret_cast<void*>(data));
// mp->_isReady = true;
// //stopping the playback must be the last thing we do since it wont continue after this...
// //mp->stop();
//}
MediaPlayer::MediaPlayer(Media* media, bool playStop /* = true*/) : /*_evMgr(NULL),`*/ _isReady(false)
{
this->_internalPtr = libvlc_media_player_new_from_media(media->getInternalPtr(), this->_ex);
this->_ex.checkThrow();
// if ( playStop == true )
// {
// this->_evMgr = new EventManager(this->getInternalPtr());
// this->_evMgr->addEvent(EventManager::MediaPlayerPositionChangedEvent, &eventPlayingCallback, static_cast<void*>(this));
// }
}
void MediaPlayer::play()
......@@ -53,6 +37,7 @@ qint64 MediaPlayer::getTime()
void MediaPlayer::setTime(qint64 time)
{
// qDebug() << "Setting media time to " << time;
libvlc_media_player_set_time(this->_internalPtr, time, this->_ex);
this->_ex.checkThrow();
}
......@@ -61,12 +46,13 @@ qint64 MediaPlayer::getLength()
{
qint64 length = libvlc_media_player_get_length(this->_internalPtr, this->_ex);
this->_ex.checkThrow();
// qDebug() << "Media length: " << length;
return length;
}
void MediaPlayer::takeSnapshot(uchar* output, unsigned int width, unsigned int heigth)
void MediaPlayer::takeSnapshot(char* outputFile, unsigned int width, unsigned int heigth)
{
libvlc_video_take_snapshot(*this, reinterpret_cast<char*>(output), width, heigth, this->_ex);
libvlc_video_take_snapshot(*this, outputFile, width, heigth, this->_ex);
this->_ex.checkThrow();
}
......
......@@ -22,7 +22,7 @@ namespace LibVLCpp
qint64 getTime();
void setTime(qint64 time);
qint64 getLength();
void takeSnapshot(uchar* output, unsigned int width, unsigned int heigth);
void takeSnapshot(char* outputFile, unsigned int width, unsigned int heigth);
int isPlaying();
int isSeekable();
//FIXME: private
......
......@@ -3,12 +3,18 @@
Media::Media(const QString& mrl) : _mrl(mrl), _snapshot(NULL)
{
this->_instance = new LibVLCpp::Instance(0, NULL);
// qDebug() << "Built instance";
this->_vlcMedia = new LibVLCpp::Media(this->_instance, this->_mrl);
// qDebug() << "Built Media";
char const *vlc_argv[] =
{
"-verbose",
"3",
//"--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);
this->_instance = new LibVLCpp::Instance(vlc_argc, vlc_argv);
// qDebug() << "Built mediaPlayer";
this->_vlcMedia = new LibVLCpp::Media(this->_instance, this->_mrl);
this->_vlcMedia->outputInVmem();
this->_vlcMedia->setLockCallback(Media::lock);
......@@ -54,19 +60,24 @@ void Media::lock(LibVLCpp::Media::DataCtx* ctx, void **renderPtr)
void Media::unlock(LibVLCpp::Media::DataCtx* ctx)
{
// QImage(ctx->media->getPixelBuffer(), VIDEOWIDTH, VIDEOHEIGHT, QImage::Format_RGB32).save("/home/chouquette/Desktop/testRender.png");
qDebug() << "frame just rendered";
// qDebug() << "frame just rendered";
ctx->mutex->unlock();
}
QImage* Media::takeSnapshot(unsigned int width, unsigned int height)
{
//FIXME
//this isn't working, but it seems like a vlc problem, since lastest release of vlc segfault when a screenshot is taken... -_-
return NULL;
if ( this->_snapshot == NULL )
{
this->_snapshot = new QImage(*this->_image);
this->_vlcMediaPlayer->setTime(this->_vlcMediaPlayer->getLength() / 2);
this->_vlcMediaPlayer->setTime(0);
qDebug() << "trying to take a snapshot";
this->_vlcMediaPlayer->takeSnapshot("/tmp/vlmcscreenshot.tmp.gif", width, height);
qDebug() << "done snapshoting";
this->_snapshot = new QImage("/tmp/vlmcscreenshot.tmp.gif");
qDebug() << "written to a QImage";
}
return this->_snapshot;
}
......@@ -80,3 +91,9 @@ int Media::isSeekable()
{
return this->_vlcMediaPlayer->isSeekable();
}
qint64 Media::getLength()
{
return this->_vlcMediaPlayer->getLength();
}
......@@ -24,6 +24,7 @@ public:
//FIXME into bool
int isPlaying();
int isSeekable();
qint64 getLength();
//FIXME
......
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