55 |
55 |
56 A video surface presents a continuous stream of identically formatted frames, where the format |
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. |
57 of each frame is compatible with a stream format supplied when starting a presentation. |
58 |
58 |
59 A list of pixel formats a surface can present is given by the supportedPixelFormats() function, |
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 complete video format is supported. In |
60 and the isFormatSupported() function will test if a video surface format is supported. If a |
61 some cases when a format is not supported; isFormatSupported() may suggest a similar format. |
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 |
62 For example if a surface supports fixed set of resolutions it may suggest the smallest |
63 supported resolution that contains the proposed resolution. |
63 supported resolution that contains the proposed resolution. |
64 |
64 |
65 The start() function takes a supported format and enables a video surface. Once started a |
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 |
66 surface will begin displaying the frames it receives in the present() function. Surfaces may |
116 |
116 |
117 Types that are first in the list can be assumed to be faster to render. |
117 Types that are first in the list can be assumed to be faster to render. |
118 */ |
118 */ |
119 |
119 |
120 /*! |
120 /*! |
121 Tests a video \a format to determine if a surface can accept it. If the format isn't supported |
121 Tests a video surface \a format to determine if a surface can accept it. |
122 the surface may suggest a \a similar format that is supported. |
|
123 |
122 |
124 Returns true if the format is supported by the surface, and false otherwise. |
123 Returns true if the format is supported by the surface, and false otherwise. |
125 */ |
124 */ |
126 |
125 |
127 bool QAbstractVideoSurface::isFormatSupported( |
126 bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const |
128 const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const |
127 { |
129 { |
|
130 Q_UNUSED(similar); |
|
131 |
|
132 return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); |
128 return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); |
133 } |
129 } |
134 |
130 |
135 /*! |
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. |
|
139 |
|
140 If the format is already supported it will be returned unchanged, or if there is no similar |
|
141 supported format an invalid format will be returned. |
|
142 */ |
|
143 |
|
144 QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat(const QVideoSurfaceFormat &format) const |
|
145 { |
|
146 return isFormatSupported(format) |
|
147 ? format |
|
148 : QVideoSurfaceFormat(); |
|
149 } |
|
150 |
|
151 /*! |
136 \fn QAbstractVideoSurface::supportedFormatsChanged() |
152 \fn QAbstractVideoSurface::supportedFormatsChanged() |
137 |
153 |
138 Signals that the set of formats supported by a video surface has changed. |
154 Signals that the set of formats supported by a video surface has changed. |
139 |
155 |
140 \sa supportedPixelFormats(), isFormatSupported() |
156 \sa supportedPixelFormats(), isFormatSupported() |
160 /*! |
176 /*! |
161 Starts a video surface presenting \a format frames. |
177 Starts a video surface presenting \a format frames. |
162 |
178 |
163 Returns true if the surface was started, and false if an error occurred. |
179 Returns true if the surface was started, and false if an error occurred. |
164 |
180 |
165 \sa isStarted(), stop() |
181 \sa isActive(), stop() |
166 */ |
182 */ |
167 |
183 |
168 bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) |
184 bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) |
169 { |
185 { |
170 Q_D(QAbstractVideoSurface); |
186 Q_D(QAbstractVideoSurface); |
171 |
187 |
172 bool wasStarted = d->started; |
188 bool wasActive = d->active; |
173 |
189 |
174 d->started = true; |
190 d->active = true; |
175 d->format = format; |
191 d->format = format; |
176 d->error = NoError; |
192 d->error = NoError; |
177 |
193 |
178 emit surfaceFormatChanged(d->format); |
194 emit surfaceFormatChanged(d->format); |
179 |
195 |
180 if (!wasStarted) |
196 if (!wasActive) |
181 emit startedChanged(true); |
197 emit activeChanged(true); |
182 |
198 |
183 return true; |
199 return true; |
184 } |
200 } |
185 |
201 |
186 /*! |
202 /*! |
187 Stops a video surface presenting frames and releases any resources acquired in start(). |
203 Stops a video surface presenting frames and releases any resources acquired in start(). |
188 |
204 |
189 \sa isStarted(), start() |
205 \sa isActive(), start() |
190 */ |
206 */ |
191 |
207 |
192 void QAbstractVideoSurface::stop() |
208 void QAbstractVideoSurface::stop() |
193 { |
209 { |
194 Q_D(QAbstractVideoSurface); |
210 Q_D(QAbstractVideoSurface); |
195 |
211 |
196 if (d->started) { |
212 if (d->active) { |
197 d->format = QVideoSurfaceFormat(); |
213 d->format = QVideoSurfaceFormat(); |
198 d->started = false; |
214 d->active = false; |
199 |
215 |
200 emit startedChanged(false); |
216 emit activeChanged(false); |
201 emit surfaceFormatChanged(d->format); |
217 emit surfaceFormatChanged(d->format); |
202 } |
218 } |
203 } |
219 } |
204 |
220 |
205 /*! |
221 /*! |
206 Indicates whether a video surface has been started. |
222 Indicates whether a video surface has been started. |
207 |
223 |
208 Returns true if the surface has been started, and false otherwise. |
224 Returns true if the surface has been started, and false otherwise. |
209 */ |
225 */ |
210 |
226 |
211 bool QAbstractVideoSurface::isStarted() const |
227 bool QAbstractVideoSurface::isActive() const |
212 { |
228 { |
213 return d_func()->started; |
229 return d_func()->active; |
214 } |
230 } |
215 |
231 |
216 /*! |
232 /*! |
217 \fn QAbstractVideoSurface::startedChanged(bool started) |
233 \fn QAbstractVideoSurface::activeChanged(bool active) |
218 |
234 |
219 Signals that the \a started state of a video surface has changed. |
235 Signals that the \a active state of a video surface has changed. |
220 |
236 |
221 \sa isStarted(), start(), stop() |
237 \sa isActive(), start(), stop() |
222 */ |
238 */ |
223 |
239 |
224 /*! |
240 /*! |
225 \fn QAbstractVideoSurface::present(const QVideoFrame &frame) |
241 \fn QAbstractVideoSurface::present(const QVideoFrame &frame) |
226 |
242 |