summaryrefslogtreecommitdiff
path: root/examples/multimedia/video/doc/src/qmlvideo.qdoc
blob: 0f4de6ce5c76a5a6567210600df48da0774b947e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\example multimedia/video/qmlvideo
\title QML Video Example
\ingroup multimedia_examples

\brief The QML Video Example demonstrates the various manipulations (move;
resize; rotate; change aspect ratio) which can be applied to QML \l{VideoOutput}
items.

\section1 Overview

This example demonstrates the various manipulations (move; resize; rotate;
change aspect ratio) which can be applied to QML \l{VideoOutput} items.

It also shows how native code can be combined with QML to implement more
advanced functionality - in this case, C++ code is used to calculate the QML
frame rate.  This value is rendered in QML in a semi-transparent item
overlaid on the video content.

The following image shows the application executing the video-overlay scene,
which creates a dummy overlay item (just a semi-transparent \l{Rectangle}),
which moves across the \l{VideoOutput} item.

\image qmlvideo-overlay.png

\section1 Application structure

The \l{multimedia/video/qmlvideo/qml/qmlvideo/main.qml} file creates a UI which includes
the following items:

\list
    \li Two \l{multimedia/video/qmlvideo/qml/qmlvideo/Button.qml}{Button} instances, each
       of which displays a filename, and can be used to launch a
       \l{multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml}{FileBrowser}
    \li An exit \l{multimedia/video/qmlvideo/qml/qmlvideo/Button.qml}{Button}
    \li A \l{multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml}{SceneSelectionPanel},
       which is a flickable list displaying the available scenes
    \li At the lower left, an item which displays the QML repainting rate - the
       upper number is the instantaneous frame rate and the lower number is the
       average over the past second.
\endlist

\image qmlvideo-menu.png

Each scene in the flickable list is implemented in its own QML file - for
example the video-basic scene (which just displays a static \l{VideoOutput}
in the center of the screen) is implemented in the
\l{multimedia/ideo/qmlvideo/qml/qmlvideo/VideoBasic.qml}{VideoBasic.qml} file.  As you
can see from the code, this makes use of a type of inheritance: a
\l{multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml}{VideoBasic} item ...

\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
\skipto import
\printuntil /^\}/

... is-a
\l{multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml}{SceneBasic} ...

\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
\skipto import
\printuntil contentType
\dots
\skipto Content
\printuntil content
\dots
\skipto }
\printuntil /^\}/

... which is-a
\l{multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml}{Scene}:

\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
\skipto import
\printuntil root
\dots
\skipto property QtObject content
\printuntil content
\dots
\skipto Button
\printuntil /^\}/

\l{multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml}{SceneBasic} describes the
structure and behaviour of the scene, but is agnostic of the type of content
which will be displayed - this is abstracted by
\l{multimedia/video/qmlvideo/qml/qmlvideo/Content.qml}{Content}.

This pattern allows us to define a particular use case (in this case, simply
display a static piece of content), and then instantiate that use case for
both video content
(\l{multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml}{VideoBasic}) and cameracontent
(\l{multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml}{CameraBasic}).  This approach
is used to implement many of the other scenes - for example, "repeatedly slide
the content from left to right and back again" is implemented by
\l{multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml}{SceneMove}, on which
\l{multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml}{VideoMove} and
\l{multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml}{CameraMove} are based.

Depending on the value of the contentType property in the top-level scene
instance, the embedded
\l{multimedia/video/qmlvideo/qml/qmlvideo/Content.qml}{Content} item creates either a
\l{MediaPlayer} or a \l{Camera} item.

\section1 Calculating and displaying QML painting rate

\input multimedia/doc/src/examples/video-qml-paint-rate.qdocinc

All that remains is to connect the afterRendering() signal of the QQuickView
object to a JavaScript function, which will eventually call frequencyItem.notify():

\quotefromfile multimedia/video/qmlvideo/main.cpp
\skipto QGuiApplication
\printuntil ;
\dots
\skipto QQuickItem
\printuntil ;
\dots
\skipto QObject::connect
\printuntil SLOT(qmlFramePainted()));

*/