Index: videowidget.cpp =================================================================== --- videowidget.cpp (revision 771149) +++ videowidget.cpp (working copy) @@ -1,5 +1,5 @@ /* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz + Copyright (C) 2005-2008 Matthias Kretz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -18,16 +18,20 @@ */ #include "videowidget.h" +#include "phonondefs_p.h" #include "videowidget_p.h" #include "videowidgetinterface.h" #include "factory.h" -#include "phonondefs_p.h" #include "phononnamespace_p.h" #include -#define PHONON_INTERFACENAME VideoWidgetInterface +#define IFACES42 VideoWidgetInterface +#define IFACES41 IFACES42 +#define IFACES40 IFACES41, VideoWidgetInterface40 +#define PHONON_INTERFACENAME IFACES40 + namespace Phonon { @@ -89,6 +93,15 @@ PHONON_INTERFACE_GETTER(qreal, saturation, d->saturation) PHONON_INTERFACE_SETTER(setSaturation, saturation, qreal) +void VideoWidget::requestSnapshot() const +{ + K_D(const VideoWidget); + ConstIface iface(d); + if (iface) { + iface->requestSnapshot(); + } +} + void VideoWidget::setFullScreen(bool newFullScreen) { pDebug() << Q_FUNC_INFO << newFullScreen; @@ -139,6 +152,7 @@ pDebug() << "calling setAspectRatio on the backend " << aspectRatio; pINTERFACE_CALL(setAspectRatio(aspectRatio)); pINTERFACE_CALL(setScaleMode(scaleMode)); + QObject::connect(m_backendObject, SIGNAL(snapshotReady(const QImage &)), q, SIGNAL(snapshotReady(const QImage &))); QWidget *w = pINTERFACE_CALL(widget()); if (w) { Index: videowidget.h =================================================================== --- videowidget.h (revision 771149) +++ videowidget.h (working copy) @@ -1,5 +1,5 @@ /* This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz + Copyright (C) 2005-2008 Matthias Kretz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -190,6 +190,30 @@ void setHue(qreal value); void setSaturation(qreal value); + /** + * Requests a QImage of the latest video frame in the original frame + * dimensions (i.e. not scaled like the video widget and without + * aspect ratio correction). + * + * The image is returned asynchronously via snapshotReady. + * + * \since KDE 4.1 + */ + void requestSnapshot() const; + + Q_SIGNALS: + /** + * Passes a QImage of the latest video frame in the original frame + * dimensions (i.e. not scaled like the video widget and without + * aspect ratio correction) + * + * This signal only gets emitted once per requestSnapshot call and + * only if the backend implements the Phonon 4.2 interface. + * + * \since KDE 4.1 + */ + void snapshotReady(const QImage &snapshot); + protected: /** * \internal Index: videowidgetinterface.h =================================================================== --- videowidgetinterface.h (revision 771149) +++ videowidgetinterface.h (working copy) @@ -1,5 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2007 Trolltech ASA. + Copyright (C) 2008 Matthias Kretz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -27,10 +28,10 @@ namespace Phonon { -class VideoWidgetInterface +class VideoWidgetInterface40 { public: - virtual ~VideoWidgetInterface() {} + virtual ~VideoWidgetInterface40() {} virtual Phonon::VideoWidget::AspectRatio aspectRatio() const = 0; virtual void setAspectRatio(Phonon::VideoWidget::AspectRatio) = 0; @@ -48,10 +49,20 @@ //X virtual int overlayCapabilities() const = 0; //X virtual bool createOverlay(QWidget *widget, int type) = 0; }; + +class VideoWidgetInterface : public VideoWidgetInterface40 +{ + public: + virtual void requestSnapshot() const = 0; +}; } -Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface, "VideoWidgetInterface3.phonon.kde.org") +// added in libphonon.so.4.0 +Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface40, "VideoWidgetInterface3.phonon.kde.org") +// added in libphonon.so.4.2 +Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface, "VideoWidgetInterface4.phonon.kde.org") + QT_END_NAMESPACE QT_END_HEADER