diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1203db418066e41e7a4b38d4deea1ba143b57d9c..955b0a5944045b677ed10c53506a087e7065a4ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,19 +45,17 @@ set( qtsflphone_LIB_SRCS call.cpp account.cpp contact.cpp - videorenderer.cpp - videodevice.cpp phonenumber.cpp - videocodec.cpp numbercategory.cpp + video/videodevice.cpp + video/videorenderer.cpp + video/videocodec.cpp #Models accountlistmodel.cpp callmodel.cpp historymodel.cpp abstractbookmarkmodel.cpp - videocodecmodel.cpp - videomodel.cpp credentialmodel.cpp audiocodecmodel.cpp instantmessagingmodel.cpp @@ -76,7 +74,9 @@ set( qtsflphone_LIB_SRCS lastusednumbermodel.cpp contactmodel.cpp itembackendmodel.cpp - videodevicemodel.cpp + video/videodevicemodel.cpp + video/videocodecmodel.cpp + video/videomodel.cpp #Data backends transitionalcontactbackend.cpp @@ -112,9 +112,6 @@ set( qtsflphone_LIB_HDRS contact.h abstractitembackend.h abstractbookmarkmodel.h - videocodecmodel.h - videomodel.h - videorenderer.h credentialmodel.h audiocodecmodel.h instantmessagingmodel.h @@ -125,7 +122,6 @@ set( qtsflphone_LIB_HDRS phonedirectorymodel.h historytimecategorymodel.h numbercategorymodel.h - videocodec.h keyexchangemodel.h tlsmethodmodel.h numbercompletionmodel.h @@ -138,8 +134,12 @@ set( qtsflphone_LIB_HDRS transitionalcontactbackend.h abstractitembackend.h itembackendmodel.h - videodevice.h - videodevicemodel.h + video/videodevice.h + video/videodevicemodel.h + video/videocodec.h + video/videocodecmodel.h + video/videomodel.h + video/videorenderer.h #commonbackendmanagerinterface.h ) diff --git a/src/account.cpp b/src/account.cpp index 14ad4f36cdcbf82f5355317abaed064e83ff85f4..9dbcc5b6093138e3929bedcc2a50845ab1e039dc 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -36,7 +36,7 @@ #include "accountlistmodel.h" #include "credentialmodel.h" #include "audiocodecmodel.h" -#include "videocodecmodel.h" +#include <video/videocodecmodel.h> #include "ringtonemodel.h" #include "phonenumber.h" #include "phonedirectorymodel.h" diff --git a/src/account.h b/src/account.h index e9a9de3a463f0140eb4181461f432ecd02697ae3..dae30a12023a19eb9ea58541dc4986866e9d3552 100644 --- a/src/account.h +++ b/src/account.h @@ -26,7 +26,7 @@ class QString; //SFLPhone -#include "videocodecmodel.h" +#include "video/videocodecmodel.h" #include "keyexchangemodel.h" #include "tlsmethodmodel.h" #include "sflphone_const.h" diff --git a/src/call.cpp b/src/call.cpp index eb86407f7868cf1dd0723ce46745bba807809f7e..a0141fa46ce5e55f065a2bc88875b2f2411b7b9f 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -35,7 +35,7 @@ #include "contact.h" #include "account.h" #include "accountlistmodel.h" -#include "videomodel.h" +#include "video/videomodel.h" #include "historymodel.h" #include "instantmessagingmodel.h" #include "useractionmodel.h" @@ -43,7 +43,7 @@ #include "numbercategory.h" #include "phonedirectorymodel.h" #include "phonenumber.h" -#include "videorenderer.h" +#include "video/videorenderer.h" #include "tlsmethodmodel.h" #include "audiosettingsmodel.h" #include "contactmodel.h" diff --git a/src/video/videochannelmodel.cpp b/src/video/videochannelmodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/video/videochannelmodel.h b/src/video/videochannelmodel.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/videocodec.cpp b/src/video/videocodec.cpp similarity index 100% rename from src/videocodec.cpp rename to src/video/videocodec.cpp diff --git a/src/videocodec.h b/src/video/videocodec.h similarity index 100% rename from src/videocodec.h rename to src/video/videocodec.h diff --git a/src/videocodecmodel.cpp b/src/video/videocodecmodel.cpp similarity index 98% rename from src/videocodecmodel.cpp rename to src/video/videocodecmodel.cpp index f4c0a5e62b8f88b2c1658581ce1d3618c46b7ce7..75db97a5a0ee05672e7ef895e902a9ebe2667fa1 100644 --- a/src/videocodecmodel.cpp +++ b/src/video/videocodecmodel.cpp @@ -16,9 +16,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #include "videocodecmodel.h" -#include "call.h" -#include "account.h" -#include "videocodec.h" +#include <call.h> +#include <account.h> +#include <video/videocodec.h> #include "dbus/videomanager.h" #include <QtCore/QCoreApplication> diff --git a/src/videocodecmodel.h b/src/video/videocodecmodel.h similarity index 99% rename from src/videocodecmodel.h rename to src/video/videocodecmodel.h index f9bb1e072667a4574bcb81cb975135779a3c8122..fd7346c75e36b0b9d6d19d470832255176275e4c 100644 --- a/src/videocodecmodel.h +++ b/src/video/videocodecmodel.h @@ -18,7 +18,7 @@ #ifndef VIDEOCODECMODEL_H #define VIDEOCODECMODEL_H -#include "typedefs.h" +#include "../typedefs.h" #include <QtCore/QAbstractListModel> //Qt diff --git a/src/videodevice.cpp b/src/video/videodevice.cpp similarity index 98% rename from src/videodevice.cpp rename to src/video/videodevice.cpp index 6ef8faf6c134a3afbbb65b5de9092b44c646e677..c3bd25567717117a78cb8ab29dbd0d8abc07e8c2 100644 --- a/src/videodevice.cpp +++ b/src/video/videodevice.cpp @@ -17,7 +17,7 @@ ***************************************************************************/ #include "videodevice.h" #include "dbus/videomanager.h" - +#include "videodevicemodel.h" Resolution::Resolution(uint _width, uint _height):QSize(_width,_height), m_pCurrentRate(nullptr),m_pChannel(nullptr) @@ -122,7 +122,7 @@ const QString VideoDevice::name() const ///Is this device the default one bool VideoDevice::isActive() const { - return QString(DBus::VideoManager::instance().getActiveDevice()) == m_DeviceId; + return VideoDeviceModel::instance()->activeDevice() == this; } Resolution* VideoChannel::activeResolution() diff --git a/src/videodevice.h b/src/video/videodevice.h similarity index 99% rename from src/videodevice.h rename to src/video/videodevice.h index 34e8a8d423d95ca4a9b983680d9a71dee7a97058..9ea86c236cff72e624e00da7f8b5996eb030972b 100644 --- a/src/videodevice.h +++ b/src/video/videodevice.h @@ -18,7 +18,7 @@ #ifndef VIDEO_DEVICE_H #define VIDEO_DEVICE_H -#include "typedefs.h" +#include "../typedefs.h" //Qt #include <QStringList> diff --git a/src/videodevicemodel.cpp b/src/video/videodevicemodel.cpp similarity index 94% rename from src/videodevicemodel.cpp rename to src/video/videodevicemodel.cpp index 07bd35ea29d721b641248adffcdf64eb56bf3a4e..6045abdcf4d453aaf4ae006d7602ce0b7eb96590 100644 --- a/src/videodevicemodel.cpp +++ b/src/video/videodevicemodel.cpp @@ -68,7 +68,7 @@ bool VideoDeviceModel::setData(const QModelIndex& idx, const QVariant &value, in ///Constructor VideoDeviceModel::VideoDeviceModel() : QAbstractListModel(QCoreApplication::instance()), m_pResolutionModel(nullptr),m_pChannelModel(nullptr),m_pRateModel(nullptr), -m_pDummyDevice(nullptr) +m_pDummyDevice(nullptr),m_pActiveDevice(nullptr) { connect(this ,SIGNAL(changed()) , channelModel () , SLOT(reload())); connect(channelModel() ,SIGNAL(changed()) , resolutionModel() , SLOT(reload())); @@ -96,6 +96,7 @@ void VideoDeviceModel::setActive(const QModelIndex& idx) if (idx.isValid()) { VideoManagerInterface& interface = DBus::VideoManager::instance(); interface.setActiveDevice(m_lDevices[idx.row()]->id()); + m_pActiveDevice = m_lDevices[idx.row()]; emit changed(); emit currentIndexChanged(idx.row()); } @@ -113,6 +114,7 @@ void VideoDeviceModel::setActive(const VideoDevice* device) VideoManagerInterface& interface = DBus::VideoManager::instance(); interface.setActiveDevice(device?device->id():VideoDevice::NONE); + m_pActiveDevice = const_cast<VideoDevice*>(device); emit changed(); const int idx = m_lDevices.indexOf((VideoDevice*)device); emit currentIndexChanged(idx); @@ -152,22 +154,25 @@ void VideoDeviceModel::reload() VideoDevice* VideoDeviceModel::activeDevice() const { - VideoManagerInterface& interface = DBus::VideoManager::instance(); - const QString deId = interface.getActiveDevice(); - if (!m_lDevices.size()) - const_cast<VideoDeviceModel*>(this)->reload(); - VideoDevice* dev = m_hDevices[deId]; - - //Handling null everywhere is too long, better create a dummy device and - //log the event - if (!dev) { - if (!deId.isEmpty()) - qWarning() << "Requested unknown device" << deId; - if (!m_pDummyDevice) - const_cast<VideoDeviceModel*>(this)->m_pDummyDevice = new VideoDevice("None"); - return m_pDummyDevice; + if (!m_pActiveDevice) { + VideoManagerInterface& interface = DBus::VideoManager::instance(); + const QString deId = interface.getActiveDevice(); + if (!m_lDevices.size()) + const_cast<VideoDeviceModel*>(this)->reload(); + VideoDevice* dev = m_hDevices[deId]; + + //Handling null everywhere is too long, better create a dummy device and + //log the event + if (!dev) { + if (!deId.isEmpty()) + qWarning() << "Requested unknown device" << deId; + if (!m_pDummyDevice) + const_cast<VideoDeviceModel*>(this)->m_pDummyDevice = new VideoDevice("None"); + return m_pDummyDevice; + } + const_cast<VideoDeviceModel*>(this)->m_pActiveDevice = dev; } - return dev; + return m_pActiveDevice; } diff --git a/src/videodevicemodel.h b/src/video/videodevicemodel.h similarity index 99% rename from src/videodevicemodel.h rename to src/video/videodevicemodel.h index cbd0359c4817c76d83ec24b4987ee359b44d7682..33946a57b658ec95642a811ee90f8d57b09bc5ef 100644 --- a/src/videodevicemodel.h +++ b/src/video/videodevicemodel.h @@ -18,7 +18,7 @@ #ifndef VIDEODEVICEMODEL_H #define VIDEODEVICEMODEL_H -#include "typedefs.h" +#include "../typedefs.h" #include <QtCore/QAbstractListModel> #include <QtCore/QUrl> #include <QtCore/QPoint> @@ -229,6 +229,7 @@ private: VideoDeviceChannelModel* m_pChannelModel ; VideoDeviceRateModel* m_pRateModel ; VideoDevice* m_pDummyDevice ; + VideoDevice* m_pActiveDevice ; public Q_SLOTS: void setActive(const QModelIndex& idx); diff --git a/src/videomodel.cpp b/src/video/videomodel.cpp similarity index 87% rename from src/videomodel.cpp rename to src/video/videomodel.cpp index f33915b3bd7d552f2ee64eb0e94496ab9b51be1f..c928e48428a36338a9d42fd45451822cdfced651 100644 --- a/src/videomodel.cpp +++ b/src/video/videomodel.cpp @@ -32,8 +32,7 @@ VideoModel* VideoModel::m_spInstance = nullptr; ///Constructor -VideoModel::VideoModel():QThread(),m_BufferSize(0),m_ShmKey(0),m_SemKey(0),m_PreviewState(false),m_SSMutex(new QMutex()), -m_pActiveDevice(nullptr) +VideoModel::VideoModel():QThread(),m_BufferSize(0),m_ShmKey(0),m_SemKey(0),m_PreviewState(false),m_SSMutex(new QMutex()) { VideoManagerInterface& interface = DBus::VideoManager::instance(); connect( &interface , SIGNAL(deviceEvent()) , this, SLOT(deviceEvent()) ); @@ -111,24 +110,6 @@ void VideoModel::deviceEvent() } -VideoDevice* VideoModel::activeDevice() const -{ - if (!m_pActiveDevice) { - VideoManagerInterface& interface = DBus::VideoManager::instance(); - const QString activeDeviceId = interface.getActiveDevice(); - foreach(VideoDevice* dev, m_hDevices) { - if (dev->id() == activeDeviceId) { - const_cast<VideoModel*>(this)->m_pActiveDevice = dev; - break; - } - } - } - if (!m_pActiveDevice) { - qWarning() << "No active devices"; - } - return m_pActiveDevice; -} - ///A video is not being rendered void VideoModel::startedDecoding(const QString& id, const QString& shmPath, int width, int height) { @@ -138,7 +119,7 @@ void VideoModel::startedDecoding(const QString& id, const QString& shmPath, int if (VideoDeviceModel::instance()->activeDevice() && VideoDeviceModel::instance()->activeDevice()->activeChannel()->activeResolution()->width() == width) { //FIXME flawed logic - res = VideoModel::activeDevice()->activeChannel()->activeResolution(); + res = VideoDeviceModel::instance()->activeDevice()->activeChannel()->activeResolution(); } else { res = new Resolution(width,height); //FIXME leak @@ -197,21 +178,6 @@ void VideoModel::stoppedDecoding(const QString& id, const QString& shmPath) delete r; } -// void VideoModel::run() -// { -// exec(); -// } - - -// void VideoModel::setActiveDevice(const VideoDevice* device) -// { -// VideoManagerInterface& interface = DBus::VideoManager::instance(); -// if (isPreviewing()) { -// switchDevice(device); -// } -// interface.setActiveDevice(device->id()); -// } - void VideoModel::switchDevice(const VideoDevice* device) const { VideoManagerInterface& interface = DBus::VideoManager::instance(); diff --git a/src/videomodel.h b/src/video/videomodel.h similarity index 95% rename from src/videomodel.h rename to src/video/videomodel.h index 69997a69c3650eacc0411182d1e3aebdb5f87818..e70f8e21f6bcb194c2915e1cc97d4c6e05ad6b77 100644 --- a/src/videomodel.h +++ b/src/video/videomodel.h @@ -18,7 +18,7 @@ #ifndef VIDEO_MODEL_H #define VIDEO_MODEL_H //Base -#include "typedefs.h" +#include "../typedefs.h" #include <QtCore/QThread> //Qt @@ -46,13 +46,13 @@ public: VideoRenderer* getRenderer(const Call* call) const; VideoRenderer* previewRenderer(); QList<VideoDevice*> devices(); - VideoDevice* activeDevice() const; +// VideoDevice* activeDevice() const; VideoDevice* device(const QString &id); QMutex* startStopMutex() const; //Setters void setBufferSize(uint size); - void setActiveDevice(const VideoDevice* device); +// void setActiveDevice(const VideoDevice* device); void switchDevice(const VideoDevice* device) const; protected: @@ -74,7 +74,6 @@ private: QMutex* m_SSMutex ; QHash<QString,VideoRenderer*> m_lRenderers; QHash<QString,VideoDevice*> m_hDevices ; - VideoDevice* m_pActiveDevice; public Q_SLOTS: void stopPreview (); diff --git a/src/video/videoratemodel.cpp b/src/video/videoratemodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/video/videoratemodel.h b/src/video/videoratemodel.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/videorenderer.cpp b/src/video/videorenderer.cpp similarity index 100% rename from src/videorenderer.cpp rename to src/video/videorenderer.cpp diff --git a/src/videorenderer.h b/src/video/videorenderer.h similarity index 99% rename from src/videorenderer.h rename to src/video/videorenderer.h index d2abb62e1eb5479360d1ce2a7e7f3db98f24133f..cd949f2b50e0ff85c9926bbb4908370923986f74 100644 --- a/src/videorenderer.h +++ b/src/video/videorenderer.h @@ -21,7 +21,7 @@ //Base #include <QtCore/QObject> #include <QtCore/QTime> -#include "typedefs.h" +#include "../typedefs.h" #include <time.h> //Qt diff --git a/src/video/videoresolutionmodel.cpp b/src/video/videoresolutionmodel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/video/videoresolutionmodel.h b/src/video/videoresolutionmodel.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391