Qt 4.8
qabstractvideosurface.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtMultimedia module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
43 
45 
94 {
95 }
96 
102  : QObject(dd, parent)
103 {
104 }
105 
111 {
112 }
113 
135 {
136  return supportedPixelFormats(format.handleType()).contains(format.pixelFormat());
137 }
138 
153 {
154  return isFormatSupported(format)
155  ? format
157 }
158 
175 {
176  return d_func()->format;
177 }
178 
199 {
201 
202  bool wasActive = d->active;
203 
204  d->active = true;
205  d->format = format;
206  d->error = NoError;
207 
208  emit surfaceFormatChanged(d->format);
209 
210  if (!wasActive)
211  emit activeChanged(true);
212 
213  return true;
214 }
215 
223 {
225 
226  if (d->active) {
227  d->format = QVideoSurfaceFormat();
228  d->active = false;
229 
230  emit activeChanged(false);
231  emit surfaceFormatChanged(d->format);
232  }
233 }
234 
242 {
243  return d_func()->active;
244 }
245 
289 {
290  return d_func()->error;
291 }
292 
298 {
300 
301  d->error = error;
302 }
303 
double d
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QVideoSurfaceFormat class specifies the stream format of a video presentation surface...
Error
This enum describes the errors that may be returned by the error() function.
void activeChanged(bool active)
Signals that the active state of a video surface has changed.
virtual void stop()
Stops a video surface presenting frames and releases any resources acquired in start().
~QAbstractVideoSurface()
Destroys a video surface.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
void setError(Error error)
Sets the value of error() to error.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define emit
Definition: qobjectdefs.h:76
void surfaceFormatChanged(const QVideoSurfaceFormat &format)
Signals that the configured format of a video surface has changed.
QVideoSurfaceFormat surfaceFormat() const
Returns the format of a video surface.
virtual QVideoSurfaceFormat nearestFormat(const QVideoSurfaceFormat &format) const
Returns a supported video surface format that is similar to format.
QAbstractVideoBuffer::HandleType handleType() const
Returns the type of handle the surface uses to present the frame data.
QAbstractVideoSurface(QObject *parent=0)
Constructs a video surface with the given parent.
virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const
Tests a video surface format to determine if a surface can accept it.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QAbstractVideoSurface class is a base class for video presentation surfaces.
Error error() const
Returns the last error that occurred.
virtual QList< QVideoFrame::PixelFormat > supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType=QAbstractVideoBuffer::NoHandle) const =0
Returns a list of pixel formats a video surface can present for a given handle type.
QVideoFrame::PixelFormat pixelFormat() const
Returns the pixel format of frames in a video stream.
bool isActive() const
Indicates whether a video surface has been started.
virtual bool start(const QVideoSurfaceFormat &format)
Starts a video surface presenting format frames.