Moved doc under src to fall in-line with the new modular structure

Change-Id: Ia2933baa1f0eaf82b5c2a626cb3661ee087049e3
Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
This commit is contained in:
Venugopal Shivashankar
2012-07-19 15:44:36 +02:00
committed by Qt by Nokia
parent ef144b647f
commit f930e088fc
101 changed files with 54 additions and 3872 deletions

View File

@@ -0,0 +1,30 @@
alias.include = input
macro.0 = "\\\\0"
macro.b = "\\\\b"
macro.n = "\\\\n"
macro.r = "\\\\r"
macro.i = "\\li"
macro.i11 = "\\li{1,1}"
macro.i12 = "\\li{1,2}"
macro.i13 = "\\li{1,3}"
macro.i14 = "\\li{1,4}"
macro.i15 = "\\li{1,5}"
macro.i16 = "\\li{1,6}"
macro.i17 = "\\li{1,7}"
macro.i18 = "\\li{1,8}"
macro.i19 = "\\li{1,9}"
macro.i21 = "\\li{2,1}"
macro.i31 = "\\li{3,1}"
macro.i41 = "\\li{4,1}"
macro.i51 = "\\li{5,1}"
macro.i61 = "\\li{6,1}"
macro.i71 = "\\li{7,1}"
macro.i81 = "\\li{8,1}"
macro.i91 = "\\li{9,1}"
macro.img = "\\image"
macro.endquote = "\\endquotation"
macro.relatesto = "\\relates"
spurious = "Missing comma in .*" \
"Missing pattern .*"

View File

@@ -0,0 +1,37 @@
macro.aacute.HTML = "&aacute;"
macro.Aring.HTML = "&Aring;"
macro.aring.HTML = "&aring;"
macro.Auml.HTML = "&Auml;"
macro.author = "\\b{Author:}"
macro.br.HTML = "<br />"
macro.BR.HTML = "<br />"
macro.copyright.HTML = "&copy;"
macro.eacute.HTML = "&eacute;"
macro.gui = "\\b"
macro.hr.HTML = "<hr />"
macro.iacute.HTML = "&iacute;"
macro.key = "\\b"
macro.menu = "\\b"
macro.note = "\\b{Note:}"
macro.oslash.HTML = "&oslash;"
macro.ouml.HTML = "&ouml;"
macro.QA = "\\e{Qt Assistant}"
macro.QD = "\\e{Qt Designer}"
macro.QL = "\\e{Qt Linguist}"
macro.QQV = "\\e{Qt QML Viewer}"
macro.param = "\\e"
macro.raisedaster.HTML = "<sup>*</sup>"
macro.rarrow.HTML = "&rarr;"
macro.reg.HTML = "<sup>&reg;</sup>"
macro.return = "Returns"
macro.starslash = "\\c{*/}"
macro.begincomment = "\\c{/*}"
macro.endcomment = "\\c{*/}"
macro.uuml.HTML = "&uuml;"
macro.mdash.HTML = "&mdash;"
macro.beginfloatleft.HTML = "<div style=\"float: left; margin-right: 2em\">"
macro.beginfloatright.HTML = "<div style=\"float: right; margin-left: 2em\">"
macro.endfloat.HTML = "</div>"
macro.clearfloat.HTML = "<br style=\"clear: both\" />"
macro.emptyspan.HTML = "<span></span>"

View File

@@ -0,0 +1,100 @@
Cpp.ignoretokens = QAXFACTORY_EXPORT \
QDESIGNER_COMPONENTS_LIBRARY \
QDESIGNER_EXTENSION_LIBRARY \
QDESIGNER_SDK_LIBRARY \
QDESIGNER_SHARED_LIBRARY \
QDESIGNER_UILIB_LIBRARY \
QM_EXPORT_CANVAS \
QM_EXPORT_DNS \
QM_EXPORT_DOM \
QM_EXPORT_FTP \
QM_EXPORT_HTTP \
QM_EXPORT_ICONVIEW \
QM_EXPORT_NETWORK \
QM_EXPORT_OPENGL \
QM_EXPORT_OPENVG \
QM_EXPORT_SQL \
QM_EXPORT_TABLE \
QM_EXPORT_WORKSPACE \
QM_EXPORT_XML \
QT_ASCII_CAST_WARN \
QT_ASCII_CAST_WARN_CONSTRUCTOR \
QT_BEGIN_HEADER \
QT_DESIGNER_STATIC \
QT_END_HEADER \
QT_FASTCALL \
QT_WIDGET_PLUGIN_EXPORT \
Q_COMPAT_EXPORT \
Q_CORE_EXPORT \
Q_CORE_EXPORT_INLINE \
Q_EXPLICIT \
Q_EXPORT \
Q_EXPORT_CODECS_CN \
Q_EXPORT_CODECS_JP \
Q_EXPORT_CODECS_KR \
Q_EXPORT_PLUGIN \
Q_GFX_INLINE \
Q_AUTOTEST_EXPORT \
QM_AUTOTEST_EXPORT \
Q_GUI_EXPORT \
Q_GUI_EXPORT_INLINE \
Q_GUI_EXPORT_STYLE_CDE \
Q_GUI_EXPORT_STYLE_COMPACT \
Q_GUI_EXPORT_STYLE_MAC \
Q_GUI_EXPORT_STYLE_MOTIF \
Q_GUI_EXPORT_STYLE_MOTIFPLUS \
Q_GUI_EXPORT_STYLE_PLATINUM \
Q_GUI_EXPORT_STYLE_POCKETPC \
Q_GUI_EXPORT_STYLE_SGI \
Q_GUI_EXPORT_STYLE_WINDOWS \
Q_GUI_EXPORT_STYLE_WINDOWSXP \
QHELP_EXPORT \
Q_INLINE_TEMPLATE \
Q_INTERNAL_WIN_NO_THROW \
Q_NETWORK_EXPORT \
Q_OPENGL_EXPORT \
Q_OPENVG_EXPORT \
Q_OUTOFLINE_TEMPLATE \
Q_SQL_EXPORT \
Q_SVG_EXPORT \
Q_SCRIPT_EXPORT \
Q_SCRIPTTOOLS_EXPORT \
Q_TESTLIB_EXPORT \
Q_TYPENAME \
Q_XML_EXPORT \
Q_XMLSTREAM_EXPORT \
Q_XMLPATTERNS_EXPORT \
QDBUS_EXPORT \
Q_DBUS_EXPORT \
QT_BEGIN_NAMESPACE \
QT_BEGIN_INCLUDE_NAMESPACE \
QT_END_NAMESPACE \
QT_END_INCLUDE_NAMESPACE \
PHONON_EXPORT \
Q_DECLARATIVE_EXPORT \
Q_GADGET \
QWEBKIT_EXPORT \
Q_INVOKABLE \
Q_MULTIMEDIA_EXPORT
Cpp.ignoredirectives = Q_DECLARE_HANDLE \
Q_DECLARE_INTERFACE \
Q_DECLARE_METATYPE \
Q_DECLARE_OPERATORS_FOR_FLAGS \
Q_DECLARE_PRIVATE \
Q_DECLARE_PUBLIC \
Q_DECLARE_SHARED \
Q_DECLARE_TR_FUNCTIONS \
Q_DECLARE_TYPEINFO \
Q_DISABLE_COPY \
QT_FORWARD_DECLARE_CLASS \
Q_DUMMY_COMPARISON_OPERATOR \
Q_ENUMS \
Q_FLAGS \
Q_INTERFACES \
__attribute__ \
K_DECLARE_PRIVATE \
PHONON_OBJECT \
PHONON_HEIR \
Q_PRIVATE_PROPERTY \
Q_DECLARE_PRIVATE_D \
Q_CLASSINFO

View File

@@ -0,0 +1,17 @@
defines = Q_QDOC \
QT_.*_SUPPORT \
QT_.*_LIB \
QT_COMPAT \
QT_KEYPAD_NAVIGATION \
QT_NO_EGL \
QT3_SUPPORT \
Q_WS_.* \
Q_OS_.* \
Q_BYTE_ORDER \
QT_DEPRECATED \
Q_NO_USING_KEYWORD \
__cplusplus
versionsym = QT_VERSION_STR
codeindent = 1

View File

@@ -0,0 +1,32 @@
# Name of the project.
project = Qt Multimedia
# Directories in which to search for files to document and images.
# By default set to the root directory of the project for sources
# and headers and qdoc will therefore generate output for each file.
# Images should be placed in <rootdir>/dic/images and examples in
# <rootdir>/examples.
# Paths are relative to the location of this file.
exampledirs += ../src/examples \
../.. \
../../examples
headerdirs += ../src \
../../src
imagedirs += ../src/images \
sourcedirs += ../src \
../../src
excludedirs +=
#Do not change the variables after this line unless you know what you are doing.
outputdir = ../ditaxml
outputformats = DITAXML
examples.fileextensions = "*.cpp *.h *.js *.svg *.xml *.ui *.qml"
examples.imageextensions = "*.png *.jpeg *.jpg *.gif *.mng"
headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"

View File

@@ -0,0 +1,85 @@
include(compat.qdocconf)
include(macros.qdocconf)
include(qt-cpp-ignore.qdocconf)
include(qt-defines.qdocconf)
# Name of the project.
project = Qt Multimedia
description = Qt Multimedia Documentation
# Directories in which to search for files to document and images.
# By default set to the root directory of the project for sources
# and headers and qdoc will therefore generate output for each file.
# Images should be placed in <rootdir>/dic/images and examples in
# <rootdir>/examples.
# Paths are relative to the location of this file.
exampledirs += .. \
../../../examples
headerdirs += src \
../..
imagedirs += src/images \
sourcedirs += src \
../..
excludedirs +=
# The index file contains links to the Qt 5 documentation.
# Point to the any .index file to cross link to other projects
#indexes = $QT5DOC/doc/html/qt.index
# The following parameters are for creating a qhp file, the qhelpgenerator
# program can convert the qhp file into a qch file which can be opened in
# Qt Assistant and/or Qt Creator.
# Defines the name of the project. You cannot use operators (+, =, -) in
# the name. Properties for this project are set using a qhp.<projectname>.property
# format.
qhp.projects = qtmultimedia
# Sets the name of the output qhp file.
qhp.qtmultimedia.file = qtmultimedia.qhp
# Namespace for the output file. This namespace is used to distinguish between
# different documentation files in Creator/Assistant.
qhp.qtmultimedia.namespace = qtmultimedia.500
# Title for the package, will be the main title for the package in
# Assistant/Creator.
qhp.qtmultimedia.indexTitle = Qt Multimedia Documentation
# Extra files to add to the output which are not linked to from anywhere
# using a qdoc \l command.
qhp.qtmultimedia.extraFiles = style/qtmultimedia.css
# Only update the name of the project for the next variables.
qhp.qtmultimedia.virtualFolder = qdoc
qhp.qtmultimedia.subprojects = classes
qhp.qtmultimedia.subprojects.classes.title = Classes
qhp.qtmultimedia.subprojects.classes.selectors = class fake:headerfile
qhp.qtmultimedia.subprojects.classes.sortPages = true
# Do NOT change the variables after this line unless you know what you are doing.
outputdir = html
outputformats = HTML
examples.fileextensions = "*.cpp *.h *.js *.svg *.xml *.ui *.qml"
examples.imageextensions = "*.png *.jpeg *.jpg *.gif *.mng"
headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"
HTML.nobreadcrumbs = "true"
HTML.templatedir = .
HTML.stylesheets = style/qtmultimedia.css
HTML.headerstyles = " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/qtmultimedia.css\" />\n"
HTML.endheader = "</head>\n<body>\n"
HTML.footer = "<div class=\"footer\">Copyright (c) 2012 Nokia Corporation and/or its subsidiaries. All rights reserved.</div>\n"

View File

@@ -0,0 +1,47 @@
win32:!win32-g++ {
unixstyle = false
} else:win32-g++:isEmpty(QMAKE_SH) {
unixstyle = false
} else {
unixstyle = true
}
qtPrepareTool(QDOC, qdoc)
isEmpty(QDOC): warning("No qdoc executable found.")
ONLINE_CONF = $$PWD/qtmultimedia.qdocconf
DITA_CONF = $$PWD/qtmultimedia-dita.qdocconf
QCH_CONF = #nothing yet
$$unixstyle {
} else {
QDOC = $$replace(QDOC, "qdoc", "qdoc3.exe")
ONLINE_CONF = $$replace(ONLINE_CONF, "/", "\\")
DITA_DOCS = $$replace(ONLINE_CONF, "/", "\\")
}
# Build rules
docs.depends = dita_docs online_docs qch_docs
online_docs.commands = $$QDOC $$ONLINE_CONF
dita_docs.commands = $$QDOC $$DITA_CONF
qch_docs.commands = #no commands yet
QMAKE_EXTRA_TARGETS += docs dita_docs online_docs qch_docs
QMAKE_CLEAN += \
"-r $$PWD/../html" \
"-r $$PWD/../ditaxml"
OTHER_FILES += \
doc/src/cameraoverview.qdoc \
doc/src/changes.qdoc \
doc/src/multimediabackend.qdoc \
doc/src/multimedia.qdoc \
doc/src/audiooverview.qdoc \
doc/src/radiooverview.qdoc \
doc/src/videooverview.qdoc \
doc/src/plugins/qml-multimedia.qdoc

View File

@@ -0,0 +1,79 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page audioengineoverview.html
\title Positional Audio
\brief 3D positional audio playback and content management
\section1 QtAudioEngine Features
Qt Multimedia includes the \c QtAudioEngine QML module for
providing 3D positional audio playback and content management.
QtAudioEngine enables developers to organize wave files into discrete \l Sound with different
\l {PlayVariation}{play variations}, group sound controls by \l {AudioCategory} categories and
define \l {AttenuationModelLinear}{attenuation models} and various 3d audio settings all in one
place. Playback of \l {SoundInstance}{sound instances} can be conveniently activated by in-app
events and managed by QtAudioEngine or controlled by explicitly defining \l SoundInstance
for easier QML bindings.
To access these QML types import the
\b{QtAudioEngine 1.0} module.
\qml
import QtQuick 2.0
import QtAudioEngine 1.0
AudioEngine {
//...
}
\endqml
\section1 Examples
\list
\li \l {AudioEngine Example}{Audio Engine}
\endlist
\section1 Reference Documentation
\section2 QML Types
\list
\li \l AudioEngine
\li \l AudioSample
\li \l AudioCategory
\li \l AttenuationModelLinear
\li \l AttenuationModelInverse
\li \l Sound
\li \l PlayVariation
\li \l AudioListener
\li \l SoundInstance
\endlist
*/

View File

@@ -0,0 +1,153 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page audiooverview.html
\title Audio Overview
\brief Audio playback, recording and processing
\section1 Audio Features
Qt Multimedia offers a range of audio classes, covering both low and
high level approaches to audio input, output and processing. In
addition to traditional audio usage, the \l {Positional Audio}{Qt AudioEngine}
QML types offer high level 3D positional audio for QML applications.
See that documentation for more information.
\section1 Audio Implementation Details
\section2 Playing Compressed Audio
For playing media or audio files that are not simple, uncompressed audio, you can
use the \l QMediaPlayer C++ class, or the \l {Audio} and \l {MediaPlayer} QML types.
The QMediaPlayer class and associated QML types are also capable of playing
\l{multimedia-playing-video}{video}, if required. The compressed audio formats supported does depend
on the operating system environment, and also what media plugins the user
may have installed.
Here is how you play a local file using C++:
\snippet doc/src/snippets/multimedia-snippets/media.cpp Local playback
You can also put files (even remote URLs) into a playlist:
\snippet doc/src/snippets/multimedia-snippets/media.cpp Audio playlist
\section2 Recording Audio to a File
For recording audio to a file, the \l {QAudioRecorder} class allows you
to compress audio data from an input device and record it.
\snippet doc/src/snippets/multimedia-snippets/media.cpp Audio recorder
\section2 Low Latency Sound Effects
In addition to the raw access to sound devices described above, the QSoundEffect class (and
\l {SoundEffect} QML type) offers a slightly higher level way to play
sounds. These classes allow you to specify a WAV format file which can
then be played with low latency when necessary. Both QSoundEffect and
SoundEffect have essentially the same API.
You can adjust the number of \l {QSoundEffect::loopCount()}{loops} a sound effect is played, as well as
the \l {QSoundEffect::setVolume()}{volume} (or \l {QSoundEffect::setMuted()}{muting}) of the effect.
For older, Qt 4.x based applications \l QSound is also available. Applications
are recommended to use QSoundEffect where possible.
\section2 Monitoring Audio Data During Playback or Recording
The \l QAudioProbe class allows you to monitor audio data being played or
recorded in the higher level classes like \l QMediaPlayer, \l QCamera and
\l QAudioRecorder. After creating your high level class, you can simply
set the source of the probe to your class, and receive audio buffers as they
are processed. This is useful for several audio processing tasks, particularly
for visualization or adjusting gain. You cannot modify the buffers, and
they may arrive at a slightly different time than the media pipeline
processes them.
Here's an example of installing a probe during recording:
\snippet doc/src/snippets/multimedia-snippets/media.cpp Audio probe
\section2 Low Level Audio Playback and Recording
Qt Multimedia offers classes for raw access to audio input and output
facilities, allowing applications to receive raw data from devices like
microphones, and to write raw data to speakers or other devices. Generally
these classes do not do any audio decoding, or other processing, but they
can support different types of raw audio data.
The QAudioOutput class offers raw audio data output, while QAudioInput
offers raw audio data input. Both classes have adjustable buffers and
latency, so they are suitable for both low latency use cases (like games
or VOIP) and high latency (like music playback). The available hardware
determines what audio outputs and inputs are available.
\section3 Push and Pull
The low level audio classes can operate in two modes - \c push and \c pull.
In \c pull mode, the audio device is started by giving it a QIODevice. For
an output device, the QAudioOutput class will pull data from the QIODevice
(using \l QIODevice::read()) when more audio data is required. Conversely,
for \c pull mode with QAudioInput, when audio data is available then the
data will be written directly to the QIODevice.
In \c push mode, the audio device provides a QIODevice instance that
can be written or read to as needed. Typically this results in simpler
code but more buffering, which may affect latency.
\section2 Decoding Compressed Audio to Memory
In some cases you may want to decode a compressed audio file and do further
processing yourself (like mix multiple samples, or some custom digital signal
processing algorithms). Qt Multimedia 5.0 offers a preliminary API for this
case - the \l QAudioDecoder class. QAudioDecoder supports decoding local files
or from a QIODevice instances.
Here's an example of decoding a local file:
\snippet doc/src/snippets/multimedia-snippets/audio.cpp Local audio decoding
Note: This API is preliminary at this time - the API may change or be
removed before the final 5.0 release.
\section1 Examples
There are both C++ and QML examples available.
\section2 C++ Examples
\annotatedlist audio_examples
\section2 QML Examples
[TBD]
\section1 Reference Documentation
\section2 C++ Classes
\annotatedlist multimedia_audio
\section2 QML Types
\annotatedlist multimedia_audio_qml
*/

View File

@@ -0,0 +1,262 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page cameraoverview.html
\title Camera Overview
\brief Camera viewfinder, still image capture, and video recording.
The Qt Multimedia API provides a number of camera related classes, so you
can access images and videos from mobile device cameras or webcameras.
There are both C++ and QML APIs for common tasks.
\section1 Camera Features
In order to use the camera classes a quick overview of the way a camera
works is needed. If you're already familiar with this, you can skip ahead to
\l {camera-tldr}{Camera implementation details}.
[TBD - this needs a diagram]
* Camera features
* lens -> sensors -> image processing -> capture/recording
\section2 The Lens Assembly
At one end of the camera assembly is the lens assembly (one or
more lenses, arranged to focus light onto the sensor). The lenses
themselves can sometimes be moved to adjust things like focus and zoom,
or they might be fixed in an arrangement to give a good balance between
objects in focus, and cost.
Some lens assemblies can automatically be adjusted so that
an object at different distances from the camera can be kept in focus.
This is usually done by measuring how sharp a particular area of the
frame is, and by adjusting the lens assembly until it is maximally
sharp. In some cases the camera will always use the center of the
frame for this. Other cameras may also allow the region to focus
to be specified (for "touch to zoom", or "face zoom" features).
\section2 The Sensor
Once light arrives at the sensor, it gets converted into digital pixels.
This process can depend on a number of things but ultimately comes down
to two things - how long the conversion is allowed to take, and how
bright the light is. The longer a conversion can take, the better the
quality. Using a flash can assist with letting more light hit the sensor,
allowing it to convert pixels faster, giving better quality for the same
amount of time. Conversely, allowing a longer conversion time can let you
take photos in darker environments, as long as the camera is steady.
\section2 Image Processing
After the image has been captured by the sensor, the camera firmware performs
various image processing tasks on it to compensate for various sensor
characteristics, current lighting, and desired image properties. Faster sensor
pixel conversion times tend to introduce digital noise, so some amount of image
processing can be done to remove this based on the camera sensor settings.
The color of the image can also be adjusted at this stage to compensate for
different light sources - fluorescent lights and sunlight give very different
appearances to the same object, so the image can be adjusted based on the
white balance of the picture (due to the different color temperatures of the
light sources).
Some forms of "special effects" can also be performed at this stage. Black
and white, sepia, or "negative" style images can be produced.
\section2 Recording for Posterity
Finally, once a perfectly focused, exposed and processed image has been
created, it can be put to good use. Camera images can be further processed
by application code (for example, to detect barcodes, or to stitch together a
panoramic image), or saved to a common format like JPEG, or used to create a movie.
Many of these tasks have classes to assist them.
\target camera-tldr
\section1 Camera Implementation Details
\section2 Viewfinder
While not strictly necessary, it's often useful to be able to see
what the camera is pointing at. Most digital cameras allow an image
feed from the camera sensor at a lower resolution (usually up to
the size of the display of the camera) so you can compose
a photo or video, and then switch to a slower but higher resolution
mode for capturing the image.
Depending on whether you're using QML or C++, you can do this in multiple ways.
In QML, you can use \l Camera and \l VideoOutput together to show a
simple viewfinder:
\qml
Camera {
id: camera
// You can adjust various settings in here
}
VideoOutput {
source: camera
}
\endqml
In C++, your choice depends on whether you are using widgets, or QGraphicsView.
The \l QVideoWidget class is used in the widgets case, and \l QGraphicsVideoItem
is useful for QGraphicsView.
\snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera overview viewfinder
For advanced usage (like processing viewfinder frames as they come, to detect
objects or patterns), you can also derive from \l QAbstractVideoSurface and
set that as the viewfinder for the QCamera object. In this case you will
need to render the viewfinder image yourself.
\snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera overview surface
\section2 Still Images
After setting up a viewfinder and finding something photogenic,
to capture an image we need to initialize a new QCameraImageCapture
object. All that is then needed is to start the camera, lock it so
that things are in focus and the settings are not different from the
viewfinder while the image capture occurs, capture the image, and
finally unlock the camera ready for the next photo.
\snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera overview capture
\section2 Movies
Previously we saw code that allowed the capture of a still image. Recording
video requires the use of a \l QMediaRecorder object.
To record video we need to create a camera object as before but this time as
well as creating a viewfinder, we will also initialize a media recorder object.
\snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera overview movie
Signals from the \e mediaRecorder can be connected to slots to react to
changes in the state of the recorder or error events. Recording itself
starts with the \l {QMediaRecorder::record()}{record()} function of
mediaRecorder being called, this causes the signal \l
{QMediaRecorder::stateChanged()}{stateChanged()} to be emitted. The
recording process can be changed with the \l {QMediaRecorder::record()}{record()},
\l {QMediaRecorder::stop()}{stop()} and \l {QMediaRecorder::setMuted()}{setMuted()}
slots in \l QMediaRecorder.
\section2 Controlling the Imaging Pipeline
Now that the basics of capturing images or movies are covered, there are a number
of ways to control the imaging pipeline to implement some interesting techniques.
As explained earlier, several physical and electronic elements combine to determine
the final images, and you can control them with different classes.
\section3 Focus and Zoom
Focusing (and zoom) is managed primarily by the \l QCameraFocus class.
QCameraFocus allows the developer to set the general policy by means of the
enums for the \l {QCameraFocus::FocusMode}{FocusMode} and the
\l {QCameraFocus::FocusPointMode}{FocusPointMode}. \l {QCameraFocus::FocusMode}{FocusMode}
deals with settings such as \l {QCameraFocus::FocusMode}{AutoFocus},
\l {QCameraFocus::FocusMode}{ContinuousFocus} and \l {QCameraFocus::FocusMode}{InfinityFocus},
whereas \l {QCameraFocus::FocusMode}{FocusPointMode} deals with the
various focus zones within the view that are used for autofocus modes. \l {QCameraFocus::FocusMode}{FocusPointMode}
has support for face recognition (where the camera supports it), center focus and a custom
focus where the focus point can be specified.
For camera hardware that supports it, \l {QCameraFocus::FocusMode}{Macro focus} allows
imaging of things that are close to the sensor. This is useful in applications like
barcode recognition, or business card scanning.
In addition to focus, QCameraFocus allows you to control any available optical or
digital zoom. In general, optical zoom is higher quality, but more expensive to
manufacture, so the available zoom range might be limited (or fixed to unity).
\section3 Exposure, Aperture, Shutter Speed and Flash
There are a number of settings that affect the amount of light that hits the
camera sensor, and hence the quality of the resulting image. The \l QCameraExposure
class allows you to adjust these settings. You can use this class to implement
some techniques like High Dynamic Range (HDR) photos by locking the exposure
parameters (with \l {QCamera::searchAndLock()}), or motion blur by setting slow shutter speeds
with small apertures.
The main settings for automatic image taking are the \l {QCameraExposure::ExposureMode}{exposure mode}
and \l {QCameraExposure::FlashMode}{flash mode}. Several other settings (aperture, ISO setting,
shutter speed) are usually managed automatically but can also be overridden if desired.
You can also adjust the \l {QCameraExposure::meteringMode()} to control which parts
of the camera frame to measure exposure at. Some camera implementations also allow
you to specify a specific point that should be used for exposure metering - this is
useful if you can let the user touch or click on an interesting part of the viewfinder,
and then use this point so that the image exposure is best at that point.
Finally, you can control the flash hardware (if present) using this class. In some cases
the hardware may also double as a torch (typically when the flash is LED based, rather than
a xenon or other bulb). See also \l {Torch} for an easy to use API for
torch functionality.
\target camera_image_processing
\section3 Image Processing
The QCameraImageProcessing class lets you adjust the image processing
part of the pipeline. This includes the \l {QCameraImageProcessing::WhiteBalanceMode}{white balance}
(or color temperature), \l {QCameraImageProcessing::contrast()}{contrast},
\l {QCameraImageProcessing::saturation()}{saturation}, \l {QCameraImageProcessing::setSharpeningLevel()}{sharpening}
and \l {QCameraImageProcessing::setDenoisingLevel()}{denoising}. Most cameras support automatic settings
for all of these, so you shouldn't need to adjust them unless the user wants a specific setting.
If you're taking a series of images (for example, to stitch them together for
a panoramic image), you should lock the image processing settings so that all the
images taken appear similar with \e {QCamera::lock(QCamera::LockWhiteBalance)}/
\section3 Canceling Asynchronous Operations
Various operations such as image capture and auto focusing occur
asynchrously. These operations can often be canceled by the start of a new
operation as long as this is supported by the camera. For image capture,
the operation can be canceled by calling
\l {QCameraImageCapture::cancelCapture()}{cancelCapture()}. For AutoFocus,
autoexposure or white balance cancellation can be done by calling
\e {QCamera::unlock(QCamera::LockFocus)}.
\section1 Examples
There are both C++ and QML examples available.
\section2 C++ Examples
\annotatedlist camera_examples
\section2 QML Examples
\annotatedlist camera_examples_qml
\section1 Reference Documentation
\section2 C++ Classes
\annotatedlist multimedia_camera
\section2 QML Types
\annotatedlist camera_qml
*/

View File

@@ -0,0 +1,157 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page changes.html
\title Changes in Qt Multimedia
\brief A description of changes in this version of Qt Multimedia
The Qt Multimedia module in Qt 5 is a combination of the Qt Multimedia module
in Qt 4.x and the Qt Multimedia Kit module of Qt Mobility. It replaces both
of these modules by combining the code. If you've previously used Qt Multimedia
there are not too many changes required for existing code, but there are some
larger changes required for porting code that used Qt Multimedia Kit (most notably
the namespace and header file prefix has changed, and the qmake pro file changes
needed to enable Qt Multimedia).
One other change of note is that widget related classes (like \l QVideoWidget)
are now in a new library (Qt Multimedia Widgets).
\section1 New features in 5.0
There are a number of new features in Qt Multimedia 5.0:
\list
\li Expanded QML API
\li New \l QAudioRecorder class
\li Volume support for QAudioOutput and QAudioInput
\li More examples and documentation
\li QML \l Torch class
\li QSound moved from QtGui to QtMultimedia
\li QSoundEffect available to C++ now, as well as QML
\li FM Radio Data System classes and types now available (\l QRadioData, \l RadioData)
\li Various other API improvements and bugfixes
\endlist
\section1 Removed features
A number of classes or features previously offered in Qt Multimedia or Qt Multimedia Kit have
been removed.
\table 70%
\header
\li Removed feature
\li Notes
\row
\li QMediaImageViewer
\li This class (and related controls and services) were removed since
their functionality was not suitable for many applications
\endtable
\section1 Changed features
A number of classes previously offered in Qt Multimedia or Qt Multimedia Kit have
changed in ways that may affect previously written code. There may be other
changes (like new features) that will not affect previously written code, and
they are documented elsewhere.
\table 70%
\header
\li Changed feature
\li Notes
\row
\li qmake .pro file changes
\li If you've used QtMultimediaKit in the past, you needed to put
\code
CONFIG += mobility
MOBILITY += multimedia
\endcode
in your .pro file. Now you need to use:
\code
QT += multimedia
\endcode
or
\code
QT += multimedia multimediawidgets
\endcode
if you need to use the widget classes.
\row
\li Namespace changes
\li For Qt Multimedia Kit the majority of the classes were in the
normal Qt namespace (usually nothing, unless built specially). There
was a Qt Multimedia Kit namespace for several enumerations. This namespace
has now changed to Qt Multimedia, so if you've used one of the
\c SupportEstimate, \c EncodingQuality, \c EncodingMode or \c AvailabilityStatus
enumerations you'll need to change your code. In fact, running a global
search and replace on \c QtMultimediaKit (to replace it with \c QtMultimedia) will
go a long way with porting your code.
\row
\li Meta-data enumeration changes
\li In Qt Multimedia Kit the available meta-data keys were in an enumeration
in the \c QtMultimediaKit namespace. These meta-data keys have been changed
to string literals in the \c {QtMultimedia::MetaData} namespace - generally your
source code will mostly be compatible unless you have created variables or
parameters with the \c {QtMultimedia::MetaData} type - you should replace these
with \c QString.
\row
\li Meta-data method changes
\li In Qt Multimedia Kit the available meta-data was split between methods to
access standard, pre-defined keys, and methods to access extensible free
form key meta-data. These have been combined into a single method to
access meta-data given a string key, and a list of pre-defined keys. If
you've used the \c extendedMetaData method of any class, you will need
to change your code to combine the standard and extended metadata methods.
\row
\li Qt Metatype registration
\li In Qt Multimedia 5.0 we've tried to make sure that we register any classes
or types that would be useful to use in cross process signals or in
QVariants. If you've previously added Q_DECLARE_METATYPE macros for any
Qt Multimedia class you will probably need to remove them.
\row
\li Video QML type
\li If you've previously used \l Video you may be excited
to learn that it should still work as expected, but you also have
the choice of using \l MediaPlayer and \l VideoOutput
together for more flexible and advanced use cases.
\row
\li QSoundEffect
\li The SoundEffect QML type was public and accessible in Qt Multimeda Kit,
and now the C++ version is also available. If you managed to use the
private class previously, you'll need to update your code.
\row
\li Camera controls
\li A large number of the camera controls (QCameraImageProcessingControl,
QCameraFocusControl etc) have been updated to address a number of
design flaws. If you have previously been using these classes, you
should check the new design. In particular, a number of discrete
accessor methods have been collapsed into parametrized methods, and
the range or data type of some parameters has been adjusted.
\endtable
*/

View File

@@ -0,0 +1,284 @@
BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
font-family: Arial, Geneva, Helvetica, sans-serif;
}
H1 {
text-align: center;
font-size: 160%;
}
H2 {
font-size: 120%;
}
H3 {
font-size: 100%;
}
h3.fn,span.fn
{
background-color: #eee;
border-width: 1px;
border-style: solid;
border-color: #ddd;
font-weight: bold;
padding: 6px 0px 6px 10px;
margin: 42px 0px 0px 0px;
}
hr {
border: 0;
color: #a0a0a0;
background-color: #ccc;
height: 1px;
width: 100%;
text-align: left;
margin: 34px 0px 34px 0px;
}
table.valuelist {
border-width: 1px 1px 1px 1px;
border-style: solid;
border-color: #dddddd;
border-collapse: collapse;
background-color: #f0f0f0;
}
table.indextable {
border-width: 1px 1px 1px 1px;
border-style: solid;
border-collapse: collapse;
background-color: #f0f0f0;
border-color:#555;
font-size: 100%;
}
table td.largeindex {
border-width: 1px 1px 1px 1px;
border-collapse: collapse;
background-color: #f0f0f0;
border-color:#555;
font-size: 120%;
}
table.valuelist th {
border-width: 1px 1px 1px 2px;
padding: 4px;
border-style: solid;
border-color: #666;
color:white;
background-color:#666;
}
th.titleheader {
border-width: 1px 0px 1px 0px;
padding: 2px;
border-style: solid;
border-color: #666;
color:white;
background-color:#555;
background-image:url('images/gradient.png')};
background-repeat: repeat-x;
font-size: 100%;
}
th.largeheader {
border-width: 1px 0px 1px 0px;
padding: 4px;
border-style: solid;
border-color: #444;
color:white;
background-color:#555555;
font-size: 120%;
}
p {
margin-left: 4px;
margin-top: 8px;
margin-bottom: 8px;
}
a:link
{
color: #0046ad;
text-decoration: none
}
a:visited
{
color: #672967;
text-decoration: none
}
a.obsolete
{
color: #661100;
text-decoration: none
}
a.compat
{
color: #661100;
text-decoration: none
}
a.obsolete:visited
{
color: #995500;
text-decoration: none
}
a.compat:visited
{
color: #995500;
text-decoration: none
}
body
{
background: #ffffff;
color: black
}
table.generic, table.annotated
{
border-width: 1px;
border-color:#bbb;
border-style:solid;
border-collapse:collapse;
}
table td.memItemLeft {
width: 180px;
padding: 2px 0px 0px 8px;
margin: 4px;
border-width: 1px;
border-color: #E0E0E0;
border-style: none;
font-size: 100%;
white-space: nowrap
}
table td.memItemRight {
padding: 2px 8px 0px 8px;
margin: 4px;
border-width: 1px;
border-color: #E0E0E0;
border-style: none;
font-size: 100%;
}
table tr.odd {
background: #f0f0f0;
color: black;
}
table tr.even {
background: #e4e4e4;
color: black;
}
table.annotated th {
padding: 3px;
text-align: left
}
table.annotated td {
padding: 3px;
}
table tr pre
{
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
border: none;
background: none
}
tr.qt-style
{
background: #96E066;
color: black
}
body pre
{
padding: 0.2em;
border: #e7e7e7 1px solid;
background: #f1f1f1;
color: black
}
table tr.qt-code pre
{
padding: 0.2em;
border: #e7e7e7 1px solid;
background: #f1f1f1;
color: black
}
span.preprocessor, span.preprocessor a
{
color: darkblue;
}
span.comment
{
color: darkred;
font-style: italic
}
span.string,span.char
{
color: darkgreen;
}
.title
{
text-align: center
}
.subtitle
{
font-size: 0.8em
}
.small-subtitle
{
font-size: 0.65em
}
.qmlitem {
padding: 0;
}
.qmlname {
white-space: nowrap;
}
.qmltype {
text-align: center;
font-size: 160%;
}
.qmlproto {
background-color: #eee;
border-width: 1px;
border-style: solid;
border-color: #ddd;
font-weight: bold;
padding: 6px 10px 6px 10px;
margin: 42px 0px 0px 0px;
}
.qmlreadonly {
float: right;
color: red
}
.qmldoc {
}
*.qmlitem p {
}

View File

@@ -0,0 +1,43 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example audiodevices
\title Audio Devices Example
\ingroup audio_examples
\brief The Audio Devices example shows the application of the audio devices APIs
This example shows how to create a simple application to list and test
the configuration for the various audio devices available on the device
or machine. This is done using the QtMobility Multimedia API.
\image audiodevices.png
*/

View File

@@ -0,0 +1,39 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example audioengine
\title AudioEngine Example
\ingroup audioengine_examples
\brief The Audio Engine example demonstrates 3D sound control using
the QtAudioEngine API.
\image audioengine.png
*/

View File

@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example audioinput
\title Audio Input Example
\ingroup audio_examples
\brief The Audio Input Example shows the use of the QAudioInput class.
*/

View File

@@ -0,0 +1,38 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example audiooutput
\title Audio Output Example
\ingroup audio_examples
\brief The Audio Output Example show the use of the QAudioOutput API.
*/

View File

@@ -0,0 +1,104 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example audiorecorder
\title Audio Recorder Example
\ingroup audio_examples
\brief The Audio Recorder Example shows how to create a simple audio recorder.
It demonstrates the discovery of the supported devices and codecs and the use
of recording functions in the QAudioRecorder class.
We display a window for the user to select the appropriate audio input,
codec, container, and sample rate. Allow a setting of either quality or
bitrate. Finally, the output file can be selected and recording can be
started.
The lists are setup using the \l{QAudioRecorder::audioInputs()}{audioInputs()},
\l{QAudioRecorder::supportedAudioCodecs()}{supportedAudioCodecs()},
\l{QAudioRecorder::supportedContainers()}{supportedContainers()},
\l{QAudioRecorder::supportedContainers()}{supportedContainers()}, and
\l{QAudioRecorder::supportedAudioSampleRates()}{supportedAudioSampleRates()}
methods. The quality slider is setup from 0 (zero) to
\l{QtMultimedia::VeryHighQuality} with a default value of
\l{QtMultimedia::NormalQuality}, while the bitrates are hardcoded
into the list.
\image audiorecorder.png
To record audio we simply create a QAudioRecorder object.
\code
audioRecorder = new QAudioRecorder(this);
\endcode
And setup the lists as described above. The text on the record and pause
buttons are toggled depending on the \l{QMediaRecorder::State}{state} of
the \c audioRecorder object. This means that if the state is
\l{QMediaRecorder::StoppedState} then the button text will be "Record" and
"Pause". In \l{QMediaRecorder::RecordingState} the record button will have
the text "Stop", and in \l{QMediaRecorder::PausedState} the pause button
will have the text "Resume".
Pressing the buttons will also result in a toggle based on the state. If
recording is stopped, then pressing the record button will setup the
\l{QAudioEncoderSettings} based on the values of the selection lists,
will set the encoding settings and container on the \c audioRecorder
object, and start recording using the
\l{QMediaRecorder::record()}{record()} method.
\code
QAudioEncoderSettings settings;
settings.setCodec(boxValue(ui->audioCodecBox).toString());
settings.setSampleRate(boxValue(ui->sampleRateBox).toInt());
settings.setBitRate(boxValue(ui->bitrateBox).toInt());
settings.setQuality(QtMultimedia::EncodingQuality(ui->qualitySlider->value()));
settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
QtMultimedia::ConstantQualityEncoding :
QtMultimedia::ConstantBitRateEncoding);
QString container = boxValue(ui->containerBox).toString();
audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container);
audioRecorder->record();
\endcode
While recording, the status bar of the application is updated with duration information
from the \l{QMediaRecorder::durationChanged()}{durationChanged} signal from the
\c audioRecorder object.
\code
ui->statusbar->showMessage(tr("Recorded %1 sec").arg(duration / 1000));
\endcode
*/

View File

@@ -0,0 +1,80 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example camera
\title Camera Example
\ingroup camera_examples
\brief The Camera Example shows how to use the API to capture a still image
or video.
The Camera Example demonstrates how you can use QtMultimedia to implement
some basic Camera functionality to take still images and record video clips
with audio.
A Camera class is created that will act as our Camera. It has a user interface,
control functions, setting values and a means of defining the location where
the image or video clip is to be saved. It will also store the image and video
settings.
The Camera class contains an instance of \l {QCamera}, the API class interface to
the hardware. It also has an instance of \l {QCameraImageCapture} to take still images
and an instance of \l {QMediaRecorder} to record video. It also contains the user
interface object.
The Camera constructor does some basic initialization. The camera object is
set to '0', the user interface is initialized and UI signal are connected to
slots that react to the triggering event. However, most of the work is done when
the \e{setCamera()} function is called, passing in a \l {QByteArray}.
\e{setCamera()} sets up various connections between the user interface and the functionality
of the Camera class using signals and slots. It also instantiates and initializes the \l {QCamera},
\l {QCameraImageCapture} and \l {QMediaRecorder} objects mentioned above. The still
and video recording visual tabs are enabled and finally the
\l {QCamera::start()}{start()} function of the \l{QCamera} object is called.
Now that the camera is ready for user commands it waits for a suitable event.
Such an event will be the key press of either the \l {Qt::Key_CameraFocus} or
\l {Qt::Key_Camera} buttons on the application window. Camera focus will
simply display the viewfinder and lock the camera settings. Key_Camera will
either call \e{takeImage()} if the \l {QCamera::captureMode()}{captureMode()}
is QCamera::CaptureStillImage, or if the capture mode is for video then one
of two actions will occur. If the recording state shows that we are currently
recording then the \e{stop()} function is called resulting in a call to
\l {QCamera::stop()}, whereas if we are not recording then a video recording
is started with a call to \l {QMediaRecorder::record()}.
\image camera-example.png
*/

View File

@@ -0,0 +1,69 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example declarative-camera
\title QML Camera Example
\ingroup camera_examples_qml
\brief The Camera Example shows how to use the API to capture a still image
or video.
\image qml-camera.png
This example demonstrates how to use the Qt Multimedia QML API to access
camera functions. It shows how to change settings and to capture images.
Most of the QML code supports the user interface for this application with the
camera types being mostly found in \e {declarative-camera.qml} and
\e {CaptureControls.qml}.
In \e {declarative-camera.qml} the \l Camera is initialized with an id
of \e {camera}, a photo preview is setup, states are implemented for image
preview or capture and \l CaptureControls is initialized. The initial
\e state is \e PhotoCapture. \l CameraCapture includes a handler, \e onImageCaptured,
for the \l {imageCaptured} signal. The handler sets up the application to process
the preview including a change in the user interface state. The \l PhotoPreview
becomes visible with any key press being picked up by the handler
in PhotoPreview and returning the state to \e PhotoCapture.
\e CaptureControls, which is implemented in \e {CaptureControls.qml},
generates a column on the right hand side of the screen which includes control
buttons for \e focus (not initially visible), \e {capture}, \e {flash modes},
\e {white balance}, \e {exposure compensation}, and if a preview is
available a \e {preview} button. The last button exits from the application.
When the Capture button is pressed the \e onClicked handler calls
\l {Camera::captureImage()}{captureImage()}
*/

View File

@@ -0,0 +1,35 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example declarative-radio
\title Declarative Radio Example
*/

View File

@@ -0,0 +1,96 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example player
\title Media Player Example
\ingroup video_examples
This example creates a simple multimedia player. We can play audio and
or video files using various codecs.
The example uses a QMediaPlayer object passed into a QVideoWidget to
control the video output. To give the application playlist capability
we also use a QPlayList object.
To activate the various functions such as play and stop on the dialog
we connect clicked() signals to slots that emit the play() and stop()
signals and in turn which we connect to the play() and stop() slots in
QMediaPlayer.
\code
connect(controls, SIGNAL(play()), player, SLOT(play()));
connect(controls, SIGNAL(pause()), player, SLOT(pause()));
connect(controls, SIGNAL(stop()), player, SLOT(stop()));
\endcode
We can get the volume (and set our user interface representation)
\code
controls->setVolume(player->volume());
\endcode
and we can make widget 'volume' changes change the volume
\code
connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
\endcode
The example also allows us to change various video properties by means
of the QVideoWidget object. We can go to Full Screen mode with a single
button click, and back again. Or if we press the "Color Options" dialog
button we can have access to more subtle influences. The dialog has a
set of sliders so that we can change the brightness, contrast, hue and
saturation of the video being watched. The connect() statements are in
pairs so that changes to either the user interface widget (the relevant
slider) or the QVideoWidget object will update the other object.
\code
connect(brightnessSlider, SIGNAL(sliderMoved(int)), videoWidget,
SLOT(setBrightness(int)));
connect(videoWidget, SIGNAL(brightnessChanged(int)),
brightnessSlider, SLOT(setValue(int)));
connect(contrastSlider, SIGNAL(sliderMoved(int)), videoWidget,
SLOT(setContrast(int)));
connect(videoWidget, SIGNAL(contrastChanged(int)), contrastSlider,
SLOT(setValue(int)));
connect(hueSlider, SIGNAL(sliderMoved(int)), videoWidget,
SLOT(setHue(int)));
connect(videoWidget, SIGNAL(hueChanged(int)), hueSlider,
SLOT(setValue(int)));
connect(saturationSlider, SIGNAL(sliderMoved(int)), videoWidget,
SLOT(setSaturation(int)));
connect(videoWidget, SIGNAL(saturationChanged(int)),
saturationSlider, SLOT(setValue(int)));
\endcode
*/

View File

@@ -0,0 +1,148 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example video/qmlvideo
\title QML Video Example
\ingroup video_examples_qml
\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{video/qmlvideo/qml/qmlvideo/main.qml} file creates a UI which includes
the following items:
\list
\li Two \l{video/qmlvideo/qml/qmlvideo/Button.qml}{Button} instances, each
of which displays a filename, and can be used to launch a
\l{video/qmlvideo/qml/qmlvideo/FileBrowser.qml}{FileBrowser}
\li An exit \l{video/qmlvideo/qml/qmlvideo/Button.qml}{Button}
\li A \l{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{video/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{video/qmlvideo/qml/qmlvideo/VideoBasic.qml}{VideoBasic} item ...
\quotefromfile video/qmlvideo/qml/qmlvideo/VideoBasic.qml
\skipto import
\printuntil /^\}/
... is-a
\l{video/qmlvideo/qml/qmlvideo/SceneBasic.qml}{SceneBasic} ...
\quotefromfile examples/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
\skipto import
\printuntil contentType
\dots
\skipto Content
\printuntil content
\dots
\skipto }
\printuntil /^\}/
... which is-a
\l{video/qmlvideo/qml/qmlvideo/Scene.qml}{Scene}:
\quotefromfile video/qmlvideo/qml/qmlvideo/Scene.qml
\skipto import
\printuntil root
\dots
\skipto property QtObject content
\printuntil content
\dots
\skipto Button
\printuntil /^\}/
\l{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{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{video/qmlvideo/qml/qmlvideo/VideoBasic.qml}{VideoBasic}) and cameracontent
(\l{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{video/qmlvideo/qml/qmlvideo/SceneMove.qml}{SceneMove}, on which
\l{video/qmlvideo/qml/qmlvideo/VideoMove.qml}{VideoMove} and
\l{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{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 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 video/qmlvideo/main.cpp
\skipto QmlApplicationViewer
\printuntil ;
\dots
\skipto QQuickItem
\printuntil ;
\dots
\skipto QObject::connect
\printuntil SLOT(qmlFramePainted()));
*/

View File

@@ -0,0 +1,223 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example video/qmlvideofx
\title QML Video Shader Effects Example
\ingroup video_examples_qml
\ingroup camera_examples_qml
\brief The QML Video Shader Effects Example shows how \l {ShaderEffect}
can be used to apply postprocessing effects, expressed in \c GLSL, to video
and camera viewfinder content.
\section1 Overview
This example shows how a \l {ShaderEffectItem} can be used to apply
postprocessing effects, expressed in GLSL, 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.
Finally, this application demonstrates the use of different top-level QML
files to handle different physical screen sizes. On small-screen devices,
menus are by default hidden, and only appear when summoned by a gesture.
Large-screen devices show a more traditional layout in which menus are
displayed around the video content pane.
The following screenshots show shader effects being applied. In each case,
the effect is implemented using a fragment shader.
Here we see an edge detection algorithm being applied to a video clip
(\l{http://orange.blender.org/}{Elephant's Dream from blender.org}).
\image qmlvideofx-video-edgedetection.png
This image shows a page curl effect, applied to the same video clip.
\image qmlvideofx-video-pagecurl.png
Here we see a 'glow' effect (edge detection plus colour quantization) being
applied to the camera viewfinder.
\image qmlvideofx-camera-glow.png
This image shows a 'lens magnification' effect applied to the viewfinder.
\image qmlvideofx-camera-magnify.png
The application includes many more effects than the ones shown here - look
for Effect*.qml files in the list above to see the full range.
\section1 Application structure
Shader effects can be applied to video or viewfinder content using
\l{ShaderEffectItem}, as shown in the following example, which applies
a wiggly effect to the content:
\code
import QtQuick 2.0
import QtMultimedia 5.0
Rectangle {
width: 300
height: 300
color: "black"
MediaPlayer {
id: mediaPlayer
source: "test.mp4"
playing: true
}
VideoOutput {
id: video
anchors.fill: parent
source: mediaPlayer
}
ShaderEffect {
property variant source: ShaderEffectSource { sourceItem: video; hideSource: true }
property real wiggleAmount: 0.005
anchors.fill: video
fragmentShader: "
varying highp vec2 qt_TexCoord0;
uniform sampler2D source;
uniform highp float wiggleAmount;
void main(void)
{
highp vec2 wiggledTexCoord = qt_TexCoord0;
wiggledTexCoord.s += sin(4.0 * 3.141592653589 * wiggledTexCoord.t) * wiggleAmount;
gl_FragColor = texture2D(source, wiggledTexCoord.st);
}
"
}
}
\endcode
In this application, the usage of the \l{ShaderEffect} and \l{VideoOutput}
types is a bit more complicated, for the following reasons:
\list
\li Each effect can be applied to either a \l{VideoOutput} or an
\l{Image} item, so the type of the source item must be abstracted away
from the effect implementation
\li For some effects (such as the edge detection and glow examples shown in
the screenshots above), the transformation is applied only to pixels to
the left of a dividing line - this allows the effect to be easily
compared with the untransformed image on the right
\li Most effects have one or more parameters which can be modified by the
user - these are controlled by sliders in the UI which are connected
to uniform values passed into the GLSL code
\endlist
The abstraction of source item type is achieved by the
\l{video/qmlvideofx/qml/qmlvideofx/Content.qml}{Content}, which uses a
\l{Loader} to create either a \l{MediaPlayer}, \l{Camera} or \l{Image}:
\quotefromfile video/qmlvideofx/qml/qmlvideofx/Content.qml
\skipto import
\printuntil {
\dots
\skipto Loader {
\printuntil }
\dots
\skipto function openImage
\printuntil "ContentImage.qml"
\skipto contentLoader.item.source
\printuntil path
\skipto }
\printuntil }
\skipto function openVideo
\printuntil "ContentVideo.qml"
\skipto contentLoader.item.mediaSource
\printuntil path
\skipto }
\printuntil }
\skipto function openCamera
\printuntil "ContentCamera.qml"
\skipto }
\printuntil }
\skipto /^\}/
\printuntil }
Each effect is implemented as a QML item which is based on the
\l{video/qmlvideofx/qml/qmlvideofx/Effect.qml}{Effect}, which in turn
is based on the \l{ShaderEffect}:
\quotefromfile video/qmlvideofx/qml/qmlvideofx/Effect.qml
\skipto import
\printuntil /^\}/
The interface of the \l Effect allows for derived effects to specify the
number of parameters which they support (and therefore the number of sliders
which should be displayed), and whether a vertical dividing line should be drawn
between transformed and untransformed image regions. As an example, here is the
implementation of the pixelation effect. As you can see, the pixelation effect
supports one parameter (which controls the pixelation granularity), and states
that the divider should be displayed.
\quotefromfile video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml
\skipto import
\printuntil /^\}/
The main.qml file shows a
\l{video/qmlvideofx/qml/qmlvideofx/FileOpen.qml}{FileOpen}, which allows
the user to select the input source and an
\l{video/qmlvideofx/qml/qmlvideofx/EffectSelectionPanel.qml}{EffectSelectionPanel}
item, which lists each of the available shader effects. As described above, a
\l{video/qmlvideofx/qml/qmlvideofx/Content.qml}{Content} item is used to load the
appropriate input and effect type. A
\l{video/qmlvideofx/qml/qmlvideofx/Divider.qml}{Divider} item draws the
vertical dividing line, which can be dragged left / right by the user. Finally,
a \l{video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml}{ParameterPanel} item
renders the sliders corresponding to each effect parameter.
Here is the source selection menu:
\image qmlvideofx-source-menu.png
And here is the effect selection menu:
\image qmlvideofx-effects-menu.png
\section1 Calculating and displaying QML painting rate
\input 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 video/qmlvideofx/main.cpp
\skipto QmlApplicationViewer
\printuntil ;
\dots
\skipto QQuickItem
\printuntil ;
\dots
\skipto QObject::connect
\printuntil SLOT(qmlFramePainted()));
*/

View File

@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example spectrum
\title Spectrum Example
\ingroup audio_examples
\brief The Spectrum Example uses a combination multimedia APIs to process microphone input.
*/

View File

@@ -0,0 +1,43 @@
The QML painting rate is calculated by the FrequencyMonitor class, which
turns a stream of events (received via the notify() slot), into an
instantaneous and an averaged frequency:
\quotefromfile video/snippets/frequencymonitor/frequencymonitor.h
\skipto class FrequencyMonitor : public QObject
\printuntil Q_OBJECT
\skipto Q_PROPERTY(qreal instantaneousFrequency
\printuntil averageFrequencyChanged)
\skipto public
\printuntil :
\dots
\skipto static void qmlRegisterType
\printuntil ;
\skipto public slots
\printuntil notify();
\skipto };
\printline };
The FrequencyMonitor class is exposed to QML like this
\quotefromfile video/snippets/frequencymonitor/frequencymonitordeclarative.cpp
\skipto FrequencyMonitor::qmlRegisterType
\printuntil }
and its data is displayed by defining a QML item called FrequencyItem, like this:
\quotefromfile video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml
\skipto import FrequencyMonitor
\printuntil id: root
\dots
\skipto function notify
\printuntil id: monitor
\skipto onAverageFrequencyChanged
\printuntil {
\skipto averageFrequencyText
\printuntil /^\}/
The result looks like this:
\image video-qml-paint-rate.png

View File

@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example videographicsitem
\title Video Graphics Item Example
\ingroup video_examples
\brief This example demonstrates how to make a simple video player using the QMediaPlayer
and QVideoGraphicsItem classes in the Graphics View framework.
*/

View File

@@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example videowidget
\title Video Widget Example
\ingroup video_examples
\brief This example demonstrates how to make a simple video player using the QMediaPlayer
and QVideoWidget classes
*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -0,0 +1,183 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page multimediaoverview.html
\title Multimedia Overview
\brief A set of APIs for working with audio, video, radio and camera devices.
\ingroup technology-apis
\section1 Overview
\section2 Features
Qt Multimedia offers APIs for doing many multimedia related tasks:
\list
\li Accessing raw audio devices for input and output
\li Play low latency sound effects
\li Play media files in playlists (like compressed audio, or video files)
\li Record audio and compress it
\li Tune and listen to radio stations, and receive radio program information
\li Use a camera, including viewfinder, image capture, and movie recording
\li Play 3D positional audio with \l {Positional Audio} {QtAudioEngine}
\li Decode audio media files into memory for processing
\li Accessing video frames or audio buffers as they are played or recorded
\endlist
\section2 Multimedia Components
All of these tasks can be broadly broken down into four main areas. More information
(including background information and class references) are available here:
\list
\li \l {Audio Overview}
\li \l {Video Overview}
\li \l {Camera Overview}
\li \l {Radio Overview}
\endlist
\section2 Multimedia Recipes
For some quick recipes for specific tasks, look at the overviews above and consult this table:
\table 70%
\header
\li Use case
\li Examples
\li QML Types
\li C++ Classes
\row
\li Playing a sound effect
\li TBD
\li \l SoundEffect
\li QSoundEffect
\row
\li Playing low latency audio
\li \l{audiooutput}, \l{spectrum}
\li
\li QAudioOutput
\row
\li Playing encoded audio (MP3, AAC etc)
\li \l{player}
\li \l Audio, \l {MediaPlayer}
\li QMediaPlayer
\row
\li Accessing raw audio input data
\li \l{spectrum}, \l audioinput
\li
\li QAudioInput
\row
\li Recording encoded audio data
\li \l audiorecorder
\li
\li QAudioRecorder
\row
\li Discovering raw audio devices
\li \l audiodevices
\li
\li QAudioDeviceInfo
\row
\li Video Playback
\li \l {player}, \l {video/qmlvideo}{qmlvideo}, \l{video/qmlvideofx}{qmlvideofx}
\li \l MediaPlayer, \l VideoOutput, \l Video
\li QMediaPlayer, QVideoWidget, QGraphicsVideoItem
\row
\li Video Processing
\li \l {video/qmlvideofx}{qmlvideofx}
\li \l {MediaPlayer}, \l VideoOutput
\li QMediaPlayer, QAbstractVideoSurface, QVideoFrame
\row
\li Listening to the radio
\li \l declarative-radio
\li \l Radio, \l RadioData
\li QRadioTuner, QRadioData
\row
\li Accessing camera viewfinder
\li \l {Camera Example}{camera}, \l declarative-camera
\li \l Camera, \l VideoOutput
\li QCamera, QVideoWidget, QGraphicsVideoItem
\row
\li Viewfinder processing
\li
\li \l Camera, \l VideoOutput
\li QCamera, QAbstractVideoSurface, QVideoFrame
\row
\li Capturing photos
\li \l {Camera Example}{camera}, \l declarative-camera
\li \l Camera
\li QCamera, QCameraImageCapture
\row
\li Capturing movies
\li \l {Camera Example}{camera}, \l declarative-camera
\li \l Camera
\li QCamera, QMediaRecorder
\row
\li 3D sound sources
\li \l {AudioEngine Example}{Audio Engine}
\li \l {AudioEngine}, \l Sound
\li
\endtable
\section1 Limitations
In many cases the Qt Multimedia APIs build upon the multimedia framework of the underlying system.
This can mean that support for various codec or containers can vary between machines,
depending on what the end user has installed.
\section1 Advanced Usage
For developers wishing to access some platform specific settings,
or to port the Qt Multimedia APIs to a new platform or technology,
see \l{Multimedia Backend Development}.
\section1 Changes from Previous Versions
If you've previously used Qt Multimedia in Qt 4.x, or used Qt Multimedia Kit in Qt Mobility, please see
\l {Changes in Qt Multimedia} for more information on what has changed, and what you might need to
change when porting code.
\section1 Reference Documentation
\section2 QML Types
The following types are accessed by using:
\qml
import QtMultimedia 5.0
\endqml
\annotatedlist multimedia_qml
The following types are accessed by using \l {Positional Audio} {QtAudioEngine}:
\qml
import QtAudioEngine 1.0
\endqml
\annotatedlist multimedia_audioengine
\section2 Multimedia Classes
\annotatedlist multimedia
*/

View File

@@ -0,0 +1,140 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\title Multimedia Backend Development
\page multimediabackend.html
\brief Information for implementing a new multimedia backend.
\ingroup mobility
\tableofcontents
\section1 Overview
A multimedia backend provides the glue between platform specific libraries, and
Qt Multimedia. In some cases the available cross-platform Multimedia APIs or
implementations are not sufficient, or not immediately available on a certain
platform. Alternatively, the multimedia implementation on a platform might expose
certain extra properties or functionality that other platforms do not, or a finer
degree of control might be possible. For these cases, it is possible to use
extended controls directly.
In addition, if you plan to port the Qt Multimedia APIs to a new platform, you do
this by implementing certain control and service classes, as detailed below.
\section1 Extending the API
For the developer who wishes to extend the functionality of the Qt Multimedia
classes there are several classes of particular importance. The classes
providing default functionality are QMediaService, QMediaServiceProvider and
QMediaControl. Some of these classes are not in the public API since they
are very seldom useful to application developers.
To extend the Multimedia API you would use the following three classes or
classes derived from them.
\list
\li QMediaServiceProvider is used by the top level client class to
request a service. The top level class knowing what kind of service it needs.
\li \l QMediaService provides a service and when asked by the top level
object, say a component, will return a QMediaControl object.
\li \l QMediaControl allows the control of the service using a known interface.
\endlist
Consider a developer creating, for example, a media player class called MyPlayer.
It may have special requirements beyond ordinary media players and so may
need a custom service and a custom control. We can subclass \l QMediaServiceProvider
to create our MyServiceProvider class. Also we will create a
MyMediaService, and the MyMediaControl to manipulate the media service.
The MyPlayer object calls MyServiceProvider::requestService() to get an
instance of MyMediaService. Then the MyPlayer object calls this service
object it has just received and calling \l {QMediaService::requestControl()}{requestControl()}
it will receive the control object derived from QMediaControl.
Now we have all the parts necessary for our media application. We have the service
provider, the service it provides and the control used to manipulate the
service. Since our MyPlayer object has instances of the service and its
control then it would be possible for these to be used by associated classes
that could do additional actions, perhaps with their own control since the
parameter to requestControl() is a zero-terminated string, \e {const char *},
for the interface.
\section2 Adding a Media Service Provider
In general, adding a new media service provider is outside the scope of this documentation.
For best results, consult the existing provider source code, and seek assistance on the relevant
mailing lists and IRC channels.
\omit
The base class for creating new service providers is \l{QMediaServiceProvider}.
The user must implement the \l{QMediaServiceProvider::requestService()}{requestService()}
function
\code
QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint);
\endcode
The details of implementation will depend on the provider. Looking at the
class \l QMediaServiceProvider for the default implementation. Notice that
\l {QMediaServiceProvider::requestService()}{requestService()} uses the
\l QMediaServiceProviderHint to look for the appropriate plugin and then to
insert it into the plugin map. However, for a specific service provider there
is probably no need for this approach, it will simply depend on what the
developer wants to implement.
Other methods that may be overloaded
\code
void releaseService(QMediaService *service);
QtMediaServices::SupportEstimate hasSupport(const QByteArray &serviceType,
const QString &mimeType,
const QStringList& codecs,
int flags) const;
QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const;
QList<QByteArray> devices(const QByteArray &serviceType) const;
QString deviceDescription(const QByteArray &serviceType, const QByteArray &device);
\endcode
The choice of what needs to be done depends on what the developer wishes to do with the service.
\endomit
\section2 Classes for service implementers.
\annotatedlist multimedia_control
*/

View File

@@ -0,0 +1,229 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\group qml-multimedia
\title QML Multimedia Plugin
QML Support for the Qt Multimedia API.
*/
/*!
\page qml-multimedia.html
\title Qt Multimedia QML API
\brief A QML API for the Qt Multimedia module.
\section1 Overview
The Qt Multimedia module gives developers a simplified way to use audio and video playback, and access camera functionality. The Multimedia QML API provides a QML friendly interface to these features.
\section1 Types
\section2 Audio
\l Audio is an easy way to add audio playback to a Qt Quick
scene. QtMultimedia provides properties for control, methods (functions) and signals.
The code extract below shows the creation and use of an Audio instance.
\qml
import QtQuick 2.0
import QtMultimedia 5.0
// ...
Item {
width: 640
height: 360
Audio {
id: playMusic
source: "music.wav"
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: { playMusic.play() }
}
}
\endqml
The snippet above shows how the inclusion of \e playMusic enables audio features on the type that contains it. So that when the parent's MouseArea is clicked the \l {Audio::play()}{play()} method of Audio is run. Other typical audio control methods are available such as \l {Audio::pause}{pause()} and \l {Audio::stop()}{stop()}.
Much of the getting / setting of \l Audio parameters is done through properties. These include
\table 70%
\header
\li Property
\li Description
\row
\li \l {Audio::source}{source}
\li The source URL of the media.
\row
\li \l {Audio::autoLoad}{autoLoad}
\li Indicates if loading of media should begin immediately.
\row
\li \l{Audio::playing}{playing}
\li Indicates that the media is playing.
\row
\li \l {Audio::paused}{paused}
\li The media is paused.
\row
\li \l{Audio::status}{status}
\li The status of media loading.
\row
\li \l{Audio::duration}{duration}
\li Amount of time in milliseconds the media will play.
\row
\li \l{Audio::position}{position}
\li Current position in the media in milliseconds of play.
\row
\li \l{Audio::volume}{volume}
\li Audio output volume: from 0.0 (silent) to 1.0 (maximum)
\row
\li \l{Audio::muted}{muted}
\li Indicates audio is muted.
\row
\li \l{Audio::bufferProgress}{bufferProgress}
\li Indicates how full the data buffer is: 0.0 (empty) to 1.0 (full).
\row
\li \l{Audio::seekable}{seekable}
\li Indicates whether the audio position can be changed.
\row
\li \l{Audio::playbackRate}{playbackRate}
\li The rate at which audio is played at as a multiple of the normal rate.
\row
\li \l{Audio::error}{error}
\li An error code for the error state including NoError
\row
\li \l{Audio::errorString}{errorString}
\li A description of the current error condition.
\endtable
The set of signals available allow the developer to create custom behavior when the following events occur,
\table 70%
\header
\li Signal
\li Description
\row
\li \l{Audio::playing}{playing}
\li Called when playback is started, or when resumed from paused state.
\row
\li \l{Audio::paused}{paused}
\li Called when playback is paused.
\row
\li \l{Audio::stopped}{stopped}
\li Called when playback is stopped.
\row
\li \l{Audio::error}{error}
\li Called when the specified error occurs.
\endtable
\section2 Camera
\l Camera enables still image and video capture using
QML. It has a number of properties that help setting it up.
The details of using a \l Camera are described in further depth
in the \l {Camera Overview} and in the corresponding reference documentation.
\section2 Video
Adding video playback, with sound, to a Qt Quick scene is also easy. The process is very similar to that of Audio above, in fact \l {Video} shares many of the property names, methods and signals. Here is the equivalent sample code to implement video playback in a scene
\qml
Video {
id: video
width : 800
height : 600
source: "video.avi"
MouseArea {
anchors.fill: parent
onClicked: {
video.play()
}
}
focus: true
Keys.onSpacePressed: video.paused = !video.paused
Keys.onLeftPressed: video.position -= 5000
Keys.onRightPressed: video.position += 5000
}
\endqml
There are similar features like \l {Video::play()}{play()} with new
features specific to video.
In the above sample when the parent of MouseArea is clicked, an area of 800x600 pixels with an id of 'video', the source "video.avi" will play in that area. Notice also that signals for the \l Keys have been defined so that a spacebar will toggle the pause button; the left arrow will move the current position in the video to 5 seconds previously; and the right arrow will advance the current position in the video by 5 seconds.
Most of the differences will obviously be about video control and information. There are many properties associated with \l {Video}, most of them deal with meta-data, control of the video media and aspects of presentation.
\section2 SoundEffect
\l SoundEffect provides a way to play short sound effects, like in video games. Multiple sound effect instances can be played simultaneously.
You should use \l Audio for music playback.
\qml
import QtQuick 2.0
import QtMultimedia 5.0
Item {
width: 640
height: 360
SoundEffect {
id: effect
source: "test.wav"
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: { effect.play() }
}
}
\endqml
In the above sample the sound effect will be played when the MouseArea is clicked.
For a complete description of this type, see \l SoundEffect
\section1 Multimedia QML Types
\annotatedlist multimedia_qml
*/

View File

@@ -0,0 +1,45 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\module QtMultimedia
\title QtMultimedia Module
\ingroup modules
\brief The QtMultimedia module provides audio, video, radio and camera functionality.
To include the definitions of the module's classes, use the
following directive:
\snippet doc/src/snippets/code/doc_src_qtmultimedia.cpp 1
To link against the module, add this line to your \l qmake \c
.pro file:
\snippet doc/src/snippets/code/doc_src_qtmultimedia.pro 0
*/

View File

@@ -0,0 +1,42 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\qmlmodule QtMultimedia 5
\title QML import for multimedia
\brief The import for the QML types in the Qt Multimedia module
\section1 Overview
The identifying string for this component is \e QtMultimedia. Use this in the QML \e import statement.
\section1 QML types
\annotatedlist multimedia_qml
*/

View File

@@ -0,0 +1,89 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page radiooverview.html
\title Radio Overview
\brief An API to control system radio tuner
The Qt Multimedia API provides a number of radio related classes for control
over the radio tuner of the system, and gives access to Radio Data System
(RDS) information for radio stations that broadcasts it.
\section1 Radio Features
The Radio API consists of two separate components. The radio tuner,
\l QRadioTuner or the \l Radio QML type, which handles control of
the radio hardware as well as tuning. The other is the radio data
component, either \l QRadioData or the \l RadioData QML type, which
gives access to RDS information.
\section1 Radio Implementation Details
The actual level of support depends on the underlying system support. It should
be noted that only analog radio is supported, and the properties of the radio
data component will only be populated if the system radio tuner supports RDS.
\section1 Examples
There are two examples showing the usage of the Radio API. One shows how to use
the QRadioTuner class from C++. The other shows how to implement a similar
application using QML and \l Radio.
\section2 Radio Example
This image shows the example using the QRadioTuner API.
\image radio-example.png
The example reads the frequency from the radio tuner, and sets the "Got Signal"
text based on the signal strength. The buttons allow the user to tune and scan
up and down the frequency band, while the slider to the side allows volume
adjustments.
Only the FM frequency band is used in this example.
\section2 Declarative Radio Example
\image declarative-radio-example.png
This example has the same functionality of the regular radio example mentioned
above, but it includes a nice horizontal dial showing the position of the
current frequency inside the band.
\section1 Reference documentation
\section2 C++ Classes
\annotatedlist multimedia_radio
\section2 QML Types
\annotatedlist multimedia_radio_qml
*/

View File

@@ -0,0 +1,251 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Audio related snippets */
#include <QFile>
#include <QTimer>
#include <QDebug>
#include "qaudiodeviceinfo.h"
#include "qaudioinput.h"
#include "qaudiooutput.h"
#include "qaudioprobe.h"
#include "qaudiodecoder.h"
class AudioInputExample : public QObject {
Q_OBJECT
public:
void setup();
public Q_SLOTS:
void stopRecording();
void stateChanged(QAudio::State newState);
private:
//! [Audio input class members]
QFile destinationFile; // class member.
QAudioInput* audio; // class member.
//! [Audio input class members]
};
void AudioInputExample::setup()
//! [Audio input setup]
{
destinationFile.setFileName("/tmp/test.raw");
destinationFile.open( QIODevice::WriteOnly | QIODevice::Truncate );
QAudioFormat format;
// set up the format you want, eg.
format.setSampleRate(8000);
format.setChannelCount(1);
format.setSampleSize(8);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
if (!info.isFormatSupported(format)) {
qWarning()<<"default format not supported try to use nearest";
format = info.nearestFormat(format);
}
audio = new QAudioInput(format, this);
connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(stateChanged(QAudio::State)));
QTimer::singleShot(3000, this, SLOT(stopRecording()));
audio->start(&destinationFile);
// Records audio for 3000ms
}
//! [Audio input setup]
//! [Audio input stop recording]
void AudioInputExample::stopRecording()
{
audio->stop();
destinationFile.close();
delete audio;
}
//! [Audio input stop recording]
//! [Audio input state changed]
void AudioInputExample::stateChanged(QAudio::State newState)
{
switch (newState) {
case QAudio::StoppedState:
if (audio->error() != QAudio::NoError) {
// Error handling
} else {
// Finished recording
}
break;
case QAudio::ActiveState:
// Started recording - read from IO device
break;
default:
// ... other cases as appropriate
break;
}
}
//! [Audio input state changed]
class AudioOutputExample : public QObject {
Q_OBJECT
public:
void setup();
public Q_SLOTS:
void stateChanged(QAudio::State newState);
private:
//! [Audio output class members]
QFile sourceFile; // class member.
QAudioOutput* audio; // class member.
//! [Audio output class members]
};
void AudioOutputExample::setup()
//! [Audio output setup]
{
sourceFile.setFileName("/tmp/test.raw");
sourceFile.open(QIODevice::ReadOnly);
QAudioFormat format;
// Set up the format, eg.
format.setSampleRate(8000);
format.setChannelCount(1);
format.setSampleSize(8);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
qWarning() << "raw audio format not supported by backend, cannot play audio.";
return;
}
audio = new QAudioOutput(format, this);
connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(stateChanged(QAudio::State)));
audio->start(&sourceFile);
}
//! [Audio output setup]
//! [Audio output state changed]
void AudioOutputExample::stateChanged(QAudio::State newState)
{
switch (newState) {
case QAudio::IdleState:
// Finished playing (no more data)
audio->stop();
sourceFile.close();
delete audio;
break;
case QAudio::StoppedState:
// Stopped for other reasons
if (audio->error() != QAudio::NoError) {
// Error handling
}
break;
default:
// ... other cases as appropriate
break;
}
}
//! [Audio output state changed]
void AudioDeviceInfo()
{
//! [Setting audio format]
QAudioFormat format;
format.setSampleRate(44100);
// ... other format parameters
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format))
format = info.nearestFormat(format);
//! [Setting audio format]
//! [Dumping audio formats]
foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
qDebug() << "Device name: " << deviceInfo.deviceName();
//! [Dumping audio formats]
}
class AudioDecodingExample : public QObject {
Q_OBJECT
public:
void decode();
public Q_SLOTS:
void stateChanged(QAudio::State newState);
void readBuffer();
};
void AudioDecodingExample::decode()
{
//! [Local audio decoding]
QAudioFormat desiredFormat;
desiredFormat.setChannelCount(2);
desiredFormat.setCodec("audio/x-raw");
desiredFormat.setSampleType(QAudioFormat::UnSignedInt);
desiredFormat.setSampleRate(48000);
desiredFormat.setSampleSize(16);
QAudioDecoder *decoder = new QAudioDecoder(this);
decoder->setAudioFormat(desiredFormat);
decoder->setSourceFilename("level1.mp3");
connect(decoder, SIGNAL(bufferReady()), this, SLOT(readBuffer()));
decoder->start();
// Now wait for bufferReady() signal and call decoder->read()
//! [Local audio decoding]
}

View File

@@ -0,0 +1,213 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include <qaudiorecorder.h>
#include <qmediaservice.h>
#include <QtMultimedia/qaudioformat.h>
#include "audiorecorder.h"
AudioRecorder::AudioRecorder()
{
//! [create-objs-1]
capture = new QAudioRecorder();
//! [create-objs-1]
// set a default file
capture->setOutputLocation(QUrl("test.raw"));
QWidget *window = new QWidget;
QGridLayout* layout = new QGridLayout;
QLabel* deviceLabel = new QLabel;
deviceLabel->setText("Devices");
deviceBox = new QComboBox(this);
deviceBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
QLabel* codecLabel = new QLabel;
codecLabel->setText("Codecs");
codecsBox = new QComboBox(this);
codecsBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
QLabel* qualityLabel = new QLabel;
qualityLabel->setText("Quality");
qualityBox = new QComboBox(this);
qualityBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
//! [device-list]
for(int i = 0; i < audiosource->deviceCount(); i++)
deviceBox->addItem(audiosource->name(i));
//! [device-list]
//! [codec-list]
QStringList codecs = capture->supportedAudioCodecs();
for(int i = 0; i < codecs.count(); i++)
codecsBox->addItem(codecs.at(i));
//! [codec-list]
qualityBox->addItem("Low");
qualityBox->addItem("Medium");
qualityBox->addItem("High");
connect(capture, SIGNAL(durationChanged(qint64)), this, SLOT(updateProgress(qint64)));
connect(capture, SIGNAL(stateChanged(QMediaRecorder::State)), this, SLOT(stateChanged(QMediaRecorder::State)));
layout->addWidget(deviceLabel,0,0,Qt::AlignHCenter);
connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int)));
layout->addWidget(deviceBox,0,1,1,3,Qt::AlignLeft);
layout->addWidget(codecLabel,1,0,Qt::AlignHCenter);
connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int)));
layout->addWidget(codecsBox,1,1,Qt::AlignLeft);
layout->addWidget(qualityLabel,1,2,Qt::AlignHCenter);
connect(qualityBox,SIGNAL(activated(int)),SLOT(qualityChanged(int)));
layout->addWidget(qualityBox,1,3,Qt::AlignLeft);
fileButton = new QPushButton(this);
fileButton->setText(tr("Output File"));
connect(fileButton,SIGNAL(clicked()),SLOT(selectOutputFile()));
layout->addWidget(fileButton,3,0,Qt::AlignHCenter);
button = new QPushButton(this);
button->setText(tr("Record"));
connect(button,SIGNAL(clicked()),SLOT(toggleRecord()));
layout->addWidget(button,3,3,Qt::AlignHCenter);
recTime = new QLabel;
recTime->setText("0 sec");
layout->addWidget(recTime,4,0,Qt::AlignHCenter);
window->setLayout(layout);
setCentralWidget(window);
window->show();
active = false;
}
AudioRecorder::~AudioRecorder()
{
delete capture;
delete audiosource;
}
void AudioRecorder::updateProgress(qint64 pos)
{
currentTime = pos;
if(currentTime == 0) currentTime = 1;
QString text = QString("%1 secs").arg(currentTime/1000);
recTime->setText(text);
}
void AudioRecorder::stateChanged(QMediaRecorder::State state)
{
qWarning()<<"stateChanged() "<<state;
}
void AudioRecorder::deviceChanged(int idx)
{
//! [get-device]
for(int i = 0; i < audiosource->deviceCount(); i++) {
if(deviceBox->itemText(idx).compare(audiosource->name(i)) == 0)
audiosource->setSelectedDevice(i);
}
//! [get-device]
}
void AudioRecorder::codecChanged(int idx)
{
Q_UNUSED(idx);
//capture->setAudioCodec(codecsBox->itemText(idx));
}
void AudioRecorder::qualityChanged(int idx)
{
Q_UNUSED(idx);
/*
if(capture->audioCodec().compare("audio/pcm") == 0) {
if(qualityBox->itemText(idx).compare("Low") == 0) {
// 8000Hz mono is 8kbps
capture->setAudioBitrate(8);
} else if(qualityBox->itemText(idx).compare("Medium") == 0) {
// 22050Hz mono is 44.1kbps
capture->setAudioBitrate(44);
} else if(qualityBox->itemText(idx).compare("High") == 0) {
// 44100Hz mono is 88.2kbps
capture->setAudioBitrate(88);
}
}
*/
}
//! [toggle-record]
void AudioRecorder::toggleRecord()
{
if(!active) {
recTime->setText("0 sec");
currentTime = 0;
capture->record();
button->setText(tr("Stop"));
active = true;
} else {
capture->stop();
button->setText(tr("Record"));
active = false;
}
}
//! [toggle-record]
void AudioRecorder::selectOutputFile()
{
QStringList fileNames;
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
if (dialog.exec())
fileNames = dialog.selectedFiles();
if(fileNames.size() > 0)
capture->setOutputLocation(QUrl(fileNames.first()));
}

View File

@@ -0,0 +1,201 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Camera snippets */
#include "qcamera.h"
#include "qcameraviewfinder.h"
#include "qmediarecorder.h"
#include "qcameraimagecapture.h"
#include "qcameraimageprocessing.h"
#include "qabstractvideosurface.h"
/* Globals so that everything is consistent. */
QCamera *camera = 0;
QCameraViewfinder *viewfinder = 0;
QMediaRecorder *recorder = 0;
QCameraImageCapture *imageCapture = 0;
void overview_viewfinder()
{
//! [Camera overview viewfinder]
camera = new QCamera;
viewfinder = new QCameraViewfinder;
camera->setViewfinder(viewfinder);
viewfinder->show();
camera->start(); // to start the viewfinder
//! [Camera overview viewfinder]
}
// -.-
class MyVideoSurface : public QAbstractVideoSurface
{
QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
{
Q_UNUSED(handleType);
return QList<QVideoFrame::PixelFormat>();
}
bool present(const QVideoFrame &frame)
{
Q_UNUSED(frame);
return true;
}
};
void overview_surface()
{
MyVideoSurface *mySurface;
//! [Camera overview surface]
camera = new QCamera;
mySurface = new MyVideoSurface;
camera->setViewfinder(mySurface);
camera->start();
// MyVideoSurface::present(..) will be called with viewfinder frames
//! [Camera overview surface]
}
void overview_still()
{
//! [Camera overview capture]
imageCapture = new QCameraImageCapture(camera);
camera->setCaptureMode(QCamera::CaptureStillImage);
camera->start(); // Viewfinder frames start flowing
//on half pressed shutter button
camera->searchAndLock();
//on shutter button pressed
imageCapture->capture();
//on shutter button released
camera->unlock();
//! [Camera overview capture]
}
void overview_movie()
{
//! [Camera overview movie]
camera = new QCamera;
recorder = new QMediaRecorder(camera);
camera->setCaptureMode(QCamera::CaptureVideo);
camera->start();
//on shutter button pressed
recorder->record();
// sometime later, or on another press
recorder->stop();
//! [Camera overview movie]
}
void camera_blah()
{
//! [Camera]
camera = new QCamera;
viewfinder = new QCameraViewfinder();
viewfinder->show();
camera->setViewfinder(viewfinder);
imageCapture = new QCameraImageCapture(camera);
camera->setCaptureMode(QCamera::CaptureStillImage);
camera->start();
//! [Camera]
//! [Camera keys]
//on half pressed shutter button
camera->searchAndLock();
//on shutter button pressed
imageCapture->capture();
//on shutter button released
camera->unlock();
//! [Camera keys]
}
void cameraimageprocessing()
{
//! [Camera image whitebalance]
camera = new QCamera;
QCameraImageProcessing *imageProcessing = camera->imageProcessing();
if (imageProcessing->isAvailable()) {
imageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceFluorescent);
}
//! [Camera image whitebalance]
//! [Camera image denoising]
imageProcessing->setDenoisingLevel(-0.3); //reduce the amount of denoising applied
//! [Camera image denoising]
}
void camerafocus()
{
//! [Camera custom zoom]
QCameraFocus *focus = camera->focus();
focus->setFocusPointMode(QCameraFocus::FocusPointCustom);
focus->setCustomFocusPoint(QPointF(0.25f, 0.75f)); // A point near the bottom left, 25% away from the corner, near that shiny vase
//! [Camera custom zoom]
//! [Camera combined zoom]
focus->zoomTo(3.0, 4.0); // Super zoom!
//! [Camera combined zoom]
//! [Camera focus zones]
focus->setFocusPointMode(QCameraFocus::FocusPointAuto);
QList<QCameraFocusZone> zones = focus->focusZones();
foreach (QCameraFocusZone zone, zones) {
if (zone.status() == QCameraFocusZone::Focused) {
// Draw a green box at zone.area()
} else if (zone.status() == QCameraFocusZone::Selected) {
// This area is selected for autofocusing, but is not in focus
// Draw a yellow box at zone.area()
}
}
//! [Camera focus zones]
}

View File

@@ -0,0 +1,315 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Media related snippets */
#include <QFile>
#include <QTimer>
#include "qmediaplaylist.h"
#include "qmediarecorder.h"
#include "qmediaservice.h"
#include "qmediaplayercontrol.h"
#include "qmediaplayer.h"
#include "qradiotuner.h"
#include "qradiodata.h"
#include "qvideowidget.h"
#include "qcameraimagecapture.h"
#include "qcamera.h"
#include "qcameraviewfinder.h"
#include "qaudioprobe.h"
#include "qaudiorecorder.h"
#include "qvideoprobe.h"
class MediaExample : public QObject {
Q_OBJECT
void MediaControl();
void MediaPlayer();
void RadioTuna();
void MediaRecorder();
void AudioRecorder();
void EncoderSettings();
void ImageEncoderSettings();
void AudioProbe();
void VideoProbe();
private:
// Common naming
QMediaService *mediaService;
QVideoWidget *videoWidget;
QWidget *widget;
QMediaPlayer *player;
QMediaPlaylist *playlist;
QMediaContent video;
QMediaRecorder *recorder;
QCamera *camera;
QCameraViewfinder *viewfinder;
QCameraImageCapture *imageCapture;
QString fileName;
QRadioTuner *radio;
QRadioData *radioData;
QAudioRecorder *audioRecorder;
QAudioProbe *audioProbe;
QVideoProbe *videoProbe;
QMediaContent image1;
QMediaContent image2;
QMediaContent image3;
static const int yourRadioStationFrequency = 11;
};
void MediaExample::MediaControl()
{
{
//! [Request control]
QMediaPlayerControl *control = qobject_cast<QMediaPlayerControl *>(
mediaService->requestControl("org.qt-project.qt.mediaplayercontrol/5.0"));
//! [Request control]
Q_UNUSED(control);
}
{
//! [Request control templated]
QMediaPlayerControl *control = mediaService->requestControl<QMediaPlayerControl *>();
//! [Request control templated]
Q_UNUSED(control);
}
}
void MediaExample::EncoderSettings()
{
//! [Audio encoder settings]
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/mpeg");
audioSettings.setChannelCount(2);
recorder->setAudioSettings(audioSettings);
//! [Audio encoder settings]
//! [Video encoder settings]
QVideoEncoderSettings videoSettings;
videoSettings.setCodec("video/mpeg2");
videoSettings.setResolution(640, 480);
recorder->setVideoSettings(videoSettings);
//! [Video encoder settings]
}
void MediaExample::ImageEncoderSettings()
{
//! [Image encoder settings]
QImageEncoderSettings imageSettings;
imageSettings.setCodec("image/jpeg");
imageSettings.setResolution(1600, 1200);
imageCapture->setEncodingSettings(imageSettings);
//! [Image encoder settings]
}
void MediaExample::MediaPlayer()
{
//! [Player]
player = new QMediaPlayer;
connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3"));
player->setVolume(50);
player->play();
//! [Player]
//! [Local playback]
player = new QMediaPlayer;
// ...
player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3"));
player->setVolume(50);
player->play();
//! [Local playback]
//! [Audio playlist]
player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
playlist->addMedia(QUrl("http://example.com/myfile1.mp3"));
playlist->addMedia(QUrl("http://example.com/myfile2.mp3"));
// ...
playlist->setCurrentIndex(1);
player->play();
//! [Audio playlist]
//! [Movie playlist]
playlist = new QMediaPlaylist;
playlist->addMedia(QUrl("http://example.com/movie1.mp4"));
playlist->addMedia(QUrl("http://example.com/movie2.mp4"));
playlist->addMedia(QUrl("http://example.com/movie3.mp4"));
playlist->setCurrentIndex(1);
player = new QMediaPlayer;
player->setPlaylist(playlist);
videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);
videoWidget->show();
player->play();
//! [Movie playlist]
}
void MediaExample::MediaRecorder()
{
//! [Media recorder]
recorder = new QMediaRecorder(camera);
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/amr");
audioSettings.setQuality(QtMultimedia::HighQuality);
recorder->setAudioSettings(audioSettings);
recorder->setOutputLocation(QUrl::fromLocalFile(fileName));
recorder->record();
//! [Media recorder]
}
void MediaExample::AudioRecorder()
{
//! [Audio recorder]
audioRecorder = new QAudioRecorder;
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/amr");
audioSettings.setQuality(QtMultimedia::HighQuality);
audioRecorder->setEncodingSettings(audioSettings);
audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));
audioRecorder->record();
//! [Audio recorder]
//! [Audio recorder inputs]
QStringList inputs = audioRecorder->audioInputs();
QString selectedInput = audioRecorder->defaultAudioInput();
foreach (QString input, inputs) {
QString description = audioRecorder->audioInputDescription(input);
// show descriptions to user and allow selection
selectedInput = input;
}
audioRecorder->setAudioInput(selectedInput);
//! [Audio recorder inputs]
}
void MediaExample::RadioTuna()
{
//! [Radio tuner]
radio = new QRadioTuner;
connect(radio, SIGNAL(frequencyChanged(int)), this, SLOT(freqChanged(int)));
if (radio->isBandSupported(QRadioTuner::FM)) {
radio->setBand(QRadioTuner::FM);
radio->setFrequency(yourRadioStationFrequency);
radio->setVolume(100);
radio->start();
}
//! [Radio tuner]
//! [Radio data setup]
radio = new QRadioTuner;
radioData = radio->radioData();
//! [Radio data setup]
}
void MediaExample::AudioProbe()
{
//! [Audio probe]
audioRecorder = new QAudioRecorder;
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/amr");
audioSettings.setQuality(QtMultimedia::HighQuality);
audioRecorder->setEncodingSettings(audioSettings);
audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));
audioProbe = new QAudioProbe(this);
if (audioProbe->setSource(audioRecorder)) {
// Probing succeeded, audioProbe->isValid() should be true.
connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)),
this, SLOT(calculateLevel(QAudioBuffer)));
}
audioRecorder->record();
// Now audio buffers being recorded should be signaled
// by the probe, so we can do things like calculating the
// audio power level, or performing a frequency transform
//! [Audio probe]
}
void MediaExample::VideoProbe()
{
//! [Video probe]
camera = new QCamera;
viewfinder = new QCameraViewfinder();
camera->setViewfinder(viewfinder);
camera->setCaptureMode(QCamera::CaptureVideo);
videoProbe = new QVideoProbe(this);
if (videoProbe->setSource(camera)) {
// Probing succeeded, videoProbe->isValid() should be true.
connect(videoProbe, SIGNAL(videoFrameProbed(QVideoFrame)),
this, SLOT(detectBarcodes(QVideoFrame)));
}
camera->start();
// Viewfinder frames should now also be emitted by
// the video probe, even in still image capture mode.
// Another alternative is to install the probe on a
// QMediaRecorder connected to the camera to get the
// recorded frames, if they are different from the
// viewfinder frames.
//! [Video probe]
}

View File

@@ -0,0 +1,24 @@
# Doc snippets - compiled for truthiness
TEMPLATE = lib
TARGET = qtmmksnippets
INCLUDEPATH += ../../../../src/global \
../../../../src/multimedia \
../../../../src/multimedia/audio \
../../../../src/multimedia/video \
../../../../src/multimedia/camera
CONFIG += console
QT += multimedia multimediawidgets widgets multimedia-private
SOURCES += \
audio.cpp \
video.cpp \
camera.cpp \
media.cpp \
qsound.cpp
OTHER_FILES += \
soundeffect.qml

View File

@@ -0,0 +1,85 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qobject.h"
#include "qsound.h"
#include "qsoundeffect.h"
void qsoundsnippet() {
//! [0]
QSound::play("mysounds/bells.wav");
//! [0]
//! [1]
QSound bells("mysounds/bells.wav");
bells.play();
//! [1]
}
void qsoundeffectsnippet() {
//! [2]
QSoundEffect effect;
effect.setSource(QUrl::fromLocalFile("engine.wav"));
effect.setLoopCount(QSoundEffect::Infinite);
effect.setVolume(0.25f);
effect.play();
//! [2]
}
QObject *clickSource;
class MyGame : public QObject {
Q_OBJECT
public:
//! [3]
MyGame()
: m_explosion(this)
{
m_explosion.setSource(QUrl::fromLocalFile("explosion.wav"));
m_explosion.setVolume(0.25f);
// Set up click handling etc.
connect(clickSource, SIGNAL(clicked()), &m_explosion, SLOT(play()));
}
private:
QSoundEffect m_explosion;
//! [3]
};

View File

@@ -0,0 +1,63 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//! [complete snippet]
import QtQuick 2.0
import QtMultimedia 5.0
Text {
text: "Click Me!";
font.pointSize: 24;
width: 150; height: 50;
//! [play sound on click]
SoundEffect {
id: playSound
source: "soundeffect.wav"
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: { playSound.play() }
}
//! [play sound on click]
}
//! [complete snippet]

View File

@@ -0,0 +1,193 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/* Video related snippets */
#include "qvideorenderercontrol.h"
#include "qmediaservice.h"
#include "qmediaplayer.h"
#include "qabstractvideosurface.h"
#include "qvideowidgetcontrol.h"
#include "qvideowindowcontrol.h"
#include "qgraphicsvideoitem.h"
#include "qmediaplaylist.h"
#include "qvideosurfaceformat.h"
#include <QFormLayout>
#include <QGraphicsView>
//! [Derived Surface]
class MyVideoSurface : public QAbstractVideoSurface
{
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const
{
Q_UNUSED(handleType);
// Return the formats you will support
return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB565;
}
bool present(const QVideoFrame &frame)
{
Q_UNUSED(frame);
// Handle the frame and do your processing
return true;
}
};
//! [Derived Surface]
//! [Video producer]
class MyVideoProducer : public QObject
{
Q_OBJECT
Q_PROPERTY(QAbstractVideoSurface *videoSurface WRITE setVideoSurface)
public:
void setVideoSurface(QAbstractVideoSurface *surface)
{
m_surface = surface;
m_surface->start(m_format);
}
// ...
public slots:
void onNewVideoContentReceived(const QVideoFrame &frame)
{
if (m_surface)
m_surface->present(frame);
}
private:
QAbstractVideoSurface *m_surface;
QVideoSurfaceFormat m_format;
};
//! [Video producer]
class VideoExample : public QObject {
Q_OBJECT
public:
void VideoGraphicsItem();
void VideoRendererControl();
void VideoWidget();
void VideoWindowControl();
void VideoWidgetControl();
private:
// Common naming
QMediaService *mediaService;
QMediaPlaylist *playlist;
QVideoWidget *videoWidget;
QWidget *widget;
QFormLayout *layout;
QAbstractVideoSurface *myVideoSurface;
QMediaPlayer *player;
QMediaContent video;
QGraphicsView *graphicsView;
};
void VideoExample::VideoRendererControl()
{
//! [Video renderer control]
QVideoRendererControl *rendererControl = mediaService->requestControl<QVideoRendererControl *>();
rendererControl->setSurface(myVideoSurface);
//! [Video renderer control]
}
void VideoExample::VideoWidget()
{
//! [Video widget]
player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
playlist->addMedia(QUrl("http://example.com/myclip1.mp4"));
playlist->addMedia(QUrl("http://example.com/myclip2.mp4"));
videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);
videoWidget->show();
playlist->setCurrentIndex(1);
player->play();
//! [Video widget]
player->stop();
//! [Setting surface in player]
player->setVideoOutput(myVideoSurface);
//! [Setting surface in player]
}
void VideoExample::VideoWidgetControl()
{
//! [Video widget control]
QVideoWidgetControl *widgetControl = mediaService->requestControl<QVideoWidgetControl *>();
layout->addWidget(widgetControl->videoWidget());
//! [Video widget control]
}
void VideoExample::VideoWindowControl()
{
//! [Video window control]
QVideoWindowControl *windowControl = mediaService->requestControl<QVideoWindowControl *>();
windowControl->setWinId(widget->winId());
windowControl->setDisplayRect(widget->rect());
windowControl->setAspectRatioMode(Qt::KeepAspectRatio);
//! [Video window control]
}
void VideoExample::VideoGraphicsItem()
{
//! [Video graphics item]
player = new QMediaPlayer(this);
QGraphicsVideoItem *item = new QGraphicsVideoItem;
player->setVideoOutput(item);
graphicsView->scene()->addItem(item);
graphicsView->show();
player->setMedia(QUrl("http://example.com/myclip4.ogv"));
player->play();
//! [Video graphics item]
}

View File

@@ -0,0 +1,3 @@
TEMPLATE = subdirs
SUBDIRS += multimedia-snippets

View File

@@ -0,0 +1,143 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page videooverview.html
\title Video Overview
\brief Video playback
\section1 Video Features
Qt Multimedia offers both high and low level C++ classes for playing and
manipulating video data, and QML types for playback and control. Some
of these classes also overlap with both \l {Camera Overview}{camera} and
\l {Audio Overview}{audio} classes, which can be useful.
\section1 Video Implementation Details
\target multimedia-playing-video
\section2 Playing Video in C++
You can use the \l QMediaPlayer class to decode a video file, and display
it using \l QVideoWidget, \l QGraphicsVideoItem, or a custom class.
Here's an example of using QVideoWidget:
\snippet doc/src/snippets/multimedia-snippets/video.cpp Video widget
And an example with QGraphicsVideoItem:
\snippet doc/src/snippets/multimedia-snippets/video.cpp Video graphics item
\section2 Playing Video in QML
You can use \l VideoOutput to render content that is
provided by either a \l MediaPlayer or a \l Camera.
The VideoOutput is a visual component that can be transformed
or acted upon by shaders (as the \l {QML Video Shader Effects Example} shows), while
all media decoding and playback control is handled by the \l MediaPlayer.
Alternatively there is also a higher level \l Video type that
acts as a single, visual element to play video and control playback.
\section2 Working with Low Level Video Frames
Qt Multimedia offers a number of low level classes to make handling
video frames a bit easier. These classes are primarily used when
writing code that processes video or camera frames (for example,
detecting barcodes, or applying a fancy vignette effect), or needs
to display video in a special way that is otherwise unsupported.
The \l QVideoFrame class encapsulates a video frame and allows the
contents to be mapped into system memory for manipulation or
processing, while deriving a class from \l QAbstractVideoSurface
allows you to receive these frames from \l QMediaPlayer and
\l QCamera.
\snippet doc/src/snippets/multimedia-snippets/video.cpp Derived Surface
and with an instance of this surface, \c myVideoSurface, you can set
the surface as the \l {QMediaPlayer::setVideoOutput()}{video output} for QMediaPlayer.
\snippet doc/src/snippets/multimedia-snippets/video.cpp Setting Surface in Player
Several of the built-in Qt classes offer this functionality
as well, so if you decode video in your application, you can present
it to classes that offer a \l QVideoRendererControl class, and in QML
you can set a custom object for the source of a \l VideoOutput
with either a writable \c videoSurface property (that the instance will
set it's internal video surface to) or a readable \c mediaObject property
with a QMediaObject derived class that implements the \l QVideoRendererControl
interface.
The following snippet shows a class that has a writable \c videoSurface property
and receives frames through a public slot \c onNewVideoContentReceived(). These
frames are then presented on the surface set in \c setVideoSurface().
\snippet doc/src/snippets/multimedia-snippets/video.cpp Video producer
\section2 Recording Video
You can use the \l QMediaRecorder class in conjunction with other
classes to record video to disk. Primarily this is used with
the camera, so consult the \l {Camera Overview} for more information.
\section2 Monitoring Video Frames
You can use the \l QVideoProbe class to access video frames as they
flow through different parts of a media pipeline when using other
classes like \l QMediaPlayer, \l QMediaRecorder or \l QCamera. After
creating the high level media class, you can set the source of the
video probe to that instance. This can be useful for performing
some video processing tasks (like barcode recognition, or object
detection) while the video is rendered normally. You can not affect
the video frames using this class, and they may arrive at a slightly
different time than they are being rendered.
Here's an example of installing a video probe while recording the camera:
\snippet doc/src/snippets/multimedia-snippets/media.cpp Video probe
\section1 Examples
There are both C++ and QML examples available.
\section2 C++ Examples
\annotatedlist video_examples
\section2 QML Examples
\annotatedlist video_examples_qml
\section1 Reference Documentation
\section2 C++ Classes
\annotatedlist multimedia_video
\section2 QML Types
\annotatedlist multimedia_video_qml
*/