summaryrefslogtreecommitdiffstats
path: root/src/plugins/directshow/helpers/directshowmediatype.h
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2016-11-10 17:55:15 +0100
committerYoann Lopes <yoann.lopes@qt.io>2017-01-27 13:27:15 +0000
commit57a4cabd78aba3d6c1dd4802b0e3baf5ed3e4758 (patch)
treefc329fb425258fee98c727691c3310ec706beb29 /src/plugins/directshow/helpers/directshowmediatype.h
parent47c672cdd67853658a2f86688ec72eb9b4d8c1ca (diff)
DirectShow: Sanitize DirectShowMediaType
The DirectShowMediaType is now a thin data wrapper around AM_MEDIA_TYPE and will for the most look and work the same way, with the exception that it cleans up after itself. All utility functions are now static, except clear() which, for convenience, is also provided as a non-static member function. In addition to the changes mentioned above, duplicated methods were removed, conversion for ARGB32 was added, and an attempt to make the usage of AM_MEDIA_TYPE and DirectShowMediaType was made more consistent. Change-Id: Iad32fb8eeabd9d4183e9bd10426cac3963e5d99a Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
Diffstat (limited to 'src/plugins/directshow/helpers/directshowmediatype.h')
-rw-r--r--src/plugins/directshow/helpers/directshowmediatype.h45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/plugins/directshow/helpers/directshowmediatype.h b/src/plugins/directshow/helpers/directshowmediatype.h
index b2b074ccc..b9aa989f0 100644
--- a/src/plugins/directshow/helpers/directshowmediatype.h
+++ b/src/plugins/directshow/helpers/directshowmediatype.h
@@ -45,39 +45,48 @@
#include <qvideosurfaceformat.h>
#include <dvdmedia.h>
+#include <QtCore/qglobal.h>
QT_USE_NAMESPACE
-class DirectShowMediaType : public AM_MEDIA_TYPE
+class DirectShowMediaType
{
public:
- DirectShowMediaType() { init(this); }
- DirectShowMediaType(const AM_MEDIA_TYPE &type) { copy(this, type); }
- DirectShowMediaType(const DirectShowMediaType &other) { copy(this, other); }
- DirectShowMediaType &operator =(const AM_MEDIA_TYPE &type) {
- freeData(this); copy(this, type); return *this; }
- DirectShowMediaType &operator =(const DirectShowMediaType &other) {
- freeData(this); copy(this, other); return *this; }
- ~DirectShowMediaType() { freeData(this); }
+ DirectShowMediaType();
+ DirectShowMediaType(const DirectShowMediaType &other);
+ DirectShowMediaType(DirectShowMediaType &&other);
+ explicit DirectShowMediaType(const AM_MEDIA_TYPE &type);
+ explicit DirectShowMediaType(AM_MEDIA_TYPE &&type);
+ ~DirectShowMediaType() { clear(mediaType); }
- void clear() { freeData(this); init(this); }
+ DirectShowMediaType &operator =(const DirectShowMediaType &other);
+ DirectShowMediaType &operator =(DirectShowMediaType &&other);
- bool isPartiallySpecified() const;
- bool isCompatibleWith(const DirectShowMediaType *type) const;
+ void clear() { clear(mediaType); }
+
+ inline AM_MEDIA_TYPE *operator &() Q_DECL_NOTHROW { return &mediaType; }
+ inline AM_MEDIA_TYPE *operator ->() Q_DECL_NOTHROW { return &mediaType; }
+
+ inline const AM_MEDIA_TYPE *const operator &() const Q_DECL_NOTHROW { return &mediaType; }
+ inline const AM_MEDIA_TYPE *const operator ->() const Q_DECL_NOTHROW { return &mediaType; }
static void init(AM_MEDIA_TYPE *type);
- static void copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE &source);
- static void freeData(AM_MEDIA_TYPE *type);
+ static void copy(AM_MEDIA_TYPE *target, const AM_MEDIA_TYPE *source);
+ static void move(AM_MEDIA_TYPE *target, AM_MEDIA_TYPE **source);
+ static void move(AM_MEDIA_TYPE *target, AM_MEDIA_TYPE &source);
+ static void clear(AM_MEDIA_TYPE &type);
static void deleteType(AM_MEDIA_TYPE *type);
-
+ static bool isPartiallySpecified(const AM_MEDIA_TYPE *mediaType);
+ static bool isCompatible(const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b);
static GUID convertPixelFormat(QVideoFrame::PixelFormat format);
- static QVideoSurfaceFormat formatFromType(const AM_MEDIA_TYPE &type);
- static QVideoFrame::PixelFormat pixelFormatFromType(const AM_MEDIA_TYPE &type);
+ static QVideoSurfaceFormat videoFormatFromType(const AM_MEDIA_TYPE *type);
+ static QVideoFrame::PixelFormat pixelFormatFromType(const AM_MEDIA_TYPE *type);
static int bytesPerLine(const QVideoSurfaceFormat &format);
+ static QVideoSurfaceFormat::Direction scanLineDirection(QVideoFrame::PixelFormat pixelFormat, const BITMAPINFOHEADER &bmiHeader);
private:
- static QVideoSurfaceFormat::Direction scanLineDirection(QVideoFrame::PixelFormat pixelFormat, const BITMAPINFOHEADER &bmiHeader);
+ AM_MEDIA_TYPE mediaType;
};
Q_DECLARE_TYPEINFO(DirectShowMediaType, Q_MOVABLE_TYPE);