From 16ce2a449fc3dba57e2aa1e1fa4a50a43fdcf9a8 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Thu, 6 Mar 2014 15:19:06 -0500 Subject: [PATCH] private declaration of VideoImpl --- Paint.cpp | 29 +++++++----------- Paint.h | 8 +++++ VideoImpl.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ VideoImpl.h | 54 ++++++++++++++++++++++++++++++++++ mapmap.pro | 4 ++- 5 files changed, 157 insertions(+), 19 deletions(-) create mode 100644 VideoImpl.cpp create mode 100644 VideoImpl.h diff --git a/Paint.cpp b/Paint.cpp index b1602d8..c2a89ee 100644 --- a/Paint.cpp +++ b/Paint.cpp @@ -19,7 +19,7 @@ */ #include "Paint.h" -#include +#include "VideoImpl.h" #include UidAllocator Paint::allocator; @@ -42,51 +42,44 @@ Paint::~Paint() allocator.free(_id); } + /* Implementation of the Video class */ Video::Video(const QString uri_, uid id=NULL_UID): Texture(id), - uri(uri_) + uri(uri_), + impl_(new VideoImpl) { + this->impl_->setUri(uri); } Video::~Video() { + delete impl_; } void Video::build() { + this->impl_->build(); } int Video::getWidth() const { - // TODO - return 0; + return this->impl_->getWidth(); } int Video::getHeight() const { - // TODO - return 0; + return this->impl_->getHeight(); } const uchar* Video::getBits() const { - // TODO - return 0; + return this->impl_->getBits(); } bool Video::hasVideoSupport() { - static bool did_print_gst_version = false; - if (! did_print_gst_version) - { - std::cout << "Using GStreamer version " << - GST_VERSION_MAJOR << "." << - GST_VERSION_MINOR << "." << - GST_VERSION_MICRO << std::endl; - did_print_gst_version = true; - } - return true; + return VideoImpl::hasVideoSupport(); } diff --git a/Paint.h b/Paint.h index 80b0b1f..998f67c 100644 --- a/Paint.h +++ b/Paint.h @@ -161,6 +161,8 @@ public: virtual const uchar* getBits() const { return image.bits(); } }; +class VideoImpl; // forware declaration + /** * Paint that is a Texture retrieved via a video file. */ @@ -187,6 +189,12 @@ public: * Checks whether or not video is supported on this platform. */ static bool hasVideoSupport(); +private: + /** + * Private implementation, so that GStreamer headers don't need + * to be included from every file in the project. + */ + VideoImpl * impl_; // PIMPL opaque pointer }; #endif /* PAINT_H_ */ diff --git a/VideoImpl.cpp b/VideoImpl.cpp new file mode 100644 index 0000000..f7df37e --- /dev/null +++ b/VideoImpl.cpp @@ -0,0 +1,81 @@ +/* + * VideoImpl.cpp + * + * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net + * + * 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 3 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, see . + */ +#include "VideoImpl.h" +#include + +// -------- private implementation of VideoImpl ------- + +bool VideoImpl::hasVideoSupport() +{ + static bool did_print_gst_version = false; + if (! did_print_gst_version) + { + std::cout << "Using GStreamer version " << + GST_VERSION_MAJOR << "." << + GST_VERSION_MINOR << "." << + GST_VERSION_MICRO << std::endl; + did_print_gst_version = true; + } + // TODO: actually check if we have it + return true; +} + +int VideoImpl::getWidth() const +{ + // TODO + std::cout << "TODO" << std::endl; + return 0; +} + +int VideoImpl::getHeight() const +{ + // TODO + std::cout << "TODO" << std::endl; + return 0; +} + +const uchar* VideoImpl::getBits() const +{ + // TODO + std::cout << "TODO" << std::endl; + return 0; +} + +void VideoImpl::build() +{ + std::cout << "TODO" << std::endl; +} + +VideoImpl::VideoImpl() +{ + std::cout << "TODO" << std::endl; +} + +VideoImpl::~VideoImpl() +{ + std::cout << "TODO" << std::endl; +} + +void VideoImpl::setUri(QString uri) +{ + this->uri_ = uri; + std::cout << "TODO" << std::endl; +} + diff --git a/VideoImpl.h b/VideoImpl.h new file mode 100644 index 0000000..350c6bf --- /dev/null +++ b/VideoImpl.h @@ -0,0 +1,54 @@ +/* + * Paint.h + * + * (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com + * (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net + * + * 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 3 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, see . + */ + +#ifndef VIDEO_IMPL_H_ +#define VIDEO_IMPL_H_ + +#include +#include +#include +#if __APPLE__ +#include +#else +#include +#endif +#include + +/** + * Private declaration of the video player. + * This is done this way so that GStreamer header don't need to be + * included in the whole project. (just in this file) + */ +class VideoImpl +{ +public: + VideoImpl(); + ~VideoImpl(); + void setUri(const QString uri); + static bool hasVideoSupport(); + void build(); + int getWidth() const; + int getHeight() const; + const uchar* getBits() const; +private: + QString uri_; +}; + +#endif /* ifndef */ diff --git a/mapmap.pro b/mapmap.pro index 11143cb..ea54b9c 100644 --- a/mapmap.pro +++ b/mapmap.pro @@ -22,7 +22,8 @@ HEADERS = \ SourceGLCanvas.h \ UidAllocator.h \ Util.h \ - unused.h + unused.h \ + VideoImpl.h SOURCES = \ # Controller.cpp \ @@ -42,6 +43,7 @@ SOURCES = \ SourceGLCanvas.cpp \ UidAllocator.cpp \ Util.cpp \ + VideoImpl.cpp \ main.cpp RESOURCES = mapmap.qrc