source: trunk/src/multimedia/video/qabstractvideosurface.cpp@ 561

Last change on this file since 561 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 9.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtMultimedia module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qabstractvideosurface_p.h"
43
44QT_BEGIN_NAMESPACE
45
46/*!
47 \class QAbstractVideoSurface
48 \brief The QAbstractVideoSurface class is a base class for video presentation surfaces.
49 \preliminary
50 \since 4.6
51
52 The QAbstractVideoSurface class defines the standard interface that video producers use to
53 inter-operate with video presentation surfaces. It is not supposed to be instantiated directly.
54 Instead, you should subclass it to create new video surfaces.
55
56 A video surface presents a continuous stream of identically formatted frames, where the format
57 of each frame is compatible with a stream format supplied when starting a presentation.
58
59 A list of pixel formats a surface can present is given by the supportedPixelFormats() function,
60 and the isFormatSupported() function will test if a video surface format is supported. If a
61 format is not supported the nearestFormat() function may be able to suggest a similar format.
62 For example if a surface supports fixed set of resolutions it may suggest the smallest
63 supported resolution that contains the proposed resolution.
64
65 The start() function takes a supported format and enables a video surface. Once started a
66 surface will begin displaying the frames it receives in the present() function. Surfaces may
67 hold a reference to the buffer of a presented video frame until a new frame is presented or
68 streaming is stopped. The stop() function will disable a surface and a release any video
69 buffers it holds references to.
70*/
71
72/*!
73 \enum QAbstractVideoSurface::Error
74 This enum describes the errors that may be returned by the error() function.
75
76 \value NoError No error occurred.
77 \value UnsupportedFormatError A video format was not supported.
78 \value IncorrectFormatError A video frame was not compatible with the format of the surface.
79 \value StoppedError The surface has not been started.
80 \value ResourceError The surface could not allocate some resource.
81*/
82
83/*!
84 Constructs a video surface with the given \a parent.
85*/
86
87QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent)
88 : QObject(*new QAbstractVideoSurfacePrivate, parent)
89{
90}
91
92/*!
93 \internal
94*/
95
96QAbstractVideoSurface::QAbstractVideoSurface(QAbstractVideoSurfacePrivate &dd, QObject *parent)
97 : QObject(dd, parent)
98{
99}
100
101/*!
102 Destroys a video surface.
103*/
104
105QAbstractVideoSurface::~QAbstractVideoSurface()
106{
107}
108
109/*!
110 \fn QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const
111
112 Returns a list of pixel formats a video surface can present for a given handle \a type.
113
114 The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer
115 that can be mapped in read-only mode.
116
117 Types that are first in the list can be assumed to be faster to render.
118*/
119
120/*!
121 Tests a video surface \a format to determine if a surface can accept it.
122
123 Returns true if the format is supported by the surface, and false otherwise.
124*/
125
126bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const
127{
128 return supportedPixelFormats(format.handleType()).contains(format.pixelFormat());
129}
130
131/*!
132 Returns a supported video surface format that is similar to \a format.
133
134 A similar surface format is one that has the same \l {QVideoSurfaceFormat::pixelFormat()}{pixel
135 format} and \l {QVideoSurfaceFormat::handleType()}{handle type} but differs in some of the other
136 properties. For example if there are restrictions on the \l {QVideoSurfaceFormat::frameSize()}
137 {frame sizes} a video surface can accept it may suggest a format with a larger frame size and
138 a \l {QVideoSurfaceFormat::viewport()}{viewport} the size of the original frame size.