From ada827de41f0f75ed00cac3c295c3b75da0f3a36 Mon Sep 17 00:00:00 2001 From: Tats Date: Sat, 26 Apr 2014 00:07:25 +0100 Subject: [PATCH] Replaced images by videos + implemented hack on update() / runVideo() to quickly test gstreamer (works!) --- MainWindow.cpp | 5 ++++- Mapper.cpp | 1 + Paint.cpp | 4 ++++ Paint.h | 4 ++++ VideoImpl.cpp | 9 ++++++--- VideoImpl.h | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/MainWindow.cpp b/MainWindow.cpp index 021420a..48e8e6a 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1087,7 +1087,7 @@ void MainWindow::addMappingItem(uint mappingId) // Add mapper. // XXX hardcoded for textures std::tr1::shared_ptr textureMapping; - if (paintType == "image") + if (paintType == "image" || paintType == "video") { textureMapping = std::tr1::static_pointer_cast(mapping); Q_CHECK_PTR(textureMapping); @@ -1160,6 +1160,9 @@ void MainWindow::addMappingItem(uint mappingId) item->setSizeHint(QSize(item->sizeHint().width(), MainWindow::SHAPE_LIST_ITEM_HEIGHT)); mappingList->insertItem(0, item); mappingList->setCurrentItem(item); + + // Build mapping! + mapping->build(); } void MainWindow::clearWindow() diff --git a/Mapper.cpp b/Mapper.cpp index f94fb24..c79aeed 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -302,6 +302,7 @@ void TextureMapper::draw(QPainter* painter) Q_ASSERT( outputShape->nVertices() == outputShape->nVertices()); // Project source texture and sent it to destination. + texture->update(); glEnable (GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture->getTextureId()); diff --git a/Paint.cpp b/Paint.cpp index 0de90ae..1f4d4b8 100644 --- a/Paint.cpp +++ b/Paint.cpp @@ -75,6 +75,10 @@ int Video::getHeight() const return this->impl_->getHeight(); } +void Video::update() { + impl_->runVideo(); +} + const uchar* Video::getBits() const { return this->impl_->getBits(); diff --git a/Paint.h b/Paint.h index 86382bb..b2f3e6c 100644 --- a/Paint.h +++ b/Paint.h @@ -64,6 +64,9 @@ public: virtual void build() {} + /// This method should be called at each call of draw(). + virtual void update() {} + void setName(const QString& name) { _name = name; } QString getName() const { return _name; } uid getId() const { return _id; } @@ -178,6 +181,7 @@ public: return uri; } virtual void build(); + virtual void update(); virtual QString getType() const { return "video"; diff --git a/VideoImpl.cpp b/VideoImpl.cpp index be20882..d81f354 100644 --- a/VideoImpl.cpp +++ b/VideoImpl.cpp @@ -54,6 +54,7 @@ const uchar* VideoImpl::getBits() const void VideoImpl::build() { + qDebug() << "Building video impl" << endl; if (!loadMovie(_uri)) { qDebug() << "Cannot load movie " << _currentMovie << "." << endl; @@ -69,6 +70,8 @@ VideoImpl::~VideoImpl() bool VideoImpl::_videoPull() { + qDebug() << "video pull" << endl; + GstBuffer *buffer; // Retrieve the buffer. @@ -85,8 +88,8 @@ bool VideoImpl::_videoPull() GstCaps* caps = GST_BUFFER_CAPS(buffer); GstStructure *capsStruct = gst_caps_get_structure (caps, 0); - int width = 320; - int height = 240; + int width = 640; + int height = 480; int bpp = 24; int depth = 24; @@ -170,7 +173,7 @@ _videoConvert(NULL), _videoColorSpace(NULL), _audioSink(NULL), _videoSink(NULL), -_width(720), +_width(640), _height(480), _data(NULL), //_audioBufferAdapter(NULL), diff --git a/VideoImpl.h b/VideoImpl.h index 410f5c8..2ba23ec 100644 --- a/VideoImpl.h +++ b/VideoImpl.h @@ -93,7 +93,7 @@ public: {} bool isConnected() const { - return (audioIsConnected && videoIsConnected); + return (/*audioIsConnected && */videoIsConnected); } };