summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt11
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/multimedia/CMakeLists.txt21
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.cpp206
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.h102
-rw-r--r--examples/multimedia/audiodecoder/audiodecoder.pro15
-rw-r--r--examples/multimedia/audiodecoder/main.cpp105
-rw-r--r--examples/multimedia/audiodecoder/wavefilewriter.cpp204
-rw-r--r--examples/multimedia/audiodecoder/wavefilewriter.h80
-rw-r--r--examples/multimedia/audiodevices/CMakeLists.txt44
-rw-r--r--examples/multimedia/audiodevices/audiodevices.cpp348
-rw-r--r--examples/multimedia/audiodevices/audiodevices.h73
-rw-r--r--examples/multimedia/audiodevices/audiodevicesbase.ui251
-rw-r--r--examples/multimedia/audiodevices/doc/src/audiodevices.qdoc33
-rw-r--r--examples/multimedia/audiodevices/main.cpp55
-rw-r--r--examples/multimedia/audioinput/audioinput.cpp359
-rw-r--r--examples/multimedia/audioinput/audioinput.h138
-rw-r--r--examples/multimedia/audioinput/audioinput.pro13
-rw-r--r--examples/multimedia/audioinput/doc/src/audioinput.qdoc45
-rw-r--r--examples/multimedia/audioinput/main.cpp64
-rw-r--r--examples/multimedia/audiooutput/CMakeLists.txt38
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp188
-rw-r--r--examples/multimedia/audiooutput/audiooutput.h67
-rw-r--r--examples/multimedia/audiooutput/doc/src/audiooutput.qdoc37
-rw-r--r--examples/multimedia/audiooutput/main.cpp55
-rw-r--r--examples/multimedia/audiorecorder/CMakeLists.txt51
-rw-r--r--examples/multimedia/audiorecorder/Info.plist.in44
-rw-r--r--examples/multimedia/audiorecorder/audiolevel.cpp56
-rw-r--r--examples/multimedia/audiorecorder/audiolevel.h53
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.cpp411
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.h79
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.pro1
-rw-r--r--examples/multimedia/audiorecorder/audiorecorder.ui8
-rw-r--r--examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc92
-rw-r--r--examples/multimedia/audiorecorder/main.cpp53
-rw-r--r--examples/multimedia/audiosource/CMakeLists.txt43
-rw-r--r--examples/multimedia/audiosource/Info.plist.in44
-rw-r--r--examples/multimedia/audiosource/audiosource.cpp251
-rw-r--r--examples/multimedia/audiosource/audiosource.h94
-rw-r--r--examples/multimedia/audiosource/audiosource.pro13
-rw-r--r--examples/multimedia/audiosource/doc/images/audiosource-example.png (renamed from examples/multimedia/audioinput/doc/images/audioinput-example.png)bin10383 -> 10383 bytes
-rw-r--r--examples/multimedia/audiosource/doc/src/audiosource.qdoc24
-rw-r--r--examples/multimedia/audiosource/main.cpp17
-rw-r--r--examples/multimedia/camera/CMakeLists.txt81
-rw-r--r--examples/multimedia/camera/android/AndroidManifest.xml39
-rw-r--r--examples/multimedia/camera/camera.cpp421
-rw-r--r--examples/multimedia/camera/camera.h104
-rw-r--r--examples/multimedia/camera/camera.pro40
-rw-r--r--examples/multimedia/camera/camera.qrc (renamed from examples/multimediawidgets/camera/camera.qrc)0
-rw-r--r--examples/multimedia/camera/camera.ui (renamed from examples/multimediawidgets/camera/camera.ui)285
-rw-r--r--examples/multimedia/camera/camera_mobile.ui504
-rw-r--r--examples/multimedia/camera/doc/images/camera-example.pngbin0 -> 151290 bytes
-rw-r--r--examples/multimedia/camera/doc/src/camera.qdoc92
-rw-r--r--examples/multimedia/camera/images/shutter.svg (renamed from examples/multimediawidgets/camera/images/shutter.svg)0
-rw-r--r--examples/multimedia/camera/imagesettings.cpp84
-rw-r--r--examples/multimedia/camera/imagesettings.h41
-rw-r--r--examples/multimedia/camera/imagesettings.ui (renamed from examples/multimediawidgets/camera/imagesettings.ui)0
-rw-r--r--examples/multimedia/camera/ios/Info.plist.in50
-rw-r--r--examples/multimedia/camera/macos/Info.plist.in49
-rw-r--r--examples/multimedia/camera/main.cpp16
-rw-r--r--examples/multimedia/camera/metadatadialog.cpp107
-rw-r--r--examples/multimedia/camera/metadatadialog.h31
-rw-r--r--examples/multimedia/camera/videosettings.cpp196
-rw-r--r--examples/multimedia/camera/videosettings.h42
-rw-r--r--examples/multimedia/camera/videosettings.ui213
-rw-r--r--examples/multimedia/camera/videosettings_mobile.ui207
-rw-r--r--examples/multimedia/declarative-camera/CMakeLists.txt79
-rw-r--r--examples/multimedia/declarative-camera/CameraButton.qml53
-rw-r--r--examples/multimedia/declarative-camera/CameraListButton.qml96
-rw-r--r--examples/multimedia/declarative-camera/CameraListPopup.qml73
-rw-r--r--examples/multimedia/declarative-camera/CameraPropertyButton.qml90
-rw-r--r--examples/multimedia/declarative-camera/CameraPropertyPopup.qml73
-rw-r--r--examples/multimedia/declarative-camera/FlashControl.qml65
-rw-r--r--examples/multimedia/declarative-camera/FocusButton.qml72
-rw-r--r--examples/multimedia/declarative-camera/Info.plist72
-rw-r--r--examples/multimedia/declarative-camera/Info.plist.in46
-rw-r--r--examples/multimedia/declarative-camera/PhotoCaptureControls.qml263
-rw-r--r--examples/multimedia/declarative-camera/PhotoPreview.qml54
-rw-r--r--examples/multimedia/declarative-camera/Popup.qml57
-rw-r--r--examples/multimedia/declarative-camera/VideoCaptureControls.qml270
-rw-r--r--examples/multimedia/declarative-camera/VideoPreview.qml70
-rw-r--r--examples/multimedia/declarative-camera/ZoomControl.qml56
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.pro1
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qml147
-rw-r--r--examples/multimedia/declarative-camera/declarative-camera.qrc2
-rw-r--r--examples/multimedia/declarative-camera/doc/images/CaptureControls.pngbin0 -> 41278 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/FlashControls.pngbin0 -> 69725 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.pngbin0 -> 35913 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/ZoomControl.pngbin0 -> 28291 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/qml-camera.pngbin28409 -> 51620 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.pngbin0 -> 49057 bytes
-rw-r--r--examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc186
-rw-r--r--examples/multimedia/declarative-camera/permission-denied.qml20
-rw-r--r--examples/multimedia/declarative-camera/qmlcamera.cpp89
-rw-r--r--examples/multimedia/multimedia.pro13
-rw-r--r--examples/multimedia/player/CMakeLists.txt42
-rw-r--r--examples/multimedia/player/doc/images/mediaplayerex.jpg (renamed from examples/multimediawidgets/player/doc/images/mediaplayerex.jpg)bin28825 -> 28825 bytes
-rw-r--r--examples/multimedia/player/doc/src/player.qdoc49
-rw-r--r--examples/multimedia/player/main.cpp37
-rw-r--r--examples/multimedia/player/player.cpp554
-rw-r--r--examples/multimedia/player/player.h105
-rw-r--r--examples/multimedia/player/player.pro (renamed from examples/multimediawidgets/player/player.pro)12
-rw-r--r--examples/multimedia/player/playercontrols.cpp (renamed from examples/multimediawidgets/player/playercontrols.cpp)95
-rw-r--r--examples/multimedia/player/playercontrols.h62
-rw-r--r--examples/multimedia/player/playlistmodel.cpp105
-rw-r--r--examples/multimedia/player/playlistmodel.h50
-rw-r--r--examples/multimedia/player/qmediaplaylist.cpp643
-rw-r--r--examples/multimedia/player/qmediaplaylist.h95
-rw-r--r--examples/multimedia/player/qmediaplaylist_p.cpp65
-rw-r--r--examples/multimedia/player/qmediaplaylist_p.h66
-rw-r--r--examples/multimedia/player/qplaylistfileparser.cpp621
-rw-r--r--examples/multimedia/player/qplaylistfileparser.h76
-rw-r--r--examples/multimedia/player/videowidget.cpp46
-rw-r--r--examples/multimedia/player/videowidget.h22
-rw-r--r--examples/multimedia/screencapture/CMakeLists.txt50
-rw-r--r--examples/multimedia/screencapture/Info.plist.in41
-rw-r--r--examples/multimedia/screencapture/doc/images/screencapture.jpgbin0 -> 42725 bytes
-rw-r--r--examples/multimedia/screencapture/doc/src/screencapture.qdoc48
-rw-r--r--examples/multimedia/screencapture/main.cpp14
-rw-r--r--examples/multimedia/screencapture/screencapture.pro18
-rw-r--r--examples/multimedia/screencapture/screencapturepreview.cpp179
-rw-r--r--examples/multimedia/screencapture/screencapturepreview.h67
-rw-r--r--examples/multimedia/screencapture/screenlistmodel.cpp54
-rw-r--r--examples/multimedia/screencapture/screenlistmodel.h30
-rw-r--r--examples/multimedia/screencapture/windowlistmodel.cpp42
-rw-r--r--examples/multimedia/screencapture/windowlistmodel.h31
-rw-r--r--examples/multimedia/shared/shared.pri46
-rw-r--r--examples/multimedia/spectrum/3rdparty/fftreal/CMakeLists.txt27
-rw-r--r--examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro11
-rw-r--r--examples/multimedia/spectrum/3rdparty/fftreal/fftreal_wrapper.h8
-rw-r--r--examples/multimedia/spectrum/CMakeLists.txt67
-rw-r--r--examples/multimedia/spectrum/Info.plist.in43
-rw-r--r--examples/multimedia/spectrum/app.pro55
-rw-r--r--examples/multimedia/spectrum/app/.gitignore2
-rw-r--r--examples/multimedia/spectrum/app/app.pro86
-rw-r--r--examples/multimedia/spectrum/app/engine.cpp783
-rw-r--r--examples/multimedia/spectrum/app/frequencyspectrum.cpp99
-rw-r--r--examples/multimedia/spectrum/app/frequencyspectrum.h107
-rw-r--r--examples/multimedia/spectrum/app/levelmeter.cpp153
-rw-r--r--examples/multimedia/spectrum/app/levelmeter.h128
-rw-r--r--examples/multimedia/spectrum/app/main.cpp63
-rw-r--r--examples/multimedia/spectrum/app/mainwidget.h157
-rw-r--r--examples/multimedia/spectrum/app/progressbar.cpp150
-rw-r--r--examples/multimedia/spectrum/app/progressbar.h85
-rw-r--r--examples/multimedia/spectrum/app/settingsdialog.cpp157
-rw-r--r--examples/multimedia/spectrum/app/settingsdialog.h99
-rw-r--r--examples/multimedia/spectrum/app/spectrograph.h108
-rw-r--r--examples/multimedia/spectrum/app/spectrum.h140
-rw-r--r--examples/multimedia/spectrum/app/spectrumanalyser.cpp286
-rw-r--r--examples/multimedia/spectrum/app/spectrumanalyser.h206
-rw-r--r--examples/multimedia/spectrum/app/tonegenerator.cpp100
-rw-r--r--examples/multimedia/spectrum/app/tonegenerator.h68
-rw-r--r--examples/multimedia/spectrum/app/tonegeneratordialog.cpp154
-rw-r--r--examples/multimedia/spectrum/app/tonegeneratordialog.h94
-rw-r--r--examples/multimedia/spectrum/app/utils.cpp149
-rw-r--r--examples/multimedia/spectrum/app/utils.h122
-rw-r--r--examples/multimedia/spectrum/app/wavfile.cpp158
-rw-r--r--examples/multimedia/spectrum/app/wavfile.h76
-rw-r--r--examples/multimedia/spectrum/doc/src/spectrum.qdoc36
-rw-r--r--examples/multimedia/spectrum/engine.cpp750
-rw-r--r--examples/multimedia/spectrum/engine.h (renamed from examples/multimedia/spectrum/app/engine.h)163
-rw-r--r--examples/multimedia/spectrum/frequencyspectrum.cpp48
-rw-r--r--examples/multimedia/spectrum/frequencyspectrum.h60
-rw-r--r--examples/multimedia/spectrum/images/record.png (renamed from examples/multimedia/spectrum/app/images/record.png)bin466 -> 466 bytes
-rw-r--r--examples/multimedia/spectrum/images/settings.png (renamed from examples/multimedia/spectrum/app/images/settings.png)bin3649 -> 3649 bytes
-rw-r--r--examples/multimedia/spectrum/levelmeter.cpp103
-rw-r--r--examples/multimedia/spectrum/levelmeter.h80
-rw-r--r--examples/multimedia/spectrum/main.cpp17
-rw-r--r--examples/multimedia/spectrum/mainwidget.cpp (renamed from examples/multimedia/spectrum/app/mainwidget.cpp)258
-rw-r--r--examples/multimedia/spectrum/mainwidget.h105
-rw-r--r--examples/multimedia/spectrum/progressbar.cpp101
-rw-r--r--examples/multimedia/spectrum/progressbar.h38
-rw-r--r--examples/multimedia/spectrum/settingsdialog.cpp102
-rw-r--r--examples/multimedia/spectrum/settingsdialog.h52
-rw-r--r--examples/multimedia/spectrum/spectrograph.cpp (renamed from examples/multimedia/spectrum/app/spectrograph.cpp)93
-rw-r--r--examples/multimedia/spectrum/spectrograph.h62
-rw-r--r--examples/multimedia/spectrum/spectrum.h91
-rw-r--r--examples/multimedia/spectrum/spectrum.pri3
-rw-r--r--examples/multimedia/spectrum/spectrum.pro6
-rw-r--r--examples/multimedia/spectrum/spectrum.qrc (renamed from examples/multimedia/spectrum/app/spectrum.qrc)0
-rw-r--r--examples/multimedia/spectrum/spectrumanalyser.cpp233
-rw-r--r--examples/multimedia/spectrum/spectrumanalyser.h151
-rw-r--r--examples/multimedia/spectrum/tonegenerator.cpp54
-rw-r--r--examples/multimedia/spectrum/tonegenerator.h21
-rw-r--r--examples/multimedia/spectrum/tonegeneratordialog.cpp105
-rw-r--r--examples/multimedia/spectrum/tonegeneratordialog.h47
-rw-r--r--examples/multimedia/spectrum/utils.cpp68
-rw-r--r--examples/multimedia/spectrum/utils.h79
-rw-r--r--examples/multimedia/spectrum/waveform.cpp (renamed from examples/multimedia/spectrum/app/waveform.cpp)188
-rw-r--r--examples/multimedia/spectrum/waveform.h (renamed from examples/multimedia/spectrum/app/waveform.h)97
-rw-r--r--examples/multimedia/video/CMakeLists.txt10
-rw-r--r--examples/multimedia/video/android/android.pro5
-rw-r--r--examples/multimedia/video/android/gstreamer/gstreamer.pro23
-rw-r--r--examples/multimedia/video/android/gstreamer/main.cpp115
-rw-r--r--examples/multimedia/video/android/gstreamer/main.qml75
-rw-r--r--examples/multimedia/video/android/gstreamer/qml.qrc5
-rw-r--r--examples/multimedia/video/doc/images/qmlvideofx-camera-glow.jpgbin74914 -> 0 bytes
-rw-r--r--examples/multimedia/video/doc/images/qmlvideofx-camera-wobble.jpgbin62992 -> 0 bytes
-rw-r--r--examples/multimedia/video/doc/images/qmlvideofx-effects-menu.jpgbin84990 -> 0 bytes
-rw-r--r--examples/multimedia/video/doc/images/qmlvideofx-video-edgedetection.jpgbin108916 -> 0 bytes
-rw-r--r--examples/multimedia/video/doc/images/qmlvideofx-video-pagecurl.jpgbin61450 -> 0 bytes
-rw-r--r--examples/multimedia/video/doc/src/qmlvideofx.qdoc207
-rw-r--r--examples/multimedia/video/mediaplayer/CMakeLists.txt69
-rw-r--r--examples/multimedia/video/mediaplayer/Main.qml178
-rw-r--r--examples/multimedia/video/mediaplayer/controls/AudioControl.qml50
-rw-r--r--examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml30
-rw-r--r--examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml318
-rw-r--r--examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml56
-rw-r--r--examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml204
-rw-r--r--examples/multimedia/video/mediaplayer/controls/TracksInfo.qml25
-rw-r--r--examples/multimedia/video/mediaplayer/controls/UrlPopup.qml54
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/mediaplayer.pngbin0 -> 49506 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/images/settings.pngbin0 -> 33705 bytes
-rw-r--r--examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc151
-rw-r--r--examples/multimedia/video/mediaplayer/images/backward10.svg5
-rw-r--r--examples/multimedia/video/mediaplayer/images/ff.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/forward10.svg5
-rw-r--r--examples/multimedia/video/mediaplayer/images/link.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/loop.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/more.svg5
-rw-r--r--examples/multimedia/video/mediaplayer/images/mute.svg6
-rw-r--r--examples/multimedia/video/mediaplayer/images/open_new.svg6
-rw-r--r--examples/multimedia/video/mediaplayer/images/pause_symbol.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/play_symbol.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/rewind.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/settings.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/speaker.svg7
-rw-r--r--examples/multimedia/video/mediaplayer/images/stop_symbol.svg3
-rw-r--r--examples/multimedia/video/mediaplayer/images/url.svg6
-rw-r--r--examples/multimedia/video/mediaplayer/images/volume.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/volume_mute.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/zoom_maximize.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/images/zoom_minimize.svg4
-rw-r--r--examples/multimedia/video/mediaplayer/main.cpp38
-rw-r--r--examples/multimedia/video/qmlvideo/CMakeLists.txt58
-rw-r--r--examples/multimedia/video/qmlvideo/Info.plist.in48
-rw-r--r--examples/multimedia/video/qmlvideo/doc/images/qmlvideo-menu.jpg (renamed from examples/multimedia/video/doc/images/qmlvideo-menu.jpg)bin21959 -> 21959 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/doc/images/qmlvideo-overlay.jpg (renamed from examples/multimedia/video/doc/images/qmlvideo-overlay.jpg)bin23787 -> 23787 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/doc/src/qmlvideo.qdoc (renamed from examples/multimedia/video/doc/src/qmlvideo.qdoc)50
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor.cpp (renamed from examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp)113
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor.h67
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt30
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml67
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitor/qmldir3
-rw-r--r--examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp10
-rw-r--r--examples/multimedia/video/qmlvideo/main.cpp143
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor.cpp31
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor.h33
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt31
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml100
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitor/qmldir3
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp12
-rw-r--r--examples/multimedia/video/qmlvideo/performancemonitordeclarative.h11
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml90
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml78
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml77
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml165
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml118
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml419
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml83
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml94
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml81
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml112
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml117
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml96
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml130
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml88
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml109
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml151
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml81
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml84
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml95
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml56
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml87
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml135
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml115
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml81
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml55
-rw-r--r--examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml284
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo.pro88
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo.qrc51
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt81
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml31
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml47
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/Content.qml125
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml70
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/Main.qml188
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml31
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml47
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml34
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml67
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml70
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml49
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneMulti.qml (renamed from examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMulti.qml)110
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml83
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml41
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml57
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml88
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml34
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/SeekControl.qml (renamed from examples/multimedia/video/qmlvideo/qml/qmlvideo/SeekControl.qml)73
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml37
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml49
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml7
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml42
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml80
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml65
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml36
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml6
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/images/folder.png (renamed from examples/multimedia/video/qmlvideo/images/folder.png)bin1829 -> 1829 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/images/leaves.jpg (renamed from examples/multimedia/video/qmlvideo/images/leaves.jpg)bin257378 -> 257378 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/images/up.png (renamed from examples/multimedia/video/qmlvideo/images/up.png)bin1268 -> 1268 bytes
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/qmldir44
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h10
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp54
-rw-r--r--examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h48
-rw-r--r--examples/multimedia/video/qmlvideo/trace.h100
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/README15
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/main.cpp526
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/main.qml131
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro17
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.qrc5
-rw-r--r--examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h141
-rw-r--r--examples/multimedia/video/qmlvideofx/Info.plist32
-rw-r--r--examples/multimedia/video/qmlvideofx/filereader.cpp69
-rw-r--r--examples/multimedia/video/qmlvideofx/filereader.h59
-rw-r--r--examples/multimedia/video/qmlvideofx/images/Dropdown_arrows.pngbin1156 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/Slider_bar.pngbin1129 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/Slider_handle.pngbin2784 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/Triangle_Top.pngbin2212 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/Triangle_bottom.pngbin2125 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/icon_BackArrow.pngbin1268 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/icon_Folder.pngbin1829 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/icon_Menu.pngbin990 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/images/qt-logo.pngbin9186 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/main.cpp168
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Button.qml93
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Content.qml164
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentCamera.qml60
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml56
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentVideo.qml85
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Curtain.qml103
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Divider.qml95
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml84
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml74
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml70
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml114
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml77
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml111
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml72
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml71
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml73
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml82
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSelectionList.qml76
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml71
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml96
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml74
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml72
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml55
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml70
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml392
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml162
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/HintedMouseArea.qml122
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Main.qml296
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml113
-rw-r--r--examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Slider.qml131
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp138
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.h79
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.pri7
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlvideofx.pngbin3400 -> 0 bytes
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlvideofx.pro24
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlvideofx.qrc71
-rw-r--r--examples/multimedia/video/qmlvideofx/qmlvideofx.svg93
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/billboard.fsh83
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/blackandwhite.fsh71
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/emboss.fsh80
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/gaussianblur_h.fsh76
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/gaussianblur_v.fsh77
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/glow.fsh81
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/isolate.fsh97
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/magnify.fsh80
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/pagecurl.fsh192
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/pixelate.fsh73
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/posterize.fsh77
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/ripple.fsh88
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/selectionpanel.fsh50
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/sepia.fsh68
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/sharpen.fsh84
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/shockwave.fsh82
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/sobeledgedetection1.fsh92
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/tiltshift.fsh84
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/toon.fsh101
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/vignette.fsh73
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/warhol.fsh75
-rw-r--r--examples/multimedia/video/qmlvideofx/shaders/wobble.fsh71
-rw-r--r--examples/multimedia/video/qmlvideofx/trace.h100
-rw-r--r--examples/multimedia/video/recorder/AudioInputSelect.qml53
-rw-r--r--examples/multimedia/video/recorder/CMakeLists.txt62
-rw-r--r--examples/multimedia/video/recorder/Controls.qml83
-rw-r--r--examples/multimedia/video/recorder/Info.plist.in46
-rw-r--r--examples/multimedia/video/recorder/MediaList.qml67
-rw-r--r--examples/multimedia/video/recorder/Playback.qml55
-rw-r--r--examples/multimedia/video/recorder/RecordButton.qml45
-rw-r--r--examples/multimedia/video/recorder/SettingsEncoder.qml102
-rw-r--r--examples/multimedia/video/recorder/SettingsMetaData.qml145
-rw-r--r--examples/multimedia/video/recorder/Style.qml31
-rw-r--r--examples/multimedia/video/recorder/StyleParameter.qml42
-rw-r--r--examples/multimedia/video/recorder/StyleRectangle.qml11
-rw-r--r--examples/multimedia/video/recorder/StyleSlider.qml35
-rw-r--r--examples/multimedia/video/recorder/VideoSourceSelect.qml165
-rw-r--r--examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gifbin0 -> 111693 bytes
-rw-r--r--examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gifbin0 -> 138905 bytes
-rw-r--r--examples/multimedia/video/recorder/doc/images/qmlrecorder.jpgbin0 -> 95965 bytes
-rw-r--r--examples/multimedia/video/recorder/doc/src/recorder.qdoc102
-rw-r--r--examples/multimedia/video/recorder/main.cpp51
-rw-r--r--examples/multimedia/video/recorder/main.qml144
-rw-r--r--examples/multimedia/video/recorder/main_no_permissions.qml26
-rw-r--r--examples/multimedia/video/recorder/qmldir2
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h111
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri5
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp57
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri5
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc5
-rw-r--r--examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml114
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp78
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitor.h77
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri5
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp60
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h60
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri6
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc5
-rw-r--r--examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml150
-rw-r--r--examples/multimedia/video/video.pro8
-rw-r--r--examples/multimedia/videographicsitem/CMakeLists.txt39
-rw-r--r--examples/multimedia/videographicsitem/doc/images/video-videographicsitem.png (renamed from examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png)bin54436 -> 54436 bytes
-rw-r--r--examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc20
-rw-r--r--examples/multimedia/videographicsitem/main.cpp37
-rw-r--r--examples/multimedia/videographicsitem/videographicsitem.pro (renamed from examples/multimediawidgets/videographicsitem/videographicsitem.pro)2
-rw-r--r--examples/multimedia/videographicsitem/videoplayer.cpp148
-rw-r--r--examples/multimedia/videographicsitem/videoplayer.h47
-rw-r--r--examples/multimedia/videowidget/CMakeLists.txt39
-rw-r--r--examples/multimedia/videowidget/doc/images/video-videowidget.png (renamed from examples/multimediawidgets/videowidget/doc/images/video-videowidget.png)bin54199 -> 54199 bytes
-rw-r--r--examples/multimedia/videowidget/doc/src/videowidget.qdoc18
-rw-r--r--examples/multimedia/videowidget/main.cpp40
-rw-r--r--examples/multimedia/videowidget/videoplayer.cpp137
-rw-r--r--examples/multimedia/videowidget/videoplayer.h44
-rw-r--r--examples/multimedia/videowidget/videowidget.pro (renamed from examples/multimediawidgets/videowidget/videowidget.pro)2
-rw-r--r--examples/multimediawidgets/camera/camera.cpp434
-rw-r--r--examples/multimediawidgets/camera/camera.h132
-rw-r--r--examples/multimediawidgets/camera/camera.pro28
-rw-r--r--examples/multimediawidgets/camera/doc/images/camera-example.pngbin13647 -> 0 bytes
-rw-r--r--examples/multimediawidgets/camera/doc/src/camera.qdoc79
-rw-r--r--examples/multimediawidgets/camera/imagesettings.cpp136
-rw-r--r--examples/multimediawidgets/camera/imagesettings.h92
-rw-r--r--examples/multimediawidgets/camera/main.cpp63
-rw-r--r--examples/multimediawidgets/camera/videosettings.cpp203
-rw-r--r--examples/multimediawidgets/camera/videosettings.h92
-rw-r--r--examples/multimediawidgets/camera/videosettings.ui211
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro16
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp64
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp155
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h88
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp185
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h94
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideosurface.pro4
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro18
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp63
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp154
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h87
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp123
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h80
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp183
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h91
-rw-r--r--examples/multimediawidgets/multimediawidgets.pro11
-rw-r--r--examples/multimediawidgets/player/doc/src/player.qdoc98
-rw-r--r--examples/multimediawidgets/player/histogramwidget.cpp341
-rw-r--r--examples/multimediawidgets/player/histogramwidget.h98
-rw-r--r--examples/multimediawidgets/player/main.cpp90
-rw-r--r--examples/multimediawidgets/player/player.cpp483
-rw-r--r--examples/multimediawidgets/player/player.h143
-rw-r--r--examples/multimediawidgets/player/playercontrols.h109
-rw-r--r--examples/multimediawidgets/player/playlistmodel.cpp169
-rw-r--r--examples/multimediawidgets/player/playlistmodel.h100
-rw-r--r--examples/multimediawidgets/player/videowidget.cpp91
-rw-r--r--examples/multimediawidgets/player/videowidget.h69
-rw-r--r--examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc42
-rw-r--r--examples/multimediawidgets/videographicsitem/main.cpp85
-rw-r--r--examples/multimediawidgets/videographicsitem/videoplayer.cpp189
-rw-r--r--examples/multimediawidgets/videographicsitem/videoplayer.h95
-rw-r--r--examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc40
-rw-r--r--examples/multimediawidgets/videowidget/main.cpp87
-rw-r--r--examples/multimediawidgets/videowidget/videoplayer.cpp177
-rw-r--r--examples/multimediawidgets/videowidget/videoplayer.h91
-rw-r--r--examples/spatialaudio/CMakeLists.txt1
-rw-r--r--examples/spatialaudio/audiopanning/CMakeLists.txt36
-rw-r--r--examples/spatialaudio/audiopanning/audiopanning.pro9
-rw-r--r--examples/spatialaudio/audiopanning/doc/images/audiopanning-example.pngbin0 -> 171760 bytes
-rw-r--r--examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc28
-rw-r--r--examples/spatialaudio/audiopanning/main.cpp241
-rw-r--r--examples/spatialaudio/spatialaudio.pro3
537 files changed, 16747 insertions, 26283 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 000000000..76d01581a
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+qt_examples_build_begin(EXTERNAL_BUILD)
+
+add_subdirectory(multimedia)
+if(QT_FEATURE_spatialaudio)
+ add_subdirectory(spatialaudio)
+endif()
+
+qt_examples_build_end()
diff --git a/examples/examples.pro b/examples/examples.pro
index 979671672..3cda36046 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += multimedia multimediawidgets
+SUBDIRS += multimedia spatialaudio
diff --git a/examples/multimedia/CMakeLists.txt b/examples/multimedia/CMakeLists.txt
new file mode 100644
index 000000000..07bf4debd
--- /dev/null
+++ b/examples/multimedia/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(TARGET Qt::Widgets)
+ if(NOT ANDROID AND NOT IOS)
+ qt_internal_add_example(audiodevices)
+ endif()
+ qt_internal_add_example(audiooutput)
+ qt_internal_add_example(audiorecorder)
+ qt_internal_add_example(audiosource)
+ qt_internal_add_example(camera)
+ qt_internal_add_example(player)
+ qt_internal_add_example(spectrum)
+ qt_internal_add_example(videographicsitem)
+ qt_internal_add_example(videowidget)
+ qt_internal_add_example(screencapture)
+endif()
+if(TARGET Qt::Quick)
+ qt_internal_add_example(declarative-camera)
+ add_subdirectory(video)
+endif()
diff --git a/examples/multimedia/audiodecoder/audiodecoder.cpp b/examples/multimedia/audiodecoder/audiodecoder.cpp
deleted file mode 100644
index f812fd3b6..000000000
--- a/examples/multimedia/audiodecoder/audiodecoder.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "audiodecoder.h"
-#include <stdio.h>
-
-AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete)
- : m_cout(stdout, QIODevice::WriteOnly)
-{
- m_isPlayback = isPlayback;
- m_isDelete = isDelete;
-
- // Make sure the data we receive is in correct PCM format.
- // Our wav file writer only supports SignedInt sample type.
- QAudioFormat format;
- format.setChannelCount(2);
- format.setSampleSize(16);
- format.setSampleRate(48000);
- format.setCodec("audio/pcm");
- format.setSampleType(QAudioFormat::SignedInt);
- m_decoder.setAudioFormat(format);
-
- connect(&m_decoder, &QAudioDecoder::bufferReady,
- this, &AudioDecoder::bufferReady);
- connect(&m_decoder, QOverload<QAudioDecoder::Error>::of(&QAudioDecoder::error),
- this, QOverload<QAudioDecoder::Error>::of(&AudioDecoder::error));
- connect(&m_decoder, &QAudioDecoder::stateChanged,
- this, &AudioDecoder::stateChanged);
- connect(&m_decoder, &QAudioDecoder::finished,
- this, &AudioDecoder::finished);
- connect(&m_decoder, &QAudioDecoder::positionChanged,
- this, &AudioDecoder::updateProgress);
- connect(&m_decoder, &QAudioDecoder::durationChanged,
- this, &AudioDecoder::updateProgress);
-
- connect(&m_soundEffect, &QSoundEffect::statusChanged,
- this, &AudioDecoder::playbackStatusChanged);
- connect(&m_soundEffect, &QSoundEffect::playingChanged,
- this, &AudioDecoder::playingChanged);
-
- m_progress = -1.0;
-}
-
-void AudioDecoder::setSourceFilename(const QString &fileName)
-{
- m_decoder.setSourceFilename(fileName);
-}
-
-void AudioDecoder::start()
-{
- m_decoder.start();
-}
-
-void AudioDecoder::stop()
-{
- m_decoder.stop();
-}
-
-void AudioDecoder::setTargetFilename(const QString &fileName)
-{
- m_targetFilename = fileName;
-}
-
-void AudioDecoder::bufferReady()
-{
- // read a buffer from audio decoder
- QAudioBuffer buffer = m_decoder.read();
- if (!buffer.isValid())
- return;
-
- if (!m_fileWriter.isOpen() && !m_fileWriter.open(m_targetFilename, buffer.format())) {
- m_decoder.stop();
- return;
- }
-
- m_fileWriter.write(buffer);
-}
-
-void AudioDecoder::error(QAudioDecoder::Error error)
-{
- switch (error) {
- case QAudioDecoder::NoError:
- return;
- case QAudioDecoder::ResourceError:
- m_cout << "Resource error\n";
- break;
- case QAudioDecoder::FormatError:
- m_cout << "Format error\n";
- break;
- case QAudioDecoder::AccessDeniedError:
- m_cout << "Access denied error\n";
- break;
- case QAudioDecoder::ServiceMissingError:
- m_cout << "Service missing error\n";
- break;
- }
-
- emit done();
-}
-
-void AudioDecoder::stateChanged(QAudioDecoder::State newState)
-{
- switch (newState) {
- case QAudioDecoder::DecodingState:
- m_cout << "Decoding...\n";
- break;
- case QAudioDecoder::StoppedState:
- m_cout << "Decoding stopped\n";
- break;
- }
-}
-
-void AudioDecoder::finished()
-{
- if (!m_fileWriter.close())
- m_cout << "Failed to finilize output file\n";
-
- m_cout << "Decoding finished\n";
-
- if (m_isPlayback) {
- m_cout << "Starting playback\n";
- m_soundEffect.setSource(QUrl::fromLocalFile(m_targetFilename));
- m_soundEffect.play();
- } else {
- emit done();
- }
-}
-
-void AudioDecoder::playbackStatusChanged()
-{
- if (m_soundEffect.status() == QSoundEffect::Error) {
- m_cout << "Playback error\n";
- emit done();
- }
-}
-
-void AudioDecoder::playingChanged()
-{
- if (!m_soundEffect.isPlaying()) {
- m_cout << "Playback finished\n";
- if (m_isDelete)
- QFile::remove(m_targetFilename);
- emit done();
- }
-}
-
-void AudioDecoder::updateProgress()
-{
- qint64 position = m_decoder.position();
- qint64 duration = m_decoder.duration();
- qreal progress = m_progress;
- if (position >= 0 && duration > 0)
- progress = position / (qreal)duration;
-
- if (progress > m_progress + 0.1) {
- m_cout << "Decoding progress: " << (int)(progress * 100.0) << "%\n";
- m_progress = progress;
- }
-}
diff --git a/examples/multimedia/audiodecoder/audiodecoder.h b/examples/multimedia/audiodecoder/audiodecoder.h
deleted file mode 100644
index e460ac94f..000000000
--- a/examples/multimedia/audiodecoder/audiodecoder.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef AUDIODECODER_H
-#define AUDIODECODER_H
-
-#include "wavefilewriter.h"
-
-#include <QAudioDecoder>
-#include <QSoundEffect>
-#include <QTextStream>
-
-class AudioDecoder : public QObject
-{
- Q_OBJECT
-
-public:
- AudioDecoder(bool isPlayback, bool isDelete);
- ~AudioDecoder() { }
-
- void setSourceFilename(const QString &fileName);
- void start();
- void stop();
-
- void setTargetFilename(const QString &fileName);
-
-signals:
- void done();
-
-public slots:
- void bufferReady();
- void error(QAudioDecoder::Error error);
- void stateChanged(QAudioDecoder::State newState);
- void finished();
-
- void playbackStatusChanged();
- void playingChanged();
-
-private slots:
- void updateProgress();
-
-private:
- bool m_isPlayback;
- bool m_isDelete;
- QAudioDecoder m_decoder;
- QTextStream m_cout;
-
- QString m_targetFilename;
- WaveFileWriter m_fileWriter;
- QSoundEffect m_soundEffect;
-
- qreal m_progress;
-};
-
-#endif // AUDIODECODER_H
diff --git a/examples/multimedia/audiodecoder/audiodecoder.pro b/examples/multimedia/audiodecoder/audiodecoder.pro
deleted file mode 100644
index 4cfb31339..000000000
--- a/examples/multimedia/audiodecoder/audiodecoder.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TEMPLATE = app
-TARGET = audiodecoder
-
-HEADERS = \
- audiodecoder.h \
- wavefilewriter.h
-SOURCES = main.cpp \
- audiodecoder.cpp \
- wavefilewriter.cpp
-
-QT += multimedia
-CONFIG += console
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audiodecoder
-INSTALLS += target
diff --git a/examples/multimedia/audiodecoder/main.cpp b/examples/multimedia/audiodecoder/main.cpp
deleted file mode 100644
index 9c536ef0a..000000000
--- a/examples/multimedia/audiodecoder/main.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "audiodecoder.h"
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QFileInfo>
-#include <QTextStream>
-
-#include <stdio.h>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- QTextStream cout(stdout, QIODevice::WriteOnly);
- if (app.arguments().size() < 2) {
- cout << "Usage: audiodecoder [-p] [-pd] SOURCEFILE [TARGETFILE]\n";
- cout << "Set -p option if you want to play output file.\n";
- cout << "Set -pd option if you want to play output file and delete it after successful playback.\n";
- cout << "Default TARGETFILE name is \"out.wav\" in the same directory as the source file.\n";
- return 0;
- }
-
- bool isPlayback = false;
- bool isDelete = false;
-
- if (app.arguments().at(1) == "-p")
- isPlayback = true;
- else if (app.arguments().at(1) == "-pd") {
- isPlayback = true;
- isDelete = true;
- }
-
- QFileInfo sourceFile;
- QFileInfo targetFile;
-
- int sourceFileIndex = (isPlayback || isDelete) ? 2 : 1;
- if (app.arguments().size() <= sourceFileIndex) {
- cout << "Error: source filename is not specified.\n";
- return 0;
- }
- sourceFile.setFile(app.arguments().at(sourceFileIndex));
- if (app.arguments().size() > sourceFileIndex + 1)
- targetFile.setFile(app.arguments().at(sourceFileIndex + 1));
- else
- targetFile.setFile(sourceFile.dir().absoluteFilePath("out.wav"));
-
- AudioDecoder decoder(isPlayback, isDelete);
- QObject::connect(&decoder, &AudioDecoder::done,
- &app, &QCoreApplication::quit);
- decoder.setSourceFilename(sourceFile.absoluteFilePath());
- decoder.setTargetFilename(targetFile.absoluteFilePath());
- decoder.start();
-
- return app.exec();
-}
diff --git a/examples/multimedia/audiodecoder/wavefilewriter.cpp b/examples/multimedia/audiodecoder/wavefilewriter.cpp
deleted file mode 100644
index cb1abbc9f..000000000
--- a/examples/multimedia/audiodecoder/wavefilewriter.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "wavefilewriter.h"
-
-#include <limits.h>
-
-struct chunk
-{
- char id[4];
- quint32 size;
-};
-
-struct RIFFHeader
-{
- chunk descriptor; // "RIFF"
- char type[4]; // "WAVE"
-};
-
-struct WAVEHeader
-{
- chunk descriptor;
- quint16 audioFormat;
- quint16 numChannels;
- quint32 sampleRate;
- quint32 byteRate;
- quint16 blockAlign;
- quint16 bitsPerSample;
-};
-
-struct DATAHeader
-{
- chunk descriptor;
-};
-
-struct CombinedHeader
-{
- RIFFHeader riff;
- WAVEHeader wave;
- DATAHeader data;
-};
-static const int HeaderLength = sizeof(CombinedHeader);
-
-
-WaveFileWriter::WaveFileWriter(QObject *parent)
- : QObject(parent)
- , m_dataLength(0)
-{
-}
-
-WaveFileWriter::~WaveFileWriter()
-{
- close();
-}
-
-bool WaveFileWriter::open(const QString& fileName, const QAudioFormat& format)
-{
- if (file.isOpen())
- return false; // file already open
-
- if (format.codec() != "audio/pcm" || format.sampleType() != QAudioFormat::SignedInt)
- return false; // data format is not supported
-
- file.setFileName(fileName);
- if (!file.open(QIODevice::WriteOnly))
- return false; // unable to open file for writing
-
- if (!writeHeader(format))
- return false;
-
- m_format = format;
- return true;
-}
-
-bool WaveFileWriter::write(const QAudioBuffer &buffer)
-{
- if (buffer.format() != m_format)
- return false; // buffer format has changed
-
- qint64 written = file.write((const char *)buffer.constData(), buffer.byteCount());
- m_dataLength += written;
- return written == buffer.byteCount();
-}
-
-bool WaveFileWriter::close()
-{
- bool result = false;
- if (file.isOpen()) {
- Q_ASSERT(m_dataLength < INT_MAX);
- result = writeDataLength();
-
- m_dataLength = 0;
- file.close();
- }
- return result;
-}
-
-bool WaveFileWriter::writeHeader(const QAudioFormat &format)
-{
- // check if format is supported
- if (format.byteOrder() == QAudioFormat::BigEndian || format.sampleType() != QAudioFormat::SignedInt)
- return false;
-
- CombinedHeader header;
- memset(&header, 0, HeaderLength);
-
-#ifndef Q_LITTLE_ENDIAN
- // only implemented for LITTLE ENDIAN
- return false;
-#else
- // RIFF header
- memcpy(header.riff.descriptor.id, "RIFF", 4);
- header.riff.descriptor.size = 0; // this will be updated with correct duration:
- // m_dataLength + HeaderLength - 8
- // WAVE header
- memcpy(header.riff.type, "WAVE", 4);
- memcpy(header.wave.descriptor.id, "fmt ", 4);
- header.wave.descriptor.size = quint32(16);
- header.wave.audioFormat = quint16(1);
- header.wave.numChannels = quint16(format.channelCount());
- header.wave.sampleRate = quint32(format.sampleRate());
- header.wave.byteRate = quint32(format.sampleRate() * format.channelCount() * format.sampleSize() / 8);
- header.wave.blockAlign = quint16(format.channelCount() * format.sampleSize() / 8);
- header.wave.bitsPerSample = quint16(format.sampleSize());
-
- // DATA header
- memcpy(header.data.descriptor.id,"data", 4);
- header.data.descriptor.size = 0; // this will be updated with correct data length: m_dataLength
-
- return (file.write(reinterpret_cast<const char *>(&header), HeaderLength) == HeaderLength);
-#endif
-}
-
-bool WaveFileWriter::writeDataLength()
-{
-#ifndef Q_LITTLE_ENDIAN
- // only implemented for LITTLE ENDIAN
- return false;
-#endif
-
- if (file.isSequential())
- return false;
-
- // seek to RIFF header size, see header.riff.descriptor.size above
- if (!file.seek(4))
- return false;
-
- quint32 length = m_dataLength + HeaderLength - 8;
- if (file.write(reinterpret_cast<const char *>(&length), 4) != 4)
- return false;
-
- // seek to DATA header size, see header.data.descriptor.size above
- if (!file.seek(40))
- return false;
-
- return file.write(reinterpret_cast<const char *>(&m_dataLength), 4) == 4;
-}
diff --git a/examples/multimedia/audiodecoder/wavefilewriter.h b/examples/multimedia/audiodecoder/wavefilewriter.h
deleted file mode 100644
index 846284746..000000000
--- a/examples/multimedia/audiodecoder/wavefilewriter.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef WAVEFILEWRITER_H
-#define WAVEFILEWRITER_H
-
-#include <QAudioBuffer>
-#include <QFile>
-#include <QObject>
-
-class WaveFileWriter : public QObject
-{
- Q_OBJECT
-
-public:
- explicit WaveFileWriter(QObject *parent = 0);
- ~WaveFileWriter();
-
- bool open(const QString &fileName, const QAudioFormat &format);
- bool write(const QAudioBuffer &buffer);
- bool close();
- bool isOpen() const { return file.isOpen(); }
-
-private:
- bool writeHeader(const QAudioFormat &format);
- bool writeDataLength();
-
- QFile file;
- QAudioFormat m_format;
- qint64 m_dataLength;
-};
-
-#endif // WAVEFILEWRITER_H
diff --git a/examples/multimedia/audiodevices/CMakeLists.txt b/examples/multimedia/audiodevices/CMakeLists.txt
new file mode 100644
index 000000000..a3003c4c5
--- /dev/null
+++ b/examples/multimedia/audiodevices/CMakeLists.txt
@@ -0,0 +1,44 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(audiodevices LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/audiodevices")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Widgets)
+
+qt_add_executable(audiodevices
+ audiodevices.cpp audiodevices.h
+ audiodevicesbase.ui
+ main.cpp
+)
+
+set_target_properties(audiodevices PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_include_directories(audiodevices PUBLIC
+ ../shared
+)
+
+target_link_libraries(audiodevices PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Widgets
+)
+
+install(TARGETS audiodevices
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp
index 52ff2176a..d211189fd 100644
--- a/examples/multimedia/audiodevices/audiodevices.cpp
+++ b/examples/multimedia/audiodevices/audiodevices.cpp
@@ -1,113 +1,86 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiodevices.h"
+#include <QCameraDevice>
+#include <QMediaDevices>
+#include <QMediaFormat>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
// Utility functions for converting QAudioFormat fields into text
-static QString toString(QAudioFormat::SampleType sampleType)
+static QString toString(QAudioFormat::SampleFormat sampleFormat)
{
- QString result("Unknown");
- switch (sampleType) {
- case QAudioFormat::SignedInt:
- result = "SignedInt";
- break;
- case QAudioFormat::UnSignedInt:
- result = "UnSignedInt";
- break;
+ switch (sampleFormat) {
+ case QAudioFormat::UInt8:
+ return "Unsigned 8 bit";
+ case QAudioFormat::Int16:
+ return "Signed 16 bit";
+ case QAudioFormat::Int32:
+ return "Signed 32 bit";
case QAudioFormat::Float:
- result = "Float";
- break;
- case QAudioFormat::Unknown:
- result = "Unknown";
+ return "Float";
+ default:
+ return "Unknown";
}
- return result;
}
-static QString toString(QAudioFormat::Endian endian)
+AudioDevicesBase::AudioDevicesBase(QWidget *parent) : QMainWindow(parent)
{
- QString result("Unknown");
- switch (endian) {
- case QAudioFormat::LittleEndian:
- result = "LittleEndian";
- break;
- case QAudioFormat::BigEndian:
- result = "BigEndian";
- break;
- }
- return result;
+ setupUi(this);
}
+AudioDevicesBase::~AudioDevicesBase() = default;
-AudioDevicesBase::AudioDevicesBase(QWidget *parent)
- : QMainWindow(parent)
+AudioTest::AudioTest(QWidget *parent) : AudioDevicesBase(parent), m_devices(new QMediaDevices(this))
{
- setupUi(this);
+ init();
}
-AudioDevicesBase::~AudioDevicesBase() {}
-
-
-AudioTest::AudioTest(QWidget *parent)
- : AudioDevicesBase(parent)
+void AudioTest::init()
{
+#if QT_CONFIG(permissions)
+ // camera
+ QCameraPermission cameraPermission;
+ switch (qApp->checkPermission(cameraPermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(cameraPermission, this, &AudioTest::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Camera permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+ // microphone
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &AudioTest::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+ m_devices->videoInputs();
+ QMediaFormat().supportedFileFormats(QMediaFormat::Encode);
connect(testButton, &QPushButton::clicked, this, &AudioTest::test);
connect(modeBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::modeChanged);
connect(deviceBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::deviceChanged);
- connect(sampleRateBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::sampleRateChanged);
- connect(channelsBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::channelChanged);
- connect(codecsBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::codecChanged);
- connect(sampleSizesBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::sampleSizeChanged);
- connect(sampleTypesBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::sampleTypeChanged);
- connect(endianBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::endianChanged);
+ connect(sampleRateSpinBox, &QSpinBox::valueChanged, this, &AudioTest::sampleRateChanged);
+ connect(channelsSpinBox, &QSpinBox::valueChanged, this, &AudioTest::channelChanged);
+ connect(sampleFormatBox, QOverload<int>::of(&QComboBox::activated), this,
+ &AudioTest::sampleFormatChanged);
connect(populateTableButton, &QPushButton::clicked, this, &AudioTest::populateTable);
+ connect(m_devices, &QMediaDevices::audioInputsChanged, this, &AudioTest::updateAudioDevices);
+ connect(m_devices, &QMediaDevices::audioOutputsChanged, this, &AudioTest::updateAudioDevices);
modeBox->setCurrentIndex(0);
modeChanged(0);
@@ -125,33 +98,32 @@ void AudioTest::test()
testResult->setText(tr("Success"));
nearestSampleRate->setText("");
nearestChannel->setText("");
- nearestCodec->setText("");
- nearestSampleSize->setText("");
- nearestSampleType->setText("");
- nearestEndian->setText("");
+ nearestSampleFormat->setText("");
} else {
- QAudioFormat nearest = m_deviceInfo.nearestFormat(m_settings);
+ QAudioFormat nearest = m_deviceInfo.preferredFormat();
testResult->setText(tr("Failed"));
- nearestSampleRate->setText(QString("%1").arg(nearest.sampleRate()));
- nearestChannel->setText(QString("%1").arg(nearest.channelCount()));
- nearestCodec->setText(nearest.codec());
- nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize()));
- nearestSampleType->setText(toString(nearest.sampleType()));
- nearestEndian->setText(toString(nearest.byteOrder()));
+ nearestSampleRate->setText(QStringLiteral("%1").arg(nearest.sampleRate()));
+ nearestChannel->setText(QStringLiteral("%1").arg(nearest.channelCount()));
+ nearestSampleFormat->setText(toString(nearest.sampleFormat()));
}
- }
- else
+ } else
testResult->setText(tr("No Device"));
}
-void AudioTest::modeChanged(int idx)
+void AudioTest::updateAudioDevices()
{
- testResult->clear();
deviceBox->clear();
- const QAudio::Mode mode = idx == 0 ? QAudio::AudioInput : QAudio::AudioOutput;
- for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(mode))
- deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo));
+ const auto devices =
+ m_mode == QAudioDevice::Input ? m_devices->audioInputs() : m_devices->audioOutputs();
+ for (auto &deviceInfo : devices)
+ deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
+}
+void AudioTest::modeChanged(int idx)
+{
+ testResult->clear();
+ m_mode = idx == 0 ? QAudioDevice::Input : QAudioDevice::Output;
+ updateAudioDevices();
deviceBox->setCurrentIndex(0);
deviceChanged(0);
}
@@ -164,52 +136,29 @@ void AudioTest::deviceChanged(int idx)
return;
// device has changed
- m_deviceInfo = deviceBox->itemData(idx).value<QAudioDeviceInfo>();
-
- sampleRateBox->clear();
- QList<int> sampleRatez = m_deviceInfo.supportedSampleRates();
- for (int i = 0; i < sampleRatez.size(); ++i)
- sampleRateBox->addItem(QString("%1").arg(sampleRatez.at(i)));
- if (sampleRatez.size())
- m_settings.setSampleRate(sampleRatez.at(0));
-
- channelsBox->clear();
- QList<int> chz = m_deviceInfo.supportedChannelCounts();
- for (int i = 0; i < chz.size(); ++i)
- channelsBox->addItem(QString("%1").arg(chz.at(i)));
- if (chz.size())
- m_settings.setChannelCount(chz.at(0));
-
- codecsBox->clear();
- QStringList codecs = m_deviceInfo.supportedCodecs();
- for (int i = 0; i < codecs.size(); ++i)
- codecsBox->addItem(QString("%1").arg(codecs.at(i)));
- if (codecs.size())
- m_settings.setCodec(codecs.at(0));
- // Add false to create failed condition!
- codecsBox->addItem("audio/test");
-
- sampleSizesBox->clear();
- QList<int> sampleSizez = m_deviceInfo.supportedSampleSizes();
- for (int i = 0; i < sampleSizez.size(); ++i)
- sampleSizesBox->addItem(QString("%1").arg(sampleSizez.at(i)));
- if (sampleSizez.size())
- m_settings.setSampleSize(sampleSizez.at(0));
-
- sampleTypesBox->clear();
- QList<QAudioFormat::SampleType> sampleTypez = m_deviceInfo.supportedSampleTypes();
-
- for (int i = 0; i < sampleTypez.size(); ++i)
- sampleTypesBox->addItem(toString(sampleTypez.at(i)));
- if (sampleTypez.size())
- m_settings.setSampleType(sampleTypez.at(0));
-
- endianBox->clear();
- QList<QAudioFormat::Endian> endianz = m_deviceInfo.supportedByteOrders();
- for (int i = 0; i < endianz.size(); ++i)
- endianBox->addItem(toString(endianz.at(i)));
- if (endianz.size())
- m_settings.setByteOrder(endianz.at(0));
+ m_deviceInfo = deviceBox->itemData(idx).value<QAudioDevice>();
+
+ sampleRateSpinBox->clear();
+ sampleRateSpinBox->setMinimum(m_deviceInfo.minimumSampleRate());
+ sampleRateSpinBox->setMaximum(m_deviceInfo.maximumSampleRate());
+ int sampleValue =
+ qBound(m_deviceInfo.minimumSampleRate(), 48000, m_deviceInfo.maximumSampleRate());
+ sampleRateSpinBox->setValue(sampleValue);
+ m_settings.setSampleRate(sampleValue);
+
+ channelsSpinBox->clear();
+ channelsSpinBox->setMinimum(m_deviceInfo.minimumChannelCount());
+ channelsSpinBox->setMaximum(m_deviceInfo.maximumChannelCount());
+ int channelValue =
+ qBound(m_deviceInfo.minimumChannelCount(), 2, m_deviceInfo.maximumChannelCount());
+ channelsSpinBox->setValue(channelValue);
+
+ sampleFormatBox->clear();
+ const QList<QAudioFormat::SampleFormat> sampleFormats = m_deviceInfo.supportedSampleFormats();
+ for (auto sampleFormat : sampleFormats)
+ sampleFormatBox->addItem(toString(sampleFormat));
+ if (sampleFormats.size())
+ m_settings.setSampleFormat(sampleFormats.at(0));
allFormatsTable->clearContents();
}
@@ -218,92 +167,43 @@ void AudioTest::populateTable()
{
int row = 0;
- QAudioFormat format;
- for (auto codec: m_deviceInfo.supportedCodecs()) {
- format.setCodec(codec);
- for (auto sampleRate: m_deviceInfo.supportedSampleRates()) {
- format.setSampleRate(sampleRate);
- for (auto channels: m_deviceInfo.supportedChannelCounts()) {
- format.setChannelCount(channels);
- for (auto sampleType: m_deviceInfo.supportedSampleTypes()) {
- format.setSampleType(sampleType);
- for (auto sampleSize: m_deviceInfo.supportedSampleSizes()) {
- format.setSampleSize(sampleSize);
- for (auto endian: m_deviceInfo.supportedByteOrders()) {
- format.setByteOrder(endian);
- if (m_deviceInfo.isFormatSupported(format)) {
- allFormatsTable->setRowCount(row + 1);
-
- QTableWidgetItem *codecItem = new QTableWidgetItem(format.codec());
- allFormatsTable->setItem(row, 0, codecItem);
-
- QTableWidgetItem *sampleRateItem = new QTableWidgetItem(QString("%1").arg(format.sampleRate()));
- allFormatsTable->setItem(row, 1, sampleRateItem);
+ for (auto sampleFormat : m_deviceInfo.supportedSampleFormats()) {
+ allFormatsTable->setRowCount(row + 1);
- QTableWidgetItem *channelsItem = new QTableWidgetItem(QString("%1").arg(format.channelCount()));
- allFormatsTable->setItem(row, 2, channelsItem);
+ QTableWidgetItem *sampleTypeItem = new QTableWidgetItem(toString(sampleFormat));
+ allFormatsTable->setItem(row, 0, sampleTypeItem);
- QTableWidgetItem *sampleTypeItem = new QTableWidgetItem(toString(format.sampleType()));
- allFormatsTable->setItem(row, 3, sampleTypeItem);
+ QTableWidgetItem *sampleRateItem =
+ new QTableWidgetItem(QStringLiteral("%1 - %2")
+ .arg(m_deviceInfo.minimumSampleRate())
+ .arg(m_deviceInfo.maximumSampleRate()));
+ allFormatsTable->setItem(row, 1, sampleRateItem);
- QTableWidgetItem *sampleSizeItem = new QTableWidgetItem(QString("%1").arg(format.sampleSize()));
- allFormatsTable->setItem(row, 4, sampleSizeItem);
+ QTableWidgetItem *channelsItem =
+ new QTableWidgetItem(QStringLiteral("%1 - %2")
+ .arg(m_deviceInfo.minimumChannelCount())
+ .arg(m_deviceInfo.maximumChannelCount()));
+ allFormatsTable->setItem(row, 2, channelsItem);
- QTableWidgetItem *byteOrderItem = new QTableWidgetItem(toString(format.byteOrder()));
- allFormatsTable->setItem(row, 5, byteOrderItem);
-
- ++row;
- }
- }
- }
- }
- }
- }
+ ++row;
}
}
-void AudioTest::sampleRateChanged(int idx)
+void AudioTest::sampleRateChanged(int value)
{
// sample rate has changed
- m_settings.setSampleRate(sampleRateBox->itemText(idx).toInt());
-}
-
-void AudioTest::channelChanged(int idx)
-{
- m_settings.setChannelCount(channelsBox->itemText(idx).toInt());
-}
-
-void AudioTest::codecChanged(int idx)
-{
- m_settings.setCodec(codecsBox->itemText(idx));
+ m_settings.setSampleRate(value);
}
-void AudioTest::sampleSizeChanged(int idx)
+void AudioTest::channelChanged(int channels)
{
- m_settings.setSampleSize(sampleSizesBox->itemText(idx).toInt());
+ m_settings.setChannelCount(channels);
}
-void AudioTest::sampleTypeChanged(int idx)
+void AudioTest::sampleFormatChanged(int idx)
{
- switch (sampleTypesBox->itemText(idx).toInt()) {
- case QAudioFormat::SignedInt:
- m_settings.setSampleType(QAudioFormat::SignedInt);
- break;
- case QAudioFormat::UnSignedInt:
- m_settings.setSampleType(QAudioFormat::UnSignedInt);
- break;
- case QAudioFormat::Float:
- m_settings.setSampleType(QAudioFormat::Float);
- }
+ auto formats = m_deviceInfo.supportedSampleFormats();
+ m_settings.setSampleFormat(formats.at(idx));
}
-void AudioTest::endianChanged(int idx)
-{
- switch (endianBox->itemText(idx).toInt()) {
- case QAudioFormat::LittleEndian:
- m_settings.setByteOrder(QAudioFormat::LittleEndian);
- break;
- case QAudioFormat::BigEndian:
- m_settings.setByteOrder(QAudioFormat::BigEndian);
- }
-}
+#include "moc_audiodevices.cpp"
diff --git a/examples/multimedia/audiodevices/audiodevices.h b/examples/multimedia/audiodevices/audiodevices.h
index 85ea828ef..efe4e373c 100644
--- a/examples/multimedia/audiodevices/audiodevices.h
+++ b/examples/multimedia/audiodevices/audiodevices.h
@@ -1,66 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIODEVICES_H
#define AUDIODEVICES_H
-#include <QAudioDeviceInfo>
+#include "ui_audiodevicesbase.h"
+
+#include <QAudioDevice>
#include <QMainWindow>
+#include <QMediaDevices>
#include <QObject>
-#include "ui_audiodevicesbase.h"
-
class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase
{
public:
- AudioDevicesBase(QWidget *parent = 0);
+ AudioDevicesBase(QWidget *parent = nullptr);
virtual ~AudioDevicesBase();
};
@@ -72,22 +26,21 @@ public:
explicit AudioTest(QWidget *parent = nullptr);
private:
- QAudioDeviceInfo m_deviceInfo;
+ QAudioDevice m_deviceInfo;
QAudioFormat m_settings;
+ QAudioDevice::Mode m_mode = QAudioDevice::Input;
+ QMediaDevices *m_devices = nullptr;
private slots:
+ void init();
+ void updateAudioDevices();
void modeChanged(int idx);
void deviceChanged(int idx);
void sampleRateChanged(int idx);
void channelChanged(int idx);
- void codecChanged(int idx);
- void sampleSizeChanged(int idx);
- void sampleTypeChanged(int idx);
- void endianChanged(int idx);
+ void sampleFormatChanged(int idx);
void test();
void populateTable();
-
};
#endif
-
diff --git a/examples/multimedia/audiodevices/audiodevicesbase.ui b/examples/multimedia/audiodevices/audiodevicesbase.ui
index 427597338..9618a3d22 100644
--- a/examples/multimedia/audiodevices/audiodevicesbase.ui
+++ b/examples/multimedia/audiodevices/audiodevicesbase.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>679</width>
- <height>598</height>
+ <width>646</width>
+ <height>528</height>
</rect>
</property>
<property name="windowTitle">
@@ -31,8 +31,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>659</width>
- <height>558</height>
+ <width>626</width>
+ <height>480</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -79,198 +79,137 @@
<string>Test format</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1">
- <widget class="QLabel" name="actualLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
+ <item row="12" column="1">
+ <widget class="QPushButton" name="testButton">
<property name="text">
- <string>&lt;i&gt;Actual Settings&lt;/i&gt;</string>
- </property>
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ <string>Test</string>
</property>
</widget>
</item>
- <item row="0" column="2">
- <widget class="QLabel" name="nearestLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
+ <item row="12" column="2">
+ <widget class="QLabel" name="testResult">
<property name="text">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Nearest Settings&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ <string/>
</property>
</widget>
</item>
- <item row="3" column="1">
- <widget class="QComboBox" name="sampleRateBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <item row="4" column="0">
+ <widget class="QLabel" name="actualChannelLabel">
+ <property name="text">
+ <string>Channels</string>
</property>
</widget>
</item>
- <item row="3" column="2">
+ <item row="2" column="2">
<widget class="QLineEdit" name="nearestSampleRate">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="5" column="1">
- <widget class="QComboBox" name="channelsBox"/>
- </item>
<item row="5" column="2">
- <widget class="QLineEdit" name="nearestChannel">
+ <widget class="QLineEdit" name="nearestSampleFormat">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="9" column="1">
- <widget class="QComboBox" name="sampleSizesBox"/>
- </item>
- <item row="9" column="2">
- <widget class="QLineEdit" name="nearestSampleSize">
- <property name="enabled">
- <bool>false</bool>
+ <item row="5" column="0">
+ <widget class="QLabel" name="actualSampleTypeLabel">
+ <property name="text">
+ <string>Sample Format</string>
</property>
</widget>
</item>
- <item row="14" column="1">
- <widget class="QComboBox" name="endianBox"/>
- </item>
- <item row="14" column="2">
- <widget class="QLineEdit" name="nearestEndian">
+ <item row="4" column="2">
+ <widget class="QLineEdit" name="nearestChannel">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="15" column="1">
- <widget class="QPushButton" name="testButton">
- <property name="text">
- <string>Test</string>
- </property>
- </widget>
- </item>
- <item row="15" column="2">
- <widget class="QLabel" name="testResult">
- <property name="text">
- <string/>
- </property>
- </widget>
+ <item row="5" column="1">
+ <widget class="QComboBox" name="sampleFormatBox"/>
</item>
- <item row="3" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="actualFreqLabel">
<property name="text">
<string>Frequency (Hz)</string>
</property>
</widget>
</item>
- <item row="5" column="0">
- <widget class="QLabel" name="actualChannelLabel">
- <property name="text">
- <string>Channels</string>
+ <item row="0" column="1">
+ <widget class="QLabel" name="actualLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- </widget>
- </item>
- <item row="9" column="0">
- <widget class="QLabel" name="actualSampleSizeLabel">
- <property name="text">
- <string>Sample size (bits)</string>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
</property>
- </widget>
- </item>
- <item row="14" column="0">
- <widget class="QLabel" name="actualEndianLabel">
<property name="text">
- <string>Endianness</string>
+ <string>&lt;i&gt;Actual Settings&lt;/i&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
- <item row="16" column="0" colspan="3">
- <widget class="QLabel" name="label">
+ <item row="0" column="2">
+ <widget class="QLabel" name="nearestLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text">
- <string>Note: an invalid codec 'audio/test' exists in order to allow an invalid format to be constructed, and therefore to trigger a 'nearest format' calculation.</string>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
</property>
- <property name="wordWrap">
- <bool>true</bool>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
</property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="actualCodecLabel">
<property name="text">
- <string>Codec</string>
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Nearest Settings&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QLineEdit" name="nearestCodec">
- <property name="enabled">
- <bool>false</bool>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
</property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="codecsBox"/>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="actualSampleTypeLabel">
- <property name="text">
- <string>SampleType</string>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
- <item row="6" column="1">
- <widget class="QComboBox" name="sampleTypesBox"/>
+ <item row="13" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
</item>
- <item row="6" column="2">
- <widget class="QLineEdit" name="nearestSampleType">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="sampleRateSpinBox"/>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="channelsSpinBox"/>
</item>
</layout>
</widget>
@@ -312,9 +251,15 @@ p, li { white-space: pre-wrap; }
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
+ <property name="columnCount">
+ <number>3</number>
+ </property>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
@@ -323,10 +268,10 @@ p, li { white-space: pre-wrap; }
</attribute>
<column>
<property name="text">
- <string>Codec</string>
+ <string>Sample Format</string>
</property>
<property name="textAlignment">
- <set>AlignHCenter|AlignVCenter|AlignCenter</set>
+ <set>AlignCenter</set>
</property>
</column>
<column>
@@ -334,7 +279,7 @@ p, li { white-space: pre-wrap; }
<string>Frequency (Hz)</string>
</property>
<property name="textAlignment">
- <set>AlignHCenter|AlignVCenter|AlignCenter</set>
+ <set>AlignCenter</set>
</property>
</column>
<column>
@@ -342,31 +287,7 @@ p, li { white-space: pre-wrap; }
<string>Channels</string>
</property>
<property name="textAlignment">
- <set>AlignHCenter|AlignVCenter|AlignCenter</set>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Sample type</string>
- </property>
- <property name="textAlignment">
- <set>AlignHCenter|AlignVCenter|AlignCenter</set>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Sample size (bits)</string>
- </property>
- <property name="textAlignment">
- <set>AlignHCenter|AlignVCenter|AlignCenter</set>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Endianness</string>
- </property>
- <property name="textAlignment">
- <set>AlignHCenter|AlignVCenter|AlignCenter</set>
+ <set>AlignCenter</set>
</property>
</column>
</widget>
diff --git a/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc b/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc
index 208590e9e..1aac6abb0 100644
--- a/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc
+++ b/examples/multimedia/audiodevices/doc/src/audiodevices.qdoc
@@ -1,35 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiodevices
+ \example audiodevices
\title Audio Devices Example
\ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
\brief Testing the available audio devices and their configuration.
+ \meta {tag} {widgets}
\e{Audio Devices} demonstrates how to create a simple application to list
and test the configuration for the various audio devices available on the
diff --git a/examples/multimedia/audiodevices/main.cpp b/examples/multimedia/audiodevices/main.cpp
index 9042d391a..411f67092 100644
--- a/examples/multimedia/audiodevices/main.cpp
+++ b/examples/multimedia/audiodevices/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QtWidgets>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiodevices.h"
+#include <QApplication>
+
int main(int argv, char **args)
{
QApplication app(argv, args);
diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp
deleted file mode 100644
index 611500c41..000000000
--- a/examples/multimedia/audioinput/audioinput.cpp
+++ /dev/null
@@ -1,359 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "audioinput.h"
-
-#include <stdlib.h>
-#include <math.h>
-
-#include <QDateTime>
-#include <QDebug>
-#include <QPainter>
-#include <QVBoxLayout>
-#include <QAudioDeviceInfo>
-#include <QAudioInput>
-#include <qendian.h>
-
-AudioInfo::AudioInfo(const QAudioFormat &format)
- : m_format(format)
-{
- switch (m_format.sampleSize()) {
- case 8:
- switch (m_format.sampleType()) {
- case QAudioFormat::UnSignedInt:
- m_maxAmplitude = 255;
- break;
- case QAudioFormat::SignedInt:
- m_maxAmplitude = 127;
- break;
- default:
- break;
- }
- break;
- case 16:
- switch (m_format.sampleType()) {
- case QAudioFormat::UnSignedInt:
- m_maxAmplitude = 65535;
- break;
- case QAudioFormat::SignedInt:
- m_maxAmplitude = 32767;
- break;
- default:
- break;
- }
- break;
-
- case 32:
- switch (m_format.sampleType()) {
- case QAudioFormat::UnSignedInt:
- m_maxAmplitude = 0xffffffff;
- break;
- case QAudioFormat::SignedInt:
- m_maxAmplitude = 0x7fffffff;
- break;
- case QAudioFormat::Float:
- m_maxAmplitude = 0x7fffffff; // Kind of
- default:
- break;
- }
- break;
-
- default:
- break;
- }
-}
-
-void AudioInfo::start()
-{
- open(QIODevice::WriteOnly);
-}
-
-void AudioInfo::stop()
-{
- close();
-}
-
-qint64 AudioInfo::readData(char *data, qint64 maxlen)
-{
- Q_UNUSED(data);
- Q_UNUSED(maxlen);
-
- return 0;
-}
-
-qint64 AudioInfo::writeData(const char *data, qint64 len)
-{
- if (m_maxAmplitude) {
- Q_ASSERT(m_format.sampleSize() % 8 == 0);
- const int channelBytes = m_format.sampleSize() / 8;
- const int sampleBytes = m_format.channelCount() * channelBytes;
- Q_ASSERT(len % sampleBytes == 0);
- const int numSamples = len / sampleBytes;
-
- quint32 maxValue = 0;
- const unsigned char *ptr = reinterpret_cast<const unsigned char *>(data);
-
- for (int i = 0; i < numSamples; ++i) {
- for (int j = 0; j < m_format.channelCount(); ++j) {
- quint32 value = 0;
-
- if (m_format.sampleSize() == 8 && m_format.sampleType() == QAudioFormat::UnSignedInt) {
- value = *reinterpret_cast<const quint8*>(ptr);
- } else if (m_format.sampleSize() == 8 && m_format.sampleType() == QAudioFormat::SignedInt) {
- value = qAbs(*reinterpret_cast<const qint8*>(ptr));
- } else if (m_format.sampleSize() == 16 && m_format.sampleType() == QAudioFormat::UnSignedInt) {
- if (m_format.byteOrder() == QAudioFormat::LittleEndian)
- value = qFromLittleEndian<quint16>(ptr);
- else
- value = qFromBigEndian<quint16>(ptr);
- } else if (m_format.sampleSize() == 16 && m_format.sampleType() == QAudioFormat::SignedInt) {
- if (m_format.byteOrder() == QAudioFormat::LittleEndian)
- value = qAbs(qFromLittleEndian<qint16>(ptr));
- else
- value = qAbs(qFromBigEndian<qint16>(ptr));
- } else if (m_format.sampleSize() == 32 && m_format.sampleType() == QAudioFormat::UnSignedInt) {
- if (m_format.byteOrder() == QAudioFormat::LittleEndian)
- value = qFromLittleEndian<quint32>(ptr);
- else
- value = qFromBigEndian<quint32>(ptr);
- } else if (m_format.sampleSize() == 32 && m_format.sampleType() == QAudioFormat::SignedInt) {
- if (m_format.byteOrder() == QAudioFormat::LittleEndian)
- value = qAbs(qFromLittleEndian<qint32>(ptr));
- else
- value = qAbs(qFromBigEndian<qint32>(ptr));
- } else if (m_format.sampleSize() == 32 && m_format.sampleType() == QAudioFormat::Float) {
- value = qAbs(*reinterpret_cast<const float*>(ptr) * 0x7fffffff); // assumes 0-1.0
- }
-
- maxValue = qMax(value, maxValue);
- ptr += channelBytes;
- }
- }
-
- maxValue = qMin(maxValue, m_maxAmplitude);
- m_level = qreal(maxValue) / m_maxAmplitude;
- }
-
- emit update();
- return len;
-}
-
-RenderArea::RenderArea(QWidget *parent)
- : QWidget(parent)
-{
- setBackgroundRole(QPalette::Base);
- setAutoFillBackground(true);
-
- setMinimumHeight(30);
- setMinimumWidth(200);
-}
-
-void RenderArea::paintEvent(QPaintEvent * /* event */)
-{
- QPainter painter(this);
-
- painter.setPen(Qt::black);
- painter.drawRect(QRect(painter.viewport().left()+10,
- painter.viewport().top()+10,
- painter.viewport().right()-20,
- painter.viewport().bottom()-20));
- if (m_level == 0.0)
- return;
-
- int pos = ((painter.viewport().right()-20)-(painter.viewport().left()+11))*m_level;
- painter.fillRect(painter.viewport().left()+11,
- painter.viewport().top()+10,
- pos,
- painter.viewport().height()-21,
- Qt::red);
-}
-
-void RenderArea::setLevel(qreal value)
-{
- m_level = value;
- update();
-}
-
-
-InputTest::InputTest()
-{
- initializeWindow();
- initializeAudio(QAudioDeviceInfo::defaultInputDevice());
-}
-
-
-void InputTest::initializeWindow()
-{
- QWidget *window = new QWidget;
- QVBoxLayout *layout = new QVBoxLayout;
-
- m_canvas = new RenderArea(this);
- layout->addWidget(m_canvas);
-
- m_deviceBox = new QComboBox(this);
- const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultInputDevice();
- m_deviceBox->addItem(defaultDeviceInfo.deviceName(), QVariant::fromValue(defaultDeviceInfo));
- for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) {
- if (deviceInfo != defaultDeviceInfo)
- m_deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo));
- }
-
- connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this, &InputTest::deviceChanged);
- layout->addWidget(m_deviceBox);
-
- m_volumeSlider = new QSlider(Qt::Horizontal, this);
- m_volumeSlider->setRange(0, 100);
- m_volumeSlider->setValue(100);
- connect(m_volumeSlider, &QSlider::valueChanged, this, &InputTest::sliderChanged);
- layout->addWidget(m_volumeSlider);
-
- m_modeButton = new QPushButton(this);
- connect(m_modeButton, &QPushButton::clicked, this, &InputTest::toggleMode);
- layout->addWidget(m_modeButton);
-
- m_suspendResumeButton = new QPushButton(this);
- connect(m_suspendResumeButton, &QPushButton::clicked, this, &InputTest::toggleSuspend);
- layout->addWidget(m_suspendResumeButton);
-
- window->setLayout(layout);
-
- setCentralWidget(window);
- window->show();
-}
-
-void InputTest::initializeAudio(const QAudioDeviceInfo &deviceInfo)
-{
- QAudioFormat format;
- format.setSampleRate(8000);
- format.setChannelCount(1);
- format.setSampleSize(16);
- format.setSampleType(QAudioFormat::SignedInt);
- format.setByteOrder(QAudioFormat::LittleEndian);
- format.setCodec("audio/pcm");
-
- if (!deviceInfo.isFormatSupported(format)) {
- qWarning() << "Default format not supported - trying to use nearest";
- format = deviceInfo.nearestFormat(format);
- }
-
- m_audioInfo.reset(new AudioInfo(format));
- connect(m_audioInfo.data(), &AudioInfo::update, [this]() {
- m_canvas->setLevel(m_audioInfo->level());
- });
-
- m_audioInput.reset(new QAudioInput(deviceInfo, format));
- qreal initialVolume = QAudio::convertVolume(m_audioInput->volume(),
- QAudio::LinearVolumeScale,
- QAudio::LogarithmicVolumeScale);
- m_volumeSlider->setValue(qRound(initialVolume * 100));
- m_audioInfo->start();
- toggleMode();
-}
-
-void InputTest::toggleMode()
-{
- m_audioInput->stop();
- toggleSuspend();
-
- // Change bewteen pull and push modes
- if (m_pullMode) {
- m_modeButton->setText(tr("Enable push mode"));
- m_audioInput->start(m_audioInfo.data());
- } else {
- m_modeButton->setText(tr("Enable pull mode"));
- auto io = m_audioInput->start();
- connect(io, &QIODevice::readyRead,
- [&, io]() {
- qint64 len = m_audioInput->bytesReady();
- const int BufferSize = 4096;
- if (len > BufferSize)
- len = BufferSize;
-
- QByteArray buffer(len, 0);
- qint64 l = io->read(buffer.data(), len);
- if (l > 0)
- m_audioInfo->write(buffer.constData(), l);
- });
- }
-
- m_pullMode = !m_pullMode;
-}
-
-void InputTest::toggleSuspend()
-{
- // toggle suspend/resume
- if (m_audioInput->state() == QAudio::SuspendedState || m_audioInput->state() == QAudio::StoppedState) {
- m_audioInput->resume();
- m_suspendResumeButton->setText(tr("Suspend recording"));
- } else if (m_audioInput->state() == QAudio::ActiveState) {
- m_audioInput->suspend();
- m_suspendResumeButton->setText(tr("Resume recording"));
- } else if (m_audioInput->state() == QAudio::IdleState) {
- // no-op
- }
-}
-
-void InputTest::deviceChanged(int index)
-{
- m_audioInfo->stop();
- m_audioInput->stop();
- m_audioInput->disconnect(this);
-
- initializeAudio(m_deviceBox->itemData(index).value<QAudioDeviceInfo>());
-}
-
-void InputTest::sliderChanged(int value)
-{
- qreal linearVolume = QAudio::convertVolume(value / qreal(100),
- QAudio::LogarithmicVolumeScale,
- QAudio::LinearVolumeScale);
-
- m_audioInput->setVolume(linearVolume);
-}
diff --git a/examples/multimedia/audioinput/audioinput.h b/examples/multimedia/audioinput/audioinput.h
deleted file mode 100644
index 33ddd51af..000000000
--- a/examples/multimedia/audioinput/audioinput.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef AUDIOINPUT_H
-#define AUDIOINPUT_H
-
-#include <QAudioInput>
-#include <QByteArray>
-#include <QComboBox>
-#include <QMainWindow>
-#include <QObject>
-#include <QPixmap>
-#include <QPushButton>
-#include <QSlider>
-#include <QWidget>
-#include <QScopedPointer>
-
-class AudioInfo : public QIODevice
-{
- Q_OBJECT
-
-public:
- AudioInfo(const QAudioFormat &format);
-
- void start();
- void stop();
-
- qreal level() const { return m_level; }
-
- qint64 readData(char *data, qint64 maxlen) override;
- qint64 writeData(const char *data, qint64 len) override;
-
-private:
- const QAudioFormat m_format;
- quint32 m_maxAmplitude = 0;
- qreal m_level = 0.0; // 0.0 <= m_level <= 1.0
-
-signals:
- void update();
-};
-
-
-class RenderArea : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit RenderArea(QWidget *parent = nullptr);
-
- void setLevel(qreal value);
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-private:
- qreal m_level = 0;
- QPixmap m_pixmap;
-};
-
-
-class InputTest : public QMainWindow
-{
- Q_OBJECT
-
-public:
- InputTest();
-
-private:
- void initializeWindow();
- void initializeAudio(const QAudioDeviceInfo &deviceInfo);
-
-private slots:
- void toggleMode();
- void toggleSuspend();
- void deviceChanged(int index);
- void sliderChanged(int value);
-
-private:
- // Owned by layout
- RenderArea *m_canvas = nullptr;
- QPushButton *m_modeButton = nullptr;
- QPushButton *m_suspendResumeButton = nullptr;
- QComboBox *m_deviceBox = nullptr;
- QSlider *m_volumeSlider = nullptr;
-
- QScopedPointer<AudioInfo> m_audioInfo;
- QScopedPointer<QAudioInput> m_audioInput;
- bool m_pullMode = true;
-};
-
-#endif // AUDIOINPUT_H
diff --git a/examples/multimedia/audioinput/audioinput.pro b/examples/multimedia/audioinput/audioinput.pro
deleted file mode 100644
index 708d40d93..000000000
--- a/examples/multimedia/audioinput/audioinput.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-TARGET = audioinput
-
-QT += multimedia widgets
-
-HEADERS = audioinput.h
-
-SOURCES = audioinput.cpp \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audioinput
-INSTALLS += target
-include(../shared/shared.pri)
diff --git a/examples/multimedia/audioinput/doc/src/audioinput.qdoc b/examples/multimedia/audioinput/doc/src/audioinput.qdoc
deleted file mode 100644
index 5339f2821..000000000
--- a/examples/multimedia/audioinput/doc/src/audioinput.qdoc
+++ /dev/null
@@ -1,45 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example multimedia/audioinput
- \title Audio Input Example
- \ingroup multimedia_examples
- \brief Recording audio using the QAudioInput class.
-
- \e{Audio Input} demonstrates the basic use cases of QAudioInput.
-
- \image audioinput-example.png
-
- Qt provides the QAudioInput class to enable audio functionality within
- a standard application user interface.
-
- This example calculates the maximum linear value of the input audio from the
- microphone and displays the output.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/multimedia/audioinput/main.cpp b/examples/multimedia/audioinput/main.cpp
deleted file mode 100644
index 393f64415..000000000
--- a/examples/multimedia/audioinput/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QtWidgets>
-
-#include "audioinput.h"
-
-int main(int argv, char **args)
-{
- QApplication app(argv, args);
- app.setApplicationName("Audio Input Test");
-
- InputTest input;
- input.show();
-
- return app.exec();
-}
diff --git a/examples/multimedia/audiooutput/CMakeLists.txt b/examples/multimedia/audiooutput/CMakeLists.txt
new file mode 100644
index 000000000..9308463d2
--- /dev/null
+++ b/examples/multimedia/audiooutput/CMakeLists.txt
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(audiooutput LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/audiooutput")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Widgets)
+
+qt_add_executable(audiooutput
+ audiooutput.cpp audiooutput.h
+ main.cpp
+)
+
+set_target_properties(audiooutput PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(audiooutput PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Widgets
+)
+
+install(TARGETS audiooutput
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index b6eb41f69..809b79293 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -1,65 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiooutput.h"
-#include <QAudioDeviceInfo>
-#include <QAudioOutput>
+#include <QAudioDevice>
+#include <QAudioSink>
#include <QDebug>
#include <QVBoxLayout>
-#include <qmath.h>
-#include <qendian.h>
+#include <QtEndian>
+#include <QtMath>
-Generator::Generator(const QAudioFormat &format
- , qint64 durationUs
- , int sampleRate)
+Generator::Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate)
{
if (format.isValid())
generateData(format, durationUs, sampleRate);
@@ -78,10 +29,9 @@ void Generator::stop()
void Generator::generateData(const QAudioFormat &format, qint64 durationUs, int sampleRate)
{
- const int channelBytes = format.sampleSize() / 8;
+ const int channelBytes = format.bytesPerSample();
const int sampleBytes = format.channelCount() * channelBytes;
- qint64 length = (format.sampleRate() * format.channelCount() * (format.sampleSize() / 8))
- * durationUs / 1000000;
+ qint64 length = format.bytesForDuration(durationUs);
Q_ASSERT(length % sampleBytes == 0);
Q_UNUSED(sampleBytes); // suppress warning in release builds
@@ -91,30 +41,25 @@ void Generator::generateData(const QAudioFormat &format, qint64 durationUs, int
while (length) {
// Produces value (-1..1)
- const qreal x = qSin(2 * M_PI * sampleRate * qreal(sampleIndex++ % format.sampleRate()) / format.sampleRate());
- for (int i=0; i<format.channelCount(); ++i) {
- if (format.sampleSize() == 8) {
- if (format.sampleType() == QAudioFormat::UnSignedInt) {
- const quint8 value = static_cast<quint8>((1.0 + x) / 2 * 255);
- *reinterpret_cast<quint8 *>(ptr) = value;
- } else if (format.sampleType() == QAudioFormat::SignedInt) {
- const qint8 value = static_cast<qint8>(x * 127);
- *reinterpret_cast<qint8 *>(ptr) = value;
- }
- } else if (format.sampleSize() == 16) {
- if (format.sampleType() == QAudioFormat::UnSignedInt) {
- quint16 value = static_cast<quint16>((1.0 + x) / 2 * 65535);
- if (format.byteOrder() == QAudioFormat::LittleEndian)
- qToLittleEndian<quint16>(value, ptr);
- else
- qToBigEndian<quint16>(value, ptr);
- } else if (format.sampleType() == QAudioFormat::SignedInt) {
- qint16 value = static_cast<qint16>(x * 32767);
- if (format.byteOrder() == QAudioFormat::LittleEndian)
- qToLittleEndian<qint16>(value, ptr);
- else
- qToBigEndian<qint16>(value, ptr);
- }
+ const qreal x = qSin(2 * M_PI * sampleRate * qreal(sampleIndex++ % format.sampleRate())
+ / format.sampleRate());
+ for (int i = 0; i < format.channelCount(); ++i) {
+ switch (format.sampleFormat()) {
+ case QAudioFormat::UInt8:
+ *reinterpret_cast<quint8 *>(ptr) = static_cast<quint8>((1.0 + x) / 2 * 255);
+ break;
+ case QAudioFormat::Int16:
+ *reinterpret_cast<qint16 *>(ptr) = static_cast<qint16>(x * 32767);
+ break;
+ case QAudioFormat::Int32:
+ *reinterpret_cast<qint32 *>(ptr) =
+ static_cast<qint32>(x * std::numeric_limits<qint32>::max());
+ break;
+ case QAudioFormat::Float:
+ *reinterpret_cast<float *>(ptr) = x;
+ break;
+ default:
+ break;
}
ptr += channelBytes;
@@ -150,11 +95,10 @@ qint64 Generator::bytesAvailable() const
return m_buffer.size() + QIODevice::bytesAvailable();
}
-AudioTest::AudioTest()
- : m_pushTimer(new QTimer(this))
+AudioTest::AudioTest() : m_devices(new QMediaDevices(this)), m_pushTimer(new QTimer(this))
{
initializeWindow();
- initializeAudio(QAudioDeviceInfo::defaultOutputDevice());
+ initializeAudio(m_devices->defaultAudioOutput());
}
AudioTest::~AudioTest()
@@ -168,13 +112,15 @@ void AudioTest::initializeWindow()
QVBoxLayout *layout = new QVBoxLayout;
m_deviceBox = new QComboBox(this);
- const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
- m_deviceBox->addItem(defaultDeviceInfo.deviceName(), QVariant::fromValue(defaultDeviceInfo));
- for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
+ const QAudioDevice &defaultDeviceInfo = m_devices->defaultAudioOutput();
+ m_deviceBox->addItem(defaultDeviceInfo.description(), QVariant::fromValue(defaultDeviceInfo));
+ for (auto &deviceInfo : m_devices->audioOutputs()) {
if (deviceInfo != defaultDeviceInfo)
- m_deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo));
+ m_deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
}
- connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::deviceChanged);
+ connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this,
+ &AudioTest::deviceChanged);
+ connect(m_devices, &QMediaDevices::audioOutputsChanged, this, &AudioTest::updateAudioDevices);
layout->addWidget(m_deviceBox);
m_modeButton = new QPushButton(this);
@@ -203,29 +149,17 @@ void AudioTest::initializeWindow()
window->show();
}
-void AudioTest::initializeAudio(const QAudioDeviceInfo &deviceInfo)
+void AudioTest::initializeAudio(const QAudioDevice &deviceInfo)
{
- QAudioFormat format;
- format.setSampleRate(44100);
- format.setChannelCount(1);
- format.setSampleSize(16);
- format.setCodec("audio/pcm");
- format.setByteOrder(QAudioFormat::LittleEndian);
- format.setSampleType(QAudioFormat::SignedInt);
-
- if (!deviceInfo.isFormatSupported(format)) {
- qWarning() << "Default format not supported - trying to use nearest";
- format = deviceInfo.nearestFormat(format);
- }
+ QAudioFormat format = deviceInfo.preferredFormat();
const int durationSeconds = 1;
const int toneSampleRateHz = 600;
m_generator.reset(new Generator(format, durationSeconds * 1000000, toneSampleRateHz));
- m_audioOutput.reset(new QAudioOutput(deviceInfo, format));
+ m_audioOutput.reset(new QAudioSink(deviceInfo, format));
m_generator->start();
- qreal initialVolume = QAudio::convertVolume(m_audioOutput->volume(),
- QAudio::LinearVolumeScale,
+ qreal initialVolume = QAudio::convertVolume(m_audioOutput->volume(), QAudio::LinearVolumeScale,
QAudio::LogarithmicVolumeScale);
m_volumeSlider->setValue(qRound(initialVolume * 100));
toggleMode();
@@ -236,18 +170,25 @@ void AudioTest::deviceChanged(int index)
m_generator->stop();
m_audioOutput->stop();
m_audioOutput->disconnect(this);
- initializeAudio(m_deviceBox->itemData(index).value<QAudioDeviceInfo>());
+ initializeAudio(m_deviceBox->itemData(index).value<QAudioDevice>());
}
void AudioTest::volumeChanged(int value)
{
- qreal linearVolume = QAudio::convertVolume(value / qreal(100),
- QAudio::LogarithmicVolumeScale,
+ qreal linearVolume = QAudio::convertVolume(value / qreal(100), QAudio::LogarithmicVolumeScale,
QAudio::LinearVolumeScale);
m_audioOutput->setVolume(linearVolume);
}
+void AudioTest::updateAudioDevices()
+{
+ m_deviceBox->clear();
+ const QList<QAudioDevice> devices = m_devices->audioOutputs();
+ for (const QAudioDevice &deviceInfo : devices)
+ m_deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
+}
+
void AudioTest::toggleMode()
{
m_pushTimer->stop();
@@ -255,11 +196,11 @@ void AudioTest::toggleMode()
toggleSuspendResume();
if (m_pullMode) {
- //switch to pull mode (QAudioOutput pulls from Generator as needed)
+ // switch to pull mode (QAudioSink pulls from Generator as needed)
m_modeButton->setText(tr("Enable push mode"));
m_audioOutput->start(m_generator.data());
} else {
- //switch to push mode (periodically push to QAudioOutput using a timer)
+ // switch to push mode (periodically push to QAudioSink using a timer)
m_modeButton->setText(tr("Enable pull mode"));
auto io = m_audioOutput->start();
m_pushTimer->disconnect();
@@ -268,19 +209,14 @@ void AudioTest::toggleMode()
if (m_audioOutput->state() == QAudio::StoppedState)
return;
- QByteArray buffer(32768, 0);
- int chunks = m_audioOutput->bytesFree() / m_audioOutput->periodSize();
- while (chunks) {
- const qint64 len = m_generator->read(buffer.data(), m_audioOutput->periodSize());
- if (len)
- io->write(buffer.data(), len);
- if (len != m_audioOutput->periodSize())
- break;
- --chunks;
- }
+ int len = m_audioOutput->bytesFree();
+ QByteArray buffer(len, 0);
+ len = m_generator->read(buffer.data(), len);
+ if (len)
+ io->write(buffer.data(), len);
});
- m_pushTimer->start(20);
+ m_pushTimer->start(10);
}
m_pullMode = !m_pullMode;
@@ -288,9 +224,10 @@ void AudioTest::toggleMode()
void AudioTest::toggleSuspendResume()
{
- if (m_audioOutput->state() == QAudio::SuspendedState || m_audioOutput->state() == QAudio::StoppedState) {
+ if (m_audioOutput->state() == QAudio::SuspendedState
+ || m_audioOutput->state() == QAudio::StoppedState) {
m_audioOutput->resume();
- m_suspendResumeButton->setText(tr("Suspend recording"));
+ m_suspendResumeButton->setText(tr("Suspend playback"));
} else if (m_audioOutput->state() == QAudio::ActiveState) {
m_audioOutput->suspend();
m_suspendResumeButton->setText(tr("Resume playback"));
@@ -299,3 +236,4 @@ void AudioTest::toggleSuspendResume()
}
}
+#include "moc_audiooutput.cpp"
diff --git a/examples/multimedia/audiooutput/audiooutput.h b/examples/multimedia/audiooutput/audiooutput.h
index c17f47727..3a82c57c4 100644
--- a/examples/multimedia/audiooutput/audiooutput.h
+++ b/examples/multimedia/audiooutput/audiooutput.h
@@ -1,69 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIOOUTPUT_H
#define AUDIOOUTPUT_H
-#include <math.h>
-
-#include <QAudioOutput>
+#include <QAudioSink>
#include <QByteArray>
#include <QComboBox>
#include <QIODevice>
#include <QLabel>
#include <QMainWindow>
+#include <QMediaDevices>
#include <QObject>
#include <QPushButton>
+#include <QScopedPointer>
#include <QSlider>
#include <QTimer>
-#include <QScopedPointer>
+
+#include <math.h>
class Generator : public QIODevice
{
@@ -78,6 +32,7 @@ public:
qint64 readData(char *data, qint64 maxlen) override;
qint64 writeData(const char *data, qint64 len) override;
qint64 bytesAvailable() const override;
+ qint64 size() const override { return m_buffer.size(); }
private:
void generateData(const QAudioFormat &format, qint64 durationUs, int sampleRate);
@@ -97,9 +52,10 @@ public:
private:
void initializeWindow();
- void initializeAudio(const QAudioDeviceInfo &deviceInfo);
+ void initializeAudio(const QAudioDevice &deviceInfo);
private:
+ QMediaDevices *m_devices = nullptr;
QTimer *m_pushTimer = nullptr;
// Owned by layout
@@ -110,7 +66,7 @@ private:
QSlider *m_volumeSlider = nullptr;
QScopedPointer<Generator> m_generator;
- QScopedPointer<QAudioOutput> m_audioOutput;
+ QScopedPointer<QAudioSink> m_audioOutput;
bool m_pullMode = true;
@@ -119,6 +75,7 @@ private slots:
void toggleSuspendResume();
void deviceChanged(int index);
void volumeChanged(int);
+ void updateAudioDevices();
};
#endif // AUDIOOUTPUT_H
diff --git a/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc b/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc
index 92dbc7e2c..93636c49d 100644
--- a/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc
+++ b/examples/multimedia/audiooutput/doc/src/audiooutput.qdoc
@@ -1,37 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiooutput
+ \example audiooutput
\title Audio Output Example
\ingroup multimedia_examples
- \brief Enabling audio playback using the QAudioOutput class.
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
+ \brief Enabling audio playback using the QAudioSink class.
+ \meta {tag} {widgets}
- \e{Audio Output} demonstrates the basic use cases of QAudioOutput.
+ \e{Audio Output} demonstrates the basic use cases of QAudioSink.
\image audiooutput-example.png
diff --git a/examples/multimedia/audiooutput/main.cpp b/examples/multimedia/audiooutput/main.cpp
index 9ed586095..8c652f0ff 100644
--- a/examples/multimedia/audiooutput/main.cpp
+++ b/examples/multimedia/audiooutput/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QApplication>
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiooutput.h"
+#include <QApplication>
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/examples/multimedia/audiorecorder/CMakeLists.txt b/examples/multimedia/audiorecorder/CMakeLists.txt
new file mode 100644
index 000000000..6ff9306fe
--- /dev/null
+++ b/examples/multimedia/audiorecorder/CMakeLists.txt
@@ -0,0 +1,51 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(audiorecorder LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/audiorecorder")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Widgets)
+
+qt_add_executable(audiorecorder
+ audiolevel.cpp audiolevel.h
+ audiorecorder.cpp audiorecorder.h audiorecorder.ui
+ main.cpp
+)
+
+set_target_properties(audiorecorder PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+)
+
+target_include_directories(audiorecorder PUBLIC
+ ../shared
+)
+
+target_link_libraries(audiorecorder PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Widgets
+)
+
+if(WIN32)
+ target_include_directories(audiorecorder PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+endif()
+
+install(TARGETS audiorecorder
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/audiorecorder/Info.plist.in b/examples/multimedia/audiorecorder/Info.plist.in
new file mode 100644
index 000000000..43b966509
--- /dev/null
+++ b/examples/multimedia/audiorecorder/Info.plist.in
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/audiorecorder/audiolevel.cpp b/examples/multimedia/audiorecorder/audiolevel.cpp
index b13e7fbc8..444dca9a4 100644
--- a/examples/multimedia/audiorecorder/audiolevel.cpp
+++ b/examples/multimedia/audiorecorder/audiolevel.cpp
@@ -1,58 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiolevel.h"
+
#include <QPainter>
-AudioLevel::AudioLevel(QWidget *parent)
- : QWidget(parent)
+AudioLevel::AudioLevel(QWidget *parent) : QWidget(parent)
{
setMinimumHeight(15);
setMaximumHeight(50);
@@ -77,3 +30,4 @@ void AudioLevel::paintEvent(QPaintEvent *event)
// clear the rest of the control
painter.fillRect(widthLevel, 0, width(), height(), Qt::black);
}
+
diff --git a/examples/multimedia/audiorecorder/audiolevel.h b/examples/multimedia/audiorecorder/audiolevel.h
index 3c71264c5..7a42a8d01 100644
--- a/examples/multimedia/audiorecorder/audiolevel.h
+++ b/examples/multimedia/audiorecorder/audiolevel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIOLEVEL_H
#define AUDIOLEVEL_H
@@ -57,7 +10,7 @@ class AudioLevel : public QWidget
{
Q_OBJECT
public:
- explicit AudioLevel(QWidget *parent = 0);
+ explicit AudioLevel(QWidget *parent = nullptr);
// Using [0; 1.0] range
void setLevel(qreal level);
diff --git a/examples/multimedia/audiorecorder/audiorecorder.cpp b/examples/multimedia/audiorecorder/audiorecorder.cpp
index 4eecae835..4131d5d51 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.cpp
+++ b/examples/multimedia/audiorecorder/audiorecorder.cpp
@@ -1,128 +1,102 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiorecorder.h"
#include "audiolevel.h"
-
#include "ui_audiorecorder.h"
-#include <QAudioProbe>
-#include <QAudioRecorder>
+#include <QAudioBuffer>
+#include <QAudioDevice>
+#include <QAudioInput>
#include <QDir>
#include <QFileDialog>
+#include <QImageCapture>
+#include <QMediaDevices>
+#include <QMediaFormat>
#include <QMediaRecorder>
+#include <QMimeType>
#include <QStandardPaths>
-static qreal getPeakValue(const QAudioFormat &format);
-static QList<qreal> getBufferLevels(const QAudioBuffer &buffer);
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
-template<class T>
-static QList<qreal> getBufferLevels(const T *buffer, int frames, int channels);
+static QList<qreal> getBufferLevels(const QAudioBuffer &buffer);
-AudioRecorder::AudioRecorder()
- : ui(new Ui::AudioRecorder)
+AudioRecorder::AudioRecorder() : ui(new Ui::AudioRecorder)
{
ui->setupUi(this);
- m_audioRecorder = new QAudioRecorder(this);
- m_probe = new QAudioProbe(this);
- connect(m_probe, &QAudioProbe::audioBufferProbed,
- this, &AudioRecorder::processBuffer);
- m_probe->setSource(m_audioRecorder);
-
- //audio devices
- ui->audioDeviceBox->addItem(tr("Default"), QVariant(QString()));
- for (auto &device: m_audioRecorder->audioInputs()) {
- ui->audioDeviceBox->addItem(device, QVariant(device));
- }
-
- //audio codecs
- ui->audioCodecBox->addItem(tr("Default"), QVariant(QString()));
- for (auto &codecName: m_audioRecorder->supportedAudioCodecs()) {
- ui->audioCodecBox->addItem(codecName, QVariant(codecName));
- }
-
- //containers
- ui->containerBox->addItem(tr("Default"), QVariant(QString()));
- for (auto &containerName: m_audioRecorder->supportedContainers()) {
- ui->containerBox->addItem(containerName, QVariant(containerName));
- }
-
- //sample rate
- ui->sampleRateBox->addItem(tr("Default"), QVariant(0));
- for (int sampleRate: m_audioRecorder->supportedAudioSampleRates()) {
- ui->sampleRateBox->addItem(QString::number(sampleRate), QVariant(
- sampleRate));
- }
-
- //channels
+ // channels
ui->channelsBox->addItem(tr("Default"), QVariant(-1));
ui->channelsBox->addItem(QStringLiteral("1"), QVariant(1));
ui->channelsBox->addItem(QStringLiteral("2"), QVariant(2));
ui->channelsBox->addItem(QStringLiteral("4"), QVariant(4));
- //quality
- ui->qualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
- ui->qualitySlider->setValue(int(QMultimedia::NormalQuality));
+ // quality
+ ui->qualitySlider->setRange(0, int(QImageCapture::VeryHighQuality));
+ ui->qualitySlider->setValue(int(QImageCapture::NormalQuality));
- //bitrates:
+ // bit rates:
ui->bitrateBox->addItem(tr("Default"), QVariant(0));
ui->bitrateBox->addItem(QStringLiteral("32000"), QVariant(32000));
ui->bitrateBox->addItem(QStringLiteral("64000"), QVariant(64000));
ui->bitrateBox->addItem(QStringLiteral("96000"), QVariant(96000));
ui->bitrateBox->addItem(QStringLiteral("128000"), QVariant(128000));
- connect(m_audioRecorder, &QAudioRecorder::durationChanged, this, &AudioRecorder::updateProgress);
- connect(m_audioRecorder, &QAudioRecorder::statusChanged, this, &AudioRecorder::updateStatus);
- connect(m_audioRecorder, &QAudioRecorder::stateChanged, this, &AudioRecorder::onStateChanged);
- connect(m_audioRecorder, QOverload<QMediaRecorder::Error>::of(&QAudioRecorder::error), this,
+ // audio input initialization
+ init();
+}
+
+void AudioRecorder::init()
+{
+#if QT_CONFIG(permissions)
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &AudioRecorder::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+
+ m_audioRecorder = new QMediaRecorder(this);
+ m_captureSession.setRecorder(m_audioRecorder);
+ m_captureSession.setAudioInput(new QAudioInput(this));
+ // ### replace with a monitoring output once we have it.
+ // m_probe = new QAudioProbe(this);
+ // connect(m_probe, &QAudioProbe::audioBufferProbed,
+ // this, &AudioRecorder::processBuffer);
+ // m_probe->setSource(m_audioRecorder);
+
+ // audio devices
+ m_mediaDevices = new QMediaDevices(this);
+ connect(m_mediaDevices, &QMediaDevices::audioInputsChanged, this,
+ &AudioRecorder::updateDevices);
+ updateDevices();
+
+ // audio codecs and container formats
+ updateFormats();
+ connect(ui->audioCodecBox, &QComboBox::currentIndexChanged, this,
+ &AudioRecorder::updateFormats);
+ connect(ui->containerBox, &QComboBox::currentIndexChanged, this, &AudioRecorder::updateFormats);
+
+ // sample rate
+ ui->sampleRateBox->setRange(m_captureSession.audioInput()->device().minimumSampleRate(),
+ m_captureSession.audioInput()->device().maximumSampleRate());
+ ui->sampleRateBox->setValue(
+ qBound(m_captureSession.audioInput()->device().minimumSampleRate(), 44100,
+ m_captureSession.audioInput()->device().maximumSampleRate()));
+
+ connect(m_audioRecorder, &QMediaRecorder::durationChanged, this,
+ &AudioRecorder::updateProgress);
+ connect(m_audioRecorder, &QMediaRecorder::recorderStateChanged, this,
+ &AudioRecorder::onStateChanged);
+ connect(m_audioRecorder, &QMediaRecorder::errorChanged, this,
&AudioRecorder::displayErrorMessage);
}
@@ -134,48 +108,33 @@ void AudioRecorder::updateProgress(qint64 duration)
ui->statusbar->showMessage(tr("Recorded %1 sec").arg(duration / 1000));
}
-void AudioRecorder::updateStatus(QMediaRecorder::Status status)
+void AudioRecorder::onStateChanged(QMediaRecorder::RecorderState state)
{
QString statusMessage;
- switch (status) {
- case QMediaRecorder::RecordingStatus:
- statusMessage = tr("Recording to %1").arg(m_audioRecorder->actualLocation().toString());
- break;
- case QMediaRecorder::PausedStatus:
- clearAudioLevels();
- statusMessage = tr("Paused");
- break;
- case QMediaRecorder::UnloadedStatus:
- case QMediaRecorder::LoadedStatus:
- clearAudioLevels();
- statusMessage = tr("Stopped");
- default:
- break;
- }
-
- if (m_audioRecorder->error() == QMediaRecorder::NoError)
- ui->statusbar->showMessage(statusMessage);
-}
-
-void AudioRecorder::onStateChanged(QMediaRecorder::State state)
-{
switch (state) {
case QMediaRecorder::RecordingState:
+ statusMessage = tr("Recording to %1").arg(m_audioRecorder->actualLocation().toString());
ui->recordButton->setText(tr("Stop"));
ui->pauseButton->setText(tr("Pause"));
break;
case QMediaRecorder::PausedState:
+ clearAudioLevels();
+ statusMessage = tr("Paused");
ui->recordButton->setText(tr("Stop"));
ui->pauseButton->setText(tr("Resume"));
break;
case QMediaRecorder::StoppedState:
+ clearAudioLevels();
+ statusMessage = tr("Stopped");
ui->recordButton->setText(tr("Record"));
ui->pauseButton->setText(tr("Pause"));
break;
}
- ui->pauseButton->setEnabled(m_audioRecorder->state() != QMediaRecorder::StoppedState);
+ ui->pauseButton->setEnabled(m_audioRecorder->recorderState() != QMediaRecorder::StoppedState);
+ if (m_audioRecorder->error() == QMediaRecorder::NoError)
+ ui->statusbar->showMessage(statusMessage);
}
static QVariant boxValue(const QComboBox *box)
@@ -189,32 +148,28 @@ static QVariant boxValue(const QComboBox *box)
void AudioRecorder::toggleRecord()
{
- if (m_audioRecorder->state() == QMediaRecorder::StoppedState) {
- m_audioRecorder->setAudioInput(boxValue(ui->audioDeviceBox).toString());
-
- QAudioEncoderSettings settings;
- settings.setCodec(boxValue(ui->audioCodecBox).toString());
- settings.setSampleRate(boxValue(ui->sampleRateBox).toInt());
- settings.setBitRate(boxValue(ui->bitrateBox).toInt());
- settings.setChannelCount(boxValue(ui->channelsBox).toInt());
- settings.setQuality(QMultimedia::EncodingQuality(ui->qualitySlider->value()));
- settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
- QMultimedia::ConstantQualityEncoding :
- QMultimedia::ConstantBitRateEncoding);
-
- QString container = boxValue(ui->containerBox).toString();
-
- m_audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container);
+ if (m_audioRecorder->recorderState() == QMediaRecorder::StoppedState) {
+ m_captureSession.audioInput()->setDevice(
+ boxValue(ui->audioDeviceBox).value<QAudioDevice>());
+
+ m_audioRecorder->setMediaFormat(selectedMediaFormat());
+ m_audioRecorder->setAudioSampleRate(ui->sampleRateBox->value());
+ m_audioRecorder->setAudioBitRate(boxValue(ui->bitrateBox).toInt());
+ m_audioRecorder->setAudioChannelCount(boxValue(ui->channelsBox).toInt());
+ m_audioRecorder->setQuality(QMediaRecorder::Quality(ui->qualitySlider->value()));
+ m_audioRecorder->setEncodingMode(ui->constantQualityRadioButton->isChecked()
+ ? QMediaRecorder::ConstantQualityEncoding
+ : QMediaRecorder::ConstantBitRateEncoding);
+
m_audioRecorder->record();
- }
- else {
+ } else {
m_audioRecorder->stop();
}
}
void AudioRecorder::togglePause()
{
- if (m_audioRecorder->state() != QMediaRecorder::PausedState)
+ if (m_audioRecorder->recorderState() != QMediaRecorder::PausedState)
m_audioRecorder->pause();
else
m_audioRecorder->record();
@@ -222,14 +177,10 @@ void AudioRecorder::togglePause()
void AudioRecorder::setOutputLocation()
{
-#ifdef Q_OS_WINRT
- // UWP does not allow to store outside the sandbox
- const QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
- if (!QDir().mkpath(cacheDir)) {
- qWarning() << "Failed to create cache directory";
- return;
- }
- QString fileName = cacheDir + QLatin1String("/output.wav");
+#ifdef Q_OS_ANDROID
+ QString fileName = QFileDialog::getSaveFileName(
+ this, tr("Save Recording"),
+ "output." + selectedMediaFormat().mimeType().preferredSuffix());
#else
QString fileName = QFileDialog::getSaveFileName();
#endif
@@ -242,48 +193,78 @@ void AudioRecorder::displayErrorMessage()
ui->statusbar->showMessage(m_audioRecorder->errorString());
}
-void AudioRecorder::clearAudioLevels()
+void AudioRecorder::updateDevices()
{
- for (int i = 0; i < m_audioLevels.size(); ++i)
- m_audioLevels.at(i)->setLevel(0);
+ const auto currentDevice = boxValue(ui->audioDeviceBox).value<QAudioDevice>();
+ int currentDeviceIndex = 0;
+
+ ui->audioDeviceBox->clear();
+
+ ui->audioDeviceBox->addItem(tr("Default"), {});
+ for (const auto &device : m_mediaDevices->audioInputs()) {
+ const auto name = device.description();
+ ui->audioDeviceBox->addItem(name, QVariant::fromValue(device));
+
+ if (device.id() == currentDevice.id())
+ currentDeviceIndex = ui->audioDeviceBox->count() - 1;
+ }
+
+ ui->audioDeviceBox->setCurrentIndex(currentDeviceIndex);
}
-// This function returns the maximum possible sample value for a given audio format
-qreal getPeakValue(const QAudioFormat& format)
+void AudioRecorder::updateFormats()
{
- // Note: Only the most common sample formats are supported
- if (!format.isValid())
- return qreal(0);
+ if (m_updatingFormats)
+ return;
+ m_updatingFormats = true;
+
+ QMediaFormat format;
+ if (ui->containerBox->count())
+ format.setFileFormat(boxValue(ui->containerBox).value<QMediaFormat::FileFormat>());
+ if (ui->audioCodecBox->count())
+ format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
+
+ int currentIndex = 0;
+ ui->audioCodecBox->clear();
+ ui->audioCodecBox->addItem(tr("Default audio codec"),
+ QVariant::fromValue(QMediaFormat::AudioCodec::Unspecified));
+ for (auto codec : format.supportedAudioCodecs(QMediaFormat::Encode)) {
+ if (codec == format.audioCodec())
+ currentIndex = ui->audioCodecBox->count();
+ ui->audioCodecBox->addItem(QMediaFormat::audioCodecDescription(codec),
+ QVariant::fromValue(codec));
+ }
+ ui->audioCodecBox->setCurrentIndex(currentIndex);
+
+ currentIndex = 0;
+ ui->containerBox->clear();
+ ui->containerBox->addItem(tr("Default file format"),
+ QVariant::fromValue(QMediaFormat::UnspecifiedFormat));
+ for (auto container : format.supportedFileFormats(QMediaFormat::Encode)) {
+ if (container < QMediaFormat::Mpeg4Audio) // Skip video formats
+ continue;
+ if (container == format.fileFormat())
+ currentIndex = ui->containerBox->count();
+ ui->containerBox->addItem(QMediaFormat::fileFormatDescription(container),
+ QVariant::fromValue(container));
+ }
+ ui->containerBox->setCurrentIndex(currentIndex);
- if (format.codec() != "audio/pcm")
- return qreal(0);
+ m_updatingFormats = false;
+}
- switch (format.sampleType()) {
- case QAudioFormat::Unknown:
- break;
- case QAudioFormat::Float:
- if (format.sampleSize() != 32) // other sample formats are not supported
- return qreal(0);
- return qreal(1.00003);
- case QAudioFormat::SignedInt:
- if (format.sampleSize() == 32)
- return qreal(INT_MAX);
- if (format.sampleSize() == 16)
- return qreal(SHRT_MAX);
- if (format.sampleSize() == 8)
- return qreal(CHAR_MAX);
- break;
- case QAudioFormat::UnSignedInt:
- if (format.sampleSize() == 32)
- return qreal(UINT_MAX);
- if (format.sampleSize() == 16)
- return qreal(USHRT_MAX);
- if (format.sampleSize() == 8)
- return qreal(UCHAR_MAX);
- break;
- }
+void AudioRecorder::clearAudioLevels()
+{
+ for (auto m_audioLevel : std::as_const(m_audioLevels))
+ m_audioLevel->setLevel(0);
+}
- return qreal(0);
+QMediaFormat AudioRecorder::selectedMediaFormat() const
+{
+ QMediaFormat format;
+ format.setFileFormat(boxValue(ui->containerBox).value<QMediaFormat::FileFormat>());
+ format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
+ return format;
}
// returns the audio level for each channel
@@ -291,70 +272,31 @@ QList<qreal> getBufferLevels(const QAudioBuffer &buffer)
{
QList<qreal> values;
- if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian)
- return values;
-
- if (buffer.format().codec() != "audio/pcm")
- return values;
-
- int channelCount = buffer.format().channelCount();
- values.fill(0, channelCount);
- qreal peak_value = getPeakValue(buffer.format());
- if (qFuzzyCompare(peak_value, qreal(0)))
+ auto format = buffer.format();
+ if (!format.isValid())
return values;
- switch (buffer.format().sampleType()) {
- case QAudioFormat::Unknown:
- case QAudioFormat::UnSignedInt:
- if (buffer.format().sampleSize() == 32)
- values = getBufferLevels(buffer.constData<quint32>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 16)
- values = getBufferLevels(buffer.constData<quint16>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 8)
- values = getBufferLevels(buffer.constData<quint8>(), buffer.frameCount(), channelCount);
- for (int i = 0; i < values.size(); ++i)
- values[i] = qAbs(values.at(i) - peak_value / 2) / (peak_value / 2);
- break;
- case QAudioFormat::Float:
- if (buffer.format().sampleSize() == 32) {
- values = getBufferLevels(buffer.constData<float>(), buffer.frameCount(), channelCount);
- for (int i = 0; i < values.size(); ++i)
- values[i] /= peak_value;
- }
- break;
- case QAudioFormat::SignedInt:
- if (buffer.format().sampleSize() == 32)
- values = getBufferLevels(buffer.constData<qint32>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 16)
- values = getBufferLevels(buffer.constData<qint16>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 8)
- values = getBufferLevels(buffer.constData<qint8>(), buffer.frameCount(), channelCount);
- for (int i = 0; i < values.size(); ++i)
- values[i] /= peak_value;
- break;
- }
-
- return values;
-}
+ int channels = buffer.format().channelCount();
+ values.fill(0, channels);
-template<class T>
-QList<qreal> getBufferLevels(const T *buffer, int frames, int channels)
-{
+ int bytesPerSample = format.bytesPerSample();
QList<qreal> max_values;
max_values.fill(0, channels);
- for (int i = 0; i < frames; ++i) {
+ const char *data = buffer.constData<char>();
+ for (int i = 0; i < buffer.frameCount(); ++i) {
for (int j = 0; j < channels; ++j) {
- qreal value = qAbs(qreal(buffer[i * channels + j]));
+ qreal value = qAbs(format.normalizedSampleValue(data));
if (value > max_values.at(j))
- max_values.replace(j, value);
+ max_values[j] = value;
+ data += bytesPerSample;
}
}
return max_values;
}
-void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
+void AudioRecorder::processBuffer(const QAudioBuffer &buffer)
{
if (m_audioLevels.count() != buffer.format().channelCount()) {
qDeleteAll(m_audioLevels);
@@ -370,3 +312,4 @@ void AudioRecorder::processBuffer(const QAudioBuffer& buffer)
for (int i = 0; i < levels.count(); ++i)
m_audioLevels.at(i)->setLevel(levels.at(i));
}
+
diff --git a/examples/multimedia/audiorecorder/audiorecorder.h b/examples/multimedia/audiorecorder/audiorecorder.h
index 6818dba90..2ce71c162 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.h
+++ b/examples/multimedia/audiorecorder/audiorecorder.h
@@ -1,65 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef AUDIORECORDER_H
#define AUDIORECORDER_H
#include <QMainWindow>
+#include <QMediaCaptureSession>
#include <QMediaRecorder>
#include <QUrl>
QT_BEGIN_NAMESPACE
-namespace Ui { class AudioRecorder; }
-class QAudioRecorder;
-class QAudioProbe;
+namespace Ui {
+class AudioRecorder;
+}
class QAudioBuffer;
+class QMediaDevices;
QT_END_NAMESPACE
class AudioLevel;
@@ -72,28 +27,34 @@ public:
AudioRecorder();
public slots:
- void processBuffer(const QAudioBuffer&);
+ void processBuffer(const QAudioBuffer &);
private slots:
+ void init();
void setOutputLocation();
void togglePause();
void toggleRecord();
- void updateStatus(QMediaRecorder::Status);
- void onStateChanged(QMediaRecorder::State);
+ void onStateChanged(QMediaRecorder::RecorderState);
void updateProgress(qint64 pos);
void displayErrorMessage();
+ void updateDevices();
+ void updateFormats();
+
private:
void clearAudioLevels();
+ QMediaFormat selectedMediaFormat() const;
Ui::AudioRecorder *ui = nullptr;
- QAudioRecorder *m_audioRecorder = nullptr;
- QAudioProbe *m_probe = nullptr;
- QList<AudioLevel*> m_audioLevels;
- bool m_outputLocationSet = false;
+ QMediaCaptureSession m_captureSession;
+ QMediaRecorder *m_audioRecorder = nullptr;
+ QMediaDevices *m_mediaDevices = nullptr;
+ QList<AudioLevel *> m_audioLevels;
+ bool m_outputLocationSet = false;
+ bool m_updatingFormats = false;
};
#endif // AUDIORECORDER_H
diff --git a/examples/multimedia/audiorecorder/audiorecorder.pro b/examples/multimedia/audiorecorder/audiorecorder.pro
index dfd0364a4..a0e05cc03 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.pro
+++ b/examples/multimedia/audiorecorder/audiorecorder.pro
@@ -21,3 +21,4 @@ INSTALLS += target
QT+=widgets
include(../shared/shared.pri)
+
diff --git a/examples/multimedia/audiorecorder/audiorecorder.ui b/examples/multimedia/audiorecorder/audiorecorder.ui
index 6ea510524..bd2560622 100644
--- a/examples/multimedia/audiorecorder/audiorecorder.ui
+++ b/examples/multimedia/audiorecorder/audiorecorder.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>297</width>
- <height>374</height>
+ <height>476</height>
</rect>
</property>
<property name="windowTitle">
@@ -51,9 +51,6 @@
<item row="2" column="1">
<widget class="QComboBox" name="containerBox"/>
</item>
- <item row="3" column="1">
- <widget class="QComboBox" name="sampleRateBox"/>
- </item>
<item row="1" column="1">
<widget class="QComboBox" name="audioCodecBox"/>
</item>
@@ -67,6 +64,9 @@
<item row="4" column="1">
<widget class="QComboBox" name="channelsBox"/>
</item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="sampleRateBox"/>
+ </item>
</layout>
</item>
<item row="1" column="0" colspan="3">
diff --git a/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc b/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc
index 4e4032bff..71481f24d 100644
--- a/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc
+++ b/examples/multimedia/audiorecorder/doc/src/audiorecorder.qdoc
@@ -1,35 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/audiorecorder
+ \example audiorecorder
\title Audio Recorder Example
\ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
\brief Discovering the available devices and supported codecs.
+ \meta {tag} {widgets}
\e{Audio Recorder} demonstrates how to identify the available devices and
supported codecs, and the use of QAudioRecorder class.
@@ -41,30 +20,33 @@
\section1 Displaying the Window and Audio Settings
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{QMultimedia::VeryHighQuality} with a default value of
- \l{QMultimedia::NormalQuality}, while the bitrates are hardcoded
+ codec, container, sample rate, and channels. It allows setting of either
+ quality or bit rate. Finally, the output file can be selected and recording
+ can be started.
+
+ The lists are populated using the following methods:
+ \list
+ \li \l{QMediaDevices::audioInputs()}
+ \li \l{QMediaFormat::supportedAudioCodecs}
+ \li \l{QMediaFormat::supportedFileFormats}
+ \li \l{QAudioDevice::maximumSampleRate()}
+ \li \l{QAudioDevice::minimumSampleRate()}
+ \endlist
+ The quality slider is setup from 0 (zero) to
+ \l{QMediaRecorder::VeryHighQuality} with a default value of
+ \l{QMediaRecorder::NormalQuality}, while the bit rate box are hard-coded
into the list.
\section1 Recording Audio
- To record audio we simply create a QAudioRecorder object.
+ 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
+ and setup the lists as described above. The text on the record and pause
+ buttons are toggled depending on the \l{QMediaRecorder::RecorderState}{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
@@ -72,25 +54,23 @@
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.
+ recording is stopped, then pressing the record button 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(QMultimedia::EncodingQuality(ui->qualitySlider->value()));
- settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
- QMultimedia::ConstantQualityEncoding :
- QMultimedia::ConstantBitRateEncoding);
+ QMediaFormat format;
+ format.setCodec(boxValue(ui->audioCodecBox).toString());
+ audioRecorder->setMediaFormat(format);
+ audioRecorder->setSampleRate(boxValue(ui->sampleRateBox).toInt());
+ audioRecorder->setBitRate(boxValue(ui->bitrateBox).toInt());
+ audioRecorder->setQuality(QMediaRecorder::EncodingQuality(ui->qualitySlider->value()));
+ audioRecorder->setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
+ QMediaRecorder::ConstantQualityEncoding :
+ QMediaRecorder::ConstantBitRateEncoding);
QString container = boxValue(ui->containerBox).toString();
- audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container);
audioRecorder->record();
\endcode
diff --git a/examples/multimedia/audiorecorder/main.cpp b/examples/multimedia/audiorecorder/main.cpp
index f13940b23..407729616 100644
--- a/examples/multimedia/audiorecorder/main.cpp
+++ b/examples/multimedia/audiorecorder/main.cpp
@@ -1,56 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "audiorecorder.h"
-#include <QtWidgets>
+#include <QApplication>
int main(int argc, char *argv[])
{
diff --git a/examples/multimedia/audiosource/CMakeLists.txt b/examples/multimedia/audiosource/CMakeLists.txt
new file mode 100644
index 000000000..65226247a
--- /dev/null
+++ b/examples/multimedia/audiosource/CMakeLists.txt
@@ -0,0 +1,43 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(audiosource LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/audiosource")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Widgets)
+
+qt_add_executable(audiosource
+ audiosource.cpp audiosource.h
+ main.cpp
+)
+
+set_target_properties(audiosource PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+)
+
+target_include_directories(audiosource PUBLIC
+ ../shared
+)
+
+target_link_libraries(audiosource PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Widgets
+)
+
+install(TARGETS audiosource
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/audiosource/Info.plist.in b/examples/multimedia/audiosource/Info.plist.in
new file mode 100644
index 000000000..43b966509
--- /dev/null
+++ b/examples/multimedia/audiosource/Info.plist.in
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/audiosource/audiosource.cpp b/examples/multimedia/audiosource/audiosource.cpp
new file mode 100644
index 000000000..48e33fa2d
--- /dev/null
+++ b/examples/multimedia/audiosource/audiosource.cpp
@@ -0,0 +1,251 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "audiosource.h"
+
+#include <QAudioDevice>
+#include <QAudioSource>
+#include <QDateTime>
+#include <QDebug>
+#include <QLabel>
+#include <QPainter>
+#include <QVBoxLayout>
+#include <QtEndian>
+
+#if QT_CONFIG(permissions)
+ #include <QCoreApplication>
+ #include <QPermission>
+#endif
+
+#include <math.h>
+#include <stdlib.h>
+
+AudioInfo::AudioInfo(const QAudioFormat &format) : m_format(format) { }
+
+void AudioInfo::start()
+{
+ open(QIODevice::WriteOnly);
+}
+
+void AudioInfo::stop()
+{
+ close();
+}
+
+qint64 AudioInfo::readData(char * /* data */, qint64 /* maxlen */)
+{
+ return 0;
+}
+
+qreal AudioInfo::calculateLevel(const char *data, qint64 len) const
+{
+ const int channelBytes = m_format.bytesPerSample();
+ const int sampleBytes = m_format.bytesPerFrame();
+ const int numSamples = len / sampleBytes;
+
+ float maxValue = 0;
+ auto *ptr = reinterpret_cast<const unsigned char *>(data);
+
+ for (int i = 0; i < numSamples; ++i) {
+ for (int j = 0; j < m_format.channelCount(); ++j) {
+ float value = m_format.normalizedSampleValue(ptr);
+
+ maxValue = qMax(value, maxValue);
+ ptr += channelBytes;
+ }
+ }
+ return maxValue;
+}
+
+qint64 AudioInfo::writeData(const char *data, qint64 len)
+{
+ m_level = calculateLevel(data, len);
+
+ emit levelChanged(m_level);
+
+ return len;
+}
+
+RenderArea::RenderArea(QWidget *parent) : QWidget(parent)
+{
+ setBackgroundRole(QPalette::Base);
+ setAutoFillBackground(true);
+
+ setMinimumHeight(30);
+ setMinimumWidth(200);
+}
+
+void RenderArea::paintEvent(QPaintEvent * /* event */)
+{
+ QPainter painter(this);
+
+ painter.setPen(Qt::black);
+
+ const QRect frame = painter.viewport() - QMargins(10, 10, 10, 10);
+ painter.drawRect(frame);
+ if (m_level == 0.0)
+ return;
+
+ const int pos = qRound(qreal(frame.width() - 1) * m_level);
+ painter.fillRect(frame.left() + 1, frame.top() + 1, pos, frame.height() - 1, Qt::red);
+}
+
+void RenderArea::setLevel(qreal value)
+{
+ m_level = value;
+ update();
+}
+
+InputTest::InputTest() : m_devices(new QMediaDevices(this))
+{
+ init();
+}
+
+void InputTest::initializeWindow()
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ m_canvas = new RenderArea(this);
+ layout->addWidget(m_canvas);
+
+ m_deviceBox = new QComboBox(this);
+ const QAudioDevice &defaultDeviceInfo = QMediaDevices::defaultAudioInput();
+ m_deviceBox->addItem(defaultDeviceInfo.description(), QVariant::fromValue(defaultDeviceInfo));
+ for (auto &deviceInfo : m_devices->audioInputs()) {
+ if (deviceInfo != defaultDeviceInfo)
+ m_deviceBox->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
+ }
+
+ connect(m_deviceBox, &QComboBox::activated, this, &InputTest::deviceChanged);
+ layout->addWidget(m_deviceBox);
+
+ m_volumeSlider = new QSlider(Qt::Horizontal, this);
+ m_volumeSlider->setRange(0, 100);
+ m_volumeSlider->setValue(100);
+ connect(m_volumeSlider, &QSlider::valueChanged, this, &InputTest::sliderChanged);
+ layout->addWidget(m_volumeSlider);
+
+ m_modeButton = new QPushButton(this);
+ connect(m_modeButton, &QPushButton::clicked, this, &InputTest::toggleMode);
+ layout->addWidget(m_modeButton);
+
+ m_suspendResumeButton = new QPushButton(this);
+ connect(m_suspendResumeButton, &QPushButton::clicked, this, &InputTest::toggleSuspend);
+ layout->addWidget(m_suspendResumeButton);
+}
+
+void InputTest::initializeAudio(const QAudioDevice &deviceInfo)
+{
+ QAudioFormat format;
+ format.setSampleRate(8000);
+ format.setChannelCount(1);
+ format.setSampleFormat(QAudioFormat::Int16);
+
+ m_audioInfo.reset(new AudioInfo(format));
+ connect(m_audioInfo.data(), &AudioInfo::levelChanged, m_canvas, &RenderArea::setLevel);
+
+ m_audioInput.reset(new QAudioSource(deviceInfo, format));
+ qreal initialVolume = QAudio::convertVolume(m_audioInput->volume(), QAudio::LinearVolumeScale,
+ QAudio::LogarithmicVolumeScale);
+ m_volumeSlider->setValue(qRound(initialVolume * 100));
+ m_audioInfo->start();
+ toggleMode();
+}
+
+void InputTest::initializeErrorWindow()
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QLabel *errorLabel = new QLabel(tr("Microphone permission is not granted!"));
+ errorLabel->setWordWrap(true);
+ errorLabel->setAlignment(Qt::AlignCenter);
+ layout->addWidget(errorLabel);
+}
+
+void InputTest::init()
+{
+#if QT_CONFIG(permissions)
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &InputTest::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ initializeErrorWindow();
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+ initializeWindow();
+ initializeAudio(QMediaDevices::defaultAudioInput());
+}
+
+void InputTest::toggleMode()
+{
+ m_audioInput->stop();
+ toggleSuspend();
+
+ // Change between pull and push modes
+ if (m_pullMode) {
+ m_modeButton->setText(tr("Enable push mode"));
+ m_audioInput->start(m_audioInfo.data());
+ } else {
+ m_modeButton->setText(tr("Enable pull mode"));
+ auto *io = m_audioInput->start();
+ if (!io)
+ return;
+
+ connect(io, &QIODevice::readyRead, [this, io]() {
+ static const qint64 BufferSize = 4096;
+ const qint64 len = qMin(m_audioInput->bytesAvailable(), BufferSize);
+
+ QByteArray buffer(len, 0);
+ qint64 l = io->read(buffer.data(), len);
+ if (l > 0) {
+ const qreal level = m_audioInfo->calculateLevel(buffer.constData(), l);
+ m_canvas->setLevel(level);
+ }
+ });
+ }
+
+ m_pullMode = !m_pullMode;
+}
+
+void InputTest::toggleSuspend()
+{
+ // toggle suspend/resume
+ switch (m_audioInput->state()) {
+ case QAudio::SuspendedState:
+ case QAudio::StoppedState:
+ m_audioInput->resume();
+ m_suspendResumeButton->setText(tr("Suspend recording"));
+ break;
+ case QAudio::ActiveState:
+ m_audioInput->suspend();
+ m_suspendResumeButton->setText(tr("Resume recording"));
+ break;
+ case QAudio::IdleState:
+ // no-op
+ break;
+ }
+}
+
+void InputTest::deviceChanged(int index)
+{
+ m_audioInput->stop();
+ m_audioInput->disconnect(this);
+ m_audioInfo->stop();
+
+ initializeAudio(m_deviceBox->itemData(index).value<QAudioDevice>());
+}
+
+void InputTest::sliderChanged(int value)
+{
+ qreal linearVolume = QAudio::convertVolume(value / qreal(100), QAudio::LogarithmicVolumeScale,
+ QAudio::LinearVolumeScale);
+
+ m_audioInput->setVolume(linearVolume);
+}
+
+#include "moc_audiosource.cpp"
diff --git a/examples/multimedia/audiosource/audiosource.h b/examples/multimedia/audiosource/audiosource.h
new file mode 100644
index 000000000..dd9a7bc4a
--- /dev/null
+++ b/examples/multimedia/audiosource/audiosource.h
@@ -0,0 +1,94 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef AUDIOINPUT_H
+#define AUDIOINPUT_H
+
+#include <QAudioSource>
+#include <QMediaDevices>
+
+#include <QComboBox>
+#include <QPushButton>
+#include <QSlider>
+#include <QWidget>
+
+#include <QPixmap>
+
+#include <QByteArray>
+#include <QScopedPointer>
+
+class AudioInfo : public QIODevice
+{
+ Q_OBJECT
+
+public:
+ AudioInfo(const QAudioFormat &format);
+
+ void start();
+ void stop();
+
+ qreal level() const { return m_level; }
+
+ qint64 readData(char *data, qint64 maxlen) override;
+ qint64 writeData(const char *data, qint64 len) override;
+
+ qreal calculateLevel(const char *data, qint64 len) const;
+
+signals:
+ void levelChanged(qreal level);
+
+private:
+ const QAudioFormat m_format;
+ qreal m_level = 0.0; // 0.0 <= m_level <= 1.0
+};
+
+class RenderArea : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit RenderArea(QWidget *parent = nullptr);
+
+ void setLevel(qreal value);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+private:
+ qreal m_level = 0;
+};
+
+class InputTest : public QWidget
+{
+ Q_OBJECT
+
+public:
+ InputTest();
+
+private:
+ void initializeWindow();
+ void initializeAudio(const QAudioDevice &deviceInfo);
+ void initializeErrorWindow();
+
+private slots:
+ void init();
+ void toggleMode();
+ void toggleSuspend();
+ void deviceChanged(int index);
+ void sliderChanged(int value);
+
+private:
+ // Owned by layout
+ RenderArea *m_canvas = nullptr;
+ QPushButton *m_modeButton = nullptr;
+ QPushButton *m_suspendResumeButton = nullptr;
+ QComboBox *m_deviceBox = nullptr;
+ QSlider *m_volumeSlider = nullptr;
+
+ QMediaDevices *m_devices = nullptr;
+ QScopedPointer<AudioInfo> m_audioInfo;
+ QScopedPointer<QAudioSource> m_audioInput;
+ bool m_pullMode = true;
+};
+
+#endif // AUDIOINPUT_H
diff --git a/examples/multimedia/audiosource/audiosource.pro b/examples/multimedia/audiosource/audiosource.pro
new file mode 100644
index 000000000..35105dace
--- /dev/null
+++ b/examples/multimedia/audiosource/audiosource.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = audiosource
+
+QT += multimedia widgets
+
+HEADERS = audiosource.h
+
+SOURCES = audiosource.cpp \
+ main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audiosource
+INSTALLS += target
+include(../shared/shared.pri)
diff --git a/examples/multimedia/audioinput/doc/images/audioinput-example.png b/examples/multimedia/audiosource/doc/images/audiosource-example.png
index fb703e68c..fb703e68c 100644
--- a/examples/multimedia/audioinput/doc/images/audioinput-example.png
+++ b/examples/multimedia/audiosource/doc/images/audiosource-example.png
Binary files differ
diff --git a/examples/multimedia/audiosource/doc/src/audiosource.qdoc b/examples/multimedia/audiosource/doc/src/audiosource.qdoc
new file mode 100644
index 000000000..2f120ce77
--- /dev/null
+++ b/examples/multimedia/audiosource/doc/src/audiosource.qdoc
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example audiosource
+ \title Audio Source Example
+ \ingroup multimedia_examples
+ \ingroup audio_examples
+ \examplecategory {Multimedia}
+ \brief Recording audio using the QAudioSource class.
+ \meta {tag} {widgets}
+
+ \e{Audio Source} demonstrates the basic use cases of QAudioSource.
+
+ \image audiosource-example.png
+
+ Qt provides the QAudioSource class to enable audio functionality within
+ a standard application user interface.
+
+ This example calculates the maximum linear value of the input audio from the
+ microphone and displays the output.
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/multimedia/audiosource/main.cpp b/examples/multimedia/audiosource/main.cpp
new file mode 100644
index 000000000..49156d860
--- /dev/null
+++ b/examples/multimedia/audiosource/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "audiosource.h"
+
+#include <QApplication>
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+ QCoreApplication::setApplicationName("Audio Source Test");
+
+ InputTest input;
+ input.show();
+
+ return QCoreApplication::exec();
+}
diff --git a/examples/multimedia/camera/CMakeLists.txt b/examples/multimedia/camera/CMakeLists.txt
new file mode 100644
index 000000000..f4d97c535
--- /dev/null
+++ b/examples/multimedia/camera/CMakeLists.txt
@@ -0,0 +1,81 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(camera LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/camera")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia MultimediaWidgets Widgets)
+
+set(camera_form "")
+set(videosettings_form "")
+if(ANDROID OR IOS)
+ set(camera_form camera_mobile.ui)
+ set(videosettings_form videosettings_mobile.ui)
+else()
+ set(camera_form camera.ui)
+ set(videosettings_form videosettings.ui)
+endif()
+
+qt_add_executable(camera
+ MANUAL_FINALIZATION
+ camera.cpp camera.h ${camera_form}
+ imagesettings.cpp imagesettings.h imagesettings.ui
+ main.cpp
+ videosettings.cpp videosettings.h ${videosettings_form}
+ metadatadialog.cpp metadatadialog.h
+)
+
+set_target_properties(camera PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+if(APPLE AND NOT IOS)
+ set_target_properties(camera PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist.in"
+ )
+elseif(IOS)
+ set_target_properties(camera PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/ios/Info.plist.in"
+ )
+endif()
+
+set_property(TARGET camera APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
+ ${CMAKE_CURRENT_SOURCE_DIR}/android)
+
+target_link_libraries(camera PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::MultimediaWidgets
+ Qt::Widgets
+)
+
+# Resources:
+set(camera_resource_files
+ "images/shutter.svg"
+)
+
+qt_add_resources(camera "camera"
+ PREFIX
+ "/"
+ FILES
+ ${camera_resource_files}
+)
+
+qt_finalize_executable(camera)
+
+install(TARGETS camera
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/camera/android/AndroidManifest.xml b/examples/multimedia/camera/android/AndroidManifest.xml
new file mode 100644
index 000000000..9f77579b4
--- /dev/null
+++ b/examples/multimedia/camera/android/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.example.camera"
+ android:installLocation="auto"
+ android:versionCode="-- %%INSERT_VERSION_CODE%% --"
+ android:versionName="-- %%INSERT_VERSION_NAME%% --">
+ <!-- %%INSERT_PERMISSIONS -->
+ <!-- %%INSERT_FEATURES -->
+
+ <supports-screens
+ android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true" />
+ <application
+ android:name="org.qtproject.qt.android.bindings.QtApplication"
+ android:extractNativeLibs="true"
+ android:hardwareAccelerated="true"
+ android:label="-- %%INSERT_APP_NAME%% --"
+ android:requestLegacyExternalStorage="true"
+ android:allowBackup="true"
+ android:fullBackupOnly="false">
+ <activity
+ android:name="org.qtproject.qt.android.bindings.QtActivity"
+ android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
+ android:launchMode="singleTop"
+ android:screenOrientation="portrait"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ <meta-data
+ android:name="android.app.lib_name"
+ android:value="-- %%INSERT_APP_LIB_NAME%% --" />
+
+ </activity>
+ </application>
+</manifest>
diff --git a/examples/multimedia/camera/camera.cpp b/examples/multimedia/camera/camera.cpp
new file mode 100644
index 000000000..c5aa19e2d
--- /dev/null
+++ b/examples/multimedia/camera/camera.cpp
@@ -0,0 +1,421 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "camera.h"
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
+# include "ui_camera_mobile.h"
+#else
+# include "ui_camera.h"
+#endif
+
+#include "imagesettings.h"
+#include "metadatadialog.h"
+#include "videosettings.h"
+
+#include <QAudioDevice>
+#include <QAudioInput>
+#include <QCameraDevice>
+#include <QMediaDevices>
+#include <QMediaFormat>
+#include <QMediaMetaData>
+#include <QMediaRecorder>
+#include <QVideoWidget>
+
+#include <QLineEdit>
+#include <QMessageBox>
+
+#include <QAction>
+#include <QActionGroup>
+#include <QImage>
+#include <QKeyEvent>
+#include <QPalette>
+
+#include <QDir>
+#include <QTimer>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
+Camera::Camera() : ui(new Ui::Camera)
+{
+ ui->setupUi(this);
+ // disable all buttons by default
+ updateCameraActive(false);
+ readyForCapture(false);
+ ui->recordButton->setEnabled(false);
+ ui->pauseButton->setEnabled(false);
+ ui->stopButton->setEnabled(false);
+ ui->metaDataButton->setEnabled(false);
+
+ // try to actually initialize camera & mic
+ init();
+}
+
+void Camera::init()
+{
+#if QT_CONFIG(permissions)
+ // camera
+ QCameraPermission cameraPermission;
+ switch (qApp->checkPermission(cameraPermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(cameraPermission, this, &Camera::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Camera permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+ // microphone
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &Camera::init);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+
+ m_audioInput.reset(new QAudioInput);
+ m_captureSession.setAudioInput(m_audioInput.get());
+
+ // Camera devices:
+
+ videoDevicesGroup = new QActionGroup(this);
+ videoDevicesGroup->setExclusive(true);
+ updateCameras();
+ connect(&m_devices, &QMediaDevices::videoInputsChanged, this, &Camera::updateCameras);
+
+ connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice);
+ connect(ui->captureWidget, &QTabWidget::currentChanged, this, &Camera::updateCaptureMode);
+
+ connect(ui->metaDataButton, &QPushButton::clicked, this, &Camera::showMetaDataDialog);
+ connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this,
+ &Camera::setExposureCompensation);
+
+ setCamera(QMediaDevices::defaultVideoInput());
+}
+
+void Camera::setCamera(const QCameraDevice &cameraDevice)
+{
+ m_camera.reset(new QCamera(cameraDevice));
+ m_captureSession.setCamera(m_camera.data());
+
+ connect(m_camera.data(), &QCamera::activeChanged, this, &Camera::updateCameraActive);
+ connect(m_camera.data(), &QCamera::errorOccurred, this, &Camera::displayCameraError);
+
+ if (!m_mediaRecorder) {
+ m_mediaRecorder.reset(new QMediaRecorder);
+ m_captureSession.setRecorder(m_mediaRecorder.data());
+ connect(m_mediaRecorder.data(), &QMediaRecorder::recorderStateChanged, this,
+ &Camera::updateRecorderState);
+ connect(m_mediaRecorder.data(), &QMediaRecorder::durationChanged, this,
+ &Camera::updateRecordTime);
+ connect(m_mediaRecorder.data(), &QMediaRecorder::errorChanged, this,
+ &Camera::displayRecorderError);
+ }
+
+ if (!m_imageCapture) {
+ m_imageCapture.reset(new QImageCapture);
+ m_captureSession.setImageCapture(m_imageCapture.get());
+ connect(m_imageCapture.get(), &QImageCapture::readyForCaptureChanged, this,
+ &Camera::readyForCapture);
+ connect(m_imageCapture.get(), &QImageCapture::imageCaptured, this,
+ &Camera::processCapturedImage);
+ connect(m_imageCapture.get(), &QImageCapture::imageSaved, this, &Camera::imageSaved);
+ connect(m_imageCapture.get(), &QImageCapture::errorOccurred, this,
+ &Camera::displayCaptureError);
+ }
+
+ m_captureSession.setVideoOutput(ui->viewfinder);
+
+ updateCameraActive(m_camera->isActive());
+ updateRecorderState(m_mediaRecorder->recorderState());
+ readyForCapture(m_imageCapture->isReadyForCapture());
+
+ updateCaptureMode();
+
+ m_camera->start();
+}
+
+void Camera::keyPressEvent(QKeyEvent *event)
+{
+ if (event->isAutoRepeat())
+ return;
+
+ switch (event->key()) {
+ case Qt::Key_CameraFocus:
+ displayViewfinder();
+ event->accept();
+ break;
+ case Qt::Key_Camera:
+ if (m_doImageCapture) {
+ takeImage();
+ } else {
+ if (m_mediaRecorder->recorderState() == QMediaRecorder::RecordingState)
+ stop();
+ else
+ record();
+ }
+ event->accept();
+ break;
+ default:
+ QMainWindow::keyPressEvent(event);
+ }
+}
+
+void Camera::updateRecordTime()
+{
+ QString str = tr("Recorded %1 sec").arg(m_mediaRecorder->duration() / 1000);
+ ui->statusbar->showMessage(str);
+}
+
+void Camera::processCapturedImage(int requestId, const QImage &img)
+{
+ Q_UNUSED(requestId);
+ QImage scaledImage =
+ img.scaled(ui->viewfinder->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+
+ ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage));
+
+ // Display captured image for 4 seconds.
+ displayCapturedImage();
+ QTimer::singleShot(4000, this, &Camera::displayViewfinder);
+}
+
+void Camera::configureCaptureSettings()
+{
+ if (m_doImageCapture)
+ configureImageSettings();
+ else
+ configureVideoSettings();
+}
+
+void Camera::configureVideoSettings()
+{
+ VideoSettings settingsDialog(m_mediaRecorder.data());
+
+ if (settingsDialog.exec())
+ settingsDialog.applySettings();
+}
+
+void Camera::configureImageSettings()
+{
+ ImageSettings settingsDialog(m_imageCapture.get());
+
+ if (settingsDialog.exec() == QDialog::Accepted)
+ settingsDialog.applyImageSettings();
+}
+
+void Camera::record()
+{
+ m_mediaRecorder->record();
+ updateRecordTime();
+}
+
+void Camera::pause()
+{
+ m_mediaRecorder->pause();
+}
+
+void Camera::stop()
+{
+ m_mediaRecorder->stop();
+}
+
+void Camera::setMuted(bool muted)
+{
+ m_captureSession.audioInput()->setMuted(muted);
+}
+
+void Camera::takeImage()
+{
+ m_isCapturingImage = true;
+ m_imageCapture->captureToFile();
+}
+
+void Camera::displayCaptureError(int id, const QImageCapture::Error error,
+ const QString &errorString)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(error);
+ QMessageBox::warning(this, tr("Image Capture Error"), errorString);
+ m_isCapturingImage = false;
+}
+
+void Camera::startCamera()
+{
+ m_camera->start();
+}
+
+void Camera::stopCamera()
+{
+ m_camera->stop();
+}
+
+void Camera::updateCaptureMode()
+{
+ int tabIndex = ui->captureWidget->currentIndex();
+ m_doImageCapture = (tabIndex == 0);
+}
+
+void Camera::updateCameraActive(bool active)
+{
+ if (active) {
+ ui->actionStartCamera->setEnabled(false);
+ ui->actionStopCamera->setEnabled(true);
+ ui->captureWidget->setEnabled(true);
+ ui->actionSettings->setEnabled(true);
+ } else {
+ ui->actionStartCamera->setEnabled(true);
+ ui->actionStopCamera->setEnabled(false);
+ ui->captureWidget->setEnabled(false);
+ ui->actionSettings->setEnabled(false);
+ }
+}
+
+void Camera::updateRecorderState(QMediaRecorder::RecorderState state)
+{
+ switch (state) {
+ case QMediaRecorder::StoppedState:
+ ui->recordButton->setEnabled(true);
+ ui->pauseButton->setEnabled(true);
+ ui->stopButton->setEnabled(false);
+ ui->metaDataButton->setEnabled(true);
+ break;
+ case QMediaRecorder::PausedState:
+ ui->recordButton->setEnabled(true);
+ ui->pauseButton->setEnabled(false);
+ ui->stopButton->setEnabled(true);
+ ui->metaDataButton->setEnabled(false);
+ break;
+ case QMediaRecorder::RecordingState:
+ ui->recordButton->setEnabled(false);
+ ui->pauseButton->setEnabled(true);
+ ui->stopButton->setEnabled(true);
+ ui->metaDataButton->setEnabled(false);
+ break;
+ }
+}
+
+void Camera::setExposureCompensation(int index)
+{
+ m_camera->setExposureCompensation(index * 0.5);
+}
+
+void Camera::displayRecorderError()
+{
+ if (m_mediaRecorder->error() != QMediaRecorder::NoError)
+ QMessageBox::warning(this, tr("Capture Error"), m_mediaRecorder->errorString());
+}
+
+void Camera::displayCameraError()
+{
+ if (m_camera->error() != QCamera::NoError)
+ QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString());
+}
+
+void Camera::updateCameraDevice(QAction *action)
+{
+ setCamera(qvariant_cast<QCameraDevice>(action->data()));
+}
+
+void Camera::displayViewfinder()
+{
+ ui->stackedWidget->setCurrentIndex(0);
+}
+
+void Camera::displayCapturedImage()
+{
+ ui->stackedWidget->setCurrentIndex(1);
+}
+
+void Camera::readyForCapture(bool ready)
+{
+ ui->takeImageButton->setEnabled(ready);
+}
+
+void Camera::imageSaved(int id, const QString &fileName)
+{
+ Q_UNUSED(id);
+ ui->statusbar->showMessage(tr("Captured \"%1\"").arg(QDir::toNativeSeparators(fileName)));
+
+ m_isCapturingImage = false;
+ if (m_applicationExiting)
+ close();
+}
+
+void Camera::closeEvent(QCloseEvent *event)
+{
+ if (m_isCapturingImage) {
+ setEnabled(false);
+ m_applicationExiting = true;
+ event->ignore();
+ } else {
+ event->accept();
+ }
+}
+
+void Camera::updateCameras()
+{
+ ui->menuDevices->clear();
+ const QList<QCameraDevice> availableCameras = QMediaDevices::videoInputs();
+ for (const QCameraDevice &cameraDevice : availableCameras) {
+ QAction *videoDeviceAction = new QAction(cameraDevice.description(), videoDevicesGroup);
+ videoDeviceAction->setCheckable(true);
+ videoDeviceAction->setData(QVariant::fromValue(cameraDevice));
+ if (cameraDevice == QMediaDevices::defaultVideoInput())
+ videoDeviceAction->setChecked(true);
+
+ ui->menuDevices->addAction(videoDeviceAction);
+ }
+}
+
+void Camera::showMetaDataDialog()
+{
+ if (!m_metaDataDialog)
+ m_metaDataDialog = new MetaDataDialog(this);
+ m_metaDataDialog->setAttribute(Qt::WA_DeleteOnClose, false);
+ if (m_metaDataDialog->exec() == QDialog::Accepted)
+ saveMetaData();
+}
+
+void Camera::saveMetaData()
+{
+ QMediaMetaData data;
+ for (int i = 0; i < QMediaMetaData::NumMetaData; i++) {
+ QString val = m_metaDataDialog->m_metaDataFields[i]->text();
+ if (!val.isEmpty()) {
+ const auto key = static_cast<QMediaMetaData::Key>(i);
+ switch (key) {
+ case QMediaMetaData::CoverArtImage: {
+ QImage coverArt(val);
+ data.insert(key, coverArt);
+ break;
+ }
+ case QMediaMetaData::ThumbnailImage: {
+ QImage thumbnail(val);
+ data.insert(key, thumbnail);
+ break;
+ }
+ case QMediaMetaData::Date: {
+ QDateTime date = QDateTime::fromString(val);
+ data.insert(key, date);
+ break;
+ }
+ case QMediaMetaData::HasHdrContent:
+ break;
+ default:
+ data.insert(key, val);
+ }
+ }
+ }
+ m_mediaRecorder->setMetaData(data);
+}
+
+#include "moc_camera.cpp"
diff --git a/examples/multimedia/camera/camera.h b/examples/multimedia/camera/camera.h
new file mode 100644
index 000000000..c92aa2d6a
--- /dev/null
+++ b/examples/multimedia/camera/camera.h
@@ -0,0 +1,104 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef CAMERA_H
+#define CAMERA_H
+
+#include <QAudioInput>
+#include <QCamera>
+#include <QImageCapture>
+#include <QMediaCaptureSession>
+#include <QMediaDevices>
+#include <QMediaMetaData>
+#include <QMediaRecorder>
+#include <QScopedPointer>
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class Camera;
+}
+class QActionGroup;
+QT_END_NAMESPACE
+
+class MetaDataDialog;
+
+class Camera : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ Camera();
+
+public slots:
+ void saveMetaData();
+
+private slots:
+ void init();
+
+ void setCamera(const QCameraDevice &cameraDevice);
+
+ void startCamera();
+ void stopCamera();
+
+ void record();
+ void pause();
+ void stop();
+ void setMuted(bool);
+
+ void takeImage();
+ void displayCaptureError(int, QImageCapture::Error, const QString &errorString);
+
+ void configureCaptureSettings();
+ void configureVideoSettings();
+ void configureImageSettings();
+
+ void displayRecorderError();
+ void displayCameraError();
+
+ void updateCameraDevice(QAction *action);
+
+ void updateCameraActive(bool active);
+ void updateCaptureMode();
+ void updateRecorderState(QMediaRecorder::RecorderState state);
+ void setExposureCompensation(int index);
+
+ void updateRecordTime();
+
+ void processCapturedImage(int requestId, const QImage &img);
+
+ void displayViewfinder();
+ void displayCapturedImage();
+
+ void readyForCapture(bool ready);
+ void imageSaved(int id, const QString &fileName);
+
+ void updateCameras();
+
+ void showMetaDataDialog();
+
+protected:
+ void keyPressEvent(QKeyEvent *event) override;
+ void closeEvent(QCloseEvent *event) override;
+
+private:
+ Ui::Camera *ui;
+
+ QActionGroup *videoDevicesGroup = nullptr;
+
+ QMediaDevices m_devices;
+ QScopedPointer<QImageCapture> m_imageCapture;
+ QMediaCaptureSession m_captureSession;
+ QScopedPointer<QCamera> m_camera;
+ QScopedPointer<QAudioInput> m_audioInput;
+ QScopedPointer<QMediaRecorder> m_mediaRecorder;
+
+ bool m_isCapturingImage = false;
+ bool m_applicationExiting = false;
+ bool m_doImageCapture = true;
+
+ MetaDataDialog *m_metaDataDialog = nullptr;
+};
+
+#endif
diff --git a/examples/multimedia/camera/camera.pro b/examples/multimedia/camera/camera.pro
new file mode 100644
index 000000000..283d84640
--- /dev/null
+++ b/examples/multimedia/camera/camera.pro
@@ -0,0 +1,40 @@
+TEMPLATE = app
+TARGET = camera
+
+QT += multimedia multimediawidgets
+
+HEADERS = \
+ camera.h \
+ imagesettings.h \
+ videosettings.h \
+ metadatadialog.h
+
+SOURCES = \
+ main.cpp \
+ camera.cpp \
+ imagesettings.cpp \
+ videosettings.cpp \
+ metadatadialog.cpp
+
+FORMS += \
+ imagesettings.ui
+
+android|ios {
+ FORMS += \
+ camera_mobile.ui \
+ videosettings_mobile.ui
+} else {
+ FORMS += \
+ camera.ui \
+ videosettings.ui
+}
+RESOURCES += camera.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/camera
+INSTALLS += target
+
+QT += widgets
+include(../../multimedia/shared/shared.pri)
+
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
+OTHER_FILES += android/AndroidManifest.xml
diff --git a/examples/multimediawidgets/camera/camera.qrc b/examples/multimedia/camera/camera.qrc
index a915eb596..a915eb596 100644
--- a/examples/multimediawidgets/camera/camera.qrc
+++ b/examples/multimedia/camera/camera.qrc
diff --git a/examples/multimediawidgets/camera/camera.ui b/examples/multimedia/camera/camera.ui
index e4ef5d7f0..560ee7fed 100644
--- a/examples/multimediawidgets/camera/camera.ui
+++ b/examples/multimedia/camera/camera.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>668</width>
- <height>422</height>
+ <height>429</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,7 +15,135 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0" rowspan="3">
+ <item row="1" column="1" colspan="2">
+ <widget class="QTabWidget" name="captureWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Image</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="3" column="0">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>161</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="0">
+ <widget class="QPushButton" name="takeImageButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Capture Photo</string>
+ </property>
+ <property name="icon">
+ <iconset resource="camera.qrc">
+ <normaloff>:/images/shutter.svg</normaloff>:/images/shutter.svg</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QSlider" name="exposureCompensation">
+ <property name="minimum">
+ <number>-4</number>
+ </property>
+ <property name="maximum">
+ <number>4</number>
+ </property>
+ <property name="pageStep">
+ <number>2</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Exposure Compensation:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Video</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="recordButton">
+ <property name="text">
+ <string>Record</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="pauseButton">
+ <property name="text">
+ <string>Pause</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="stopButton">
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>76</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="0">
+ <widget class="QPushButton" name="muteButton">
+ <property name="text">
+ <string>Mute</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QPushButton" name="metaDataButton">
+ <property name="text">
+ <string>Set metadata</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="0" column="0" rowspan="2">
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -93,7 +221,7 @@
<widget class="QWidget" name="viewfinderPage">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
- <widget class="QCameraViewfinder" name="viewfinder" native="true"/>
+ <widget class="QVideoWidget" name="viewfinder" native="true"/>
</item>
</layout>
</widget>
@@ -119,131 +247,6 @@
</widget>
</widget>
</item>
- <item row="1" column="1" colspan="2">
- <widget class="QPushButton" name="lockButton">
- <property name="text">
- <string>Focus</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="2">
- <widget class="QTabWidget" name="captureWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab_2">
- <attribute name="title">
- <string>Image</string>
- </attribute>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QPushButton" name="takeImageButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Capture Photo</string>
- </property>
- <property name="icon">
- <iconset resource="camera.qrc">
- <normaloff>:/images/shutter.svg</normaloff>:/images/shutter.svg</iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>161</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Exposure Compensation:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QSlider" name="exposureCompensation">
- <property name="minimum">
- <number>-4</number>
- </property>
- <property name="maximum">
- <number>4</number>
- </property>
- <property name="pageStep">
- <number>2</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="tickPosition">
- <enum>QSlider::TicksAbove</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Video</string>
- </attribute>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QPushButton" name="recordButton">
- <property name="text">
- <string>Record</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="pauseButton">
- <property name="text">
- <string>Pause</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="stopButton">
- <property name="text">
- <string>Stop</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>76</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="4" column="0">
- <widget class="QPushButton" name="muteButton">
- <property name="text">
- <string>Mute</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
@@ -252,7 +255,7 @@
<x>0</x>
<y>0</y>
<width>668</width>
- <height>21</height>
+ <height>28</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -277,7 +280,7 @@
<widget class="QStatusBar" name="statusbar"/>
<action name="actionExit">
<property name="text">
- <string>Exit</string>
+ <string>Close</string>
</property>
</action>
<action name="actionStartCamera">
@@ -292,15 +295,15 @@
</action>
<action name="actionSettings">
<property name="text">
- <string>Settings</string>
+ <string>Change Settings</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
- <class>QCameraViewfinder</class>
+ <class>QVideoWidget</class>
<extends>QWidget</extends>
- <header>qcameraviewfinder.h</header>
+ <header>qvideowidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
@@ -389,22 +392,6 @@
</hints>
</connection>
<connection>
- <sender>lockButton</sender>
- <signal>clicked()</signal>
- <receiver>Camera</receiver>
- <slot>toggleLock()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>658</x>
- <y>75</y>
- </hint>
- <hint type="destinationlabel">
- <x>453</x>
- <y>119</y>
- </hint>
- </hints>
- </connection>
- <connection>
<sender>muteButton</sender>
<signal>toggled(bool)</signal>
<receiver>Camera</receiver>
diff --git a/examples/multimedia/camera/camera_mobile.ui b/examples/multimedia/camera/camera_mobile.ui
new file mode 100644
index 000000000..7f269b17b
--- /dev/null
+++ b/examples/multimedia/camera/camera_mobile.ui
@@ -0,0 +1,504 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Camera</class>
+ <widget class="QMainWindow" name="Camera">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>668</width>
+ <height>429</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Camera</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="1" column="1" colspan="2">
+ <widget class="QTabWidget" name="captureWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Image</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="4" column="0">
+ <widget class="QSlider" name="exposureCompensation">
+ <property name="minimum">
+ <number>-4</number>
+ </property>
+ <property name="maximum">
+ <number>4</number>
+ </property>
+ <property name="pageStep">
+ <number>2</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Exposure Compensation:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QPushButton" name="takeImageButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Capture Photo</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/shutter.svg</normaloff>:/images/shutter.svg</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Video</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="recordButton">
+ <property name="text">
+ <string>Record</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pauseButton">
+ <property name="text">
+ <string>Pause</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="stopButton">
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="muteButton">
+ <property name="text">
+ <string>Mute</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="metaDataButton">
+ <property name="text">
+ <string>Set metadata</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QStackedWidget" name="stackedWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>145</red>
+ <green>145</green>
+ <blue>145</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>145</red>
+ <green>145</green>
+ <blue>145</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>145</red>
+ <green>145</green>
+ <blue>145</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>145</red>
+ <green>145</green>
+ <blue>145</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="viewfinderPage">
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="0" column="0">
+ <widget class="QVideoWidget" name="viewfinder" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="previewPage">
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lastImagePreviewLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>668</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="actionStartCamera"/>
+ <addaction name="actionStopCamera"/>
+ <addaction name="separator"/>
+ <addaction name="actionSettings"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
+ </widget>
+ <widget class="QMenu" name="menuDevices">
+ <property name="title">
+ <string>Devices</string>
+ </property>
+ </widget>
+ <addaction name="menuFile"/>
+ <addaction name="menuDevices"/>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ <action name="actionExit">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </action>
+ <action name="actionStartCamera">
+ <property name="text">
+ <string>Start Camera</string>
+ </property>
+ </action>
+ <action name="actionStopCamera">
+ <property name="text">
+ <string>Stop Camera</string>
+ </property>
+ </action>
+ <action name="actionSettings">
+ <property name="text">
+ <string>Change Settings</string>
+ </property>
+ </action>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QVideoWidget</class>
+ <extends>QWidget</extends>
+ <header>qvideowidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>recordButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Camera</receiver>
+ <slot>record()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>647</x>
+ <y>149</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>61</x>
+ <y>238</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>stopButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Camera</receiver>
+ <slot>stop()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>647</x>
+ <y>225</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>140</x>
+ <y>236</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>pauseButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Camera</receiver>
+ <slot>pause()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>647</x>
+ <y>187</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>234</x>
+ <y>237</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionExit</sender>
+ <signal>triggered()</signal>
+ <receiver>Camera</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>154</x>
+ <y>130</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>takeImageButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Camera</receiver>
+ <slot>takeImage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>625</x>
+ <y>132</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>603</x>
+ <y>169</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>muteButton</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>Camera</receiver>
+ <slot>setMuted(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>647</x>
+ <y>377</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>5</x>
+ <y>280</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>exposureCompensation</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>Camera</receiver>
+ <slot>setExposureCompensation(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>559</x>
+ <y>367</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>665</x>
+ <y>365</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionSettings</sender>
+ <signal>triggered()</signal>
+ <receiver>Camera</receiver>
+ <slot>configureCaptureSettings()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>333</x>
+ <y>210</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionStartCamera</sender>
+ <signal>triggered()</signal>
+ <receiver>Camera</receiver>
+ <slot>startCamera()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>333</x>
+ <y>210</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionStopCamera</sender>
+ <signal>triggered()</signal>
+ <receiver>Camera</receiver>
+ <slot>stopCamera()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>333</x>
+ <y>210</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>record()</slot>
+ <slot>pause()</slot>
+ <slot>stop()</slot>
+ <slot>enablePreview(bool)</slot>
+ <slot>configureCaptureSettings()</slot>
+ <slot>takeImage()</slot>
+ <slot>startCamera()</slot>
+ <slot>toggleLock()</slot>
+ <slot>setMuted(bool)</slot>
+ <slot>stopCamera()</slot>
+ <slot>setExposureCompensation(int)</slot>
+ </slots>
+</ui>
diff --git a/examples/multimedia/camera/doc/images/camera-example.png b/examples/multimedia/camera/doc/images/camera-example.png
new file mode 100644
index 000000000..f7d7e4f67
--- /dev/null
+++ b/examples/multimedia/camera/doc/images/camera-example.png
Binary files differ
diff --git a/examples/multimedia/camera/doc/src/camera.qdoc b/examples/multimedia/camera/doc/src/camera.qdoc
new file mode 100644
index 000000000..ae6877129
--- /dev/null
+++ b/examples/multimedia/camera/doc/src/camera.qdoc
@@ -0,0 +1,92 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+/*!
+
+\example camera
+\title Camera Example
+\ingroup multimedia_examples
+\ingroup video_examples
+\ingroup camera_examples
+\examplecategory {Multimedia}
+\meta {tag} {widgets}
+\brief Shows how to capture a still image or record video.
+
+\image camera-example.png
+
+The Camera Example demonstrates how you can use \l{Qt Multimedia} to implement
+some basic Camera functionality to take still images and record video clips
+with audio.
+
+\include examples-run.qdocinc
+
+The example implements a \c Camera class that acts as our camera interface. 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 uses:
+\list
+ \li An instance of \l {QCamera}, the API class interface to the hardware.
+ \li An instance of \l {QImageCapture} to take still images.
+ \li An instance of \l {QMediaRecorder} to record video. It also contains
+ the user interface object.
+\endlist
+
+\section1 The Camera constructor
+
+The Camera constructor does some basic initialization of the user interface
+including disabling all buttons by default.
+
+\quotefromfile camera/camera.cpp
+\skipto Camera::Camera()
+\printuntil ui->metaDataButton->setEnabled(false);
+
+It seeks permissions for input device access:
+
+\skipto #if QT_CONFIG(permissions)
+\printuntil #endif
+
+Inputs are assigned:
+\printuntil updateCameras()
+
+ UI signals are connected to slots that react to the triggering event:
+\printuntil setCamera(QMediaDevices::defaultVideoInput());
+
+However, most of the work is done when the \e{setCamera()} function is called,
+passing in a \l QCameraDevice.
+
+\section1 setCamera()
+
+\c{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 {QImageCapture}, and \l {QMediaRecorder}
+objects.
+
+\skipto void Camera::setCamera(const QCameraDevice &cameraDevice)
+\printto m_captureSession.setVideoOutput(ui->viewfinder);
+
+The still and video recording visual tabs are enabled:
+
+\printuntil updateCaptureMode();
+
+Finally the \l {QCamera::start}{start()} function of the \l{QCamera}
+object is called.
+
+\printuntil m_camera->start();
+
+\section1 Triggering capturing
+
+Now that the camera is ready for user commands it waits for a suitable event.
+Such an event can be a key press of either the \l {Qt::Key_CameraFocus} or
+\l {Qt::Key_Camera} buttons on the application window.
+
+Key_CameraFocus will simply display the preview and lock the camera settings.
+\printto case Qt::Key_Camera:
+
+\c Key_Camera will either call \e{takeImage()} if doing an image capture, or call
+\c record() or \c stop() (if already recording) on the QMediaRecorder instance
+when recording video.
+
+\printuntil break;
+
+*/
diff --git a/examples/multimediawidgets/camera/images/shutter.svg b/examples/multimedia/camera/images/shutter.svg
index 18493361d..18493361d 100644
--- a/examples/multimediawidgets/camera/images/shutter.svg
+++ b/examples/multimedia/camera/images/shutter.svg
diff --git a/examples/multimedia/camera/imagesettings.cpp b/examples/multimedia/camera/imagesettings.cpp
new file mode 100644
index 000000000..c2b022a70
--- /dev/null
+++ b/examples/multimedia/camera/imagesettings.cpp
@@ -0,0 +1,84 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "imagesettings.h"
+#include "ui_imagesettings.h"
+
+#include <QCamera>
+#include <QImageCapture>
+#include <QMediaCaptureSession>
+
+#include <QComboBox>
+
+#include <QDebug>
+
+using namespace Qt::StringLiterals;
+
+ImageSettings::ImageSettings(QImageCapture *imageCapture, QWidget *parent)
+ : QDialog(parent), ui(new Ui::ImageSettingsUi), imagecapture(imageCapture)
+{
+ ui->setupUi(this);
+
+ // image codecs
+ ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString()));
+ const auto supportedImageFormats = QImageCapture::supportedFormats();
+ for (const auto &f : supportedImageFormats) {
+ QString description = QImageCapture::fileFormatDescription(f);
+ ui->imageCodecBox->addItem(QImageCapture::fileFormatName(f) + ": " + description,
+ QVariant::fromValue(f));
+ }
+
+ ui->imageQualitySlider->setRange(0, int(QImageCapture::VeryHighQuality));
+
+ ui->imageResolutionBox->addItem(tr("Default Resolution"));
+ const QList<QSize> supportedResolutions =
+ imagecapture->captureSession()->camera()->cameraDevice().photoResolutions();
+ for (const QSize &resolution : supportedResolutions) {
+ ui->imageResolutionBox->addItem(
+ u"%1x%2"_s.arg(resolution.width()).arg(resolution.height()),
+ QVariant(resolution));
+ }
+
+ selectComboBoxItem(ui->imageCodecBox, QVariant::fromValue(imagecapture->fileFormat()));
+ selectComboBoxItem(ui->imageResolutionBox, QVariant(imagecapture->resolution()));
+ ui->imageQualitySlider->setValue(imagecapture->quality());
+}
+
+ImageSettings::~ImageSettings()
+{
+ delete ui;
+}
+
+void ImageSettings::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void ImageSettings::applyImageSettings() const
+{
+ imagecapture->setFileFormat(boxValue(ui->imageCodecBox).value<QImageCapture::FileFormat>());
+ imagecapture->setQuality(QImageCapture::Quality(ui->imageQualitySlider->value()));
+ imagecapture->setResolution(boxValue(ui->imageResolutionBox).toSize());
+}
+
+QVariant ImageSettings::boxValue(const QComboBox *box) const
+{
+ const int idx = box->currentIndex();
+ return idx != -1 ? box->itemData(idx) : QVariant{};
+}
+
+void ImageSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
+{
+ const int idx = box->findData(value);
+ if (idx != -1)
+ box->setCurrentIndex(idx);
+}
+
+#include "moc_imagesettings.cpp"
diff --git a/examples/multimedia/camera/imagesettings.h b/examples/multimedia/camera/imagesettings.h
new file mode 100644
index 000000000..0e2ef8e5b
--- /dev/null
+++ b/examples/multimedia/camera/imagesettings.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef IMAGESETTINGS_H
+#define IMAGESETTINGS_H
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QComboBox;
+class QImageCapture;
+namespace Ui {
+class ImageSettingsUi;
+}
+QT_END_NAMESPACE
+
+class ImageSettings : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ImageSettings(QImageCapture *imageCapture, QWidget *parent = nullptr);
+ ~ImageSettings();
+
+ void applyImageSettings() const;
+
+ QString format() const;
+ void setFormat(const QString &format);
+
+protected:
+ void changeEvent(QEvent *e) override;
+
+private:
+ QVariant boxValue(const QComboBox *box) const;
+ void selectComboBoxItem(QComboBox *box, const QVariant &value);
+
+ Ui::ImageSettingsUi *ui;
+ QImageCapture *imagecapture;
+};
+
+#endif // IMAGESETTINGS_H
diff --git a/examples/multimediawidgets/camera/imagesettings.ui b/examples/multimedia/camera/imagesettings.ui
index 8c59ca01d..8c59ca01d 100644
--- a/examples/multimediawidgets/camera/imagesettings.ui
+++ b/examples/multimedia/camera/imagesettings.ui
diff --git a/examples/multimedia/camera/ios/Info.plist.in b/examples/multimedia/camera/ios/Info.plist.in
new file mode 100644
index 000000000..6a6b8db11
--- /dev/null
+++ b/examples/multimedia/camera/ios/Info.plist.in
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+
+ <key>NSCameraUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+</dict>
+</plist>
+
diff --git a/examples/multimedia/camera/macos/Info.plist.in b/examples/multimedia/camera/macos/Info.plist.in
new file mode 100644
index 000000000..ae2d945f1
--- /dev/null
+++ b/examples/multimedia/camera/macos/Info.plist.in
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+
+ <key>NSCameraUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/camera/main.cpp b/examples/multimedia/camera/main.cpp
new file mode 100644
index 000000000..13554fc2b
--- /dev/null
+++ b/examples/multimedia/camera/main.cpp
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "camera.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Camera camera;
+ camera.show();
+
+ return app.exec();
+};
diff --git a/examples/multimedia/camera/metadatadialog.cpp b/examples/multimedia/camera/metadatadialog.cpp
new file mode 100644
index 000000000..8213baa6f
--- /dev/null
+++ b/examples/multimedia/camera/metadatadialog.cpp
@@ -0,0 +1,107 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "metadatadialog.h"
+
+#include <QMediaMetaData>
+
+#include <QDialog>
+#include <QDialogButtonBox>
+#include <QFileDialog>
+#include <QFormLayout>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QScrollArea>
+#include <QVBoxLayout>
+#include <QWidget>
+
+#include <QString>
+
+static QString defaultValue(QMediaMetaData::Key key)
+{
+ switch (key) {
+ case QMediaMetaData::Title:
+ return MetaDataDialog::tr("Qt Camera Example");
+ case QMediaMetaData::Author:
+ return MetaDataDialog::tr("The Qt Company");
+ case QMediaMetaData::Date:
+ return QDateTime::currentDateTime().toString();
+ default:
+ break;
+ }
+ return {};
+}
+
+MetaDataDialog::MetaDataDialog(QWidget *parent) : QDialog(parent)
+{
+ auto *viewport = new QWidget;
+ auto *metaDataLayout = new QFormLayout(viewport);
+
+ for (int i = 0; i < QMediaMetaData::NumMetaData; ++i) {
+ const auto key = static_cast<QMediaMetaData::Key>(i);
+ QString label = QMediaMetaData::metaDataKeyToString(key);
+ auto *lineEdit = new QLineEdit(defaultValue(key));
+ lineEdit->setClearButtonEnabled(true);
+ m_metaDataFields[key] = lineEdit;
+
+ switch (key) {
+ case QMediaMetaData::ThumbnailImage: {
+ QPushButton *openThumbnail = new QPushButton(tr("Open"));
+ connect(openThumbnail, &QPushButton::clicked, this,
+ &MetaDataDialog::openThumbnailImage);
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(lineEdit);
+ layout->addWidget(openThumbnail);
+ metaDataLayout->addRow(label, layout);
+ }
+ break;
+ case QMediaMetaData::CoverArtImage: {
+ QPushButton *openCoverArt = new QPushButton(tr("Open"));
+ connect(openCoverArt, &QPushButton::clicked, this, &MetaDataDialog::openCoverArtImage);
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addWidget(lineEdit);
+ layout->addWidget(openCoverArt);
+ metaDataLayout->addRow(label, layout);
+ }
+ break;
+ case QMediaMetaData::HasHdrContent:
+ break; // Read-only
+ default:
+ metaDataLayout->addRow(label, lineEdit);
+ break;
+ }
+ }
+
+ QScrollArea *scrollArea = new QScrollArea;
+ scrollArea->setWidget(viewport);
+ auto *dialogLayout = new QVBoxLayout(this);
+ dialogLayout->addWidget(scrollArea);
+
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ dialogLayout->addWidget(buttonBox);
+
+ setWindowTitle(tr("Set Metadata"));
+ resize(400, 300);
+
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &MetaDataDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &MetaDataDialog::reject);
+}
+
+void MetaDataDialog::openThumbnailImage()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::currentPath(),
+ tr("Image Files (*.png *.jpg *.bmp)"));
+ if (!fileName.isEmpty())
+ m_metaDataFields[QMediaMetaData::ThumbnailImage]->setText(fileName);
+}
+
+void MetaDataDialog::openCoverArtImage()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::currentPath(),
+ tr("Image Files (*.png *.jpg *.bmp)"));
+ if (!fileName.isEmpty())
+ m_metaDataFields[QMediaMetaData::CoverArtImage]->setText(fileName);
+}
+
+#include "moc_metadatadialog.cpp"
diff --git a/examples/multimedia/camera/metadatadialog.h b/examples/multimedia/camera/metadatadialog.h
new file mode 100644
index 000000000..5bb5a4b0b
--- /dev/null
+++ b/examples/multimedia/camera/metadatadialog.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include <QDialog>
+#include <QMediaMetaData>
+
+QT_BEGIN_NAMESPACE
+class QLabel;
+class QLineEdit;
+QT_END_NAMESPACE
+
+//! [0]
+class MetaDataDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit MetaDataDialog(QWidget *parent = nullptr);
+
+ QLineEdit *m_metaDataFields[QMediaMetaData::NumMetaData] = {};
+
+private slots:
+ void openThumbnailImage();
+ void openCoverArtImage();
+};
+//! [0]
+
+#endif
diff --git a/examples/multimedia/camera/videosettings.cpp b/examples/multimedia/camera/videosettings.cpp
new file mode 100644
index 000000000..68177e0f3
--- /dev/null
+++ b/examples/multimedia/camera/videosettings.cpp
@@ -0,0 +1,196 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videosettings.h"
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
+# include "ui_videosettings_mobile.h"
+#else
+# include "ui_videosettings.h"
+#endif
+
+#include <QAudioDevice>
+#include <QAudioInput>
+#include <QCamera>
+#include <QCameraDevice>
+#include <QMediaCaptureSession>
+#include <QMediaFormat>
+#include <QMediaRecorder>
+
+#include <QComboBox>
+#include <QSpinBox>
+
+#include <QDebug>
+#include <QTextStream>
+
+static QString toFormattedString(const QCameraFormat &cameraFormat)
+{
+ QString string;
+ QTextStream str(&string);
+ str << QVideoFrameFormat::pixelFormatToString(cameraFormat.pixelFormat())
+ << ' ' << cameraFormat.resolution().width()
+ << 'x' << cameraFormat.resolution().height()
+ << ' ' << cameraFormat.minFrameRate()
+ << '-' << cameraFormat.maxFrameRate() << "FPS";
+ return string;
+}
+
+VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent)
+ : QDialog(parent), ui(new Ui::VideoSettingsUi), mediaRecorder(mediaRecorder)
+{
+ ui->setupUi(this);
+
+ // sample rate:
+ auto audioDevice = mediaRecorder->captureSession()->audioInput()->device();
+ ui->audioSampleRateBox->setRange(audioDevice.minimumSampleRate(),
+ audioDevice.maximumSampleRate());
+
+ // camera format
+ ui->videoFormatBox->addItem(tr("Default camera format"));
+
+ auto *camera = mediaRecorder->captureSession()->camera();
+ const QList<QCameraFormat> videoFormats = camera->cameraDevice().videoFormats();
+
+ for (const QCameraFormat &format : videoFormats)
+ ui->videoFormatBox->addItem(toFormattedString(format), QVariant::fromValue(format));
+
+ connect(ui->videoFormatBox, &QComboBox::currentIndexChanged, [this](int /*index*/) {
+ this->setFpsRange(boxValue(ui->videoFormatBox).value<QCameraFormat>());
+ });
+
+ setFpsRange(camera->cameraFormat());
+
+ connect(ui->fpsSlider, &QSlider::valueChanged, ui->fpsSpinBox, &QSpinBox::setValue);
+ connect(ui->fpsSpinBox, &QSpinBox::valueChanged, ui->fpsSlider, &QSlider::setValue);
+
+ updateFormatsAndCodecs();
+ connect(ui->audioCodecBox, &QComboBox::currentIndexChanged, this,
+ &VideoSettings::updateFormatsAndCodecs);
+ connect(ui->videoCodecBox, &QComboBox::currentIndexChanged, this,
+ &VideoSettings::updateFormatsAndCodecs);
+ connect(ui->containerFormatBox, &QComboBox::currentIndexChanged, this,
+ &VideoSettings::updateFormatsAndCodecs);
+
+ ui->qualitySlider->setRange(0, int(QMediaRecorder::VeryHighQuality));
+
+ QMediaFormat format = mediaRecorder->mediaFormat();
+ selectComboBoxItem(ui->containerFormatBox, QVariant::fromValue(format.fileFormat()));
+ selectComboBoxItem(ui->audioCodecBox, QVariant::fromValue(format.audioCodec()));
+ selectComboBoxItem(ui->videoCodecBox, QVariant::fromValue(format.videoCodec()));
+
+ ui->qualitySlider->setValue(mediaRecorder->quality());
+ ui->audioSampleRateBox->setValue(mediaRecorder->audioSampleRate());
+ selectComboBoxItem(ui->videoFormatBox,
+ QVariant::fromValue(camera->cameraFormat()));
+
+ ui->fpsSlider->setValue(mediaRecorder->videoFrameRate());
+ ui->fpsSpinBox->setValue(mediaRecorder->videoFrameRate());
+}
+
+VideoSettings::~VideoSettings()
+{
+ delete ui;
+}
+
+void VideoSettings::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void VideoSettings::setFpsRange(const QCameraFormat &format)
+{
+ ui->fpsSlider->setRange(format.minFrameRate(), format.maxFrameRate());
+ ui->fpsSpinBox->setRange(format.minFrameRate(), format.maxFrameRate());
+}
+
+void VideoSettings::applySettings()
+{
+ QMediaFormat format;
+ format.setFileFormat(boxValue(ui->containerFormatBox).value<QMediaFormat::FileFormat>());
+ format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
+ format.setVideoCodec(boxValue(ui->videoCodecBox).value<QMediaFormat::VideoCodec>());
+
+ mediaRecorder->setMediaFormat(format);
+ mediaRecorder->setQuality(QMediaRecorder::Quality(ui->qualitySlider->value()));
+ mediaRecorder->setAudioSampleRate(ui->audioSampleRateBox->value());
+
+ const auto &cameraFormat = boxValue(ui->videoFormatBox).value<QCameraFormat>();
+ mediaRecorder->setVideoResolution(cameraFormat.resolution());
+ mediaRecorder->setVideoFrameRate(ui->fpsSlider->value());
+
+ mediaRecorder->captureSession()->camera()->setCameraFormat(cameraFormat);
+}
+
+void VideoSettings::updateFormatsAndCodecs()
+{
+ if (m_updatingFormats)
+ return;
+ m_updatingFormats = true;
+
+ QMediaFormat format;
+ if (ui->containerFormatBox->count())
+ format.setFileFormat(boxValue(ui->containerFormatBox).value<QMediaFormat::FileFormat>());
+ if (ui->audioCodecBox->count())
+ format.setAudioCodec(boxValue(ui->audioCodecBox).value<QMediaFormat::AudioCodec>());
+ if (ui->videoCodecBox->count())
+ format.setVideoCodec(boxValue(ui->videoCodecBox).value<QMediaFormat::VideoCodec>());
+
+ int currentIndex = 0;
+ ui->audioCodecBox->clear();
+ ui->audioCodecBox->addItem(tr("Default audio codec"),
+ QVariant::fromValue(QMediaFormat::AudioCodec::Unspecified));
+ for (auto codec : format.supportedAudioCodecs(QMediaFormat::Encode)) {
+ if (codec == format.audioCodec())
+ currentIndex = ui->audioCodecBox->count();
+ ui->audioCodecBox->addItem(QMediaFormat::audioCodecDescription(codec),
+ QVariant::fromValue(codec));
+ }
+ ui->audioCodecBox->setCurrentIndex(currentIndex);
+
+ currentIndex = 0;
+ ui->videoCodecBox->clear();
+ ui->videoCodecBox->addItem(tr("Default video codec"),
+ QVariant::fromValue(QMediaFormat::VideoCodec::Unspecified));
+ for (auto codec : format.supportedVideoCodecs(QMediaFormat::Encode)) {
+ if (codec == format.videoCodec())
+ currentIndex = ui->videoCodecBox->count();
+ ui->videoCodecBox->addItem(QMediaFormat::videoCodecDescription(codec),
+ QVariant::fromValue(codec));
+ }
+ ui->videoCodecBox->setCurrentIndex(currentIndex);
+
+ currentIndex = 0;
+ ui->containerFormatBox->clear();
+ ui->containerFormatBox->addItem(tr("Default file format"),
+ QVariant::fromValue(QMediaFormat::UnspecifiedFormat));
+ for (auto container : format.supportedFileFormats(QMediaFormat::Encode)) {
+ if (container == format.fileFormat())
+ currentIndex = ui->containerFormatBox->count();
+ ui->containerFormatBox->addItem(QMediaFormat::fileFormatDescription(container),
+ QVariant::fromValue(container));
+ }
+ ui->containerFormatBox->setCurrentIndex(currentIndex);
+
+ m_updatingFormats = false;
+}
+
+QVariant VideoSettings::boxValue(const QComboBox *box) const
+{
+ const int idx = box->currentIndex();
+ return idx != -1 ? box->itemData(idx) : QVariant{};
+}
+
+void VideoSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
+{
+ const int idx = box->findData(value);
+ if (idx != -1)
+ box->setCurrentIndex(idx);
+}
+
+#include "moc_videosettings.cpp"
diff --git a/examples/multimedia/camera/videosettings.h b/examples/multimedia/camera/videosettings.h
new file mode 100644
index 000000000..358b1fb16
--- /dev/null
+++ b/examples/multimedia/camera/videosettings.h
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOSETTINGS_H
+#define VIDEOSETTINGS_H
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QCameraFormat;
+class QComboBox;
+class QMediaRecorder;
+namespace Ui {
+class VideoSettingsUi;
+}
+QT_END_NAMESPACE
+
+class VideoSettings : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = nullptr);
+ ~VideoSettings();
+
+ void applySettings();
+ void updateFormatsAndCodecs();
+
+protected:
+ void changeEvent(QEvent *e) override;
+
+private:
+ void setFpsRange(const QCameraFormat &format);
+ QVariant boxValue(const QComboBox *) const;
+ void selectComboBoxItem(QComboBox *box, const QVariant &value);
+
+ Ui::VideoSettingsUi *ui;
+ QMediaRecorder *mediaRecorder;
+ bool m_updatingFormats = false;
+};
+
+#endif // VIDEOSETTINGS_H
diff --git a/examples/multimedia/camera/videosettings.ui b/examples/multimedia/camera/videosettings.ui
new file mode 100644
index 000000000..3c1f71f11
--- /dev/null
+++ b/examples/multimedia/camera/videosettings.ui
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>VideoSettingsUi</class>
+ <widget class="QDialog" name="VideoSettingsUi">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>686</width>
+ <height>499</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Video Settings</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="4" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Video</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>Camera Format</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QComboBox" name="videoCodecBox"/>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Framerate:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Video Codec:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QComboBox" name="videoFormatBox"/>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QSpinBox" name="fpsSpinBox"/>
+ </item>
+ <item>
+ <widget class="QSlider" name="fpsSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QWidget" name="widget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Audio</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Audio Codec:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="audioCodecBox"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Sample Rate:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="audioSampleRateBox"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Quality:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="qualitySlider">
+ <property name="maximum">
+ <number>4</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>File Format:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="containerFormatBox"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>VideoSettingsUi</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>322</x>
+ <y>272</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>44</x>
+ <y>230</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>VideoSettingsUi</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>405</x>
+ <y>262</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>364</x>
+ <y>227</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/multimedia/camera/videosettings_mobile.ui b/examples/multimedia/camera/videosettings_mobile.ui
new file mode 100644
index 000000000..6584f07f9
--- /dev/null
+++ b/examples/multimedia/camera/videosettings_mobile.ui
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>VideoSettingsUi</class>
+ <widget class="QDialog" name="VideoSettingsUi">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>329</width>
+ <height>591</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Video Settings</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="2" column="0">
+ <widget class="QWidget" name="widget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Audio</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Audio Codec:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="audioCodecBox"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Sample Rate:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="audioSampleRateBox"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Quality:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="qualitySlider">
+ <property name="maximum">
+ <number>4</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>File Format:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="containerFormatBox"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Video</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="2" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Frames per second:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" colspan="2">
+ <widget class="QComboBox" name="videoCodecBox"/>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>Camera Format:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Video Codec:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QComboBox" name="videoFormatBox"/>
+ </item>
+ <item row="7" column="0">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QSpinBox" name="fpsSpinBox">
+ <property name="minimum">
+ <number>8</number>
+ </property>
+ <property name="maximum">
+ <number>30</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="fpsSlider">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>VideoSettingsUi</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>322</x>
+ <y>272</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>44</x>
+ <y>230</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>VideoSettingsUi</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>405</x>
+ <y>262</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>364</x>
+ <y>227</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/multimedia/declarative-camera/CMakeLists.txt b/examples/multimedia/declarative-camera/CMakeLists.txt
new file mode 100644
index 000000000..50b0ba48d
--- /dev/null
+++ b/examples/multimedia/declarative-camera/CMakeLists.txt
@@ -0,0 +1,79 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(declarative-camera LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/declarative-camera")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Qml Quick)
+
+qt_add_executable(declarative-camera
+ qmlcamera.cpp
+)
+
+set_target_properties(declarative-camera PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+)
+
+target_include_directories(declarative-camera PUBLIC
+ ../shared
+)
+
+target_link_libraries(declarative-camera PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Qml
+ Qt::Quick
+)
+
+# Resources:
+set(declarative-camera_resource_files
+ "CameraButton.qml"
+ "CameraListButton.qml"
+ "CameraListPopup.qml"
+ "CameraPropertyButton.qml"
+ "CameraPropertyPopup.qml"
+ "FlashControl.qml"
+ "PhotoCaptureControls.qml"
+ "PhotoPreview.qml"
+ "Popup.qml"
+ "VideoCaptureControls.qml"
+ "VideoPreview.qml"
+ "ZoomControl.qml"
+ "declarative-camera.qml"
+ "images/camera_auto_mode.png"
+ "images/camera_camera_setting.png"
+ "images/camera_flash_auto.png"
+ "images/camera_flash_fill.png"
+ "images/camera_flash_off.png"
+ "images/camera_flash_redeye.png"
+ "images/camera_white_balance_cloudy.png"
+ "images/camera_white_balance_flourescent.png"
+ "images/camera_white_balance_incandescent.png"
+ "images/camera_white_balance_sunny.png"
+ "images/toolbutton.png"
+ "images/toolbutton.sci"
+)
+
+qt_add_resources(declarative-camera "declarative-camera"
+ PREFIX
+ "/"
+ FILES
+ ${declarative-camera_resource_files}
+)
+
+install(TARGETS declarative-camera
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/declarative-camera/CameraButton.qml b/examples/multimedia/declarative-camera/CameraButton.qml
index 27fb1eb2d..43837bcb3 100644
--- a/examples/multimedia/declarative-camera/CameraButton.qml
+++ b/examples/multimedia/declarative-camera/CameraButton.qml
@@ -1,54 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: button
diff --git a/examples/multimedia/declarative-camera/CameraListButton.qml b/examples/multimedia/declarative-camera/CameraListButton.qml
index 75fb2fb62..b6361eac2 100644
--- a/examples/multimedia/declarative-camera/CameraListButton.qml
+++ b/examples/multimedia/declarative-camera/CameraListButton.qml
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
+import QtMultimedia
Item {
id: cameraListButton
@@ -67,18 +21,54 @@ Item {
CameraButton {
anchors.fill: parent
- text: popup.currentItem != null ? popup.currentItem.displayName : ""
+ text: popup.currentItem !== null ? popup.currentItem.description : ""
onClicked: popup.toggle()
}
CameraListPopup {
id: popup
- anchors.right: parent.left
anchors.rightMargin: 16
- anchors.top: parent.top
visible: opacity > 0
+ model: mediaDevices.videoInputs
+
+ MediaDevices {
+ id: mediaDevices
+ }
onSelected: popup.toggle()
}
+
+ states: [
+ State {
+ name: "MobilePortrait"
+ AnchorChanges {
+ target: popup
+ // qmllint disable incompatible-type
+ anchors.bottom: cameraListButton.top
+ anchors.left: cameraListButton.left
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "MobileLandscape"
+ AnchorChanges {
+ target: popup
+ // qmllint disable incompatible-type
+ anchors.top: cameraListButton.top
+ anchors.right: cameraListButton.left
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "Other"
+ AnchorChanges {
+ target: popup
+ // qmllint disable incompatible-type
+ anchors.top: cameraListButton.top
+ anchors.right: cameraListButton.left
+ // qmllint enable incompatible-type
+ }
+ }
+ ]
}
diff --git a/examples/multimedia/declarative-camera/CameraListPopup.qml b/examples/multimedia/declarative-camera/CameraListPopup.qml
index 4a9e39740..83c9843ee 100644
--- a/examples/multimedia/declarative-camera/CameraListPopup.qml
+++ b/examples/multimedia/declarative-camera/CameraListPopup.qml
@@ -1,61 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtMultimedia
Popup {
id: cameraListPopup
property alias model : view.model
- property variant currentValue
- property variant currentItem : model[view.currentIndex]
+ property cameraDevice currentValue
+ property cameraDevice currentItem : model[view.currentIndex]
property int itemWidth : 200
property int itemHeight : 50
@@ -73,13 +28,19 @@ Popup {
highlightFollowsCurrentItem: true
highlight: Rectangle { color: "gray"; radius: 5 }
currentIndex: 0
+ clip: true
delegate: Item {
+ id: cameraListItem
+
+ required property int index
+ required property cameraDevice modelData
+
width: cameraListPopup.itemWidth
height: cameraListPopup.itemHeight
Text {
- text: modelData.displayName
+ text: cameraListItem.modelData.description
anchors.fill: parent
anchors.margins: 5
@@ -95,9 +56,9 @@ Popup {
MouseArea {
anchors.fill: parent
onClicked: {
- view.currentIndex = index
- cameraListPopup.currentValue = modelData.deviceId
- cameraListPopup.selected(modelData.deviceId)
+ view.currentIndex = cameraListItem.index
+ cameraListPopup.currentValue = cameraListItem.modelData
+ cameraListPopup.selected()
}
}
}
diff --git a/examples/multimedia/declarative-camera/CameraPropertyButton.qml b/examples/multimedia/declarative-camera/CameraPropertyButton.qml
index cfc0f51c9..3a9e60a98 100644
--- a/examples/multimedia/declarative-camera/CameraPropertyButton.qml
+++ b/examples/multimedia/declarative-camera/CameraPropertyButton.qml
@@ -1,55 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtMultimedia 5.0
+import QtQuick
Item {
id: propertyButton
@@ -77,14 +29,44 @@ Item {
CameraPropertyPopup {
id: popup
- anchors.right: parent.left
anchors.rightMargin: 16
- anchors.top: parent.top
visible: opacity > 0
currentValue: propertyButton.value
onSelected: popup.toggle()
}
-}
+ states: [
+ State {
+ name: "MobilePortrait"
+ AnchorChanges {
+ target: popup
+ // qmllint disable incompatible-type
+ anchors.bottom: propertyButton.top
+ anchors.left: propertyButton.left
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "MobileLandscape"
+ AnchorChanges {
+ target: popup
+ // qmllint disable incompatible-type
+ anchors.verticalCenter: propertyButton.top
+ anchors.right: propertyButton.left
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "Other"
+ AnchorChanges {
+ target: popup
+ // qmllint disable incompatible-type
+ anchors.top: propertyButton.top
+ anchors.right: propertyButton.left
+ // qmllint enable incompatible-type
+ }
+ }
+ ]
+}
diff --git a/examples/multimedia/declarative-camera/CameraPropertyPopup.qml b/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
index e245968f7..774775a5b 100644
--- a/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
+++ b/examples/multimedia/declarative-camera/CameraPropertyPopup.qml
@@ -1,61 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma ComponentBehavior: Bound
+import QtQuick
Popup {
id: propertyPopup
property alias model : view.model
- property variant currentValue
- property variant currentItem : model.get(view.currentIndex)
+ property var currentValue
+ property var currentItem : model.get(view.currentIndex)
property int itemWidth : 100
property int itemHeight : 70
@@ -85,21 +39,26 @@ Popup {
snapMode: ListView.SnapOneItem
highlightFollowsCurrentItem: true
highlight: Rectangle { color: "gray"; radius: 5 }
- currentIndex: indexForValue(propertyPopup.currentValue)
+ currentIndex: propertyPopup.indexForValue(propertyPopup.currentValue)
delegate: Item {
+ id: propertyItem
+
+ required property url icon
+ required property var value
+
width: propertyPopup.itemWidth
height: 70
Image {
anchors.centerIn: parent
- source: icon
+ source: propertyItem.icon
}
MouseArea {
anchors.fill: parent
onClicked: {
- propertyPopup.currentValue = value
- propertyPopup.selected(value)
+ propertyPopup.currentValue = propertyItem.value
+ propertyPopup.selected()
}
}
}
diff --git a/examples/multimedia/declarative-camera/FlashControl.qml b/examples/multimedia/declarative-camera/FlashControl.qml
new file mode 100644
index 000000000..61550f098
--- /dev/null
+++ b/examples/multimedia/declarative-camera/FlashControl.qml
@@ -0,0 +1,65 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Item {
+ id: flashControl
+
+ height: column.height
+
+ property Camera cameraDevice
+ property bool mIsFlashSupported: (cameraDevice && cameraDevice.active) ? cameraDevice.isFlashModeSupported(Camera.FlashOn) : false
+ property bool mIsTorchSupported: (cameraDevice && cameraDevice.active) ? cameraDevice.isTorchModeSupported(Camera.TorchOn) : false
+
+ Column {
+ id: column
+
+ Switch {
+ id: flashModeControl
+ visible: flashControl.mIsFlashSupported
+ opacity: checked ? 0.75 : 0.25
+ text: "Flash"
+ contentItem: Text {
+ text: flashModeControl.text
+ color: "white"
+ leftPadding: flashModeControl.indicator.width + flashModeControl.spacing
+ }
+
+ onPositionChanged: {
+ if (position) {
+ if (torchModeControl.checked)
+ torchModeControl.toggle();
+ flashControl.cameraDevice.flashMode = Camera.FlashOn
+
+ } else {
+ flashControl.cameraDevice.flashMode = Camera.FlashOff
+ }
+ }
+ }
+
+ Switch {
+ id: torchModeControl
+ visible: flashControl.mIsTorchSupported
+ opacity: checked ? 0.75 : 0.25
+ text: "Torch"
+ contentItem: Text {
+ text: torchModeControl.text
+ color: "white"
+ leftPadding: torchModeControl.indicator.width + torchModeControl.spacing
+ }
+
+ onPositionChanged: {
+ if (position) {
+ if (flashModeControl.checked)
+ flashModeControl.toggle();
+ flashControl.cameraDevice.torchMode = Camera.TorchOn
+ } else {
+ flashControl.cameraDevice.torchMode = Camera.TorchOff
+ }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/declarative-camera/FocusButton.qml b/examples/multimedia/declarative-camera/FocusButton.qml
deleted file mode 100644
index fab8aa11e..000000000
--- a/examples/multimedia/declarative-camera/FocusButton.qml
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.0
-
-CameraButton {
- property Camera camera
-
- onClicked: {
- if (camera.lockStatus == Camera.Unlocked)
- camera.searchAndLock();
- else
- camera.unlock();
- }
-
- text: {
- if (camera.lockStatus == Camera.Unlocked)
- "Focus";
- else if (camera.lockStatus == Camera.Searching)
- "Focusing"
- else
- "Unlock"
- }
-}
diff --git a/examples/multimedia/declarative-camera/Info.plist b/examples/multimedia/declarative-camera/Info.plist
index 462df2ae0..7a1b26e1e 100644
--- a/examples/multimedia/declarative-camera/Info.plist
+++ b/examples/multimedia/declarative-camera/Info.plist
@@ -2,40 +2,42 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>CFBundleIconFile</key>
- <string></string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleExecutable</key>
- <string>declarative-camera</string>
- <key>CFBundleIdentifier</key>
- <string>com.qt-company.${PRODUCT_NAME:rfc1034identifier}</string>
- <key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
- <key>LSRequiresIPhoneOS</key>
- <true/>
- <key>UILaunchStoryboardName</key>
- <string>LaunchScreen</string>
- <key>UISupportedInterfaceOrientations</key>
- <array>
- <string>UIInterfaceOrientationPortrait</string>
- <string>UIInterfaceOrientationPortraitUpsideDown</string>
- <string>UIInterfaceOrientationLandscapeLeft</string>
- <string>UIInterfaceOrientationLandscapeRight</string>
- </array>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
- <key>NSCameraUsageDescription</key>
- <string>Qt Multimedia Example</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Created by Qt/QMake</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleExecutable</key>
+ <string>declarative-camera</string>
+ <key>CFBundleIdentifier</key>
+ <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
+ <key>CFBundleDisplayName</key>
+ <string>declarative-camera</string>
+ <key>CFBundleName</key>
+ <string>declarative-camera</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UILaunchStoryboardName</key>
+ <string>LaunchScreen</string>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>NSCameraUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NOTE</key>
+ <string>This file was generated by Qt/QMake.</string>
</dict>
</plist>
diff --git a/examples/multimedia/declarative-camera/Info.plist.in b/examples/multimedia/declarative-camera/Info.plist.in
new file mode 100644
index 000000000..46a9ecf2d
--- /dev/null
+++ b/examples/multimedia/declarative-camera/Info.plist.in
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSCameraUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/declarative-camera/PhotoCaptureControls.qml b/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
index 2845d151a..f4ecee37b 100644
--- a/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
+++ b/examples/multimedia/declarative-camera/PhotoCaptureControls.qml
@@ -1,174 +1,229 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.4
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+import QtQuick.Layouts
FocusScope {
- property Camera camera
+ id : captureControls
+ property CaptureSession captureSession
property bool previewAvailable : false
- property int buttonsPanelWidth: buttonPaneShadow.width
+ property int buttonsmargin: 8
+ property int buttonsPanelWidth
+ property int buttonsPanelPortraitHeight
+ property int buttonsWidth
signal previewSelected
signal videoModeSelected
- id : captureControls
Rectangle {
id: buttonPaneShadow
- width: bottomColumn.width + 16
- height: parent.height
- anchors.top: parent.top
- anchors.right: parent.right
color: Qt.rgba(0.08, 0.08, 0.08, 1)
- Column {
- anchors {
- right: parent.right
- top: parent.top
- margins: 8
- }
-
+ GridLayout {
id: buttonsColumn
- spacing: 8
-
- FocusButton {
- camera: captureControls.camera
- visible: camera.cameraStatus == Camera.ActiveStatus && camera.focus.isFocusModeSupported(Camera.FocusAuto)
- }
-
+ anchors.margins: captureControls.buttonsmargin
+ flow: captureControls.state === "MobilePortrait"
+ ? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraButton {
text: "Capture"
- visible: camera.imageCapture.ready
- onClicked: camera.imageCapture.capture()
+ implicitWidth: captureControls.buttonsWidth
+ visible: captureControls.captureSession.imageCapture.readyForCapture
+ onClicked: captureControls.captureSession.imageCapture.captureToFile("")
}
CameraPropertyButton {
id : wbModesButton
- value: CameraImageProcessing.WhiteBalanceAuto
+ implicitWidth: captureControls.buttonsWidth
+ state: captureControls.state
+ value: Camera.WhiteBalanceAuto
model: ListModel {
ListElement {
icon: "images/camera_auto_mode.png"
- value: CameraImageProcessing.WhiteBalanceAuto
+ value: Camera.WhiteBalanceAuto
text: "Auto"
}
ListElement {
icon: "images/camera_white_balance_sunny.png"
- value: CameraImageProcessing.WhiteBalanceSunlight
+ value: Camera.WhiteBalanceSunlight
text: "Sunlight"
}
ListElement {
icon: "images/camera_white_balance_cloudy.png"
- value: CameraImageProcessing.WhiteBalanceCloudy
+ value: Camera.WhiteBalanceCloudy
text: "Cloudy"
}
ListElement {
icon: "images/camera_white_balance_incandescent.png"
- value: CameraImageProcessing.WhiteBalanceTungsten
+ value: Camera.WhiteBalanceTungsten
text: "Tungsten"
}
ListElement {
icon: "images/camera_white_balance_flourescent.png"
- value: CameraImageProcessing.WhiteBalanceFluorescent
+ value: Camera.WhiteBalanceFluorescent
text: "Fluorescent"
}
}
- onValueChanged: captureControls.camera.imageProcessing.whiteBalanceMode = wbModesButton.value
+ onValueChanged: captureControls.captureSession.camera.whiteBalanceMode = wbModesButton.value
}
- CameraButton {
- text: "View"
- onClicked: captureControls.previewSelected()
- visible: captureControls.previewAvailable
+ Item {
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
+ CameraButton {
+ text: "View"
+ anchors.fill: parent
+ onClicked: captureControls.previewSelected()
+ visible: captureControls.previewAvailable
+ }
}
}
- Column {
- anchors {
- bottom: parent.bottom
- right: parent.right
- margins: 8
- }
-
+ GridLayout {
id: bottomColumn
- spacing: 8
+ anchors.margins: captureControls.buttonsmargin
+ flow: captureControls.state === "MobilePortrait"
+ ? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraListButton {
- model: QtMultimedia.availableCameras
- onValueChanged: captureControls.camera.deviceId = value
+ implicitWidth: captureControls.buttonsWidth
+ state: captureControls.state
+ onValueChanged: captureControls.captureSession.camera.cameraDevice = value
}
CameraButton {
text: "Switch to Video"
+ implicitWidth: captureControls.buttonsWidth
onClicked: captureControls.videoModeSelected()
}
CameraButton {
id: quitButton
+ implicitWidth: captureControls.buttonsWidth
text: "Quit"
onClicked: Qt.quit()
}
}
-
-
}
-
ZoomControl {
+ id: zoomControl
x : 0
- y : 0
+ y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height/2 : 0
width : 100
- height: parent.height
+ height: parent.height - (flashControl.visible * flashControl.height)
+
+ currentZoom: captureControls.captureSession.camera.zoomFactor
+ maximumZoom: captureControls.captureSession.camera.maximumZoomFactor
+ onZoomTo: (target) => captureControls.captureSession.camera.zoomFactor = target
+ }
+
+ FlashControl {
+ id: flashControl
+ x : 10
+ y : captureControls.state === "MobilePortrait" ?
+ parent.height - (buttonPaneShadow.height + height) : parent.height - height
- currentZoom: camera.digitalZoom
- maximumZoom: Math.min(4.0, camera.maximumDigitalZoom)
- onZoomTo: camera.setDigitalZoom(value)
+ cameraDevice: captureControls.captureSession.camera
}
+
+ states: [
+ State {
+ name: "MobilePortrait"
+ PropertyChanges {
+ buttonPaneShadow.width: parent.width
+ buttonPaneShadow.height: captureControls.buttonsPanelPortraitHeight
+ buttonsColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ bottomColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ }
+ AnchorChanges {
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.bottom: captureControls.bottom
+ anchors.left: captureControls.left
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ anchors.top: buttonPaneShadow.top
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "MobileLandscape"
+ PropertyChanges {
+ buttonPaneShadow.width: buttonsPanelWidth
+ buttonPaneShadow.height: parent.height
+ buttonsColumn.height: parent.height
+ buttonsColumn.width: buttonPaneShadow.width / 2
+ bottomColumn.height: parent.height
+ bottomColumn.width: buttonPaneShadow.width / 2
+ }
+ AnchorChanges {
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "Other"
+ PropertyChanges {
+ buttonPaneShadow.width: bottomColumn.width + 16
+ buttonPaneShadow.height: parent.height
+ }
+ AnchorChanges {
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ }
+ ]
}
diff --git a/examples/multimedia/declarative-camera/PhotoPreview.qml b/examples/multimedia/declarative-camera/PhotoPreview.qml
index e5f47844b..98af8a12a 100644
--- a/examples/multimedia/declarative-camera/PhotoPreview.qml
+++ b/examples/multimedia/declarative-camera/PhotoPreview.qml
@@ -1,55 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtMultimedia 5.0
+import QtQuick
Item {
property alias source : preview.source
diff --git a/examples/multimedia/declarative-camera/Popup.qml b/examples/multimedia/declarative-camera/Popup.qml
index bbf94f465..fc57f3002 100644
--- a/examples/multimedia/declarative-camera/Popup.qml
+++ b/examples/multimedia/declarative-camera/Popup.qml
@@ -1,54 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Rectangle {
id: popup
@@ -64,12 +17,12 @@ Rectangle {
states: [
State {
name: "invisible"
- PropertyChanges { target: popup; opacity: 0 }
+ PropertyChanges { popup.opacity: 0 }
},
State {
name: "visible"
- PropertyChanges { target: popup; opacity: 1.0 }
+ PropertyChanges { popup.opacity: 1.0 }
}
]
diff --git a/examples/multimedia/declarative-camera/VideoCaptureControls.qml b/examples/multimedia/declarative-camera/VideoCaptureControls.qml
index 9aadcdf95..39acae106 100644
--- a/examples/multimedia/declarative-camera/VideoCaptureControls.qml
+++ b/examples/multimedia/declarative-camera/VideoCaptureControls.qml
@@ -1,147 +1,211 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.4
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+import QtQuick.Layouts
FocusScope {
- property Camera camera
+ id : captureControls
+ property CaptureSession captureSession
property bool previewAvailable : false
- property int buttonsPanelWidth: buttonPaneShadow.width
+ property int buttonsmargin: 8
+ property int buttonsPanelWidth
+ property int buttonsPanelPortraitHeight
+ property int buttonsWidth
signal previewSelected
signal photoModeSelected
- id : captureControls
Rectangle {
id: buttonPaneShadow
- width: bottomColumn.width + 16
- height: parent.height
- anchors.top: parent.top
- anchors.right: parent.right
color: Qt.rgba(0.08, 0.08, 0.08, 1)
- Column {
- anchors {
- right: parent.right
- top: parent.top
- margins: 8
- }
-
+ GridLayout {
id: buttonsColumn
- spacing: 8
-
- FocusButton {
- camera: captureControls.camera
- visible: camera.cameraStatus == Camera.ActiveStatus && camera.focus.isFocusModeSupported(Camera.FocusAuto)
- }
-
- CameraButton {
- text: "Record"
- visible: camera.videoRecorder.recorderStatus == CameraRecorder.LoadedStatus
- onClicked: camera.videoRecorder.record()
+ anchors.margins: captureControls.buttonsmargin
+ flow: captureControls.state === "MobilePortrait"
+ ? GridLayout.LeftToRight : GridLayout.TopToBottom
+ Item {
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
+ CameraButton {
+ text: "Record"
+ anchors.fill: parent
+ visible: captureControls.captureSession.recorder.recorderState !== MediaRecorder.RecordingState
+ onClicked: captureControls.captureSession.recorder.record()
+ }
}
- CameraButton {
- id: stopButton
- text: "Stop"
- visible: camera.videoRecorder.recorderStatus == CameraRecorder.RecordingStatus
- onClicked: camera.videoRecorder.stop()
+ Item {
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
+ CameraButton {
+ id: stopButton
+ text: "Stop"
+ anchors.fill: parent
+ visible: captureControls.captureSession.recorder.recorderState === MediaRecorder.RecordingState
+ onClicked: captureControls.captureSession.recorder.stop()
+ }
}
- CameraButton {
- text: "View"
- onClicked: captureControls.previewSelected()
- //don't show View button during recording
- visible: camera.videoRecorder.actualLocation && !stopButton.visible
+ Item {
+ implicitWidth: captureControls.buttonsWidth
+ implicitHeight: 70
+ CameraButton {
+ text: "View"
+ anchors.fill: parent
+ onClicked: captureControls.previewSelected()
+ //don't show View button during recording
+ visible: captureControls.captureSession.recorder.actualLocation.toString() !== ""
+ && !stopButton.visible
+ }
}
}
- Column {
- anchors {
- bottom: parent.bottom
- right: parent.right
- margins: 8
- }
-
+ GridLayout {
id: bottomColumn
- spacing: 8
+ anchors.margins: captureControls.buttonsmargin
+ flow: captureControls.state === "MobilePortrait"
+ ? GridLayout.LeftToRight : GridLayout.TopToBottom
CameraListButton {
- model: QtMultimedia.availableCameras
- onValueChanged: captureControls.camera.deviceId = value
+ implicitWidth: captureControls.buttonsWidth
+ onValueChanged: captureControls.captureSession.camera.cameraDevice = value
+ state: captureControls.state
}
CameraButton {
text: "Switch to Photo"
+ implicitWidth: captureControls.buttonsWidth
onClicked: captureControls.photoModeSelected()
}
CameraButton {
id: quitButton
text: "Quit"
+ implicitWidth: captureControls.buttonsWidth
onClicked: Qt.quit()
}
}
}
-
ZoomControl {
x : 0
- y : 0
+ y : captureControls.state === "MobilePortrait" ? -buttonPaneShadow.height/2 : 0
width : 100
- height: parent.height
+ height: parent.height - (flashControl.visible * flashControl.height)
- currentZoom: camera.digitalZoom
- maximumZoom: Math.min(4.0, camera.maximumDigitalZoom)
- onZoomTo: camera.setDigitalZoom(value)
+ currentZoom: captureControls.captureSession.camera.zoomFactor
+ maximumZoom: captureControls.captureSession.camera.maximumZoomFactor
+ onZoomTo: (target) => captureControls.captureSession.camera.zoomFactor = target
}
+
+ FlashControl {
+ id: flashControl
+ x : 10
+ y : captureControls.state === "MobilePortrait" ?
+ parent.height - (buttonPaneShadow.height + height) : parent.height - height
+
+ cameraDevice: captureControls.captureSession.camera
+ }
+
+ states: [
+ State {
+ name: "MobilePortrait"
+ PropertyChanges {
+ buttonPaneShadow.width: parent.width
+ buttonPaneShadow.height: buttonsPanelPortraitHeight
+ buttonsColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ bottomColumn.height: captureControls.buttonsPanelPortraitHeight / 2 - buttonsmargin
+ }
+ AnchorChanges {
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.bottom: captureControls.bottom
+ anchors.left: captureControls.left
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ anchors.top: buttonPaneShadow.top
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "MobileLandscape"
+ PropertyChanges {
+ buttonPaneShadow.width: buttonsPanelWidth
+ buttonPaneShadow.height: parent.height
+ buttonsColumn.height: parent.height
+ buttonsColumn.width: buttonPaneShadow.width / 2
+ bottomColumn.height: parent.height
+ bottomColumn.width: buttonPaneShadow.width / 2
+ }
+ AnchorChanges {
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.left: buttonPaneShadow.left
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ },
+ State {
+ name: "Other"
+ PropertyChanges {
+ buttonPaneShadow.width: bottomColumn.width + 16
+ buttonPaneShadow.height: parent.height
+ }
+ AnchorChanges {
+ target: buttonPaneShadow
+ // qmllint disable incompatible-type
+ anchors.top: captureControls.top
+ anchors.right: captureControls.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: buttonsColumn
+ // qmllint disable incompatible-type
+ anchors.top: buttonPaneShadow.top
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ AnchorChanges {
+ target: bottomColumn
+ // qmllint disable incompatible-type
+ anchors.bottom: buttonPaneShadow.bottom
+ anchors.right: buttonPaneShadow.right
+ // qmllint enable incompatible-type
+ }
+ }
+ ]
}
diff --git a/examples/multimedia/declarative-camera/VideoPreview.qml b/examples/multimedia/declarative-camera/VideoPreview.qml
index 218804426..f7b306794 100644
--- a/examples/multimedia/declarative-camera/VideoPreview.qml
+++ b/examples/multimedia/declarative-camera/VideoPreview.qml
@@ -1,55 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtMultimedia 5.0
+import QtQuick
+import QtMultimedia
Item {
id: videoPreview
@@ -58,17 +11,24 @@ Item {
MediaPlayer {
id: player
- autoPlay: true
//switch back to viewfinder after playback finished
- onStatusChanged: {
- if (status == MediaPlayer.EndOfMedia)
+ onMediaStatusChanged: {
+ if (mediaStatus == MediaPlayer.EndOfMedia)
videoPreview.closed();
}
+ onSourceChanged: {
+ if (videoPreview.visible && source !== "")
+ play();
+ }
+
+ videoOutput: output
+ audioOutput: AudioOutput {
+ }
}
VideoOutput {
- source: player
+ id: output
anchors.fill : parent
}
diff --git a/examples/multimedia/declarative-camera/ZoomControl.qml b/examples/multimedia/declarative-camera/ZoomControl.qml
index 659205e93..c60495fd0 100644
--- a/examples/multimedia/declarative-camera/ZoomControl.qml
+++ b/examples/multimedia/declarative-camera/ZoomControl.qml
@@ -1,61 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import QtMultimedia 5.0
+import QtQuick
Item {
id : zoomControl
property real currentZoom : 1
property real maximumZoom : 1
- signal zoomTo(real value)
+ signal zoomTo(real target)
visible: zoomControl.maximumZoom > 1
diff --git a/examples/multimedia/declarative-camera/declarative-camera.pro b/examples/multimedia/declarative-camera/declarative-camera.pro
index 2d6e2e759..621342b39 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.pro
+++ b/examples/multimedia/declarative-camera/declarative-camera.pro
@@ -9,3 +9,4 @@ RESOURCES += declarative-camera.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/declarative-camera
INSTALLS += target
include(../shared/shared.pri)
+
diff --git a/examples/multimedia/declarative-camera/declarative-camera.qml b/examples/multimedia/declarative-camera/declarative-camera.qml
index 87dee35f3..24477150e 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.qml
+++ b/examples/multimedia/declarative-camera/declarative-camera.qml
@@ -1,55 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.4
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
Rectangle {
id : cameraUI
@@ -60,12 +13,15 @@ Rectangle {
color: "black"
state: "PhotoCapture"
+ property string platformScreen: ""
+ property int buttonsPanelLandscapeWidth: cameraUI.width/2
+ property int buttonsPanelPortraitHeight: cameraUI.height/3
+
states: [
State {
name: "PhotoCapture"
StateChangeScript {
script: {
- camera.captureMode = Camera.CaptureStillImage
camera.start()
}
}
@@ -77,7 +33,6 @@ Rectangle {
name: "VideoCapture"
StateChangeScript {
script: {
- camera.captureMode = Camera.CaptureVideo
camera.start()
}
}
@@ -92,70 +47,100 @@ Rectangle {
}
]
- Camera {
- id: camera
- captureMode: Camera.CaptureStillImage
-
- imageCapture {
- onImageCaptured: {
- photoPreview.source = preview
- stillControls.previewAvailable = true
- cameraUI.state = "PhotoPreview"
- }
+ CaptureSession {
+ id: captureSession
+ camera: Camera {
+ id: camera
+ }
+ imageCapture: ImageCapture {
+ id: imageCapture
}
- videoRecorder {
- resolution: "640x480"
- frameRate: 30
+ recorder: MediaRecorder {
+ id: recorder
+// resolution: "640x480"
+// frameRate: 30
}
+ videoOutput: viewfinder
}
PhotoPreview {
id : photoPreview
anchors.fill : parent
onClosed: cameraUI.state = "PhotoCapture"
- visible: cameraUI.state == "PhotoPreview"
+ visible: (cameraUI.state === "PhotoPreview")
focus: visible
+ source: imageCapture.preview
}
VideoPreview {
id : videoPreview
anchors.fill : parent
onClosed: cameraUI.state = "VideoCapture"
- visible: cameraUI.state == "VideoPreview"
+ visible: (cameraUI.state === "VideoPreview")
focus: visible
//don't load recorded video if preview is invisible
- source: visible ? camera.videoRecorder.actualLocation : ""
+ source: visible ? recorder.actualLocation : ""
}
VideoOutput {
id: viewfinder
- visible: cameraUI.state == "PhotoCapture" || cameraUI.state == "VideoCapture"
+ visible: ((cameraUI.state === "PhotoCapture") || (cameraUI.state === "VideoCapture"))
+ anchors.fill: parent
+ // autoOrientation: true
+ }
- x: 0
- y: 0
- width: parent.width - stillControls.buttonsPanelWidth
- height: parent.height
+ Item {
+ id: controlLayout
+
+ readonly property bool isMobile: Qt.platform.os === "android" || Qt.platform.os === "ios"
+ readonly property bool isLandscape: Screen.desktopAvailableWidth >= Screen.desktopAvailableHeight
+ property int buttonsWidth: state === "MobilePortrait" ? Screen.desktopAvailableWidth / 3.4 : 114
+
+ states: [
+ State {
+ name: "MobileLandscape"
+ when: controlLayout.isMobile && controlLayout.isLandscape
+ },
+ State {
+ name: "MobilePortrait"
+ when: controlLayout.isMobile && !controlLayout.isLandscape
+ },
+ State {
+ name: "Other"
+ when: !controlLayout.isMobile
+ }
+ ]
- source: camera
- autoOrientation: true
+ onStateChanged: {
+ console.log("State: " + controlLayout.state)
+ }
}
PhotoCaptureControls {
id: stillControls
+ state: controlLayout.state
anchors.fill: parent
- camera: camera
- visible: cameraUI.state == "PhotoCapture"
+ buttonsWidth: controlLayout.buttonsWidth
+ buttonsPanelPortraitHeight: cameraUI.buttonsPanelPortraitHeight
+ buttonsPanelWidth: cameraUI.buttonsPanelLandscapeWidth
+ captureSession: captureSession
+ visible: (cameraUI.state === "PhotoCapture")
onPreviewSelected: cameraUI.state = "PhotoPreview"
onVideoModeSelected: cameraUI.state = "VideoCapture"
+ previewAvailable: imageCapture.preview.length !== 0
}
VideoCaptureControls {
id: videoControls
+ state: controlLayout.state
anchors.fill: parent
- camera: camera
- visible: cameraUI.state == "VideoCapture"
+ buttonsWidth: controlLayout.buttonsWidth
+ buttonsPanelPortraitHeight: cameraUI.buttonsPanelPortraitHeight
+ buttonsPanelWidth: cameraUI.buttonsPanelLandscapeWidth
+ captureSession: captureSession
+ visible: (cameraUI.state === "VideoCapture")
onPreviewSelected: cameraUI.state = "VideoPreview"
onPhotoModeSelected: cameraUI.state = "PhotoCapture"
}
diff --git a/examples/multimedia/declarative-camera/declarative-camera.qrc b/examples/multimedia/declarative-camera/declarative-camera.qrc
index 6d654d59f..ddfcefa7b 100644
--- a/examples/multimedia/declarative-camera/declarative-camera.qrc
+++ b/examples/multimedia/declarative-camera/declarative-camera.qrc
@@ -4,7 +4,6 @@
<file>ZoomControl.qml</file>
<file>VideoCaptureControls.qml</file>
<file>VideoPreview.qml</file>
- <file>FocusButton.qml</file>
<file>PhotoCaptureControls.qml</file>
<file>declarative-camera.qml</file>
<file>Popup.qml</file>
@@ -13,6 +12,7 @@
<file>CameraButton.qml</file>
<file>CameraListPopup.qml</file>
<file>CameraListButton.qml</file>
+ <file>FlashControl.qml</file>
<file>images/camera_auto_mode.png</file>
<file>images/camera_camera_setting.png</file>
<file>images/camera_flash_auto.png</file>
diff --git a/examples/multimedia/declarative-camera/doc/images/CaptureControls.png b/examples/multimedia/declarative-camera/doc/images/CaptureControls.png
new file mode 100644
index 000000000..8c24d8030
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/CaptureControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/FlashControls.png b/examples/multimedia/declarative-camera/doc/images/FlashControls.png
new file mode 100644
index 000000000..93eec867b
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/FlashControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png b/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png
new file mode 100644
index 000000000..c35be7beb
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/VideoCaptureControls.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/ZoomControl.png b/examples/multimedia/declarative-camera/doc/images/ZoomControl.png
new file mode 100644
index 000000000..d628e60f1
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/ZoomControl.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/qml-camera.png b/examples/multimedia/declarative-camera/doc/images/qml-camera.png
index 0cd61f0a0..4b710670d 100644
--- a/examples/multimedia/declarative-camera/doc/images/qml-camera.png
+++ b/examples/multimedia/declarative-camera/doc/images/qml-camera.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png b/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png
new file mode 100644
index 000000000..7adfdb021
--- /dev/null
+++ b/examples/multimedia/declarative-camera/doc/images/qml-declarative-portrait.png
Binary files differ
diff --git a/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc b/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
index 2818c22b0..c6701a68b 100644
--- a/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
+++ b/examples/multimedia/declarative-camera/doc/src/declarative-camera.qdoc
@@ -1,56 +1,158 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\example multimedia/declarative-camera
-\title QML Camera Example
+\example declarative-camera
+\title QML Camera Application
\ingroup multimedia_examples
\ingroup camera_examples_qml
-\brief The Camera Example shows how to use the API to capture a still image
-or video.
+\examplecategory {Multimedia}
+\examplecategory {Mobile}
+\brief This Qt Quick based application shows how to use the API to capture a
+still image or video.
\image qml-camera.png
-This example demonstrates how to use the
-\l{Qt Multimedia QML Types}{Qt Multimedia QML API} to access camera functions.
-It shows how to change settings and to capture images.
+This example demonstrates how to access camera functions via QML.
+It shows how to change settings and capture images or video.
\include examples-run.qdocinc
-\section1 Application Structure
+\section1 Application structure
-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}.
+Most of the QML code in this example supports the user interface. Custom types
+that support the requirements have been implemented using existing Qt Quick
+controls.
-CaptureControls, which is implemented in \e {CaptureControls.qml},
-generates a column on the right hand side of the screen which includes control
-buttons for focus (not initially visible), capture, flash modes,
-white balance, exposure compensation, and if a preview is
-available, a preview button. The last button exits from the application.
+\section1 Using screen orientation to select layout
+The orientation and control layout state logic is encapsulated in a separate
+Item, \c controlLayout like so:
+
+\quotefromfile declarative-camera/declarative-camera.qml
+\skipto Item {
+\printuntil /^ }/
+
+The \c stillControls and \c videoControls objects both bind to the \c state
+and \c buttonsWidth properties of this Item, as shown in \c stillControls:
+
+\skipto PhotoCaptureControls
+\printuntil /^ }/
+
+To support debugging, a message about layout state change is logged.
+
+Here is the portrait layout:
+
+\image qml-declarative-portrait.png
+
+You can see the \c state property is initially set as \c PhotoCapture.
+
+Then the \c states themselves are defined like so:
+
+\quotefromfile declarative-camera/declarative-camera.qml
+\skipto states: [
+\printuntil /^ ]/
+
+\section1 Controls for capturing
+
+Controls for capturing are implemented in \c PhotoCaptureControls.qml and
+VideoCaptureControls.qml. They each are based on a \l FocusScope that defines
+common buttons dimensions and margins that are used by the control buttons and
+then declares the buttons.
+
+This generates a column on the right hand side of the screen which includes,
+listed top to bottom, the following controls:
+\div {class="multi-column"}
+ \div {class="doc-column"}
+ \list
+ \li A \c Capture or \c Record button, which initiates capturing.
+ \li A \c{capture properties} button that displays the icon of the current
+ white balance mode selected and when pressed uses a pop-up to displays
+ the following option's icons:
+ \list
+ \li Flash mode (if available)
+ \li White balance modes
+ \li Exposure compensation
+ \endlist
+ \li A \c View button, once something has been captured.
+ \li A button which displays the currently selected capture device and
+ when pressed provides a list of available devices to switch to, using a
+ pop-up.
+ \li A \c{Switch To} button that displays the alternate capture mode
+ (video or photo) depending on the current active selection and switches
+ the mode when pressed.
+ \li A \c Quit button, that exits the application.
+ \endlist
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage CaptureControls.png
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage VideoCaptureControls.png
+ \enddiv
+\enddiv
+
+\section1 Image capturing
+
+The button that triggers this is defined in CameraButton.qml:
+but its interaction with the camera is in the controls types, lets look at
+PhotoCaptureControls:
+
+\quotefromfile declarative-camera/PhotoCaptureControls.qml
+\skipto CameraButton {
+\printto CameraPropertyButton {
+
+\section1 Zoom control
+
+\div {class="multi-column"}
+ \div {class="doc-column"}
+ Implemented in \c ZoomControl.qml the ZoomControl type is based on an Item
+ and creates a bar that represents the zoom level, which can also be dragged.
+ It uses an exponential calculation method to determine the zoom factor given
+ the position of the \c grove.
+
+ The bar is only visible if the initialZoom is greater than 1. This means
+ the currently active camera has a zoom function.
+ \enddiv
+ \div {class="doc-column"}
+ \inlineimage ZoomControl.png
+ \enddiv
+\enddiv
+
+\quotefromfile declarative-camera/ZoomControl.qml
+\skipto Item {
+\printuntil font.pixelSize: 18
+
+In PhotoCaptureControls.qml and VideoCaptureControls.qml the signal \c zoomTo
+will set the selected camera's \l{Camera::}{zoomFactor} property to the
+calculated \c target value, as well as updating the ZoomControl bar.
+
+\quotefromfile declarative-camera/VideoCaptureControls.qml
+\skipto ZoomControl {
+\printto FlashControl {
+
+\section1 Flash and torch control
+
+\image FlashControls.png
+
+Defined in \c FlashControl.qml this enables flash mode selection and torch
+functionality to be toggled via a Switch. As with the zoom control, the switches
+are only visible on top of the preview window if the active device supports
+these functions.
+
+Here we check if the functions are supported:
+
+\quotefromfile declarative-camera/FlashControl.qml
+\skipto property Camera cameraDevice
+\printline Camera
+\printline FlashOn
+\printline TorchOn
+
+Here we implement the \c flashModeControl switch, which also directly controls
+the Camera device.
+
+\skipto Switch {
+\printuntil /^ }/
+
+Torch control is implemented in a similar way.
*/
diff --git a/examples/multimedia/declarative-camera/permission-denied.qml b/examples/multimedia/declarative-camera/permission-denied.qml
new file mode 100644
index 000000000..19eb58ead
--- /dev/null
+++ b/examples/multimedia/declarative-camera/permission-denied.qml
@@ -0,0 +1,20 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+
+Rectangle {
+ color: "black"
+ width: 800
+ height: 600
+
+ Text {
+ anchors.fill: parent
+ text: qsTr("Grant the camera permission and restart the app")
+ color: "white"
+ font.pointSize: 20
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+}
diff --git a/examples/multimedia/declarative-camera/qmlcamera.cpp b/examples/multimedia/declarative-camera/qmlcamera.cpp
index edffe6bb0..9844fd53b 100644
--- a/examples/multimedia/declarative-camera/qmlcamera.cpp
+++ b/examples/multimedia/declarative-camera/qmlcamera.cpp
@@ -1,68 +1,39 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
-#include <QQuickView>
#include <QQmlEngine>
+#include <QQuickView>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- QGuiApplication app(argc,argv);
+ QGuiApplication app(argc, argv);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
- // Qt.quit() called in embedded .qml by default only emits
- // quit() signal, so do this (optionally use Qt.exit()).
- QObject::connect(view.engine(), &QQmlEngine::quit,
- qApp, &QGuiApplication::quit);
- view.setSource(QUrl("qrc:///declarative-camera.qml"));
- view.resize(800, 480);
- view.show();
+
+ auto setupView = [&view](const QUrl &viewSource) {
+ // Qt.quit() called in embedded .qml by default only emits
+ // quit() signal, so do this (optionally use Qt.exit()).
+ QObject::connect(view.engine(), &QQmlEngine::quit, qApp, &QGuiApplication::quit);
+ view.setSource(viewSource);
+ view.show();
+ };
+
+#if QT_CONFIG(permissions)
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&setupView](const QPermission &permission) {
+ if (permission.status() == Qt::PermissionStatus::Denied)
+ setupView(QUrl("qrc:///permission-denied.qml"));
+ else
+ setupView(QUrl("qrc:///declarative-camera.qml"));
+ });
+#else
+ setupView();
+#endif
+
return app.exec();
}
diff --git a/examples/multimedia/multimedia.pro b/examples/multimedia/multimedia.pro
index a221d4bb5..765aa69a7 100644
--- a/examples/multimedia/multimedia.pro
+++ b/examples/multimedia/multimedia.pro
@@ -1,16 +1,18 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += multimedia-private
-SUBDIRS += audiodecoder
-
# These examples all need widgets for now (using creator templates that use widgets)
qtHaveModule(widgets) {
SUBDIRS += \
- spectrum \
- audiorecorder \
audiodevices \
- audioinput \
audiooutput \
+ audiorecorder \
+ camera \
+ player \
+ spectrum \
+ videographicsitem \
+ videowidget \
+ screencapture
}
qtHaveModule(quick) {
@@ -18,4 +20,3 @@ qtHaveModule(quick) {
declarative-camera \
video
}
-
diff --git a/examples/multimedia/player/CMakeLists.txt b/examples/multimedia/player/CMakeLists.txt
new file mode 100644
index 000000000..93a0037a7
--- /dev/null
+++ b/examples/multimedia/player/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(player LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/player")
+
+find_package(Qt6 REQUIRED COMPONENTS MultimediaWidgets Network)
+
+qt_add_executable(player
+ main.cpp
+ player.cpp player.h
+ playercontrols.cpp playercontrols.h
+ playlistmodel.cpp playlistmodel.h
+ videowidget.cpp videowidget.h
+ qmediaplaylist.cpp qmediaplaylist.h
+ qmediaplaylist_p.cpp qmediaplaylist_p.h
+ qplaylistfileparser.cpp qplaylistfileparser.h
+)
+
+set_target_properties(player PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(player PUBLIC
+ Qt::MultimediaWidgets
+ Qt::Network
+)
+
+install(TARGETS player
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg b/examples/multimedia/player/doc/images/mediaplayerex.jpg
index e875bd134..e875bd134 100644
--- a/examples/multimediawidgets/player/doc/images/mediaplayerex.jpg
+++ b/examples/multimedia/player/doc/images/mediaplayerex.jpg
Binary files differ
diff --git a/examples/multimedia/player/doc/src/player.qdoc b/examples/multimedia/player/doc/src/player.qdoc
new file mode 100644
index 000000000..4c4b26969
--- /dev/null
+++ b/examples/multimedia/player/doc/src/player.qdoc
@@ -0,0 +1,49 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example player
+ \title Media Player Example
+ \ingroup multimedia_examples
+ \ingroup video_examples
+ \examplecategory {Multimedia}
+ \brief Playing audio and video.
+ \meta {tag} {widgets}
+
+ \image mediaplayerex.jpg
+
+ \e{Media Player} demonstrates a simple multimedia player that can play
+ audio and or video files using various codecs.
+
+ \include examples-run.qdocinc
+
+ 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,
+ the button clicked events emit the play() and stop() signals, which
+ are connected to the play() and stop() slots of 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 video properties by means
+ of the QVideoWidget object. We can go to Full Screen mode with a single
+ button click, and back again.
+*/
diff --git a/examples/multimedia/player/main.cpp b/examples/multimedia/player/main.cpp
new file mode 100644
index 000000000..3f9993570
--- /dev/null
+++ b/examples/multimedia/player/main.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "player.h"
+
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QDir>
+#include <QUrl>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("Player Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt MultiMedia Player Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL(s) to open.");
+ parser.process(app);
+
+ Player player;
+
+ if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
+ QList<QUrl> urls;
+ for (auto &a : parser.positionalArguments())
+ urls.append(QUrl::fromUserInput(a, QDir::currentPath()));
+ player.addToPlaylist(urls);
+ }
+
+ player.show();
+ return app.exec();
+}
diff --git a/examples/multimedia/player/player.cpp b/examples/multimedia/player/player.cpp
new file mode 100644
index 000000000..3db9aebb9
--- /dev/null
+++ b/examples/multimedia/player/player.cpp
@@ -0,0 +1,554 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "player.h"
+#include "playercontrols.h"
+#include "playlistmodel.h"
+#include "qmediaplaylist.h"
+#include "videowidget.h"
+
+#include <QApplication>
+#include <QAudioDevice>
+#include <QAudioOutput>
+#include <QBoxLayout>
+#include <QComboBox>
+#include <QDir>
+#include <QFileDialog>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListView>
+#include <QMediaDevices>
+#include <QMediaFormat>
+#include <QMediaMetaData>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSlider>
+#include <QStandardPaths>
+#include <QStatusBar>
+#include <QVBoxLayout>
+
+Player::Player(QWidget *parent) : QWidget(parent)
+{
+ //! [create-objs]
+ m_player = new QMediaPlayer(this);
+ m_audioOutput = new QAudioOutput(this);
+ m_player->setAudioOutput(m_audioOutput);
+ //! [create-objs]
+ connect(m_player, &QMediaPlayer::durationChanged, this, &Player::durationChanged);
+ connect(m_player, &QMediaPlayer::positionChanged, this, &Player::positionChanged);
+ connect(m_player, QOverload<>::of(&QMediaPlayer::metaDataChanged), this,
+ &Player::metaDataChanged);
+ connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &Player::statusChanged);
+ connect(m_player, &QMediaPlayer::bufferProgressChanged, this, &Player::bufferingProgress);
+ connect(m_player, &QMediaPlayer::hasVideoChanged, this, &Player::videoAvailableChanged);
+ connect(m_player, &QMediaPlayer::errorChanged, this, &Player::displayErrorMessage);
+ connect(m_player, &QMediaPlayer::tracksChanged, this, &Player::tracksChanged);
+
+ //! [2]
+ m_videoWidget = new VideoWidget(this);
+ m_videoWidget->resize(1280, 720);
+ m_player->setVideoOutput(m_videoWidget);
+
+ m_playlistModel = new PlaylistModel(this);
+ m_playlist = m_playlistModel->playlist();
+ //! [2]
+ connect(m_playlist, &QMediaPlaylist::currentIndexChanged, this,
+ &Player::playlistPositionChanged);
+
+ // player layout
+ QBoxLayout *layout = new QVBoxLayout(this);
+
+ // display
+ QBoxLayout *displayLayout = new QHBoxLayout;
+ displayLayout->addWidget(m_videoWidget, 2);
+#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
+ m_playlistView = new QListView();
+ m_playlistView->setModel(m_playlistModel);
+ m_playlistView->setCurrentIndex(m_playlistModel->index(m_playlist->currentIndex(), 0));
+ connect(m_playlistView, &QAbstractItemView::activated, this, &Player::jump);
+ displayLayout->addWidget(m_playlistView);
+#endif
+ layout->addLayout(displayLayout);
+
+ // duration slider and label
+ QHBoxLayout *hLayout = new QHBoxLayout;
+
+ m_slider = new QSlider(Qt::Horizontal, this);
+ m_slider->setRange(0, m_player->duration());
+ connect(m_slider, &QSlider::sliderMoved, this, &Player::seek);
+ hLayout->addWidget(m_slider);
+
+ m_labelDuration = new QLabel();
+ m_labelDuration->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ hLayout->addWidget(m_labelDuration);
+ layout->addLayout(hLayout);
+
+ // controls
+ QBoxLayout *controlLayout = new QHBoxLayout;
+ controlLayout->setContentsMargins(0, 0, 0, 0);
+
+ QPushButton *openButton = new QPushButton(tr("Open"), this);
+ connect(openButton, &QPushButton::clicked, this, &Player::open);
+ controlLayout->addWidget(openButton);
+ controlLayout->addStretch(1);
+
+ PlayerControls *controls = new PlayerControls();
+ controls->setState(m_player->playbackState());
+ controls->setVolume(m_audioOutput->volume());
+ controls->setMuted(controls->isMuted());
+
+ connect(controls, &PlayerControls::play, m_player, &QMediaPlayer::play);
+ connect(controls, &PlayerControls::pause, m_player, &QMediaPlayer::pause);
+ connect(controls, &PlayerControls::stop, m_player, &QMediaPlayer::stop);
+ connect(controls, &PlayerControls::next, m_playlist, &QMediaPlaylist::next);
+ connect(controls, &PlayerControls::previous, this, &Player::previousClicked);
+ connect(controls, &PlayerControls::changeVolume, m_audioOutput, &QAudioOutput::setVolume);
+ connect(controls, &PlayerControls::changeMuting, m_audioOutput, &QAudioOutput::setMuted);
+ connect(controls, &PlayerControls::changeRate, m_player, &QMediaPlayer::setPlaybackRate);
+ connect(controls, &PlayerControls::stop, m_videoWidget, QOverload<>::of(&QVideoWidget::update));
+
+ connect(m_player, &QMediaPlayer::playbackStateChanged, controls, &PlayerControls::setState);
+ connect(m_audioOutput, &QAudioOutput::volumeChanged, controls, &PlayerControls::setVolume);
+ connect(m_audioOutput, &QAudioOutput::mutedChanged, controls, &PlayerControls::setMuted);
+
+ controlLayout->addWidget(controls);
+ controlLayout->addStretch(1);
+
+ m_fullScreenButton = new QPushButton(tr("FullScreen"), this);
+ m_fullScreenButton->setCheckable(true);
+ controlLayout->addWidget(m_fullScreenButton);
+
+#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
+ m_audioOutputCombo = new QComboBox(this);
+ controlLayout->addWidget(m_audioOutputCombo);
+
+ updateAudioDevices();
+
+ connect(m_audioOutputCombo, QOverload<int>::of(&QComboBox::activated), this,
+ &Player::audioOutputChanged);
+
+ QObject::connect(&m_mediaDevices, &QMediaDevices::audioOutputsChanged, this, [this] {
+ updateAudioDevices();
+ });
+#endif
+
+ layout->addLayout(controlLayout);
+
+ // tracks
+ QGridLayout *tracksLayout = new QGridLayout;
+
+ m_audioTracks = new QComboBox(this);
+ connect(m_audioTracks, &QComboBox::activated, this, &Player::selectAudioStream);
+ tracksLayout->addWidget(new QLabel(tr("Audio Tracks:")), 0, 0);
+ tracksLayout->addWidget(m_audioTracks, 0, 1);
+
+ m_videoTracks = new QComboBox(this);
+ connect(m_videoTracks, &QComboBox::activated, this, &Player::selectVideoStream);
+ tracksLayout->addWidget(new QLabel(tr("Video Tracks:")), 1, 0);
+ tracksLayout->addWidget(m_videoTracks, 1, 1);
+
+ m_subtitleTracks = new QComboBox(this);
+ connect(m_subtitleTracks, &QComboBox::activated, this, &Player::selectSubtitleStream);
+ tracksLayout->addWidget(new QLabel(tr("Subtitle Tracks:")), 2, 0);
+ tracksLayout->addWidget(m_subtitleTracks, 2, 1);
+
+ layout->addLayout(tracksLayout);
+
+#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
+ // metadata
+
+ QLabel *metaDataLabel = new QLabel(tr("Metadata for file:"));
+ layout->addWidget(metaDataLabel);
+
+ QGridLayout *metaDataLayout = new QGridLayout;
+ int key = QMediaMetaData::Title;
+ for (int i = 0; i < (QMediaMetaData::NumMetaData + 2) / 3; i++) {
+ for (int j = 0; j < 6; j += 2) {
+ m_metaDataLabels[key] = new QLabel(
+ QMediaMetaData::metaDataKeyToString(static_cast<QMediaMetaData::Key>(key)));
+ if (key == QMediaMetaData::ThumbnailImage || key == QMediaMetaData::CoverArtImage)
+ m_metaDataFields[key] = new QLabel;
+ else
+ m_metaDataFields[key] = new QLineEdit;
+ m_metaDataLabels[key]->setDisabled(true);
+ m_metaDataFields[key]->setDisabled(true);
+ metaDataLayout->addWidget(m_metaDataLabels[key], i, j);
+ metaDataLayout->addWidget(m_metaDataFields[key], i, j + 1);
+ key++;
+ if (key == QMediaMetaData::NumMetaData)
+ break;
+ }
+ }
+
+ layout->addLayout(metaDataLayout);
+#endif
+
+#if defined(Q_OS_QNX)
+ // On QNX, the main window doesn't have a title bar (or any other decorations).
+ // Create a status bar for the status information instead.
+ m_statusLabel = new QLabel;
+ m_statusBar = new QStatusBar;
+ m_statusBar->addPermanentWidget(m_statusLabel);
+ m_statusBar->setSizeGripEnabled(false); // Without mouse grabbing, it doesn't work very well.
+ layout->addWidget(m_statusBar);
+#endif
+
+ setLayout(layout);
+
+ if (!isPlayerAvailable()) {
+ QMessageBox::warning(this, tr("Service not available"),
+ tr("The QMediaPlayer object does not have a valid service.\n"
+ "Please check the media service plugins are installed."));
+
+ controls->setEnabled(false);
+ if (m_playlistView)
+ m_playlistView->setEnabled(false);
+ openButton->setEnabled(false);
+ m_fullScreenButton->setEnabled(false);
+ }
+
+ metaDataChanged();
+}
+
+bool Player::isPlayerAvailable() const
+{
+ return m_player->isAvailable();
+}
+
+void Player::open()
+{
+ QFileDialog fileDialog(this);
+ fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
+ fileDialog.setWindowTitle(tr("Open Files"));
+ fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation)
+ .value(0, QDir::homePath()));
+ if (fileDialog.exec() == QDialog::Accepted)
+ addToPlaylist(fileDialog.selectedUrls());
+}
+
+static bool isPlaylist(const QUrl &url) // Check for ".m3u" playlists.
+{
+ if (!url.isLocalFile())
+ return false;
+ const QFileInfo fileInfo(url.toLocalFile());
+ return fileInfo.exists()
+ && !fileInfo.suffix().compare(QLatin1String("m3u"), Qt::CaseInsensitive);
+}
+
+void Player::addToPlaylist(const QList<QUrl> &urls)
+{
+ const int previousMediaCount = m_playlist->mediaCount();
+ for (auto &url : urls) {
+ if (isPlaylist(url))
+ m_playlist->load(url);
+ else
+ m_playlist->addMedia(url);
+ }
+ if (m_playlist->mediaCount() > previousMediaCount) {
+ auto index = m_playlistModel->index(previousMediaCount, 0);
+ if (m_playlistView)
+ m_playlistView->setCurrentIndex(index);
+ jump(index);
+ }
+}
+
+void Player::durationChanged(qint64 duration)
+{
+ m_duration = duration / 1000;
+ m_slider->setMaximum(duration);
+}
+
+void Player::positionChanged(qint64 progress)
+{
+ if (!m_slider->isSliderDown())
+ m_slider->setValue(progress);
+
+ updateDurationInfo(progress / 1000);
+}
+
+void Player::metaDataChanged()
+{
+ auto metaData = m_player->metaData();
+ setTrackInfo(QStringLiteral("%1 - %2")
+ .arg(metaData.value(QMediaMetaData::AlbumArtist).toString())
+ .arg(metaData.value(QMediaMetaData::Title).toString()));
+
+#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
+ for (int i = 0; i < QMediaMetaData::NumMetaData; i++) {
+ if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[i]))
+ field->clear();
+ else if (QLabel *label = qobject_cast<QLabel *>(m_metaDataFields[i]))
+ label->clear();
+ m_metaDataFields[i]->setDisabled(true);
+ m_metaDataLabels[i]->setDisabled(true);
+ }
+
+ for (auto &key : metaData.keys()) {
+ int i = int(key);
+ if (key == QMediaMetaData::CoverArtImage) {
+ QVariant v = metaData.value(key);
+ if (QLabel *cover = qobject_cast<QLabel *>(m_metaDataFields[key])) {
+ QImage coverImage = v.value<QImage>();
+ cover->setPixmap(QPixmap::fromImage(coverImage));
+ }
+ } else if (key == QMediaMetaData::ThumbnailImage) {
+ QVariant v = metaData.value(key);
+ if (QLabel *thumbnail = qobject_cast<QLabel *>(m_metaDataFields[key])) {
+ QImage thumbnailImage = v.value<QImage>();
+ thumbnail->setPixmap(QPixmap::fromImage(thumbnailImage));
+ }
+ } else if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[key])) {
+ QString stringValue = metaData.stringValue(key);
+ field->setText(stringValue);
+ }
+ m_metaDataFields[i]->setDisabled(false);
+ m_metaDataLabels[i]->setDisabled(false);
+ }
+
+ const QList<QMediaMetaData> tracks = m_player->videoTracks();
+ const int currentVideoTrack = m_player->activeVideoTrack();
+ if (currentVideoTrack >= 0 && currentVideoTrack < tracks.size()) {
+ const QMediaMetaData track = tracks.value(currentVideoTrack);
+ for (const QMediaMetaData::Key &key : track.keys()) {
+ if (QLineEdit *field = qobject_cast<QLineEdit *>(m_metaDataFields[key])) {
+ QString stringValue = track.stringValue(key);
+ field->setText(stringValue);
+ }
+ m_metaDataFields[key]->setDisabled(true);
+ m_metaDataLabels[key]->setDisabled(true);
+ }
+ }
+#endif
+}
+
+QString Player::trackName(const QMediaMetaData &metaData, int index)
+{
+ QString name;
+ QString title = metaData.stringValue(QMediaMetaData::Title);
+ QLocale::Language lang = metaData.value(QMediaMetaData::Language).value<QLocale::Language>();
+
+ if (title.isEmpty()) {
+ if (lang == QLocale::Language::AnyLanguage)
+ name = tr("Track %1").arg(index + 1);
+ else
+ name = QLocale::languageToString(lang);
+ } else {
+ if (lang == QLocale::Language::AnyLanguage)
+ name = title;
+ else
+ name = QStringLiteral("%1 - [%2]").arg(title).arg(QLocale::languageToString(lang));
+ }
+ return name;
+}
+
+void Player::tracksChanged()
+{
+ m_audioTracks->clear();
+ m_videoTracks->clear();
+ m_subtitleTracks->clear();
+
+ const auto audioTracks = m_player->audioTracks();
+ m_audioTracks->addItem(QStringLiteral("No audio"), -1);
+ for (int i = 0; i < audioTracks.size(); ++i)
+ m_audioTracks->addItem(trackName(audioTracks.at(i), i), i);
+ m_audioTracks->setCurrentIndex(m_player->activeAudioTrack() + 1);
+
+ const auto videoTracks = m_player->videoTracks();
+ m_videoTracks->addItem(QStringLiteral("No video"), -1);
+ for (int i = 0; i < videoTracks.size(); ++i)
+ m_videoTracks->addItem(trackName(videoTracks.at(i), i), i);
+ m_videoTracks->setCurrentIndex(m_player->activeVideoTrack() + 1);
+
+ m_subtitleTracks->addItem(QStringLiteral("No subtitles"), -1);
+ const auto subtitleTracks = m_player->subtitleTracks();
+ for (int i = 0; i < subtitleTracks.size(); ++i)
+ m_subtitleTracks->addItem(trackName(subtitleTracks.at(i), i), i);
+ m_subtitleTracks->setCurrentIndex(m_player->activeSubtitleTrack() + 1);
+}
+
+void Player::previousClicked()
+{
+ // Go to previous track if we are within the first 5 seconds of playback
+ // Otherwise, seek to the beginning.
+ if (m_player->position() <= 5000) {
+ m_playlist->previous();
+ } else {
+ m_player->setPosition(0);
+ }
+}
+
+void Player::jump(const QModelIndex &index)
+{
+ if (index.isValid()) {
+ m_playlist->setCurrentIndex(index.row());
+ }
+}
+
+void Player::playlistPositionChanged(int currentItem)
+{
+ if (m_playlistView)
+ m_playlistView->setCurrentIndex(m_playlistModel->index(currentItem, 0));
+ m_player->setSource(m_playlist->currentMedia());
+}
+
+void Player::seek(int mseconds)
+{
+ m_player->setPosition(mseconds);
+}
+
+void Player::statusChanged(QMediaPlayer::MediaStatus status)
+{
+ handleCursor(status);
+
+ // handle status message
+ switch (status) {
+ case QMediaPlayer::NoMedia:
+ case QMediaPlayer::LoadedMedia:
+ setStatusInfo(QString());
+ break;
+ case QMediaPlayer::LoadingMedia:
+ setStatusInfo(tr("Loading..."));
+ break;
+ case QMediaPlayer::BufferingMedia:
+ case QMediaPlayer::BufferedMedia:
+ setStatusInfo(tr("Buffering %1%").arg(qRound(m_player->bufferProgress() * 100.)));
+ break;
+ case QMediaPlayer::StalledMedia:
+ setStatusInfo(tr("Stalled %1%").arg(qRound(m_player->bufferProgress() * 100.)));
+ break;
+ case QMediaPlayer::EndOfMedia:
+ QApplication::alert(this);
+ m_playlist->next();
+ break;
+ case QMediaPlayer::InvalidMedia:
+ displayErrorMessage();
+ break;
+ }
+}
+
+void Player::handleCursor(QMediaPlayer::MediaStatus status)
+{
+#ifndef QT_NO_CURSOR
+ if (status == QMediaPlayer::LoadingMedia || status == QMediaPlayer::BufferingMedia
+ || status == QMediaPlayer::StalledMedia)
+ setCursor(QCursor(Qt::BusyCursor));
+ else
+ unsetCursor();
+#endif
+}
+
+void Player::bufferingProgress(float progress)
+{
+ if (m_player->mediaStatus() == QMediaPlayer::StalledMedia)
+ setStatusInfo(tr("Stalled %1%").arg(qRound(progress * 100.)));
+ else
+ setStatusInfo(tr("Buffering %1%").arg(qRound(progress * 100.)));
+}
+
+void Player::videoAvailableChanged(bool available)
+{
+ if (!available) {
+ disconnect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget,
+ &QVideoWidget::setFullScreen);
+ disconnect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton,
+ &QPushButton::setChecked);
+ m_videoWidget->setFullScreen(false);
+ } else {
+ connect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget,
+ &QVideoWidget::setFullScreen);
+ connect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton,
+ &QPushButton::setChecked);
+
+ if (m_fullScreenButton->isChecked())
+ m_videoWidget->setFullScreen(true);
+ }
+}
+
+void Player::selectAudioStream()
+{
+ int stream = m_audioTracks->currentData().toInt();
+ m_player->setActiveAudioTrack(stream);
+}
+
+void Player::selectVideoStream()
+{
+ int stream = m_videoTracks->currentData().toInt();
+ m_player->setActiveVideoTrack(stream);
+}
+
+void Player::selectSubtitleStream()
+{
+ int stream = m_subtitleTracks->currentData().toInt();
+ m_player->setActiveSubtitleTrack(stream);
+}
+
+void Player::setTrackInfo(const QString &info)
+{
+ m_trackInfo = info;
+
+ if (m_statusBar) {
+ m_statusBar->showMessage(m_trackInfo);
+ m_statusLabel->setText(m_statusInfo);
+ } else {
+ if (!m_statusInfo.isEmpty())
+ setWindowTitle(QStringLiteral("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
+ else
+ setWindowTitle(m_trackInfo);
+ }
+}
+
+void Player::setStatusInfo(const QString &info)
+{
+ m_statusInfo = info;
+
+ if (m_statusBar) {
+ m_statusBar->showMessage(m_trackInfo);
+ m_statusLabel->setText(m_statusInfo);
+ } else {
+ if (!m_statusInfo.isEmpty())
+ setWindowTitle(QStringLiteral("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
+ else
+ setWindowTitle(m_trackInfo);
+ }
+}
+
+void Player::displayErrorMessage()
+{
+ if (m_player->error() == QMediaPlayer::NoError)
+ return;
+ setStatusInfo(m_player->errorString());
+}
+
+void Player::updateDurationInfo(qint64 currentInfo)
+{
+ QString tStr;
+ if (currentInfo || m_duration) {
+ QTime currentTime((currentInfo / 3600) % 60, (currentInfo / 60) % 60, currentInfo % 60,
+ (currentInfo * 1000) % 1000);
+ QTime totalTime((m_duration / 3600) % 60, (m_duration / 60) % 60, m_duration % 60,
+ (m_duration * 1000) % 1000);
+ QString format = "mm:ss";
+ if (m_duration > 3600)
+ format = "hh:mm:ss";
+ tStr = currentTime.toString(format) + " / " + totalTime.toString(format);
+ }
+ m_labelDuration->setText(tStr);
+}
+
+void Player::updateAudioDevices()
+{
+ m_audioOutputCombo->clear();
+
+ m_audioOutputCombo->addItem(QStringLiteral("Default"), QVariant::fromValue(QAudioDevice()));
+ for (auto &deviceInfo : QMediaDevices::audioOutputs())
+ m_audioOutputCombo->addItem(deviceInfo.description(), QVariant::fromValue(deviceInfo));
+}
+
+void Player::audioOutputChanged(int index)
+{
+ auto device = m_audioOutputCombo->itemData(index).value<QAudioDevice>();
+ m_player->audioOutput()->setDevice(device);
+}
+
+#include "moc_player.cpp"
diff --git a/examples/multimedia/player/player.h b/examples/multimedia/player/player.h
new file mode 100644
index 000000000..f20995fcf
--- /dev/null
+++ b/examples/multimedia/player/player.h
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYER_H
+#define PLAYER_H
+
+#include "qmediaplaylist.h"
+
+#include <QMediaMetaData>
+#include <QMediaPlayer>
+#include <QMediaDevices>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractItemView;
+class QLabel;
+class QMediaPlayer;
+class QModelIndex;
+class QPushButton;
+class QComboBox;
+class QSlider;
+class QStatusBar;
+class QVideoWidget;
+QT_END_NAMESPACE
+
+class PlaylistModel;
+
+class Player : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Player(QWidget *parent = nullptr);
+ ~Player() = default;
+
+ bool isPlayerAvailable() const;
+
+ void addToPlaylist(const QList<QUrl> &urls);
+
+signals:
+ void fullScreenChanged(bool fullScreen);
+
+private slots:
+ void open();
+ void durationChanged(qint64 duration);
+ void positionChanged(qint64 progress);
+ void metaDataChanged();
+ void tracksChanged();
+
+ void previousClicked();
+
+ void seek(int mseconds);
+ void jump(const QModelIndex &index);
+ void playlistPositionChanged(int);
+
+ void statusChanged(QMediaPlayer::MediaStatus status);
+ void bufferingProgress(float progress);
+ void videoAvailableChanged(bool available);
+
+ void selectAudioStream();
+ void selectVideoStream();
+ void selectSubtitleStream();
+
+ void displayErrorMessage();
+
+ void audioOutputChanged(int);
+
+private:
+ void setTrackInfo(const QString &info);
+ void setStatusInfo(const QString &info);
+ void handleCursor(QMediaPlayer::MediaStatus status);
+ void updateDurationInfo(qint64 currentInfo);
+
+ void updateAudioDevices();
+
+ QString trackName(const QMediaMetaData &metaData, int index);
+
+ QMediaPlayer *m_player = nullptr;
+ QAudioOutput *m_audioOutput = nullptr;
+ QMediaPlaylist *m_playlist = nullptr;
+ QVideoWidget *m_videoWidget = nullptr;
+ QSlider *m_slider = nullptr;
+ QLabel *m_labelDuration = nullptr;
+ QPushButton *m_fullScreenButton = nullptr;
+ QComboBox *m_audioOutputCombo = nullptr;
+ QLabel *m_statusLabel = nullptr;
+ QStatusBar *m_statusBar = nullptr;
+
+ QComboBox *m_audioTracks = nullptr;
+ QComboBox *m_videoTracks = nullptr;
+ QComboBox *m_subtitleTracks = nullptr;
+
+ PlaylistModel *m_playlistModel = nullptr;
+ QAbstractItemView *m_playlistView = nullptr;
+ QString m_trackInfo;
+ QString m_statusInfo;
+ qint64 m_duration;
+
+ QMediaDevices m_mediaDevices;
+
+ QWidget *m_metaDataFields[QMediaMetaData::NumMetaData] = {};
+ QLabel *m_metaDataLabels[QMediaMetaData::NumMetaData] = {};
+};
+
+#endif // PLAYER_H
diff --git a/examples/multimediawidgets/player/player.pro b/examples/multimedia/player/player.pro
index 0c5be6888..6d9383692 100644
--- a/examples/multimediawidgets/player/player.pro
+++ b/examples/multimedia/player/player.pro
@@ -2,7 +2,6 @@ TEMPLATE = app
TARGET = player
QT += network \
- xml \
multimedia \
multimediawidgets \
widgets
@@ -12,13 +11,18 @@ HEADERS = \
playercontrols.h \
playlistmodel.h \
videowidget.h \
- histogramwidget.h
+ qmediaplaylist.h \
+ qmediaplaylist_p.h \
+ qplaylistfileparser.h
+
SOURCES = main.cpp \
player.cpp \
playercontrols.cpp \
playlistmodel.cpp \
videowidget.cpp \
- histogramwidget.cpp
+ qmediaplaylist.cpp \
+ qmediaplaylist_p.cpp \
+ qplaylistfileparser.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/player
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/player
INSTALLS += target
diff --git a/examples/multimediawidgets/player/playercontrols.cpp b/examples/multimedia/player/playercontrols.cpp
index 3c06c01c6..4933bf8cf 100644
--- a/examples/multimediawidgets/player/playercontrols.cpp
+++ b/examples/multimedia/player/playercontrols.cpp
@@ -1,64 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "playercontrols.h"
+#include <QAudio>
#include <QBoxLayout>
+#include <QComboBox>
#include <QSlider>
#include <QStyle>
#include <QToolButton>
-#include <QComboBox>
-#include <QAudio>
-PlayerControls::PlayerControls(QWidget *parent)
- : QWidget(parent)
+PlayerControls::PlayerControls(QWidget *parent) : QWidget(parent)
{
m_playButton = new QToolButton(this);
m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
@@ -88,8 +40,12 @@ PlayerControls::PlayerControls(QWidget *parent)
m_volumeSlider = new QSlider(Qt::Horizontal, this);
m_volumeSlider->setRange(0, 100);
+ QSizePolicy sp = m_volumeSlider->sizePolicy();
+ sp.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
+ m_volumeSlider->setSizePolicy(sp);
- connect(m_volumeSlider, &QSlider::valueChanged, this, &PlayerControls::onVolumeSliderValueChanged);
+ connect(m_volumeSlider, &QSlider::valueChanged, this,
+ &PlayerControls::onVolumeSliderValueChanged);
m_rateBox = new QComboBox(this);
m_rateBox->addItem("0.5x", QVariant(0.5));
@@ -97,7 +53,8 @@ PlayerControls::PlayerControls(QWidget *parent)
m_rateBox->addItem("2.0x", QVariant(2.0));
m_rateBox->setCurrentIndex(1);
- connect(m_rateBox, QOverload<int>::of(&QComboBox::activated), this, &PlayerControls::updateRate);
+ connect(m_rateBox, QOverload<int>::of(&QComboBox::activated), this,
+ &PlayerControls::updateRate);
QBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
@@ -111,12 +68,12 @@ PlayerControls::PlayerControls(QWidget *parent)
setLayout(layout);
}
-QMediaPlayer::State PlayerControls::state() const
+QMediaPlayer::PlaybackState PlayerControls::state() const
{
return m_playerState;
}
-void PlayerControls::setState(QMediaPlayer::State state)
+void PlayerControls::setState(QMediaPlayer::PlaybackState state)
{
if (state != m_playerState) {
m_playerState = state;
@@ -138,19 +95,18 @@ void PlayerControls::setState(QMediaPlayer::State state)
}
}
-int PlayerControls::volume() const
+float PlayerControls::volume() const
{
- qreal linearVolume = QAudio::convertVolume(m_volumeSlider->value() / qreal(100),
- QAudio::LogarithmicVolumeScale,
- QAudio::LinearVolumeScale);
+ qreal linearVolume =
+ QAudio::convertVolume(m_volumeSlider->value() / qreal(100),
+ QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale);
- return qRound(linearVolume * 100);
+ return linearVolume;
}
-void PlayerControls::setVolume(int volume)
+void PlayerControls::setVolume(float volume)
{
- qreal logarithmicVolume = QAudio::convertVolume(volume / qreal(100),
- QAudio::LinearVolumeScale,
+ qreal logarithmicVolume = QAudio::convertVolume(volume, QAudio::LinearVolumeScale,
QAudio::LogarithmicVolumeScale);
m_volumeSlider->setValue(qRound(logarithmicVolume * 100));
@@ -166,9 +122,8 @@ void PlayerControls::setMuted(bool muted)
if (muted != m_playerMuted) {
m_playerMuted = muted;
- m_muteButton->setIcon(style()->standardIcon(muted
- ? QStyle::SP_MediaVolumeMuted
- : QStyle::SP_MediaVolume));
+ m_muteButton->setIcon(style()->standardIcon(muted ? QStyle::SP_MediaVolumeMuted
+ : QStyle::SP_MediaVolume));
}
}
@@ -204,7 +159,7 @@ void PlayerControls::setPlaybackRate(float rate)
}
}
- m_rateBox->addItem(QString("%1x").arg(rate), QVariant(rate));
+ m_rateBox->addItem(QStringLiteral("%1x").arg(rate), QVariant(rate));
m_rateBox->setCurrentIndex(m_rateBox->count() - 1);
}
@@ -217,3 +172,5 @@ void PlayerControls::onVolumeSliderValueChanged()
{
emit changeVolume(volume());
}
+
+#include "moc_playercontrols.cpp"
diff --git a/examples/multimedia/player/playercontrols.h b/examples/multimedia/player/playercontrols.h
new file mode 100644
index 000000000..72dddd68f
--- /dev/null
+++ b/examples/multimedia/player/playercontrols.h
@@ -0,0 +1,62 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYERCONTROLS_H
+#define PLAYERCONTROLS_H
+
+#include <QMediaPlayer>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QAbstractSlider;
+class QComboBox;
+QT_END_NAMESPACE
+
+class PlayerControls : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit PlayerControls(QWidget *parent = nullptr);
+
+ QMediaPlayer::PlaybackState state() const;
+ float volume() const;
+ bool isMuted() const;
+ qreal playbackRate() const;
+
+public slots:
+ void setState(QMediaPlayer::PlaybackState state);
+ void setVolume(float volume);
+ void setMuted(bool muted);
+ void setPlaybackRate(float rate);
+
+signals:
+ void play();
+ void pause();
+ void stop();
+ void next();
+ void previous();
+ void changeVolume(float volume);
+ void changeMuting(bool muting);
+ void changeRate(qreal rate);
+
+private slots:
+ void playClicked();
+ void muteClicked();
+ void updateRate();
+ void onVolumeSliderValueChanged();
+
+private:
+ QMediaPlayer::PlaybackState m_playerState = QMediaPlayer::StoppedState;
+ bool m_playerMuted = false;
+ QAbstractButton *m_playButton = nullptr;
+ QAbstractButton *m_stopButton = nullptr;
+ QAbstractButton *m_nextButton = nullptr;
+ QAbstractButton *m_previousButton = nullptr;
+ QAbstractButton *m_muteButton = nullptr;
+ QAbstractSlider *m_volumeSlider = nullptr;
+ QComboBox *m_rateBox = nullptr;
+};
+
+#endif // PLAYERCONTROLS_H
diff --git a/examples/multimedia/player/playlistmodel.cpp b/examples/multimedia/player/playlistmodel.cpp
new file mode 100644
index 000000000..7ae76bcac
--- /dev/null
+++ b/examples/multimedia/player/playlistmodel.cpp
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "playlistmodel.h"
+#include "qmediaplaylist.h"
+
+#include <QFileInfo>
+#include <QUrl>
+
+PlaylistModel::PlaylistModel(QObject *parent) : QAbstractItemModel(parent)
+{
+ m_playlist.reset(new QMediaPlaylist);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this,
+ &PlaylistModel::beginInsertItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this,
+ &PlaylistModel::endInsertItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this,
+ &PlaylistModel::beginRemoveItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems);
+ connect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems);
+}
+
+PlaylistModel::~PlaylistModel() = default;
+
+int PlaylistModel::rowCount(const QModelIndex &parent) const
+{
+ return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0;
+}
+
+int PlaylistModel::columnCount(const QModelIndex &parent) const
+{
+ return !parent.isValid() ? ColumnCount : 0;
+}
+
+QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const
+{
+ return m_playlist && !parent.isValid() && row >= 0 && row < m_playlist->mediaCount()
+ && column >= 0 && column < ColumnCount
+ ? createIndex(row, column)
+ : QModelIndex();
+}
+
+QModelIndex PlaylistModel::parent(const QModelIndex &child) const
+{
+ Q_UNUSED(child);
+
+ return QModelIndex();
+}
+
+QVariant PlaylistModel::data(const QModelIndex &index, int role) const
+{
+ if (index.isValid() && role == Qt::DisplayRole) {
+ QVariant value = m_data[index];
+ if (!value.isValid() && index.column() == Title) {
+ QUrl location = m_playlist->media(index.row());
+ return QFileInfo(location.path()).fileName();
+ }
+
+ return value;
+ }
+ return QVariant();
+}
+
+QMediaPlaylist *PlaylistModel::playlist() const
+{
+ return m_playlist.data();
+}
+
+bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ Q_UNUSED(role);
+ m_data[index] = value;
+ emit dataChanged(index, index);
+ return true;
+}
+
+void PlaylistModel::beginInsertItems(int start, int end)
+{
+ m_data.clear();
+ beginInsertRows(QModelIndex(), start, end);
+}
+
+void PlaylistModel::endInsertItems()
+{
+ endInsertRows();
+}
+
+void PlaylistModel::beginRemoveItems(int start, int end)
+{
+ m_data.clear();
+ beginRemoveRows(QModelIndex(), start, end);
+}
+
+void PlaylistModel::endRemoveItems()
+{
+ endInsertRows();
+}
+
+void PlaylistModel::changeItems(int start, int end)
+{
+ m_data.clear();
+ emit dataChanged(index(start, 0), index(end, ColumnCount));
+}
+
+#include "moc_playlistmodel.cpp"
diff --git a/examples/multimedia/player/playlistmodel.h b/examples/multimedia/player/playlistmodel.h
new file mode 100644
index 000000000..0c510f6e0
--- /dev/null
+++ b/examples/multimedia/player/playlistmodel.h
@@ -0,0 +1,50 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYLISTMODEL_H
+#define PLAYLISTMODEL_H
+
+#include <QAbstractItemModel>
+#include <QScopedPointer>
+
+QT_BEGIN_NAMESPACE
+class QMediaPlaylist;
+QT_END_NAMESPACE
+
+class PlaylistModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ enum Column { Title = 0, ColumnCount };
+
+ explicit PlaylistModel(QObject *parent = nullptr);
+ ~PlaylistModel();
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+
+ QMediaPlaylist *playlist() const;
+
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::DisplayRole) override;
+
+private slots:
+ void beginInsertItems(int start, int end);
+ void endInsertItems();
+ void beginRemoveItems(int start, int end);
+ void endRemoveItems();
+ void changeItems(int start, int end);
+
+private:
+ QScopedPointer<QMediaPlaylist> m_playlist;
+ QMap<QModelIndex, QVariant> m_data;
+};
+
+#endif // PLAYLISTMODEL_H
diff --git a/examples/multimedia/player/qmediaplaylist.cpp b/examples/multimedia/player/qmediaplaylist.cpp
new file mode 100644
index 000000000..739dd1cb2
--- /dev/null
+++ b/examples/multimedia/player/qmediaplaylist.cpp
@@ -0,0 +1,643 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "qmediaplaylist.h"
+#include "qmediaplaylist_p.h"
+#include "qplaylistfileparser.h"
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QList>
+#include <QRandomGenerator>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+class QM3uPlaylistWriter
+{
+public:
+ QM3uPlaylistWriter(QIODevice *device)
+ : m_device(device), m_textStream(new QTextStream(m_device))
+ {
+ }
+
+ ~QM3uPlaylistWriter() { delete m_textStream; }
+
+ bool writeItem(const QUrl &item)
+ {
+ *m_textStream << item.toString() << Qt::endl;
+ return true;
+ }
+
+private:
+ QIODevice *m_device;
+ QTextStream *m_textStream;
+};
+
+int QMediaPlaylistPrivate::nextPosition(int steps) const
+{
+ if (playlist.count() == 0)
+ return -1;
+
+ int next = currentPos + steps;
+
+ switch (playbackMode) {
+ case QMediaPlaylist::CurrentItemOnce:
+ return steps != 0 ? -1 : currentPos;
+ case QMediaPlaylist::CurrentItemInLoop:
+ return currentPos;
+ case QMediaPlaylist::Sequential:
+ if (next >= playlist.size())
+ next = 0;
+ break;
+ case QMediaPlaylist::Loop:
+ next %= playlist.count();
+ break;
+ }
+
+ return next;
+}
+
+int QMediaPlaylistPrivate::prevPosition(int steps) const
+{
+ if (playlist.count() == 0)
+ return -1;
+
+ int next = currentPos;
+ if (next < 0)
+ next = playlist.size();
+ next -= steps;
+
+ switch (playbackMode) {
+ case QMediaPlaylist::CurrentItemOnce:
+ return steps != 0 ? -1 : currentPos;
+ case QMediaPlaylist::CurrentItemInLoop:
+ return currentPos;
+ case QMediaPlaylist::Sequential:
+ if (next < 0)
+ next = playlist.size() - 1;
+ break;
+ case QMediaPlaylist::Loop:
+ next %= playlist.size();
+ if (next < 0)
+ next += playlist.size();
+ break;
+ }
+
+ return next;
+}
+
+/*!
+ \class QMediaPlaylist
+ \inmodule QtMultimedia
+ \ingroup multimedia
+ \ingroup multimedia_playback
+
+
+ \brief The QMediaPlaylist class provides a list of media content to play.
+
+ QMediaPlaylist is intended to be used with other media objects,
+ like QMediaPlayer.
+
+ QMediaPlaylist allows to access the service intrinsic playlist functionality
+ if available, otherwise it provides the local memory playlist implementation.
+
+ \snippet multimedia-snippets/media.cpp Movie playlist
+
+ Depending on playlist source implementation, most of the playlist mutating
+ operations can be asynchronous.
+
+ QMediaPlayList currently supports M3U playlists (file extension .m3u and .m3u8).
+
+ \sa QUrl
+*/
+
+/*!
+ \enum QMediaPlaylist::PlaybackMode
+
+ The QMediaPlaylist::PlaybackMode describes the order items in playlist are played.
+
+ \value CurrentItemOnce The current item is played only once.
+
+ \value CurrentItemInLoop The current item is played repeatedly in a loop.
+
+ \value Sequential Playback starts from the current and moves through each successive
+ item until the last is reached and then stops. The next item is a null item when the last one is
+ currently playing.
+
+ \value Loop Playback restarts at the first item after the last has finished
+ playing.
+
+ \value Random Play items in random order.
+*/
+
+/*!
+ Create a new playlist object with the given \a parent.
+*/
+
+QMediaPlaylist::QMediaPlaylist(QObject *parent) : QObject(parent), d_ptr(new QMediaPlaylistPrivate)
+{
+ Q_D(QMediaPlaylist);
+
+ d->q_ptr = this;
+}
+
+/*!
+ Destroys the playlist.
+ */
+
+QMediaPlaylist::~QMediaPlaylist()
+{
+ delete d_ptr;
+}
+
+/*!
+ \property QMediaPlaylist::playbackMode
+
+ This property defines the order that items in the playlist are played.
+
+ \sa QMediaPlaylist::PlaybackMode
+*/
+
+QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode() const
+{
+ return d_func()->playbackMode;
+}
+
+void QMediaPlaylist::setPlaybackMode(QMediaPlaylist::PlaybackMode mode)
+{
+ Q_D(QMediaPlaylist);
+
+ if (mode == d->playbackMode)
+ return;
+
+ d->playbackMode = mode;
+
+ emit playbackModeChanged(mode);
+}
+
+/*!
+ Returns position of the current media content in the playlist.
+*/
+int QMediaPlaylist::currentIndex() const
+{
+ return d_func()->currentPos;
+}
+
+/*!
+ Returns the current media content.
+*/
+
+QUrl QMediaPlaylist::currentMedia() const
+{
+ Q_D(const QMediaPlaylist);
+ if (d->currentPos < 0 || d->currentPos >= d->playlist.size())
+ return QUrl();
+ return d_func()->playlist.at(d_func()->currentPos);
+}
+
+/*!
+ Returns the index of the item, which would be current after calling next()
+ \a steps times.
+
+ Returned value depends on the size of playlist, current position
+ and playback mode.
+
+ \sa QMediaPlaylist::playbackMode(), previousIndex()
+*/
+int QMediaPlaylist::nextIndex(int steps) const
+{
+ return d_func()->nextPosition(steps);
+}
+
+/*!
+ Returns the index of the item, which would be current after calling previous()
+ \a steps times.
+
+ \sa QMediaPlaylist::playbackMode(), nextIndex()
+*/
+
+int QMediaPlaylist::previousIndex(int steps) const
+{
+ return d_func()->prevPosition(steps);
+}
+
+/*!
+ Returns the number of items in the playlist.
+
+ \sa isEmpty()
+ */
+int QMediaPlaylist::mediaCount() const
+{
+ return d_func()->playlist.count();
+}
+
+/*!
+ Returns true if the playlist contains no items, otherwise returns false.
+
+ \sa mediaCount()
+ */
+bool QMediaPlaylist::isEmpty() const
+{
+ return mediaCount() == 0;
+}
+
+/*!
+ Returns the media content at \a index in the playlist.
+*/
+
+QUrl QMediaPlaylist::media(int index) const
+{
+ Q_D(const QMediaPlaylist);
+ if (index < 0 || index >= d->playlist.size())
+ return QUrl();
+ return d->playlist.at(index);
+}
+
+/*!
+ Append the media \a content to the playlist.
+
+ Returns true if the operation is successful, otherwise returns false.
+ */
+void QMediaPlaylist::addMedia(const QUrl &content)
+{
+ Q_D(QMediaPlaylist);
+ int pos = d->playlist.size();
+ emit mediaAboutToBeInserted(pos, pos);
+ d->playlist.append(content);
+ emit mediaInserted(pos, pos);
+}
+
+/*!
+ Append multiple media content \a items to the playlist.
+
+ Returns true if the operation is successful, otherwise returns false.
+ */
+void QMediaPlaylist::addMedia(const QList<QUrl> &items)
+{
+ if (!items.size())
+ return;
+
+ Q_D(QMediaPlaylist);
+ int first = d->playlist.size();
+ int last = first + items.size() - 1;
+ emit mediaAboutToBeInserted(first, last);
+ d_func()->playlist.append(items);
+ emit mediaInserted(first, last);
+}
+
+/*!
+ Insert the media \a content to the playlist at position \a pos.
+
+ Returns true if the operation is successful, otherwise returns false.
+*/
+
+bool QMediaPlaylist::insertMedia(int pos, const QUrl &content)
+{
+ Q_D(QMediaPlaylist);
+ pos = qBound(0, pos, d->playlist.size());
+ emit mediaAboutToBeInserted(pos, pos);
+ d->playlist.insert(pos, content);
+ emit mediaInserted(pos, pos);
+ return true;
+}
+
+/*!
+ Insert multiple media content \a items to the playlist at position \a pos.
+
+ Returns true if the operation is successful, otherwise returns false.
+*/
+
+bool QMediaPlaylist::insertMedia(int pos, const QList<QUrl> &items)
+{
+ if (!items.size())
+ return true;
+
+ Q_D(QMediaPlaylist);
+ pos = qBound(0, pos, d->playlist.size());
+ int last = pos + items.size() - 1;
+ emit mediaAboutToBeInserted(pos, last);
+ auto newList = d->playlist.mid(0, pos);
+ newList += items;
+ newList += d->playlist.mid(pos);
+ d->playlist = newList;
+ emit mediaInserted(pos, last);
+ return true;
+}
+
+/*!
+ Move the item from position \a from to position \a to.
+
+ Returns true if the operation is successful, otherwise false.
+
+ \since 5.7
+*/
+bool QMediaPlaylist::moveMedia(int from, int to)
+{
+ Q_D(QMediaPlaylist);
+ if (from < 0 || from > d->playlist.count() || to < 0 || to > d->playlist.count())
+ return false;
+
+ d->playlist.move(from, to);
+ emit mediaChanged(from, to);
+ return true;
+}
+
+/*!
+ Remove the item from the playlist at position \a pos.
+
+ Returns true if the operation is successful, otherwise return false.
+ */
+bool QMediaPlaylist::removeMedia(int pos)
+{
+ return removeMedia(pos, pos);
+}
+
+/*!
+ Remove items in the playlist from \a start to \a end inclusive.
+
+ Returns true if the operation is successful, otherwise return false.
+ */
+bool QMediaPlaylist::removeMedia(int start, int end)
+{
+ Q_D(QMediaPlaylist);
+ if (end < start || end < 0 || start >= d->playlist.count())
+ return false;
+ start = qBound(0, start, d->playlist.size() - 1);
+ end = qBound(0, end, d->playlist.size() - 1);
+
+ emit mediaAboutToBeRemoved(start, end);
+ d->playlist.remove(start, end - start + 1);
+ emit mediaRemoved(start, end);
+ return true;
+}
+
+/*!
+ Remove all the items from the playlist.
+
+ Returns true if the operation is successful, otherwise return false.
+ */
+void QMediaPlaylist::clear()
+{
+ Q_D(QMediaPlaylist);
+ int size = d->playlist.size();
+ emit mediaAboutToBeRemoved(0, size - 1);
+ d->playlist.clear();
+ emit mediaRemoved(0, size - 1);
+}
+
+/*!
+ Load playlist from \a location. If \a format is specified, it is used,
+ otherwise format is guessed from location name and data.
+
+ New items are appended to playlist.
+
+ QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
+ otherwise the playlist emits loadFailed().
+*/
+
+void QMediaPlaylist::load(const QUrl &location, const char *format)
+{
+ Q_D(QMediaPlaylist);
+
+ d->error = NoError;
+ d->errorString.clear();
+
+ d->ensureParser();
+ d->parser->start(location, QString::fromUtf8(format));
+}
+
+/*!
+ Load playlist from QIODevice \a device. If \a format is specified, it is used,
+ otherwise format is guessed from device data.
+
+ New items are appended to playlist.
+
+ QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
+ otherwise the playlist emits loadFailed().
+*/
+void QMediaPlaylist::load(QIODevice *device, const char *format)
+{
+ Q_D(QMediaPlaylist);
+
+ d->error = NoError;
+ d->errorString.clear();
+
+ d->ensureParser();
+ d->parser->start(device, QString::fromUtf8(format));
+}
+
+/*!
+ Save playlist to \a location. If \a format is specified, it is used,
+ otherwise format is guessed from location name.
+
+ Returns true if playlist was saved successfully, otherwise returns false.
+ */
+bool QMediaPlaylist::save(const QUrl &location, const char *format) const
+{
+ Q_D(const QMediaPlaylist);
+
+ d->error = NoError;
+ d->errorString.clear();
+
+ if (!d->checkFormat(format))
+ return false;
+
+ QFile file(location.toLocalFile());
+
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ d->error = AccessDeniedError;
+ d->errorString = tr("The file could not be accessed.");
+ return false;
+ }
+
+ return save(&file, format);
+}
+
+/*!
+ Save playlist to QIODevice \a device using format \a format.
+
+ Returns true if playlist was saved successfully, otherwise returns false.
+*/
+bool QMediaPlaylist::save(QIODevice *device, const char *format) const
+{
+ Q_D(const QMediaPlaylist);
+
+ d->error = NoError;
+ d->errorString.clear();
+
+ if (!d->checkFormat(format))
+ return false;
+
+ QM3uPlaylistWriter writer(device);
+ for (const auto &entry : d->playlist)
+ writer.writeItem(entry);
+ return true;
+}
+
+/*!
+ Returns the last error condition.
+*/
+QMediaPlaylist::Error QMediaPlaylist::error() const
+{
+ return d_func()->error;
+}
+
+/*!
+ Returns the string describing the last error condition.
+*/
+QString QMediaPlaylist::errorString() const
+{
+ return d_func()->errorString;
+}
+
+/*!
+ Shuffle items in the playlist.
+*/
+void QMediaPlaylist::shuffle()
+{
+ Q_D(QMediaPlaylist);
+ QList<QUrl> playlist;
+
+ // keep the current item when shuffling
+ QUrl current;
+ if (d->currentPos != -1)
+ current = d->playlist.takeAt(d->currentPos);
+
+ while (!d->playlist.isEmpty())
+ playlist.append(
+ d->playlist.takeAt(QRandomGenerator::global()->bounded(int(d->playlist.size()))));
+
+ if (d->currentPos != -1)
+ playlist.insert(d->currentPos, current);
+ d->playlist = playlist;
+ emit mediaChanged(0, d->playlist.count());
+}
+
+/*!
+ Advance to the next media content in playlist.
+*/
+void QMediaPlaylist::next()
+{
+ Q_D(QMediaPlaylist);
+ d->currentPos = d->nextPosition(1);
+
+ emit currentIndexChanged(d->currentPos);
+ emit currentMediaChanged(currentMedia());
+}
+
+/*!
+ Return to the previous media content in playlist.
+*/
+void QMediaPlaylist::previous()
+{
+ Q_D(QMediaPlaylist);
+ d->currentPos = d->prevPosition(1);
+
+ emit currentIndexChanged(d->currentPos);
+ emit currentMediaChanged(currentMedia());
+}
+
+/*!
+ Activate media content from playlist at position \a playlistPosition.
+*/
+
+void QMediaPlaylist::setCurrentIndex(int playlistPosition)
+{
+ Q_D(QMediaPlaylist);
+ if (playlistPosition < 0 || playlistPosition >= d->playlist.size())
+ playlistPosition = -1;
+ d->currentPos = playlistPosition;
+
+ emit currentIndexChanged(d->currentPos);
+ emit currentMediaChanged(currentMedia());
+}
+
+/*!
+ \fn void QMediaPlaylist::mediaInserted(int start, int end)
+
+ This signal is emitted after media has been inserted into the playlist.
+ The new items are those between \a start and \a end inclusive.
+ */
+
+/*!
+ \fn void QMediaPlaylist::mediaRemoved(int start, int end)
+
+ This signal is emitted after media has been removed from the playlist.
+ The removed items are those between \a start and \a end inclusive.
+ */
+
+/*!
+ \fn void QMediaPlaylist::mediaChanged(int start, int end)
+
+ This signal is emitted after media has been changed in the playlist
+ between \a start and \a end positions inclusive.
+ */
+
+/*!
+ \fn void QMediaPlaylist::currentIndexChanged(int position)
+
+ Signal emitted when playlist position changed to \a position.
+*/
+
+/*!
+ \fn void QMediaPlaylist::playbackModeChanged(QMediaPlaylist::PlaybackMode mode)
+
+ Signal emitted when playback mode changed to \a mode.
+*/
+
+/*!
+ \fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end)
+
+ Signal emitted when items are to be inserted at \a start and ending at \a end.
+*/
+
+/*!
+ \fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end)
+
+ Signal emitted when item are to be deleted at \a start and ending at \a end.
+*/
+
+/*!
+ \fn void QMediaPlaylist::currentMediaChanged(const QUrl &content)
+
+ Signal emitted when current media changes to \a content.
+*/
+
+/*!
+ \property QMediaPlaylist::currentIndex
+ \brief Current position.
+*/
+
+/*!
+ \property QMediaPlaylist::currentMedia
+ \brief Current media content.
+*/
+
+/*!
+ \fn QMediaPlaylist::loaded()
+
+ Signal emitted when playlist finished loading.
+*/
+
+/*!
+ \fn QMediaPlaylist::loadFailed()
+
+ Signal emitted if failed to load playlist.
+*/
+
+/*!
+ \enum QMediaPlaylist::Error
+
+ This enum describes the QMediaPlaylist error codes.
+
+ \value NoError No errors.
+ \value FormatError Format error.
+ \value FormatNotSupportedError Format not supported.
+ \value NetworkError Network error.
+ \value AccessDeniedError Access denied error.
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qmediaplaylist.cpp"
diff --git a/examples/multimedia/player/qmediaplaylist.h b/examples/multimedia/player/qmediaplaylist.h
new file mode 100644
index 000000000..358f8ca60
--- /dev/null
+++ b/examples/multimedia/player/qmediaplaylist.h
@@ -0,0 +1,95 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef QMEDIAPLAYLIST_H
+#define QMEDIAPLAYLIST_H
+
+#include <QObject>
+
+#include <qmediaenumdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlaylistPrivate;
+class QMediaPlaylist : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode
+ NOTIFY playbackModeChanged)
+ Q_PROPERTY(QUrl currentMedia READ currentMedia NOTIFY currentMediaChanged)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
+
+public:
+ enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop };
+ Q_ENUM(PlaybackMode)
+ enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError };
+ Q_ENUM(Error)
+
+ explicit QMediaPlaylist(QObject *parent = nullptr);
+ virtual ~QMediaPlaylist();
+
+ PlaybackMode playbackMode() const;
+ void setPlaybackMode(PlaybackMode mode);
+
+ int currentIndex() const;
+ QUrl currentMedia() const;
+
+ int nextIndex(int steps = 1) const;
+ int previousIndex(int steps = 1) const;
+
+ QUrl media(int index) const;
+
+ int mediaCount() const;
+ bool isEmpty() const;
+
+ void addMedia(const QUrl &content);
+ void addMedia(const QList<QUrl> &items);
+ bool insertMedia(int index, const QUrl &content);
+ bool insertMedia(int index, const QList<QUrl> &items);
+ bool moveMedia(int from, int to);
+ bool removeMedia(int pos);
+ bool removeMedia(int start, int end);
+ void clear();
+
+ void load(const QUrl &location, const char *format = nullptr);
+ void load(QIODevice *device, const char *format = nullptr);
+
+ bool save(const QUrl &location, const char *format = nullptr) const;
+ bool save(QIODevice *device, const char *format) const;
+
+ Error error() const;
+ QString errorString() const;
+
+public slots:
+ void shuffle();
+
+ void next();
+ void previous();
+
+ void setCurrentIndex(int index);
+
+signals:
+ void currentIndexChanged(int index);
+ void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
+ void currentMediaChanged(const QUrl &);
+
+ void mediaAboutToBeInserted(int start, int end);
+ void mediaInserted(int start, int end);
+ void mediaAboutToBeRemoved(int start, int end);
+ void mediaRemoved(int start, int end);
+ void mediaChanged(int start, int end);
+
+ void loaded();
+ void loadFailed();
+
+private:
+ QMediaPlaylistPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QMediaPlaylist)
+};
+
+QT_END_NAMESPACE
+
+Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, PlaybackMode)
+Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, Error)
+
+#endif // QMEDIAPLAYLIST_H
diff --git a/examples/multimedia/player/qmediaplaylist_p.cpp b/examples/multimedia/player/qmediaplaylist_p.cpp
new file mode 100644
index 000000000..13e164484
--- /dev/null
+++ b/examples/multimedia/player/qmediaplaylist_p.cpp
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "qmediaplaylist_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QMediaPlaylistPrivate::QMediaPlaylistPrivate() : error(QMediaPlaylist::NoError) { }
+
+QMediaPlaylistPrivate::~QMediaPlaylistPrivate()
+{
+ delete parser;
+}
+
+void QMediaPlaylistPrivate::loadFailed(QMediaPlaylist::Error error, const QString &errorString)
+{
+ this->error = error;
+ this->errorString = errorString;
+
+ emit q_ptr->loadFailed();
+}
+
+void QMediaPlaylistPrivate::loadFinished()
+{
+ q_ptr->addMedia(parser->playlist);
+
+ emit q_ptr->loaded();
+}
+
+bool QMediaPlaylistPrivate::checkFormat(const char *format) const
+{
+ QLatin1String f(format);
+ QPlaylistFileParser::FileType type =
+ format ? QPlaylistFileParser::UNKNOWN : QPlaylistFileParser::M3U8;
+ if (format) {
+ if (f == QLatin1String("m3u") || f == QLatin1String("text/uri-list")
+ || f == QLatin1String("audio/x-mpegurl") || f == QLatin1String("audio/mpegurl"))
+ type = QPlaylistFileParser::M3U;
+ else if (f == QLatin1String("m3u8") || f == QLatin1String("application/x-mpegURL")
+ || f == QLatin1String("application/vnd.apple.mpegurl"))
+ type = QPlaylistFileParser::M3U8;
+ }
+
+ if (type == QPlaylistFileParser::UNKNOWN || type == QPlaylistFileParser::PLS) {
+ error = QMediaPlaylist::FormatNotSupportedError;
+ errorString = QMediaPlaylist::tr("This file format is not supported.");
+ return false;
+ }
+ return true;
+}
+
+void QMediaPlaylistPrivate::ensureParser()
+{
+ if (parser)
+ return;
+
+ parser = new QPlaylistFileParser(q_ptr);
+ QObject::connect(parser, &QPlaylistFileParser::finished, q_ptr, [this]() { loadFinished(); });
+ QObject::connect(parser, &QPlaylistFileParser::error, q_ptr,
+ [this](QMediaPlaylist::Error err, const QString &errorMsg) {
+ loadFailed(err, errorMsg);
+ });
+}
+
+QT_END_NAMESPACE
diff --git a/examples/multimedia/player/qmediaplaylist_p.h b/examples/multimedia/player/qmediaplaylist_p.h
new file mode 100644
index 000000000..df43776fc
--- /dev/null
+++ b/examples/multimedia/player/qmediaplaylist_p.h
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef QMEDIAPLAYLIST_P_H
+#define QMEDIAPLAYLIST_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmediaplaylist.h"
+#include "qplaylistfileparser.h"
+
+#include <QUrl>
+
+#include <QDebug>
+
+#ifdef Q_MOC_RUN
+# pragma Q_MOC_EXPAND_MACROS
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QMediaPlaylistControl;
+
+class QMediaPlaylistPrivate
+{
+ Q_DECLARE_PUBLIC(QMediaPlaylist)
+public:
+ QMediaPlaylistPrivate();
+
+ virtual ~QMediaPlaylistPrivate();
+
+ void loadFailed(QMediaPlaylist::Error error, const QString &errorString);
+
+ void loadFinished();
+
+ bool checkFormat(const char *format) const;
+
+ void ensureParser();
+
+ int nextPosition(int steps) const;
+ int prevPosition(int steps) const;
+
+ QList<QUrl> playlist;
+
+ int currentPos = -1;
+ QMediaPlaylist::PlaybackMode playbackMode = QMediaPlaylist::Sequential;
+
+ QPlaylistFileParser *parser = nullptr;
+ mutable QMediaPlaylist::Error error;
+ mutable QString errorString;
+
+ QMediaPlaylist *q_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMEDIAPLAYLIST_P_H
diff --git a/examples/multimedia/player/qplaylistfileparser.cpp b/examples/multimedia/player/qplaylistfileparser.cpp
new file mode 100644
index 000000000..3f5104761
--- /dev/null
+++ b/examples/multimedia/player/qplaylistfileparser.cpp
@@ -0,0 +1,621 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "qmediametadata.h"
+#include "qmediaplayer.h"
+#include "qplaylistfileparser.h"
+
+#include <QDebug>
+#include <QFileInfo>
+#include <QIODevice>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+
+class ParserBase
+{
+public:
+ explicit ParserBase(QPlaylistFileParser *parent) : m_parent(parent), m_aborted(false)
+ {
+ Q_ASSERT(m_parent);
+ }
+
+ bool parseLine(int lineIndex, const QString &line, const QUrl &root)
+ {
+ if (m_aborted)
+ return false;
+
+ const bool ok = parseLineImpl(lineIndex, line, root);
+ return ok && !m_aborted;
+ }
+
+ virtual void abort() { m_aborted = true; }
+ virtual ~ParserBase() = default;
+
+protected:
+ virtual bool parseLineImpl(int lineIndex, const QString &line, const QUrl &root) = 0;
+
+ static QUrl expandToFullPath(const QUrl &root, const QString &line)
+ {
+ // On Linux, backslashes are not converted to forward slashes :/
+ if (line.startsWith(QLatin1String("//")) || line.startsWith(QLatin1String("\\\\"))) {
+ // Network share paths are not resolved
+ return QUrl::fromLocalFile(line);
+ }
+
+ QUrl url(line);
+ if (url.scheme().isEmpty()) {
+ // Resolve it relative to root
+ if (root.isLocalFile())
+ return QUrl::fromUserInput(line, root.adjusted(QUrl::RemoveFilename).toLocalFile(),
+ QUrl::AssumeLocalFile);
+ return root.resolved(url);
+ }
+ if (url.scheme().length() == 1)
+ // Assume it's a drive letter for a Windows path
+ url = QUrl::fromLocalFile(line);
+
+ return url;
+ }
+
+ void newItemFound(const QVariant &content) { Q_EMIT m_parent->newItem(content); }
+
+ QPlaylistFileParser *m_parent;
+ bool m_aborted;
+};
+
+class M3UParser : public ParserBase
+{
+public:
+ explicit M3UParser(QPlaylistFileParser *q) : ParserBase(q), m_extendedFormat(false) { }
+
+ /*
+ *
+ Extended M3U directives
+
+ #EXTM3U - header - must be first line of file
+ #EXTINF - extra info - length (seconds), title
+ #EXTINF - extra info - length (seconds), artist '-' title
+
+ Example
+
+ #EXTM3U
+ #EXTINF:123, Sample artist - Sample title
+ C:\Documents and Settings\I\My Music\Sample.mp3
+ #EXTINF:321,Example Artist - Example title
+ C:\Documents and Settings\I\My Music\Greatest Hits\Example.ogg
+
+ */
+ bool parseLineImpl(int lineIndex, const QString &line, const QUrl &root) override
+ {
+ if (line[0] == u'#') {
+ if (m_extendedFormat) {
+ if (line.startsWith(QLatin1String("#EXTINF:"))) {
+ m_extraInfo.clear();
+ int artistStart = line.indexOf(QLatin1String(","), 8);
+ bool ok = false;
+ QStringView lineView{ line };
+ int length = lineView.mid(8, artistStart < 8 ? -1 : artistStart - 8)
+ .trimmed()
+ .toInt(&ok);
+ if (ok && length > 0) {
+ // convert from second to milisecond
+ m_extraInfo[QMediaMetaData::Duration] = QVariant(length * 1000);
+ }
+ if (artistStart > 0) {
+ int titleStart = getSplitIndex(line, artistStart);
+ if (titleStart > artistStart) {
+ m_extraInfo[QMediaMetaData::Author] =
+ lineView.mid(artistStart + 1, titleStart - artistStart - 1)
+ .trimmed()
+ .toString()
+ .replace(QLatin1String("--"), QLatin1String("-"));
+ m_extraInfo[QMediaMetaData::Title] =
+ lineView.mid(titleStart + 1)
+ .trimmed()
+ .toString()
+ .replace(QLatin1String("--"), QLatin1String("-"));
+ } else {
+ m_extraInfo[QMediaMetaData::Title] =
+ lineView.mid(artistStart + 1)
+ .trimmed()
+ .toString()
+ .replace(QLatin1String("--"), QLatin1String("-"));
+ }
+ }
+ }
+ } else if (lineIndex == 0 && line.startsWith(QLatin1String("#EXTM3U"))) {
+ m_extendedFormat = true;
+ }
+ } else {
+ QUrl url = expandToFullPath(root, line);
+ m_extraInfo[QMediaMetaData::Url] = url;
+ m_parent->playlist.append(url);
+ newItemFound(QVariant::fromValue(m_extraInfo));
+ m_extraInfo.clear();
+ }
+
+ return true;
+ }
+
+ int getSplitIndex(const QString &line, int startPos)
+ {
+ if (startPos < 0)
+ startPos = 0;
+ const QChar *buf = line.data();
+ for (int i = startPos; i < line.length(); ++i) {
+ if (buf[i] == u'-') {
+ if (i == line.length() - 1)
+ return i;
+ ++i;
+ if (buf[i] != u'-')
+ return i - 1;
+ }
+ }
+ return -1;
+ }
+
+private:
+ QMediaMetaData m_extraInfo;
+ bool m_extendedFormat;
+};
+
+class PLSParser : public ParserBase
+{
+public:
+ explicit PLSParser(QPlaylistFileParser *q) : ParserBase(q) { }
+
+ /*
+ *
+ The format is essentially that of an INI file structured as follows:
+
+ Header
+
+ * [playlist] : This tag indicates that it is a Playlist File
+
+ Track Entry
+ Assuming track entry #X
+
+ * FileX : Variable defining location of stream.
+ * TitleX : Defines track title.
+ * LengthX : Length in seconds of track. Value of -1 indicates indefinite.
+
+ Footer
+
+ * NumberOfEntries : This variable indicates the number of tracks.
+ * Version : Playlist version. Currently only a value of 2 is valid.
+
+ [playlist]
+
+ File1=Alternative\everclear - SMFTA.mp3
+
+ Title1=Everclear - So Much For The Afterglow
+
+ Length1=233
+
+ File2=http://www.site.com:8000/listen.pls
+
+ Title2=My Cool Stream
+
+ Length5=-1
+
+ NumberOfEntries=2
+
+ Version=2
+ */
+ bool parseLineImpl(int, const QString &line, const QUrl &root) override
+ {
+ // We ignore everything but 'File' entries, since that's the only thing we care about.
+ if (!line.startsWith(QLatin1String("File")))
+ return true;
+
+ QString value = getValue(line);
+ if (value.isEmpty())
+ return true;
+
+ QUrl path = expandToFullPath(root, value);
+ m_parent->playlist.append(path);
+ newItemFound(path);
+
+ return true;
+ }
+
+ QString getValue(QStringView line)
+ {
+ int start = line.indexOf(u'=');
+ if (start < 0)
+ return QString();
+ return line.mid(start + 1).trimmed().toString();
+ }
+};
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////
+
+class QPlaylistFileParserPrivate
+{
+ Q_DECLARE_PUBLIC(QPlaylistFileParser)
+public:
+ QPlaylistFileParserPrivate(QPlaylistFileParser *q)
+ : q_ptr(q),
+ m_stream(nullptr),
+ m_type(QPlaylistFileParser::UNKNOWN),
+ m_scanIndex(0),
+ m_lineIndex(-1),
+ m_utf8(false),
+ m_aborted(false)
+ {
+ }
+
+ void handleData();
+ void handleParserFinished();
+ void abort();
+ void reset();
+
+ QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> m_source;
+ QScopedPointer<ParserBase> m_currentParser;
+ QByteArray m_buffer;
+ QUrl m_root;
+ QNetworkAccessManager m_mgr;
+ QString m_mimeType;
+ QPlaylistFileParser *q_ptr;
+ QPointer<QIODevice> m_stream;
+ QPlaylistFileParser::FileType m_type;
+ struct ParserJob
+ {
+ QIODevice *m_stream;
+ QUrl m_media;
+ QString m_mimeType;
+ [[nodiscard]] bool isValid() const { return m_stream || !m_media.isEmpty(); }
+ void reset()
+ {
+ m_stream = nullptr;
+ m_media = QUrl();
+ m_mimeType = QString();
+ }
+ } m_pendingJob;
+ int m_scanIndex;
+ int m_lineIndex;
+ bool m_utf8;
+ bool m_aborted;
+
+private:
+ bool processLine(int startIndex, int length);
+};
+
+#define LINE_LIMIT 4096
+#define READ_LIMIT 64
+
+bool QPlaylistFileParserPrivate::processLine(int startIndex, int length)
+{
+ Q_Q(QPlaylistFileParser);
+ m_lineIndex++;
+
+ if (!m_currentParser) {
+ const QString urlString = m_root.toString();
+ const QString &suffix = !urlString.isEmpty() ? QFileInfo(urlString).suffix() : urlString;
+ QString mimeType;
+ if (m_source)
+ mimeType = m_source->header(QNetworkRequest::ContentTypeHeader).toString();
+ m_type = QPlaylistFileParser::findPlaylistType(
+ suffix, !mimeType.isEmpty() ? mimeType : m_mimeType, m_buffer.constData(),
+ quint32(m_buffer.size()));
+
+ switch (m_type) {
+ case QPlaylistFileParser::UNKNOWN:
+ emit q->error(QMediaPlaylist::FormatError,
+ QMediaPlaylist::tr("%1 playlist type is unknown").arg(m_root.toString()));
+ q->abort();
+ return false;
+ case QPlaylistFileParser::M3U:
+ m_currentParser.reset(new M3UParser(q));
+ break;
+ case QPlaylistFileParser::M3U8:
+ m_currentParser.reset(new M3UParser(q));
+ m_utf8 = true;
+ break;
+ case QPlaylistFileParser::PLS:
+ m_currentParser.reset(new PLSParser(q));
+ break;
+ }
+
+ Q_ASSERT(!m_currentParser.isNull());
+ }
+
+ QString line;
+
+ if (m_utf8) {
+ line = QString::fromUtf8(m_buffer.constData() + startIndex, length).trimmed();
+ } else {
+ line = QString::fromLatin1(m_buffer.constData() + startIndex, length).trimmed();
+ }
+ if (line.isEmpty())
+ return true;
+
+ Q_ASSERT(m_currentParser);
+ return m_currentParser->parseLine(m_lineIndex, line, m_root);
+}
+
+void QPlaylistFileParserPrivate::handleData()
+{
+ Q_Q(QPlaylistFileParser);
+ while (m_stream->bytesAvailable() && !m_aborted) {
+ int expectedBytes =
+ qMin(READ_LIMIT,
+ int(qMin(m_stream->bytesAvailable(), qint64(LINE_LIMIT - m_buffer.size()))));
+ m_buffer.push_back(m_stream->read(expectedBytes));
+ int processedBytes = 0;
+ while (m_scanIndex < m_buffer.length() && !m_aborted) {
+ char s = m_buffer[m_scanIndex];
+ if (s == '\r' || s == '\n') {
+ int l = m_scanIndex - processedBytes;
+ if (l > 0) {
+ if (!processLine(processedBytes, l))
+ break;
+ }
+ processedBytes = m_scanIndex + 1;
+ if (!m_stream) {
+ // some error happened, so exit parsing
+ return;
+ }
+ }
+ m_scanIndex++;
+ }
+
+ if (m_aborted)
+ break;
+
+ if (m_buffer.length() - processedBytes >= LINE_LIMIT) {
+ emit q->error(QMediaPlaylist::FormatError,
+ QMediaPlaylist::tr("invalid line in playlist file"));
+ q->abort();
+ break;
+ }
+
+ if (!m_stream->bytesAvailable() && (!m_source || !m_source->isFinished())) {
+ // last line
+ processLine(processedBytes, -1);
+ break;
+ }
+
+ Q_ASSERT(m_buffer.length() == m_scanIndex);
+ if (processedBytes == 0)
+ continue;
+
+ int copyLength = m_buffer.length() - processedBytes;
+ if (copyLength > 0) {
+ Q_ASSERT(copyLength <= READ_LIMIT);
+ m_buffer = m_buffer.right(copyLength);
+ } else {
+ m_buffer.clear();
+ }
+ m_scanIndex = 0;
+ }
+
+ handleParserFinished();
+}
+
+QPlaylistFileParser::QPlaylistFileParser(QObject *parent)
+ : QObject(parent), d_ptr(new QPlaylistFileParserPrivate(this))
+{
+}
+
+QPlaylistFileParser::~QPlaylistFileParser() = default;
+
+QPlaylistFileParser::FileType QPlaylistFileParser::findByMimeType(const QString &mime)
+{
+ if (mime == QLatin1String("text/uri-list") || mime == QLatin1String("audio/x-mpegurl")
+ || mime == QLatin1String("audio/mpegurl"))
+ return QPlaylistFileParser::M3U;
+
+ if (mime == QLatin1String("application/x-mpegURL")
+ || mime == QLatin1String("application/vnd.apple.mpegurl"))
+ return QPlaylistFileParser::M3U8;
+
+ if (mime == QLatin1String("audio/x-scpls"))
+ return QPlaylistFileParser::PLS;
+
+ return QPlaylistFileParser::UNKNOWN;
+}
+
+QPlaylistFileParser::FileType QPlaylistFileParser::findBySuffixType(const QString &suffix)
+{
+ const QString &s = suffix.toLower();
+
+ if (s == QLatin1String("m3u"))
+ return QPlaylistFileParser::M3U;
+
+ if (s == QLatin1String("m3u8"))
+ return QPlaylistFileParser::M3U8;
+
+ if (s == QLatin1String("pls"))
+ return QPlaylistFileParser::PLS;
+
+ return QPlaylistFileParser::UNKNOWN;
+}
+
+QPlaylistFileParser::FileType QPlaylistFileParser::findByDataHeader(const char *data, quint32 size)
+{
+ if (!data || size == 0)
+ return QPlaylistFileParser::UNKNOWN;
+
+ if (size >= 7 && strncmp(data, "#EXTM3U", 7) == 0)
+ return QPlaylistFileParser::M3U;
+
+ if (size >= 10 && strncmp(data, "[playlist]", 10) == 0)
+ return QPlaylistFileParser::PLS;
+
+ return QPlaylistFileParser::UNKNOWN;
+}
+
+QPlaylistFileParser::FileType QPlaylistFileParser::findPlaylistType(const QString &suffix,
+ const QString &mime,
+ const char *data, quint32 size)
+{
+
+ FileType dataHeaderType = findByDataHeader(data, size);
+ if (dataHeaderType != UNKNOWN)
+ return dataHeaderType;
+
+ FileType mimeType = findByMimeType(mime);
+ if (mimeType != UNKNOWN)
+ return mimeType;
+
+ mimeType = findBySuffixType(mime);
+ if (mimeType != UNKNOWN)
+ return mimeType;
+
+ FileType suffixType = findBySuffixType(suffix);
+ if (suffixType != UNKNOWN)
+ return suffixType;
+
+ return UNKNOWN;
+}
+
+/*
+ * Delegating
+ */
+void QPlaylistFileParser::start(const QUrl &media, QIODevice *stream, const QString &mimeType)
+{
+ if (stream)
+ start(stream, mimeType);
+ else
+ start(media, mimeType);
+}
+
+void QPlaylistFileParser::start(QIODevice *stream, const QString &mimeType)
+{
+ Q_D(QPlaylistFileParser);
+ const bool validStream = stream ? (stream->isOpen() && stream->isReadable()) : false;
+
+ if (!validStream) {
+ Q_EMIT error(QMediaPlaylist::AccessDeniedError, QMediaPlaylist::tr("Invalid stream"));
+ return;
+ }
+
+ if (!d->m_currentParser.isNull()) {
+ abort();
+ d->m_pendingJob = { stream, QUrl(), mimeType };
+ return;
+ }
+
+ playlist.clear();
+ d->reset();
+ d->m_mimeType = mimeType;
+ d->m_stream = stream;
+ connect(d->m_stream, SIGNAL(readyRead()), this, SLOT(handleData()));
+ d->handleData();
+}
+
+void QPlaylistFileParser::start(const QUrl &request, const QString &mimeType)
+{
+ Q_D(QPlaylistFileParser);
+ const QUrl &url = request.url();
+
+ if (url.isLocalFile() && !QFile::exists(url.toLocalFile())) {
+ emit error(QMediaPlaylist::AccessDeniedError,
+ QString(QMediaPlaylist::tr("%1 does not exist")).arg(url.toString()));
+ return;
+ }
+
+ if (!d->m_currentParser.isNull()) {
+ abort();
+ d->m_pendingJob = { nullptr, request, mimeType };
+ return;
+ }
+
+ d->reset();
+ d->m_root = url;
+ d->m_mimeType = mimeType;
+ d->m_source.reset(d->m_mgr.get(QNetworkRequest(request)));
+ d->m_stream = d->m_source.get();
+ connect(d->m_source.data(), SIGNAL(readyRead()), this, SLOT(handleData()));
+ connect(d->m_source.data(), SIGNAL(finished()), this, SLOT(handleData()));
+ connect(d->m_source.data(), SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this,
+ SLOT(handleError()));
+
+ if (url.isLocalFile())
+ d->handleData();
+}
+
+void QPlaylistFileParser::abort()
+{
+ Q_D(QPlaylistFileParser);
+ d->abort();
+
+ if (d->m_source)
+ d->m_source->disconnect();
+
+ if (d->m_stream)
+ disconnect(d->m_stream, SIGNAL(readyRead()), this, SLOT(handleData()));
+
+ playlist.clear();
+}
+
+void QPlaylistFileParser::handleData()
+{
+ Q_D(QPlaylistFileParser);
+ d->handleData();
+}
+
+void QPlaylistFileParserPrivate::handleParserFinished()
+{
+ Q_Q(QPlaylistFileParser);
+ const bool isParserValid = !m_currentParser.isNull();
+ if (!isParserValid && !m_aborted)
+ emit q->error(QMediaPlaylist::FormatNotSupportedError,
+ QMediaPlaylist::tr("Empty file provided"));
+
+ if (isParserValid && !m_aborted) {
+ m_currentParser.reset();
+ emit q->finished();
+ }
+
+ if (!m_aborted)
+ q->abort();
+
+ if (!m_source.isNull())
+ m_source.reset();
+
+ if (m_pendingJob.isValid())
+ q->start(m_pendingJob.m_media, m_pendingJob.m_stream, m_pendingJob.m_mimeType);
+}
+
+void QPlaylistFileParserPrivate::abort()
+{
+ m_aborted = true;
+ if (!m_currentParser.isNull())
+ m_currentParser->abort();
+}
+
+void QPlaylistFileParserPrivate::reset()
+{
+ Q_ASSERT(m_currentParser.isNull());
+ Q_ASSERT(m_source.isNull());
+ m_buffer.clear();
+ m_root.clear();
+ m_mimeType.clear();
+ m_stream = nullptr;
+ m_type = QPlaylistFileParser::UNKNOWN;
+ m_scanIndex = 0;
+ m_lineIndex = -1;
+ m_utf8 = false;
+ m_aborted = false;
+ m_pendingJob.reset();
+}
+
+void QPlaylistFileParser::handleError()
+{
+ Q_D(QPlaylistFileParser);
+ const QString &errorString = d->m_source->errorString();
+ Q_EMIT error(QMediaPlaylist::NetworkError, errorString);
+ abort();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qplaylistfileparser.cpp"
diff --git a/examples/multimedia/player/qplaylistfileparser.h b/examples/multimedia/player/qplaylistfileparser.h
new file mode 100644
index 000000000..0d83289c4
--- /dev/null
+++ b/examples/multimedia/player/qplaylistfileparser.h
@@ -0,0 +1,76 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PLAYLISTFILEPARSER_P_H
+#define PLAYLISTFILEPARSER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmediaplaylist.h"
+#include "qtmultimediaglobal.h"
+
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QIODevice;
+class QUrl;
+class QNetworkRequest;
+
+class QPlaylistFileParserPrivate;
+
+class QPlaylistFileParser : public QObject
+{
+ Q_OBJECT
+public:
+ QPlaylistFileParser(QObject *parent = nullptr);
+ ~QPlaylistFileParser();
+
+ enum FileType {
+ UNKNOWN,
+ M3U,
+ M3U8, // UTF-8 version of M3U
+ PLS
+ };
+
+ void start(const QUrl &media, QIODevice *stream = nullptr, const QString &mimeType = QString());
+ void start(const QUrl &request, const QString &mimeType = QString());
+ void start(QIODevice *stream, const QString &mimeType = QString());
+ void abort();
+
+ QList<QUrl> playlist;
+
+signals:
+ void newItem(const QVariant &content);
+ void finished();
+ void error(QMediaPlaylist::Error err, const QString &errorMsg);
+
+private slots:
+ void handleData();
+ void handleError();
+
+private:
+ static FileType findByMimeType(const QString &mime);
+ static FileType findBySuffixType(const QString &suffix);
+ static FileType findByDataHeader(const char *data, quint32 size);
+ static FileType findPlaylistType(QIODevice *device, const QString &mime);
+ static FileType findPlaylistType(const QString &suffix, const QString &mime,
+ const char *data = nullptr, quint32 size = 0);
+
+ Q_DISABLE_COPY(QPlaylistFileParser)
+ Q_DECLARE_PRIVATE(QPlaylistFileParser)
+ QScopedPointer<QPlaylistFileParserPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // PLAYLISTFILEPARSER_P_H
diff --git a/examples/multimedia/player/videowidget.cpp b/examples/multimedia/player/videowidget.cpp
new file mode 100644
index 000000000..c09d90f37
--- /dev/null
+++ b/examples/multimedia/player/videowidget.cpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videowidget.h"
+
+#include <QKeyEvent>
+#include <QMouseEvent>
+
+VideoWidget::VideoWidget(QWidget *parent) : QVideoWidget(parent)
+{
+ setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+
+ QPalette p = palette();
+ p.setColor(QPalette::Window, Qt::black);
+ setPalette(p);
+
+#ifndef Q_OS_ANDROID // QTBUG-95723
+ setAttribute(Qt::WA_OpaquePaintEvent);
+#endif
+}
+
+void VideoWidget::keyPressEvent(QKeyEvent *event)
+{
+ if ((event->key() == Qt::Key_Escape || event->key() == Qt::Key_Back) && isFullScreen()) {
+ setFullScreen(false);
+ event->accept();
+ } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
+ setFullScreen(!isFullScreen());
+ event->accept();
+ } else {
+ QVideoWidget::keyPressEvent(event);
+ }
+}
+
+void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ setFullScreen(!isFullScreen());
+ event->accept();
+}
+
+void VideoWidget::mousePressEvent(QMouseEvent *event)
+{
+ QVideoWidget::mousePressEvent(event);
+}
+
+#include "moc_videowidget.cpp"
diff --git a/examples/multimedia/player/videowidget.h b/examples/multimedia/player/videowidget.h
new file mode 100644
index 000000000..3505a3fb8
--- /dev/null
+++ b/examples/multimedia/player/videowidget.h
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOWIDGET_H
+#define VIDEOWIDGET_H
+
+#include <QVideoWidget>
+
+class VideoWidget : public QVideoWidget
+{
+ Q_OBJECT
+
+public:
+ explicit VideoWidget(QWidget *parent = nullptr);
+
+protected:
+ void keyPressEvent(QKeyEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+};
+
+#endif // VIDEOWIDGET_H
diff --git a/examples/multimedia/screencapture/CMakeLists.txt b/examples/multimedia/screencapture/CMakeLists.txt
new file mode 100644
index 000000000..69ebf8d27
--- /dev/null
+++ b/examples/multimedia/screencapture/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(screencapture VERSION 0.1 LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
+find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS MultimediaWidgets Widgets)
+
+set(PROJECT_SOURCES
+ screencapture.pro
+ main.cpp
+ screencapturepreview.cpp
+ screencapturepreview.h
+ screenlistmodel.h
+ screenlistmodel.cpp
+ windowlistmodel.h
+ windowlistmodel.cpp
+)
+
+qt_add_executable(screencapture
+ MANUAL_FINALIZATION
+ ${PROJECT_SOURCES}
+ )
+
+target_link_libraries(screencapture PRIVATE
+ Qt${QT_VERSION_MAJOR}::Core
+ Qt${QT_VERSION_MAJOR}::Gui
+ Qt${QT_VERSION_MAJOR}::Widgets
+ Qt${QT_VERSION_MAJOR}::Multimedia
+ Qt${QT_VERSION_MAJOR}::MultimediaWidgets)
+
+set_target_properties(screencapture PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+ MACOSX_BUNDLE TRUE
+ WIN32_EXECUTABLE TRUE
+)
+
+install(TARGETS screencapture
+ BUNDLE DESTINATION .
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+qt_finalize_executable(screencapture)
diff --git a/examples/multimedia/screencapture/Info.plist.in b/examples/multimedia/screencapture/Info.plist.in
new file mode 100644
index 000000000..02c09f852
--- /dev/null
+++ b/examples/multimedia/screencapture/Info.plist.in
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/screencapture/doc/images/screencapture.jpg b/examples/multimedia/screencapture/doc/images/screencapture.jpg
new file mode 100644
index 000000000..fb61fcd73
--- /dev/null
+++ b/examples/multimedia/screencapture/doc/images/screencapture.jpg
Binary files differ
diff --git a/examples/multimedia/screencapture/doc/src/screencapture.qdoc b/examples/multimedia/screencapture/doc/src/screencapture.qdoc
new file mode 100644
index 000000000..405c59dbd
--- /dev/null
+++ b/examples/multimedia/screencapture/doc/src/screencapture.qdoc
@@ -0,0 +1,48 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example screencapture
+ \title Screen Capture Example
+ \ingroup multimedia_examples
+ \examplecategory {Multimedia}
+ \brief Capturing a screen or window.
+ \meta {tag} {widgets}
+
+ \e{Screen Capture} demonstrates how to capture a screen or window using
+ QScreenCapture and QWindowCapture. The example shows a list of screens and
+ windows and displays a live preview of the selected item using a
+ QMediaCaptureSession and a QVideoWidget. Capturing can be started and stopped
+ with a \l{QPushButton}{button}.
+
+ \image screencapture.jpg
+
+ \include examples-run.qdocinc
+
+ \section1 Application Structure
+
+ The example consists of three custom classes. The UI and all screen capture
+ functionality is implemented in the class ScreenCapturePreview. The classes
+ ScreenListModel and WindowListModel only serve as models behind the two
+ QListView widgets. The main function creates a ScreenCapturePreview object,
+ which in turn creates instances of QScreenCapture and QWindowCapture,
+ and a QMediaCaptureSession and QVideoWidget, in addition to all the UI widgets.
+
+ The screen and window models are populated with the return values of
+ \l QGuiApplication::screens() and \l QWindowCapture::capturableWindows(),
+ respectively.
+
+ When a list item is selected, it is connected to the QScreenCapture object
+ with \l{QScreenCapture::}{setScreen()}, or to the QWindowCapture object
+ with \l{QWindowCapture::}{setWindow()}. The capture object is connected to
+ the QMediaCaptureSession object with \l{QMediaCaptureSession::}{setScreenCapture()}
+ and \l{QMediaCaptureSession::}{setWindowCapture()}, respectively.
+ The capture session in turn is connected to the QVideoWidget object with
+ \l{QMediaCaptureSession::}{setVideoOutput()}. Thus, the capture output is
+ previewed in the video widget on the right hand side of the UI.
+
+ The start/stop button calls \l QScreenCapture::start() and \l QScreenCapture::stop(),
+ or \l QWindowCapture::start() and \l QWindowCapture::stop().
+
+ A QMessageBox pops up if the \l{QScreenCapture::}{errorOccurred} signal is emitted.
+*/
diff --git a/examples/multimedia/screencapture/main.cpp b/examples/multimedia/screencapture/main.cpp
new file mode 100644
index 000000000..6ed104f3e
--- /dev/null
+++ b/examples/multimedia/screencapture/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "screencapturepreview.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ ScreenCapturePreview screenCapturePreview;
+ screenCapturePreview.show();
+ return app.exec();
+}
diff --git a/examples/multimedia/screencapture/screencapture.pro b/examples/multimedia/screencapture/screencapture.pro
new file mode 100644
index 000000000..d18f556ee
--- /dev/null
+++ b/examples/multimedia/screencapture/screencapture.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = screencapture
+
+QT += multimedia multimediawidgets
+
+HEADERS = \
+ screencapturepreview.h \
+ screenlistmodel.h \
+ windowlistmodel.h
+
+SOURCES = \
+ main.cpp \
+ screencapturepreview.cpp \
+ screenlistmodel.cpp \
+ windowlistmodel.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/screencapture
+INSTALLS += target
diff --git a/examples/multimedia/screencapture/screencapturepreview.cpp b/examples/multimedia/screencapture/screencapturepreview.cpp
new file mode 100644
index 000000000..6eda008a8
--- /dev/null
+++ b/examples/multimedia/screencapture/screencapturepreview.cpp
@@ -0,0 +1,179 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "screencapturepreview.h"
+#include "screenlistmodel.h"
+#include "windowlistmodel.h"
+
+#include <QMediaCaptureSession>
+#include <QScreenCapture>
+#include <QVideoWidget>
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QAction>
+
+ScreenCapturePreview::ScreenCapturePreview(QWidget *parent)
+ : QWidget(parent),
+ screenListView(new QListView(this)),
+ windowListView(new QListView(this)),
+ screenCapture(new QScreenCapture(this)),
+ windowCapture(new QWindowCapture(this)),
+ mediaCaptureSession(new QMediaCaptureSession(this)),
+ videoWidget(new QVideoWidget(this)),
+ gridLayout(new QGridLayout(this)),
+ startStopButton(new QPushButton(this)),
+ screenLabel(new QLabel(tr("Select screen to capture:"), this)),
+ windowLabel(new QLabel(tr("Select window to capture:"), this)),
+ videoWidgetLabel(new QLabel(tr("Capture output:"), this))
+{
+ // Get lists of screens and windows:
+ screenListModel = new ScreenListModel(this);
+ windowListModel = new WindowListModel(this);
+
+ // Setup QScreenCapture with initial source:
+
+ mediaCaptureSession->setScreenCapture(screenCapture);
+ mediaCaptureSession->setWindowCapture(windowCapture);
+ mediaCaptureSession->setVideoOutput(videoWidget);
+
+ // Setup UI:
+
+ screenListView->setModel(screenListModel);
+ windowListView->setModel(windowListModel);
+
+ auto updateAction = new QAction(tr("Update Windows List"), this);
+ connect(updateAction, &QAction::triggered, windowListModel, &WindowListModel::populate);
+ windowListView->addAction(updateAction);
+ windowListView->setContextMenuPolicy(Qt::ActionsContextMenu);
+
+ gridLayout->addWidget(screenLabel, 0, 0);
+ gridLayout->addWidget(screenListView, 1, 0);
+ gridLayout->addWidget(windowLabel, 2, 0);
+ gridLayout->addWidget(windowListView, 3, 0);
+ gridLayout->addWidget(startStopButton, 4, 0);
+ gridLayout->addWidget(videoWidgetLabel, 0, 1);
+ gridLayout->addWidget(videoWidget, 1, 1, 4, 1);
+
+ gridLayout->setColumnStretch(1, 1);
+ gridLayout->setRowStretch(1, 1);
+ gridLayout->setColumnMinimumWidth(0, 400);
+ gridLayout->setColumnMinimumWidth(1, 400);
+ gridLayout->setRowMinimumHeight(3, 1);
+
+ connect(screenListView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
+ &ScreenCapturePreview::onCurrentScreenSelectionChanged);
+ connect(windowListView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
+ &ScreenCapturePreview::onCurrentWindowSelectionChanged);
+ connect(startStopButton, &QPushButton::clicked, this,
+ &ScreenCapturePreview::onStartStopButtonClicked);
+ connect(screenCapture, &QScreenCapture::errorChanged, this,
+ &ScreenCapturePreview::onScreenCaptureErrorChanged, Qt::QueuedConnection);
+ connect(windowCapture, &QWindowCapture::errorChanged, this,
+ &ScreenCapturePreview::onWindowCaptureErrorChanged, Qt::QueuedConnection);
+
+ updateActive(SourceType::Screen, true);
+}
+
+ScreenCapturePreview::~ScreenCapturePreview() = default;
+
+void ScreenCapturePreview::onCurrentScreenSelectionChanged(QItemSelection selection)
+{
+ if (auto indexes = selection.indexes(); !indexes.empty()) {
+ screenCapture->setScreen(screenListModel->screen(indexes.front()));
+ updateActive(SourceType::Screen, isActive());
+
+ windowListView->clearSelection();
+ } else {
+ screenCapture->setScreen(nullptr);
+ }
+}
+
+void ScreenCapturePreview::onCurrentWindowSelectionChanged(QItemSelection selection)
+{
+ if (auto indexes = selection.indexes(); !indexes.empty()) {
+ auto window = windowListModel->window(indexes.front());
+ if (!window.isValid()) {
+ const auto questionResult = QMessageBox::question(
+ this, tr("Invalid window"),
+ tr("The window is no longer valid. Update the list of windows?"));
+ if (questionResult == QMessageBox::Yes) {
+ updateActive(SourceType::Window, false);
+
+ windowListView->clearSelection();
+ windowListModel->populate();
+ return;
+ }
+ }
+
+ windowCapture->setWindow(window);
+ updateActive(SourceType::Window, isActive());
+
+ screenListView->clearSelection();
+ } else {
+ windowCapture->setWindow({});
+ }
+}
+
+void ScreenCapturePreview::onWindowCaptureErrorChanged()
+{
+ if (windowCapture->error() == QWindowCapture::NoError)
+ return;
+
+ QMessageBox::warning(this, tr("QWindowCapture: Error occurred"), windowCapture->errorString());
+}
+
+void ScreenCapturePreview::onScreenCaptureErrorChanged()
+{
+ if (screenCapture->error() == QScreenCapture::NoError)
+ return;
+
+ QMessageBox::warning(this, tr("QScreenCapture: Error occurred"), screenCapture->errorString());
+}
+
+void ScreenCapturePreview::onStartStopButtonClicked()
+{
+ updateActive(sourceType, !isActive());
+}
+
+void ScreenCapturePreview::updateStartStopButtonText()
+{
+ switch (sourceType) {
+ case SourceType::Window:
+ startStopButton->setText(isActive() ? tr("Stop window capture")
+ : tr("Start window capture"));
+ break;
+ case SourceType::Screen:
+ startStopButton->setText(isActive() ? tr("Stop screen capture")
+ : tr("Start screen capture"));
+ break;
+ }
+}
+
+void ScreenCapturePreview::updateActive(SourceType sourceType, bool active)
+{
+ this->sourceType = sourceType;
+
+ screenCapture->setActive(active && sourceType == SourceType::Screen);
+ windowCapture->setActive(active && sourceType == SourceType::Window);
+
+ updateStartStopButtonText();
+}
+
+bool ScreenCapturePreview::isActive() const
+{
+ switch (sourceType) {
+ case SourceType::Window:
+ return windowCapture->isActive();
+ case SourceType::Screen:
+ return screenCapture->isActive();
+ default:
+ return false;
+ }
+}
+
+#include "moc_screencapturepreview.cpp"
diff --git a/examples/multimedia/screencapture/screencapturepreview.h b/examples/multimedia/screencapture/screencapturepreview.h
new file mode 100644
index 000000000..7f0e46491
--- /dev/null
+++ b/examples/multimedia/screencapture/screencapturepreview.h
@@ -0,0 +1,67 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SCREENCAPTUREPREVIEW_H
+#define SCREENCAPTUREPREVIEW_H
+
+#include <QScreenCapture>
+#include <QWindowCapture>
+#include <QWidget>
+#include <QItemSelection>
+
+class ScreenListModel;
+class WindowListModel;
+
+QT_BEGIN_NAMESPACE
+class QListView;
+class QMediaCaptureSession;
+class QVideoWidget;
+class QGridLayout;
+class QHBoxLayout;
+class QLineEdit;
+class QPushButton;
+class QLabel;
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class ScreenCapturePreview : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit ScreenCapturePreview(QWidget *parent = nullptr);
+ ~ScreenCapturePreview() override;
+
+private slots:
+ void onCurrentScreenSelectionChanged(QItemSelection index);
+ void onCurrentWindowSelectionChanged(QItemSelection index);
+ void onWindowCaptureErrorChanged();
+ void onScreenCaptureErrorChanged();
+ void onStartStopButtonClicked();
+
+private:
+ enum class SourceType { Screen, Window };
+
+ void updateActive(SourceType sourceType, bool active);
+ void updateStartStopButtonText();
+ bool isActive() const;
+
+private:
+ ScreenListModel *screenListModel = nullptr;
+ WindowListModel *windowListModel = nullptr;
+ QListView *screenListView = nullptr;
+ QListView *windowListView = nullptr;
+ QScreenCapture *screenCapture = nullptr;
+ QWindowCapture *windowCapture = nullptr;
+ QMediaCaptureSession *mediaCaptureSession = nullptr;
+ QVideoWidget *videoWidget = nullptr;
+ QGridLayout *gridLayout = nullptr;
+ QPushButton *startStopButton = nullptr;
+ QLabel *screenLabel = nullptr;
+ QLabel *windowLabel = nullptr;
+ QLabel *videoWidgetLabel = nullptr;
+ SourceType sourceType = SourceType::Screen;
+};
+
+#endif // SCREENCAPTUREPREVIEW_H
diff --git a/examples/multimedia/screencapture/screenlistmodel.cpp b/examples/multimedia/screencapture/screenlistmodel.cpp
new file mode 100644
index 000000000..0b46560cc
--- /dev/null
+++ b/examples/multimedia/screencapture/screenlistmodel.cpp
@@ -0,0 +1,54 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "screenlistmodel.h"
+
+#include <QGuiApplication>
+#include <QScreen>
+
+#include <QTextStream>
+
+ScreenListModel::ScreenListModel(QObject *parent) :
+ QAbstractListModel(parent)
+{
+ auto *app = qApp;
+ connect(app, &QGuiApplication::screenAdded, this, &ScreenListModel::screensChanged);
+ connect(app, &QGuiApplication::screenRemoved, this, &ScreenListModel::screensChanged);
+ connect(app, &QGuiApplication::primaryScreenChanged, this, &ScreenListModel::screensChanged);
+}
+
+int ScreenListModel::rowCount(const QModelIndex &) const
+{
+ return QGuiApplication::screens().size();
+}
+
+QVariant ScreenListModel::data(const QModelIndex &index, int role) const
+{
+ const auto screenList = QGuiApplication::screens();
+ Q_ASSERT(index.isValid());
+ Q_ASSERT(index.row() <= screenList.size());
+
+ if (role == Qt::DisplayRole) {
+ auto *screen = screenList.at(index.row());
+ QString description;
+ QTextStream str(&description);
+ str << '"' << screen->name() << "\" " << screen->size().width() << 'x'
+ << screen->size().height() << ", " << screen->logicalDotsPerInch() << "DPI";
+ return description;
+ }
+
+ return {};
+}
+
+QScreen *ScreenListModel::screen(const QModelIndex &index) const
+{
+ return QGuiApplication::screens().value(index.row());
+}
+
+void ScreenListModel::screensChanged()
+{
+ beginResetModel();
+ endResetModel();
+}
+
+#include "moc_screenlistmodel.cpp"
diff --git a/examples/multimedia/screencapture/screenlistmodel.h b/examples/multimedia/screencapture/screenlistmodel.h
new file mode 100644
index 000000000..3bfa30b8f
--- /dev/null
+++ b/examples/multimedia/screencapture/screenlistmodel.h
@@ -0,0 +1,30 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SCREENLISTMODEL_H
+#define SCREENLISTMODEL_H
+
+#include <QAbstractListModel>
+
+QT_BEGIN_NAMESPACE
+class QScreen;
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class ScreenListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ explicit ScreenListModel(QObject *parent = nullptr);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QScreen *screen(const QModelIndex &index) const;
+
+private Q_SLOTS:
+ void screensChanged();
+};
+
+#endif // SCREENLISTMODEL_H
diff --git a/examples/multimedia/screencapture/windowlistmodel.cpp b/examples/multimedia/screencapture/windowlistmodel.cpp
new file mode 100644
index 000000000..45b8ceabd
--- /dev/null
+++ b/examples/multimedia/screencapture/windowlistmodel.cpp
@@ -0,0 +1,42 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "windowlistmodel.h"
+#include <QWindowCapture>
+
+WindowListModel::WindowListModel(QObject *parent)
+ : QAbstractListModel(parent), windowList(QWindowCapture::capturableWindows())
+{
+}
+
+int WindowListModel::rowCount(const QModelIndex &) const
+{
+ return windowList.size();
+}
+
+QVariant WindowListModel::data(const QModelIndex &index, int role) const
+{
+ Q_ASSERT(index.isValid());
+ Q_ASSERT(index.row() <= windowList.size());
+
+ if (role == Qt::DisplayRole) {
+ auto window = windowList.at(index.row());
+ return window.description();
+ }
+
+ return {};
+}
+
+QCapturableWindow WindowListModel::window(const QModelIndex &index) const
+{
+ return windowList.at(index.row());
+}
+
+void WindowListModel::populate()
+{
+ beginResetModel();
+ windowList = QWindowCapture::capturableWindows();
+ endResetModel();
+}
+
+#include "moc_windowlistmodel.cpp"
diff --git a/examples/multimedia/screencapture/windowlistmodel.h b/examples/multimedia/screencapture/windowlistmodel.h
new file mode 100644
index 000000000..caccbb0de
--- /dev/null
+++ b/examples/multimedia/screencapture/windowlistmodel.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef WINDOWLISTMODEL_H
+#define WINDOWLISTMODEL_H
+
+#include <QAbstractListModel>
+#include <QCapturableWindow>
+
+QT_USE_NAMESPACE
+
+class WindowListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ explicit WindowListModel(QObject *parent = nullptr);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+
+ QCapturableWindow window(const QModelIndex &index) const;
+
+public Q_SLOTS:
+ void populate();
+
+private:
+ QList<QCapturableWindow> windowList;
+};
+
+#endif // WINDOWLISTMODEL_H
diff --git a/examples/multimedia/shared/shared.pri b/examples/multimedia/shared/shared.pri
index cb70f2b49..16239013d 100644
--- a/examples/multimedia/shared/shared.pri
+++ b/examples/multimedia/shared/shared.pri
@@ -1,4 +1,4 @@
-darwin {
+ios {
PRODUCT_NAME = $$TARGET
macx-xcode: PRODUCT_NAME = $${LITERAL_DOLLAR}{PRODUCT_NAME}
INFOPLIST = \
@@ -17,7 +17,7 @@ darwin {
" <key>CFBundleExecutable</key>" \
" <string>$$TARGET</string>" \
" <key>CFBundleIdentifier</key>" \
- " <string>com.digia.$${LITERAL_DOLLAR}{PRODUCT_NAME:rfc1034identifier}</string>" \
+ " <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>" \
" <key>CFBundleDisplayName</key>" \
" <string>$$PRODUCT_NAME</string>" \
" <key>CFBundleName</key>" \
@@ -48,3 +48,45 @@ darwin {
write_file($$OUT_PWD/Info.plist, INFOPLIST)|error()
QMAKE_INFO_PLIST = $$OUT_PWD/Info.plist
}
+
+macos {
+ PRODUCT_NAME = $$TARGET
+ macx-xcode: PRODUCT_NAME = $${LITERAL_DOLLAR}{PRODUCT_NAME}
+ INFOPLIST = \
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" \
+ "<plist version=\"1.0\">" \
+ "<dict>" \
+ " <key>CFBundleIconFile</key>" \
+ " <string></string>" \
+ " <key>CFBundlePackageType</key>" \
+ " <string>APPL</string>" \
+ " <key>CFBundleGetInfoString</key>" \
+ " <string>Created by Qt/QMake</string>" \
+ " <key>CFBundleSignature</key>" \
+ " <string>????</string>" \
+ " <key>CFBundleExecutable</key>" \
+ " <string>$$TARGET</string>" \
+ " <key>CFBundleIdentifier</key>" \
+ " <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>" \
+ " <key>CFBundleDisplayName</key>" \
+ " <string>$$PRODUCT_NAME</string>" \
+ " <key>CFBundleName</key>" \
+ " <string>$$PRODUCT_NAME</string>" \
+ " <key>CFBundleShortVersionString</key>" \
+ " <string>1.0</string>" \
+ " <key>CFBundleVersion</key>" \
+ " <string>1.0</string>" \
+ " <key>NSPrincipalClass</key>" \
+ " <string>NSApplication</string>" \
+ " <key>NSCameraUsageDescription</key>" \
+ " <string>Qt Multimedia Example</string>" \
+ " <key>NSMicrophoneUsageDescription</key>" \
+ " <string>Qt Multimedia Example</string>" \
+ " <key>NOTE</key>" \
+ " <string>This file was generated by Qt/QMake.</string>" \
+ "</dict>" \
+ "</plist>"
+ write_file($$OUT_PWD/Info.plist, INFOPLIST)|error()
+ QMAKE_INFO_PLIST = $$OUT_PWD/Info.plist
+}
diff --git a/examples/multimedia/spectrum/3rdparty/fftreal/CMakeLists.txt b/examples/multimedia/spectrum/3rdparty/fftreal/CMakeLists.txt
new file mode 100644
index 000000000..6c2af7a83
--- /dev/null
+++ b/examples/multimedia/spectrum/3rdparty/fftreal/CMakeLists.txt
@@ -0,0 +1,27 @@
+find_package(Qt6 REQUIRED COMPONENTS Core)
+
+add_library(fftreal STATIC
+ Array.h Array.hpp
+ DynArray.h DynArray.hpp
+ FFTRealFixLen.h FFTRealFixLen.hpp
+ FFTRealFixLenParam.h
+ FFTRealPassDirect.h FFTRealPassDirect.hpp
+ FFTRealPassInverse.h FFTRealPassInverse.hpp
+ FFTRealSelect.h FFTRealSelect.hpp
+ FFTRealUseTrigo.h FFTRealUseTrigo.hpp
+ OscSinCos.h OscSinCos.hpp
+ def.h
+ fftreal_wrapper.cpp fftreal_wrapper.h
+)
+
+target_compile_definitions(fftreal PRIVATE
+ FFTREAL_LIBRARY
+ LOG_ENGINE
+ LOG_SPECTRUMANALYSER
+ SPECTRUM_ANALYSER_SEPARATE_THREAD
+ SUPERIMPOSE_PROGRESS_ON_WAVEFORM
+)
+
+target_link_libraries(fftreal PRIVATE Qt6::Core)
+
+target_include_directories(fftreal INTERFACE .)
diff --git a/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro b/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro
index b2c96f96c..0b36ee7d1 100644
--- a/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro
+++ b/examples/multimedia/spectrum/3rdparty/fftreal/fftreal.pro
@@ -1,8 +1,7 @@
include(../../spectrum.pri)
-static: error(This library cannot be built for static linkage)
-
TEMPLATE = lib
+CONFIG += static
TARGET = fftreal
# FFTReal
@@ -24,18 +23,14 @@ HEADERS += Array.h \
OscSinCos.h \
OscSinCos.hpp \
def.h
-
+
# Wrapper used to export the required instantiation of the FFTRealFixLen template
HEADERS += fftreal_wrapper.h
SOURCES += fftreal_wrapper.cpp
DEFINES += FFTREAL_LIBRARY
-macx {
- CONFIG += lib_bundle
-} else {
- DESTDIR = ../..$${spectrum_build_dir}
-}
+DESTDIR = ../..$${spectrum_build_dir}
EXAMPLE_FILES = bwins/fftreal.def eabi/fftreal.def readme.txt license.txt
diff --git a/examples/multimedia/spectrum/3rdparty/fftreal/fftreal_wrapper.h b/examples/multimedia/spectrum/3rdparty/fftreal/fftreal_wrapper.h
index 2da3147ac..1b92d8e65 100644
--- a/examples/multimedia/spectrum/3rdparty/fftreal/fftreal_wrapper.h
+++ b/examples/multimedia/spectrum/3rdparty/fftreal/fftreal_wrapper.h
@@ -22,12 +22,6 @@
#include <QtCore/QtGlobal>
-#if defined(FFTREAL_LIBRARY)
-# define FFTREAL_EXPORT Q_DECL_EXPORT
-#else
-# define FFTREAL_EXPORT Q_DECL_IMPORT
-#endif
-
class FFTRealWrapperPrivate;
// Each pass of the FFT processes 2^X samples, where X is the
@@ -46,7 +40,7 @@ static const int FFTLengthPowerOfTwo = 12;
*
* See http://ldesoras.free.fr/prod.html
*/
-class FFTREAL_EXPORT FFTRealWrapper
+class FFTRealWrapper
{
public:
FFTRealWrapper();
diff --git a/examples/multimedia/spectrum/CMakeLists.txt b/examples/multimedia/spectrum/CMakeLists.txt
new file mode 100644
index 000000000..faabe9c27
--- /dev/null
+++ b/examples/multimedia/spectrum/CMakeLists.txt
@@ -0,0 +1,67 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(spectrum LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/spectrum")
+
+find_package(Qt6 REQUIRED COMPONENTS Multimedia Widgets)
+
+add_subdirectory(3rdparty/fftreal)
+
+qt_add_executable(spectrum
+ engine.cpp engine.h
+ frequencyspectrum.cpp frequencyspectrum.h
+ levelmeter.cpp levelmeter.h
+ main.cpp
+ mainwidget.cpp mainwidget.h
+ progressbar.cpp progressbar.h
+ settingsdialog.cpp settingsdialog.h
+ spectrograph.cpp spectrograph.h
+ spectrum.h
+ spectrumanalyser.cpp spectrumanalyser.h
+ tonegenerator.cpp tonegenerator.h
+ tonegeneratordialog.cpp tonegeneratordialog.h
+ utils.cpp utils.h
+ waveform.cpp waveform.h
+)
+
+set_target_properties(spectrum PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+)
+
+target_compile_definitions(spectrum PRIVATE
+ LOG_ENGINE
+ LOG_SPECTRUMANALYSER
+ SPECTRUM_ANALYSER_SEPARATE_THREAD
+ SUPERIMPOSE_PROGRESS_ON_WAVEFORM
+)
+
+target_link_libraries(spectrum PRIVATE
+ Qt6::Multimedia
+ Qt6::Widgets
+ fftreal
+)
+
+qt_add_resources(spectrum "spectrum"
+ PREFIX
+ "/"
+ FILES
+ "images/record.png"
+ "images/settings.png"
+)
+
+install(TARGETS spectrum
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/spectrum/Info.plist.in b/examples/multimedia/spectrum/Info.plist.in
new file mode 100644
index 000000000..d0b9ddd11
--- /dev/null
+++ b/examples/multimedia/spectrum/Info.plist.in
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>Qt ${MACOSX_BUNDLE_BUNDLE_NAME} Example</string>
+ <key>CFBundleIdentifier</key>
+ <string>Qt ${MACOSX_BUNDLE_GUI_IDENTIFIER} Example</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+</dict>
+</plist>
diff --git a/examples/multimedia/spectrum/app.pro b/examples/multimedia/spectrum/app.pro
new file mode 100644
index 000000000..9688940bb
--- /dev/null
+++ b/examples/multimedia/spectrum/app.pro
@@ -0,0 +1,55 @@
+include(spectrum.pri)
+
+TEMPLATE = app
+
+TARGET = spectrum
+
+QT += multimedia widgets
+
+SOURCES += main.cpp \
+ engine.cpp \
+ frequencyspectrum.cpp \
+ levelmeter.cpp \
+ mainwidget.cpp \
+ progressbar.cpp \
+ settingsdialog.cpp \
+ spectrograph.cpp \
+ spectrumanalyser.cpp \
+ tonegenerator.cpp \
+ tonegeneratordialog.cpp \
+ utils.cpp \
+ waveform.cpp \
+
+HEADERS += engine.h \
+ frequencyspectrum.h \
+ levelmeter.h \
+ mainwidget.h \
+ progressbar.h \
+ settingsdialog.h \
+ spectrograph.h \
+ spectrum.h \
+ spectrumanalyser.h \
+ tonegenerator.h \
+ tonegeneratordialog.h \
+ utils.h \
+ waveform.h \
+
+fftreal_dir = 3rdparty/fftreal
+
+INCLUDEPATH += $${fftreal_dir}
+
+RESOURCES = spectrum.qrc
+
+LIBS += -L./$${spectrum_build_dir}
+android:LIBS += -lfftreal_$$QT_ARCH
+else:LIBS += -lfftreal
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/spectrum
+INSTALLS += target
+
+CONFIG += install_ok # Do not cargo-cult this!
+
+# Deployment
+
+DESTDIR = ./$${spectrum_build_dir}
+include(../shared/shared.pri)
diff --git a/examples/multimedia/spectrum/app/.gitignore b/examples/multimedia/spectrum/app/.gitignore
deleted file mode 100644
index 82cf2a28f..000000000
--- a/examples/multimedia/spectrum/app/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-spectrum
-spectrum.exe
diff --git a/examples/multimedia/spectrum/app/app.pro b/examples/multimedia/spectrum/app/app.pro
deleted file mode 100644
index 726ce2d3f..000000000
--- a/examples/multimedia/spectrum/app/app.pro
+++ /dev/null
@@ -1,86 +0,0 @@
-include(../spectrum.pri)
-
-TEMPLATE = app
-
-TARGET = spectrum
-
-QT += multimedia widgets
-
-SOURCES += main.cpp \
- engine.cpp \
- frequencyspectrum.cpp \
- levelmeter.cpp \
- mainwidget.cpp \
- progressbar.cpp \
- settingsdialog.cpp \
- spectrograph.cpp \
- spectrumanalyser.cpp \
- tonegenerator.cpp \
- tonegeneratordialog.cpp \
- utils.cpp \
- waveform.cpp \
- wavfile.cpp
-
-HEADERS += engine.h \
- frequencyspectrum.h \
- levelmeter.h \
- mainwidget.h \
- progressbar.h \
- settingsdialog.h \
- spectrograph.h \
- spectrum.h \
- spectrumanalyser.h \
- tonegenerator.h \
- tonegeneratordialog.h \
- utils.h \
- waveform.h \
- wavfile.h
-
-fftreal_dir = ../3rdparty/fftreal
-
-INCLUDEPATH += $${fftreal_dir}
-
-RESOURCES = spectrum.qrc
-
-# Dynamic linkage against FFTReal DLL
-!contains(DEFINES, DISABLE_FFT) {
- macx {
- # Link to fftreal framework
- LIBS += -F$${fftreal_dir}
- LIBS += -framework fftreal
- } else {
- LIBS += -L..$${spectrum_build_dir}
- LIBS += -lfftreal
- }
-}
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/spectrum
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
-
-# Deployment
-
-DESTDIR = ..$${spectrum_build_dir}
-macx {
- !contains(DEFINES, DISABLE_FFT) {
- # Relocate fftreal.framework into spectrum.app bundle
- framework_dir = ../spectrum.app/Contents/Frameworks
- framework_name = fftreal.framework/Versions/1/fftreal
- QMAKE_POST_LINK = \
- mkdir -p $${framework_dir} &&\
- rm -rf $${framework_dir}/fftreal.framework &&\
- cp -R $${fftreal_dir}/fftreal.framework $${framework_dir} &&\
- install_name_tool -id @executable_path/../Frameworks/$${framework_name} \
- $${framework_dir}/$${framework_name} &&\
- install_name_tool -change $${framework_name} \
- @executable_path/../Frameworks/$${framework_name} \
- ../spectrum.app/Contents/MacOS/spectrum
- }
-} else {
- linux-g++*: {
- # Provide relative path from application to fftreal library
- QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN
- }
-}
-include(../../shared/shared.pri)
diff --git a/examples/multimedia/spectrum/app/engine.cpp b/examples/multimedia/spectrum/app/engine.cpp
deleted file mode 100644
index f934f8788..000000000
--- a/examples/multimedia/spectrum/app/engine.cpp
+++ /dev/null
@@ -1,783 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "engine.h"
-#include "tonegenerator.h"
-#include "utils.h"
-
-#include <math.h>
-
-#include <QAudioInput>
-#include <QAudioOutput>
-#include <QCoreApplication>
-#include <QDebug>
-#include <QFile>
-#include <QMetaObject>
-#include <QSet>
-#include <QThread>
-
-//-----------------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------------
-
-const qint64 BufferDurationUs = 10 * 1000000;
-const int NotifyIntervalMs = 100;
-
-// Size of the level calculation window in microseconds
-const int LevelWindowUs = 0.1 * 1000000;
-
-//-----------------------------------------------------------------------------
-// Constructor and destructor
-//-----------------------------------------------------------------------------
-
-Engine::Engine(QObject *parent)
- : QObject(parent)
- , m_mode(QAudio::AudioInput)
- , m_state(QAudio::StoppedState)
- , m_generateTone(false)
- , m_file(0)
- , m_analysisFile(0)
- , m_availableAudioInputDevices
- (QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
- , m_audioInputDevice(QAudioDeviceInfo::defaultInputDevice())
- , m_audioInput(0)
- , m_audioInputIODevice(0)
- , m_recordPosition(0)
- , m_availableAudioOutputDevices
- (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
- , m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice())
- , m_audioOutput(0)
- , m_playPosition(0)
- , m_bufferPosition(0)
- , m_bufferLength(0)
- , m_dataLength(0)
- , m_levelBufferLength(0)
- , m_rmsLevel(0.0)
- , m_peakLevel(0.0)
- , m_spectrumBufferLength(0)
- , m_spectrumAnalyser()
- , m_spectrumPosition(0)
- , m_count(0)
-{
- qRegisterMetaType<FrequencySpectrum>("FrequencySpectrum");
- qRegisterMetaType<WindowFunction>("WindowFunction");
- connect(&m_spectrumAnalyser, QOverload<const FrequencySpectrum&>::of(&SpectrumAnalyser::spectrumChanged),
- this, QOverload<const FrequencySpectrum&>::of(&Engine::spectrumChanged));
-
- // This code might misinterpret things like "-something -category". But
- // it's unlikely that that needs to be supported so we'll let it go.
- QStringList arguments = QCoreApplication::instance()->arguments();
- for (int i = 0; i < arguments.count(); ++i) {
- if (arguments.at(i) == QStringLiteral("--"))
- break;
-
- if (arguments.at(i) == QStringLiteral("-category")
- || arguments.at(i) == QStringLiteral("--category")) {
- ++i;
- if (i < arguments.count())
- m_audioOutputCategory = arguments.at(i);
- else
- --i;
- }
- }
-
- initialize();
-
-#ifdef DUMP_DATA
- createOutputDir();
-#endif
-
-#ifdef DUMP_SPECTRUM
- m_spectrumAnalyser.setOutputPath(outputPath());
-#endif
-}
-
-Engine::~Engine()
-{
-
-}
-
-//-----------------------------------------------------------------------------
-// Public functions
-//-----------------------------------------------------------------------------
-
-bool Engine::loadFile(const QString &fileName)
-{
- reset();
- bool result = false;
- Q_ASSERT(!m_generateTone);
- Q_ASSERT(!m_file);
- Q_ASSERT(!fileName.isEmpty());
- m_file = new WavFile(this);
- if (m_file->open(fileName)) {
- if (isPCMS16LE(m_file->fileFormat())) {
- result = initialize();
- } else {
- emit errorMessage(tr("Audio format not supported"),
- formatToString(m_file->fileFormat()));
- }
- } else {
- emit errorMessage(tr("Could not open file"), fileName);
- }
- if (result) {
- m_analysisFile = new WavFile(this);
- m_analysisFile->open(fileName);
- }
- return result;
-}
-
-bool Engine::generateTone(const Tone &tone)
-{
- reset();
- Q_ASSERT(!m_generateTone);
- Q_ASSERT(!m_file);
- m_generateTone = true;
- m_tone = tone;
- ENGINE_DEBUG << "Engine::generateTone"
- << "startFreq" << m_tone.startFreq
- << "endFreq" << m_tone.endFreq
- << "amp" << m_tone.amplitude;
- return initialize();
-}
-
-bool Engine::generateSweptTone(qreal amplitude)
-{
- Q_ASSERT(!m_generateTone);
- Q_ASSERT(!m_file);
- m_generateTone = true;
- m_tone.startFreq = 1;
- m_tone.endFreq = 0;
- m_tone.amplitude = amplitude;
- ENGINE_DEBUG << "Engine::generateSweptTone"
- << "startFreq" << m_tone.startFreq
- << "amp" << m_tone.amplitude;
- return initialize();
-}
-
-bool Engine::initializeRecord()
-{
- reset();
- ENGINE_DEBUG << "Engine::initializeRecord";
- Q_ASSERT(!m_generateTone);
- Q_ASSERT(!m_file);
- m_generateTone = false;
- m_tone = SweptTone();
- return initialize();
-}
-
-qint64 Engine::bufferLength() const
-{
- return m_file ? m_file->size() : m_bufferLength;
-}
-
-void Engine::setWindowFunction(WindowFunction type)
-{
- m_spectrumAnalyser.setWindowFunction(type);
-}
-
-
-//-----------------------------------------------------------------------------
-// Public slots
-//-----------------------------------------------------------------------------
-
-void Engine::startRecording()
-{
- if (m_audioInput) {
- if (QAudio::AudioInput == m_mode &&
- QAudio::SuspendedState == m_state) {
- m_audioInput->resume();
- } else {
- m_spectrumAnalyser.cancelCalculation();
- spectrumChanged(0, 0, FrequencySpectrum());
-
- m_buffer.fill(0);
- setRecordPosition(0, true);
- stopPlayback();
- m_mode = QAudio::AudioInput;
- connect(m_audioInput, &QAudioInput::stateChanged,
- this, &Engine::audioStateChanged);
- connect(m_audioInput, &QAudioInput::notify,
- this, &Engine::audioNotify);
-
- m_count = 0;
- m_dataLength = 0;
- emit dataLengthChanged(0);
- m_audioInputIODevice = m_audioInput->start();
- connect(m_audioInputIODevice, &QIODevice::readyRead,
- this, &Engine::audioDataReady);
- }
- }
-}
-
-void Engine::startPlayback()
-{
- if (m_audioOutput) {
- if (QAudio::AudioOutput == m_mode &&
- QAudio::SuspendedState == m_state) {
-#ifdef Q_OS_WIN
- // The Windows backend seems to internally go back into ActiveState
- // while still returning SuspendedState, so to ensure that it doesn't
- // ignore the resume() call, we first re-suspend
- m_audioOutput->suspend();
-#endif
- m_audioOutput->resume();
- } else {
- m_spectrumAnalyser.cancelCalculation();
- spectrumChanged(0, 0, FrequencySpectrum());
- setPlayPosition(0, true);
- stopRecording();
- m_mode = QAudio::AudioOutput;
- connect(m_audioOutput, &QAudioOutput::stateChanged,
- this, &Engine::audioStateChanged);
- connect(m_audioOutput, &QAudioOutput::notify,
- this, &Engine::audioNotify);
-
- m_count = 0;
- if (m_file) {
- m_file->seek(0);
- m_bufferPosition = 0;
- m_dataLength = 0;
- m_audioOutput->start(m_file);
- } else {
- m_audioOutputIODevice.close();
- m_audioOutputIODevice.setBuffer(&m_buffer);
- m_audioOutputIODevice.open(QIODevice::ReadOnly);
- m_audioOutput->start(&m_audioOutputIODevice);
- }
- }
- }
-}
-
-void Engine::suspend()
-{
- if (QAudio::ActiveState == m_state ||
- QAudio::IdleState == m_state) {
- switch (m_mode) {
- case QAudio::AudioInput:
- m_audioInput->suspend();
- break;
- case QAudio::AudioOutput:
- m_audioOutput->suspend();
- break;
- }
- }
-}
-
-void Engine::setAudioInputDevice(const QAudioDeviceInfo &device)
-{
- if (device.deviceName() != m_audioInputDevice.deviceName()) {
- m_audioInputDevice = device;
- initialize();
- }
-}
-
-void Engine::setAudioOutputDevice(const QAudioDeviceInfo &device)
-{
- if (device.deviceName() != m_audioOutputDevice.deviceName()) {
- m_audioOutputDevice = device;
- initialize();
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Private slots
-//-----------------------------------------------------------------------------
-
-void Engine::audioNotify()
-{
- switch (m_mode) {
- case QAudio::AudioInput: {
- const qint64 recordPosition = qMin(m_bufferLength, audioLength(m_format, m_audioInput->processedUSecs()));
- setRecordPosition(recordPosition);
- const qint64 levelPosition = m_dataLength - m_levelBufferLength;
- if (levelPosition >= 0)
- calculateLevel(levelPosition, m_levelBufferLength);
- if (m_dataLength >= m_spectrumBufferLength) {
- const qint64 spectrumPosition = m_dataLength - m_spectrumBufferLength;
- calculateSpectrum(spectrumPosition);
- }
- emit bufferChanged(0, m_dataLength, m_buffer);
- }
- break;
- case QAudio::AudioOutput: {
- const qint64 playPosition = audioLength(m_format, m_audioOutput->processedUSecs());
- setPlayPosition(qMin(bufferLength(), playPosition));
- const qint64 levelPosition = playPosition - m_levelBufferLength;
- const qint64 spectrumPosition = playPosition - m_spectrumBufferLength;
- if (m_file) {
- if (levelPosition > m_bufferPosition ||
- spectrumPosition > m_bufferPosition ||
- qMax(m_levelBufferLength, m_spectrumBufferLength) > m_dataLength) {
- m_bufferPosition = 0;
- m_dataLength = 0;
- // Data needs to be read into m_buffer in order to be analysed
- const qint64 readPos = qMax(qint64(0), qMin(levelPosition, spectrumPosition));
- const qint64 readEnd = qMin(m_analysisFile->size(), qMax(levelPosition + m_levelBufferLength, spectrumPosition + m_spectrumBufferLength));
- const qint64 readLen = readEnd - readPos + audioLength(m_format, WaveformWindowDuration);
- qDebug() << "Engine::audioNotify [1]"
- << "analysisFileSize" << m_analysisFile->size()
- << "readPos" << readPos
- << "readLen" << readLen;
- if (m_analysisFile->seek(readPos + m_analysisFile->headerLength())) {
- m_buffer.resize(readLen);
- m_bufferPosition = readPos;
- m_dataLength = m_analysisFile->read(m_buffer.data(), readLen);
- qDebug() << "Engine::audioNotify [2]" << "bufferPosition" << m_bufferPosition << "dataLength" << m_dataLength;
- } else {
- qDebug() << "Engine::audioNotify [2]" << "file seek error";
- }
- emit bufferChanged(m_bufferPosition, m_dataLength, m_buffer);
- }
- } else {
- if (playPosition >= m_dataLength)
- stopPlayback();
- }
- if (levelPosition >= 0 && levelPosition + m_levelBufferLength < m_bufferPosition + m_dataLength)
- calculateLevel(levelPosition, m_levelBufferLength);
- if (spectrumPosition >= 0 && spectrumPosition + m_spectrumBufferLength < m_bufferPosition + m_dataLength)
- calculateSpectrum(spectrumPosition);
- }
- break;
- }
-}
-
-void Engine::audioStateChanged(QAudio::State state)
-{
- ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state
- << "to" << state;
-
- if (QAudio::IdleState == state && m_file && m_file->pos() == m_file->size()) {
- stopPlayback();
- } else {
- if (QAudio::StoppedState == state) {
- // Check error
- QAudio::Error error = QAudio::NoError;
- switch (m_mode) {
- case QAudio::AudioInput:
- error = m_audioInput->error();
- break;
- case QAudio::AudioOutput:
- error = m_audioOutput->error();
- break;
- }
- if (QAudio::NoError != error) {
- reset();
- return;
- }
- }
- setState(state);
- }
-}
-
-void Engine::audioDataReady()
-{
- Q_ASSERT(0 == m_bufferPosition);
- const qint64 bytesReady = m_audioInput->bytesReady();
- const qint64 bytesSpace = m_buffer.size() - m_dataLength;
- const qint64 bytesToRead = qMin(bytesReady, bytesSpace);
-
- const qint64 bytesRead = m_audioInputIODevice->read(
- m_buffer.data() + m_dataLength,
- bytesToRead);
-
- if (bytesRead) {
- m_dataLength += bytesRead;
- emit dataLengthChanged(dataLength());
- }
-
- if (m_buffer.size() == m_dataLength)
- stopRecording();
-}
-
-void Engine::spectrumChanged(const FrequencySpectrum &spectrum)
-{
- ENGINE_DEBUG << "Engine::spectrumChanged" << "pos" << m_spectrumPosition;
- emit spectrumChanged(m_spectrumPosition, m_spectrumBufferLength, spectrum);
-}
-
-
-//-----------------------------------------------------------------------------
-// Private functions
-//-----------------------------------------------------------------------------
-
-void Engine::resetAudioDevices()
-{
- delete m_audioInput;
- m_audioInput = 0;
- m_audioInputIODevice = 0;
- setRecordPosition(0);
- delete m_audioOutput;
- m_audioOutput = 0;
- setPlayPosition(0);
- m_spectrumPosition = 0;
- setLevel(0.0, 0.0, 0);
-}
-
-void Engine::reset()
-{
- stopRecording();
- stopPlayback();
- setState(QAudio::AudioInput, QAudio::StoppedState);
- setFormat(QAudioFormat());
- m_generateTone = false;
- delete m_file;
- m_file = 0;
- delete m_analysisFile;
- m_analysisFile = 0;
- m_buffer.clear();
- m_bufferPosition = 0;
- m_bufferLength = 0;
- m_dataLength = 0;
- emit dataLengthChanged(0);
- resetAudioDevices();
-}
-
-bool Engine::initialize()
-{
- bool result = false;
-
- QAudioFormat format = m_format;
-
- if (selectFormat()) {
- if (m_format != format) {
- resetAudioDevices();
- if (m_file) {
- emit bufferLengthChanged(bufferLength());
- emit dataLengthChanged(dataLength());
- emit bufferChanged(0, 0, m_buffer);
- setRecordPosition(bufferLength());
- result = true;
- } else {
- m_bufferLength = audioLength(m_format, BufferDurationUs);
- m_buffer.resize(m_bufferLength);
- m_buffer.fill(0);
- emit bufferLengthChanged(bufferLength());
- if (m_generateTone) {
- if (0 == m_tone.endFreq) {
- const qreal nyquist = nyquistFrequency(m_format);
- m_tone.endFreq = qMin(qreal(SpectrumHighFreq), nyquist);
- }
- // Call function defined in utils.h, at global scope
- ::generateTone(m_tone, m_format, m_buffer);
- m_dataLength = m_bufferLength;
- emit dataLengthChanged(dataLength());
- emit bufferChanged(0, m_dataLength, m_buffer);
- setRecordPosition(m_bufferLength);
- result = true;
- } else {
- emit bufferChanged(0, 0, m_buffer);
- m_audioInput = new QAudioInput(m_audioInputDevice, m_format, this);
- m_audioInput->setNotifyInterval(NotifyIntervalMs);
- result = true;
- }
- }
- m_audioOutput = new QAudioOutput(m_audioOutputDevice, m_format, this);
- m_audioOutput->setNotifyInterval(NotifyIntervalMs);
- m_audioOutput->setCategory(m_audioOutputCategory);
- }
- } else {
- if (m_file)
- emit errorMessage(tr("Audio format not supported"),
- formatToString(m_format));
- else if (m_generateTone)
- emit errorMessage(tr("No suitable format found"), "");
- else
- emit errorMessage(tr("No common input / output format found"), "");
- }
-
- ENGINE_DEBUG << "Engine::initialize" << "m_bufferLength" << m_bufferLength;
- ENGINE_DEBUG << "Engine::initialize" << "m_dataLength" << m_dataLength;
- ENGINE_DEBUG << "Engine::initialize" << "format" << m_format;
- ENGINE_DEBUG << "Engine::initialize" << "m_audioOutputCategory" << m_audioOutputCategory;
-
- return result;
-}
-
-bool Engine::selectFormat()
-{
- bool foundSupportedFormat = false;
-
- if (m_file || QAudioFormat() != m_format) {
- QAudioFormat format = m_format;
- if (m_file)
- // Header is read from the WAV file; just need to check whether
- // it is supported by the audio output device
- format = m_file->fileFormat();
- if (m_audioOutputDevice.isFormatSupported(format)) {
- setFormat(format);
- foundSupportedFormat = true;
- }
- } else {
-
- QList<int> sampleRatesList;
- #ifdef Q_OS_WIN
- // The Windows audio backend does not correctly report format support
- // (see QTBUG-9100). Furthermore, although the audio subsystem captures
- // at 11025Hz, the resulting audio is corrupted.
- sampleRatesList += 8000;
- #endif
-
- if (!m_generateTone)
- sampleRatesList += m_audioInputDevice.supportedSampleRates();
-
- sampleRatesList += m_audioOutputDevice.supportedSampleRates();
- std::sort(sampleRatesList.begin(), sampleRatesList.end());
- const auto uniqueRatesEnd = std::unique(sampleRatesList.begin(), sampleRatesList.end());
- sampleRatesList.erase(uniqueRatesEnd, sampleRatesList.end());
- ENGINE_DEBUG << "Engine::initialize frequenciesList" << sampleRatesList;
-
- QList<int> channelsList;
- channelsList += m_audioInputDevice.supportedChannelCounts();
- channelsList += m_audioOutputDevice.supportedChannelCounts();
- std::sort(channelsList.begin(), channelsList.end());
- const auto uniqueChannelsEnd = std::unique(channelsList.begin(), channelsList.end());
- channelsList.erase(uniqueChannelsEnd, channelsList.end());
- ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList;
-
- QAudioFormat format;
- format.setByteOrder(QAudioFormat::LittleEndian);
- format.setCodec("audio/pcm");
- format.setSampleSize(16);
- format.setSampleType(QAudioFormat::SignedInt);
- for (int sampleRate : qAsConst(sampleRatesList)) {
- if (foundSupportedFormat)
- break;
- format.setSampleRate(sampleRate);
- for (int channels : qAsConst(channelsList)) {
- format.setChannelCount(channels);
- const bool inputSupport = m_generateTone ||
- m_audioInputDevice.isFormatSupported(format);
- const bool outputSupport = m_audioOutputDevice.isFormatSupported(format);
- ENGINE_DEBUG << "Engine::initialize checking " << format
- << "input" << inputSupport
- << "output" << outputSupport;
- if (inputSupport && outputSupport) {
- foundSupportedFormat = true;
- break;
- }
- }
- }
-
- if (!foundSupportedFormat)
- format = QAudioFormat();
-
- setFormat(format);
- }
-
- return foundSupportedFormat;
-}
-
-void Engine::stopRecording()
-{
- if (m_audioInput) {
- m_audioInput->stop();
- QCoreApplication::instance()->processEvents();
- m_audioInput->disconnect();
- }
- m_audioInputIODevice = 0;
-
-#ifdef DUMP_AUDIO
- dumpData();
-#endif
-}
-
-void Engine::stopPlayback()
-{
- if (m_audioOutput) {
- m_audioOutput->stop();
- QCoreApplication::instance()->processEvents();
- m_audioOutput->disconnect();
- setPlayPosition(0);
- }
-}
-
-void Engine::setState(QAudio::State state)
-{
- const bool changed = (m_state != state);
- m_state = state;
- if (changed)
- emit stateChanged(m_mode, m_state);
-}
-
-void Engine::setState(QAudio::Mode mode, QAudio::State state)
-{
- const bool changed = (m_mode != mode || m_state != state);
- m_mode = mode;
- m_state = state;
- if (changed)
- emit stateChanged(m_mode, m_state);
-}
-
-void Engine::setRecordPosition(qint64 position, bool forceEmit)
-{
- const bool changed = (m_recordPosition != position);
- m_recordPosition = position;
- if (changed || forceEmit)
- emit recordPositionChanged(m_recordPosition);
-}
-
-void Engine::setPlayPosition(qint64 position, bool forceEmit)
-{
- const bool changed = (m_playPosition != position);
- m_playPosition = position;
- if (changed || forceEmit)
- emit playPositionChanged(m_playPosition);
-}
-
-void Engine::calculateLevel(qint64 position, qint64 length)
-{
-#ifdef DISABLE_LEVEL
- Q_UNUSED(position);
- Q_UNUSED(length);
-#else
- Q_ASSERT(position + length <= m_bufferPosition + m_dataLength);
-
- qreal peakLevel = 0.0;
-
- qreal sum = 0.0;
- const char *ptr = m_buffer.constData() + position - m_bufferPosition;
- const char *const end = ptr + length;
- while (ptr < end) {
- const qint16 value = *reinterpret_cast<const qint16*>(ptr);
- const qreal fracValue = pcmToReal(value);
- peakLevel = qMax(peakLevel, fracValue);
- sum += fracValue * fracValue;
- ptr += 2;
- }
- const int numSamples = length / 2;
- qreal rmsLevel = sqrt(sum / numSamples);
-
- rmsLevel = qMax(qreal(0.0), rmsLevel);
- rmsLevel = qMin(qreal(1.0), rmsLevel);
- setLevel(rmsLevel, peakLevel, numSamples);
-
- ENGINE_DEBUG << "Engine::calculateLevel" << "pos" << position << "len" << length
- << "rms" << rmsLevel << "peak" << peakLevel;
-#endif
-}
-
-void Engine::calculateSpectrum(qint64 position)
-{
-#ifdef DISABLE_SPECTRUM
- Q_UNUSED(position);
-#else
- Q_ASSERT(position + m_spectrumBufferLength <= m_bufferPosition + m_dataLength);
- Q_ASSERT(0 == m_spectrumBufferLength % 2); // constraint of FFT algorithm
-
- // QThread::currentThread is marked 'for internal use only', but
- // we're only using it for debug output here, so it's probably OK :)
- ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread()
- << "count" << m_count << "pos" << position << "len" << m_spectrumBufferLength
- << "spectrumAnalyser.isReady" << m_spectrumAnalyser.isReady();
-
- if (m_spectrumAnalyser.isReady()) {
- m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position - m_bufferPosition,
- m_spectrumBufferLength);
- m_spectrumPosition = position;
- m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
- }
-#endif
-}
-
-void Engine::setFormat(const QAudioFormat &format)
-{
- const bool changed = (format != m_format);
- m_format = format;
- m_levelBufferLength = audioLength(m_format, LevelWindowUs);
- m_spectrumBufferLength = SpectrumLengthSamples *
- (m_format.sampleSize() / 8) * m_format.channelCount();
- if (changed)
- emit formatChanged(m_format);
-}
-
-void Engine::setLevel(qreal rmsLevel, qreal peakLevel, int numSamples)
-{
- m_rmsLevel = rmsLevel;
- m_peakLevel = peakLevel;
- emit levelChanged(m_rmsLevel, m_peakLevel, numSamples);
-}
-
-#ifdef DUMP_DATA
-void Engine::createOutputDir()
-{
- m_outputDir.setPath("output");
-
- // Ensure output directory exists and is empty
- if (m_outputDir.exists()) {
- const QStringList files = m_outputDir.entryList(QDir::Files);
- for (const QString &file : files)
- m_outputDir.remove(file);
- } else {
- QDir::current().mkdir("output");
- }
-}
-#endif // DUMP_DATA
-
-#ifdef DUMP_AUDIO
-void Engine::dumpData()
-{
- const QString txtFileName = m_outputDir.filePath("data.txt");
- QFile txtFile(txtFileName);
- txtFile.open(QFile::WriteOnly | QFile::Text);
- QTextStream stream(&txtFile);
- const qint16 *ptr = reinterpret_cast<const qint16*>(m_buffer.constData());
- const int numSamples = m_dataLength / (2 * m_format.channels());
- for (int i=0; i<numSamples; ++i) {
- stream << i << "\t" << *ptr << "\n";
- ptr += m_format.channels();
- }
-
- const QString pcmFileName = m_outputDir.filePath("data.pcm");
- QFile pcmFile(pcmFileName);
- pcmFile.open(QFile::WriteOnly);
- pcmFile.write(m_buffer.constData(), m_dataLength);
-}
-#endif // DUMP_AUDIO
diff --git a/examples/multimedia/spectrum/app/frequencyspectrum.cpp b/examples/multimedia/spectrum/app/frequencyspectrum.cpp
deleted file mode 100644
index abec65d23..000000000
--- a/examples/multimedia/spectrum/app/frequencyspectrum.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "frequencyspectrum.h"
-
-FrequencySpectrum::FrequencySpectrum(int numPoints)
- : m_elements(numPoints)
-{
-
-}
-
-void FrequencySpectrum::reset()
-{
- iterator i = begin();
- for ( ; i != end(); ++i)
- *i = Element();
-}
-
-int FrequencySpectrum::count() const
-{
- return m_elements.count();
-}
-
-FrequencySpectrum::Element &FrequencySpectrum::operator[](int index)
-{
- return m_elements[index];
-}
-
-const FrequencySpectrum::Element &FrequencySpectrum::operator[](int index) const
-{
- return m_elements[index];
-}
-
-FrequencySpectrum::iterator FrequencySpectrum::begin()
-{
- return m_elements.begin();
-}
-
-FrequencySpectrum::iterator FrequencySpectrum::end()
-{
- return m_elements.end();
-}
-
-FrequencySpectrum::const_iterator FrequencySpectrum::begin() const
-{
- return m_elements.begin();
-}
-
-FrequencySpectrum::const_iterator FrequencySpectrum::end() const
-{
- return m_elements.end();
-}
diff --git a/examples/multimedia/spectrum/app/frequencyspectrum.h b/examples/multimedia/spectrum/app/frequencyspectrum.h
deleted file mode 100644
index 4b13cbb99..000000000
--- a/examples/multimedia/spectrum/app/frequencyspectrum.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef FREQUENCYSPECTRUM_H
-#define FREQUENCYSPECTRUM_H
-
-#include <QtCore/QList>
-
-/**
- * Represents a frequency spectrum as a series of elements, each of which
- * consists of a frequency, an amplitude and a phase.
- */
-class FrequencySpectrum {
-public:
- FrequencySpectrum(int numPoints = 0);
-
- struct Element {
- Element()
- : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false)
- { }
-
- /**
- * Frequency in Hertz
- */
- qreal frequency;
-
- /**
- * Amplitude in range [0.0, 1.0]
- */
- qreal amplitude;
-
- /**
- * Phase in range [0.0, 2*PI]
- */
- qreal phase;
-
- /**
- * Indicates whether value has been clipped during spectrum analysis
- */
- bool clipped;
- };
-
- typedef QList<Element>::iterator iterator;
- typedef QList<Element>::const_iterator const_iterator;
-
- void reset();
-
- int count() const;
- Element& operator[](int index);
- const Element& operator[](int index) const;
- iterator begin();
- iterator end();
- const_iterator begin() const;
- const_iterator end() const;
-
-private:
- QList<Element> m_elements;
-};
-
-#endif // FREQUENCYSPECTRUM_H
diff --git a/examples/multimedia/spectrum/app/levelmeter.cpp b/examples/multimedia/spectrum/app/levelmeter.cpp
deleted file mode 100644
index f0c66eeb3..000000000
--- a/examples/multimedia/spectrum/app/levelmeter.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "levelmeter.h"
-
-#include <math.h>
-
-#include <QPainter>
-#include <QTimer>
-#include <QDebug>
-
-
-// Constants
-const int RedrawInterval = 100; // ms
-const qreal PeakDecayRate = 0.001;
-const int PeakHoldLevelDuration = 2000; // ms
-
-
-LevelMeter::LevelMeter(QWidget *parent)
- : QWidget(parent)
- , m_rmsLevel(0.0)
- , m_peakLevel(0.0)
- , m_decayedPeakLevel(0.0)
- , m_peakDecayRate(PeakDecayRate)
- , m_peakHoldLevel(0.0)
- , m_redrawTimer(new QTimer(this))
- , m_rmsColor(Qt::red)
- , m_peakColor(255, 200, 200, 255)
-{
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
- setMinimumWidth(30);
-
- connect(m_redrawTimer, &QTimer::timeout,
- this, &LevelMeter::redrawTimerExpired);
- m_redrawTimer->start(RedrawInterval);
-}
-
-LevelMeter::~LevelMeter()
-{
-
-}
-
-void LevelMeter::reset()
-{
- m_rmsLevel = 0.0;
- m_peakLevel = 0.0;
- update();
-}
-
-void LevelMeter::levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
-{
- // Smooth the RMS signal
- const qreal smooth = pow(qreal(0.9), static_cast<qreal>(numSamples) / 256); // TODO: remove this magic number
- m_rmsLevel = (m_rmsLevel * smooth) + (rmsLevel * (1.0 - smooth));
-
- if (peakLevel > m_decayedPeakLevel) {
- m_peakLevel = peakLevel;
- m_decayedPeakLevel = peakLevel;
- m_peakLevelChanged.start();
- }
-
- if (peakLevel > m_peakHoldLevel) {
- m_peakHoldLevel = peakLevel;
- m_peakHoldLevelChanged.start();
- }
-
- update();
-}
-
-void LevelMeter::redrawTimerExpired()
-{
- // Decay the peak signal
- const int elapsedMs = m_peakLevelChanged.elapsed();
- const qreal decayAmount = m_peakDecayRate * elapsedMs;
- if (decayAmount < m_peakLevel)
- m_decayedPeakLevel = m_peakLevel - decayAmount;
- else
- m_decayedPeakLevel = 0.0;
-
- // Check whether to clear the peak hold level
- if (m_peakHoldLevelChanged.elapsed() > PeakHoldLevelDuration)
- m_peakHoldLevel = 0.0;
-
- update();
-}
-
-void LevelMeter::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
-
- QPainter painter(this);
- painter.fillRect(rect(), Qt::black);
-
- QRect bar = rect();
-
- bar.setTop(rect().top() + (1.0 - m_peakHoldLevel) * rect().height());
- bar.setBottom(bar.top() + 5);
- painter.fillRect(bar, m_rmsColor);
- bar.setBottom(rect().bottom());
-
- bar.setTop(rect().top() + (1.0 - m_decayedPeakLevel) * rect().height());
- painter.fillRect(bar, m_peakColor);
-
- bar.setTop(rect().top() + (1.0 - m_rmsLevel) * rect().height());
- painter.fillRect(bar, m_rmsColor);
-}
diff --git a/examples/multimedia/spectrum/app/levelmeter.h b/examples/multimedia/spectrum/app/levelmeter.h
deleted file mode 100644
index 987f90e8f..000000000
--- a/examples/multimedia/spectrum/app/levelmeter.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef LEVELMETER_H
-#define LEVELMETER_H
-
-#include <QElapsedTimer>
-#include <QWidget>
-
-/**
- * Widget which displays a vertical audio level meter, indicating the
- * RMS and peak levels of the window of audio samples most recently analyzed
- * by the Engine.
- */
-class LevelMeter : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit LevelMeter(QWidget *parent = 0);
- ~LevelMeter();
-
- void paintEvent(QPaintEvent *event) override;
-
-public slots:
- void reset();
- void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
-
-private slots:
- void redrawTimerExpired();
-
-private:
- /**
- * Height of RMS level bar.
- * Range 0.0 - 1.0.
- */
- qreal m_rmsLevel;
-
- /**
- * Most recent peak level.
- * Range 0.0 - 1.0.
- */
- qreal m_peakLevel;
-
- /**
- * Height of peak level bar.
- * This is calculated by decaying m_peakLevel depending on the
- * elapsed time since m_peakLevelChanged, and the value of m_decayRate.
- */
- qreal m_decayedPeakLevel;
-
- /**
- * Time at which m_peakLevel was last changed.
- */
- QElapsedTimer m_peakLevelChanged;
-
- /**
- * Rate at which peak level bar decays.
- * Expressed in level units / millisecond.
- */
- qreal m_peakDecayRate;
-
- /**
- * High watermark of peak level.
- * Range 0.0 - 1.0.
- */
- qreal m_peakHoldLevel;
-
- /**
- * Time at which m_peakHoldLevel was last changed.
- */
- QElapsedTimer m_peakHoldLevelChanged;
-
- QTimer *m_redrawTimer;
-
- QColor m_rmsColor;
- QColor m_peakColor;
-
-};
-
-#endif // LEVELMETER_H
diff --git a/examples/multimedia/spectrum/app/main.cpp b/examples/multimedia/spectrum/app/main.cpp
deleted file mode 100644
index 7eeb94949..000000000
--- a/examples/multimedia/spectrum/app/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "mainwidget.h"
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- app.setApplicationName("Qt Multimedia spectrum analyzer");
-
- MainWidget w;
- w.show();
-
- return app.exec();
-}
diff --git a/examples/multimedia/spectrum/app/mainwidget.h b/examples/multimedia/spectrum/app/mainwidget.h
deleted file mode 100644
index 2ff863a13..000000000
--- a/examples/multimedia/spectrum/app/mainwidget.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef MAINWIDGET_H
-#define MAINWIDGET_H
-
-#include <QAudio>
-#include <QIcon>
-#include <QWidget>
-
-class Engine;
-class FrequencySpectrum;
-class LevelMeter;
-class ProgressBar;
-class SettingsDialog;
-class Spectrograph;
-class ToneGeneratorDialog;
-class Waveform;
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QAudioFormat;
-class QLabel;
-class QMenu;
-class QPushButton;
-QT_END_NAMESPACE
-
-/**
- * Main application widget, responsible for connecting the various UI
- * elements to the Engine.
- */
-class MainWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit MainWidget(QWidget *parent = 0);
- ~MainWidget();
-
- // QObject
- void timerEvent(QTimerEvent *event) override;
-
-public slots:
- void stateChanged(QAudio::Mode mode, QAudio::State state);
- void formatChanged(const QAudioFormat &format);
- void spectrumChanged(qint64 position, qint64 length,
- const FrequencySpectrum &spectrum);
- void infoMessage(const QString &message, int timeoutMs);
- void errorMessage(const QString &heading, const QString &detail);
- void audioPositionChanged(qint64 position);
- void bufferLengthChanged(qint64 length);
-
-private slots:
- void showFileDialog();
- void showSettingsDialog();
- void showToneGeneratorDialog();
- void initializeRecord();
- void updateModeMenu();
- void updateButtonStates();
-
-private:
- void createUi();
- void createMenus();
- void connectUi();
- void reset();
-
- enum Mode {
- NoMode,
- RecordMode,
- GenerateToneMode,
- LoadFileMode
- };
-
- void setMode(Mode mode);
-
-private:
- Mode m_mode;
-
- Engine* m_engine;
-
-#ifndef DISABLE_WAVEFORM
- Waveform* m_waveform;
-#endif
- ProgressBar* m_progressBar;
- Spectrograph* m_spectrograph;
- LevelMeter* m_levelMeter;
-
- QPushButton* m_modeButton;
- QPushButton* m_recordButton;
- QIcon m_recordIcon;
- QPushButton* m_pauseButton;
- QIcon m_pauseIcon;
- QPushButton* m_playButton;
- QIcon m_playIcon;
- QPushButton* m_settingsButton;
- QIcon m_settingsIcon;
-
- QLabel* m_infoMessage;
- int m_infoMessageTimerId;
-
- SettingsDialog* m_settingsDialog;
- ToneGeneratorDialog* m_toneGeneratorDialog;
-
- QMenu* m_modeMenu;
- QAction* m_loadFileAction;
- QAction* m_generateToneAction;
- QAction* m_recordAction;
-};
-
-#endif // MAINWIDGET_H
diff --git a/examples/multimedia/spectrum/app/progressbar.cpp b/examples/multimedia/spectrum/app/progressbar.cpp
deleted file mode 100644
index b42816e1c..000000000
--- a/examples/multimedia/spectrum/app/progressbar.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "progressbar.h"
-#include "spectrum.h"
-#include <QPainter>
-
-ProgressBar::ProgressBar(QWidget *parent)
- : QWidget(parent)
- , m_bufferLength(0)
- , m_recordPosition(0)
- , m_playPosition(0)
- , m_windowPosition(0)
- , m_windowLength(0)
-{
- setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- setMinimumHeight(30);
-#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
- setAutoFillBackground(false);
-#endif
-}
-
-ProgressBar::~ProgressBar()
-{
-
-}
-
-void ProgressBar::reset()
-{
- m_bufferLength = 0;
- m_recordPosition = 0;
- m_playPosition = 0;
- m_windowPosition = 0;
- m_windowLength = 0;
- update();
-}
-
-void ProgressBar::paintEvent(QPaintEvent * /*event*/)
-{
- QPainter painter(this);
-
- QColor bufferColor(0, 0, 255);
- QColor windowColor(0, 255, 0);
-
-#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
- bufferColor.setAlphaF(0.5);
- windowColor.setAlphaF(0.5);
-#else
- painter.fillRect(rect(), Qt::black);
-#endif
-
- if (m_bufferLength) {
- QRect bar = rect();
- const qreal play = qreal(m_playPosition) / m_bufferLength;
- bar.setLeft(rect().left() + play * rect().width());
- const qreal record = qreal(m_recordPosition) / m_bufferLength;
- bar.setRight(rect().left() + record * rect().width());
- painter.fillRect(bar, bufferColor);
-
- QRect window = rect();
- const qreal windowLeft = qreal(m_windowPosition) / m_bufferLength;
- window.setLeft(rect().left() + windowLeft * rect().width());
- const qreal windowWidth = qreal(m_windowLength) / m_bufferLength;
- window.setWidth(windowWidth * rect().width());
- painter.fillRect(window, windowColor);
- }
-}
-
-void ProgressBar::bufferLengthChanged(qint64 bufferSize)
-{
- m_bufferLength = bufferSize;
- m_recordPosition = 0;
- m_playPosition = 0;
- m_windowPosition = 0;
- m_windowLength = 0;
- repaint();
-}
-
-void ProgressBar::recordPositionChanged(qint64 recordPosition)
-{
- Q_ASSERT(recordPosition >= 0);
- Q_ASSERT(recordPosition <= m_bufferLength);
- m_recordPosition = recordPosition;
- repaint();
-}
-
-void ProgressBar::playPositionChanged(qint64 playPosition)
-{
- Q_ASSERT(playPosition >= 0);
- Q_ASSERT(playPosition <= m_bufferLength);
- m_playPosition = playPosition;
- repaint();
-}
-
-void ProgressBar::windowChanged(qint64 position, qint64 length)
-{
- Q_ASSERT(position >= 0);
- Q_ASSERT(position <= m_bufferLength);
- Q_ASSERT(position + length <= m_bufferLength);
- m_windowPosition = position;
- m_windowLength = length;
- repaint();
-}
diff --git a/examples/multimedia/spectrum/app/progressbar.h b/examples/multimedia/spectrum/app/progressbar.h
deleted file mode 100644
index 601900efb..000000000
--- a/examples/multimedia/spectrum/app/progressbar.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef PROGRESSBAR_H
-#define PROGRESSBAR_H
-
-#include <QWidget>
-
-/**
- * Widget which displays a the current fill state of the Engine's internal
- * buffer, and the current play/record position within that buffer.
- */
-class ProgressBar : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit ProgressBar(QWidget *parent = 0);
- ~ProgressBar();
-
- void reset();
- void paintEvent(QPaintEvent *event) override;
-
-public slots:
- void bufferLengthChanged(qint64 length);
- void recordPositionChanged(qint64 recordPosition);
- void playPositionChanged(qint64 playPosition);
- void windowChanged(qint64 position, qint64 length);
-
-private:
- qint64 m_bufferLength;
- qint64 m_recordPosition;
- qint64 m_playPosition;
- qint64 m_windowPosition;
- qint64 m_windowLength;
-};
-
-#endif // PROGRESSBAR_H
diff --git a/examples/multimedia/spectrum/app/settingsdialog.cpp b/examples/multimedia/spectrum/app/settingsdialog.cpp
deleted file mode 100644
index 889fcf639..000000000
--- a/examples/multimedia/spectrum/app/settingsdialog.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "settingsdialog.h"
-#include <QCheckBox>
-#include <QComboBox>
-#include <QDialogButtonBox>
-#include <QLabel>
-#include <QPushButton>
-#include <QSlider>
-#include <QSpinBox>
-#include <QVBoxLayout>
-
-SettingsDialog::SettingsDialog(
- const QList<QAudioDeviceInfo> &availableInputDevices,
- const QList<QAudioDeviceInfo> &availableOutputDevices,
- QWidget *parent)
- : QDialog(parent)
- , m_windowFunction(DefaultWindowFunction)
- , m_inputDeviceComboBox(new QComboBox(this))
- , m_outputDeviceComboBox(new QComboBox(this))
- , m_windowFunctionComboBox(new QComboBox(this))
-{
- QVBoxLayout *dialogLayout = new QVBoxLayout(this);
-
- // Populate combo boxes
-
- for (const QAudioDeviceInfo &device : availableInputDevices)
- m_inputDeviceComboBox->addItem(device.deviceName(),
- QVariant::fromValue(device));
- for (const QAudioDeviceInfo &device : availableOutputDevices)
- m_outputDeviceComboBox->addItem(device.deviceName(),
- QVariant::fromValue(device));
-
- m_windowFunctionComboBox->addItem(tr("None"), QVariant::fromValue(int(NoWindow)));
- m_windowFunctionComboBox->addItem("Hann", QVariant::fromValue(int(HannWindow)));
- m_windowFunctionComboBox->setCurrentIndex(m_windowFunction);
-
- // Initialize default devices
- if (!availableInputDevices.empty())
- m_inputDevice = availableInputDevices.front();
- if (!availableOutputDevices.empty())
- m_outputDevice = availableOutputDevices.front();
-
- // Add widgets to layout
-
- QScopedPointer<QHBoxLayout> inputDeviceLayout(new QHBoxLayout);
- QLabel *inputDeviceLabel = new QLabel(tr("Input device"), this);
- inputDeviceLayout->addWidget(inputDeviceLabel);
- inputDeviceLayout->addWidget(m_inputDeviceComboBox);
- dialogLayout->addLayout(inputDeviceLayout.data());
- inputDeviceLayout.take(); // ownership transferred to dialogLayout
-
- QScopedPointer<QHBoxLayout> outputDeviceLayout(new QHBoxLayout);
- QLabel *outputDeviceLabel = new QLabel(tr("Output device"), this);
- outputDeviceLayout->addWidget(outputDeviceLabel);
- outputDeviceLayout->addWidget(m_outputDeviceComboBox);
- dialogLayout->addLayout(outputDeviceLayout.data());
- outputDeviceLayout.take(); // ownership transferred to dialogLayout
-
- QScopedPointer<QHBoxLayout> windowFunctionLayout(new QHBoxLayout);
- QLabel *windowFunctionLabel = new QLabel(tr("Window function"), this);
- windowFunctionLayout->addWidget(windowFunctionLabel);
- windowFunctionLayout->addWidget(m_windowFunctionComboBox);
- dialogLayout->addLayout(windowFunctionLayout.data());
- windowFunctionLayout.take(); // ownership transferred to dialogLayout
-
- // Connect
- connect(m_inputDeviceComboBox, QOverload<int>::of(&QComboBox::activated),
- this, &SettingsDialog::inputDeviceChanged);
- connect(m_outputDeviceComboBox, QOverload<int>::of(&QComboBox::activated),
- this, &SettingsDialog::outputDeviceChanged);
- connect(m_windowFunctionComboBox, QOverload<int>::of(&QComboBox::activated),
- this, &SettingsDialog::windowFunctionChanged);
-
- // Add standard buttons to layout
- QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
- buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- dialogLayout->addWidget(buttonBox);
-
- // Connect standard buttons
- connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
- this, &SettingsDialog::accept);
- connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
- this, &SettingsDialog::reject);
-
- setLayout(dialogLayout);
-}
-
-SettingsDialog::~SettingsDialog()
-{
-
-}
-
-void SettingsDialog::windowFunctionChanged(int index)
-{
- m_windowFunction = static_cast<WindowFunction>(
- m_windowFunctionComboBox->itemData(index).value<int>());
-}
-
-void SettingsDialog::inputDeviceChanged(int index)
-{
- m_inputDevice = m_inputDeviceComboBox->itemData(index).value<QAudioDeviceInfo>();
-}
-
-void SettingsDialog::outputDeviceChanged(int index)
-{
- m_outputDevice = m_outputDeviceComboBox->itemData(index).value<QAudioDeviceInfo>();
-}
-
diff --git a/examples/multimedia/spectrum/app/settingsdialog.h b/examples/multimedia/spectrum/app/settingsdialog.h
deleted file mode 100644
index 3200ccf54..000000000
--- a/examples/multimedia/spectrum/app/settingsdialog.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef SETTINGSDIALOG_H
-#define SETTINGSDIALOG_H
-
-#include "spectrum.h"
-#include <QDialog>
-#include <QAudioDeviceInfo>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QCheckBox;
-class QSlider;
-class QSpinBox;
-class QGridLayout;
-QT_END_NAMESPACE
-
-/**
- * Dialog used to control settings such as the audio input / output device
- * and the windowing function.
- */
-class SettingsDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- SettingsDialog(const QList<QAudioDeviceInfo> &availableInputDevices,
- const QList<QAudioDeviceInfo> &availableOutputDevices,
- QWidget *parent = 0);
- ~SettingsDialog();
-
- WindowFunction windowFunction() const { return m_windowFunction; }
- const QAudioDeviceInfo &inputDevice() const { return m_inputDevice; }
- const QAudioDeviceInfo &outputDevice() const { return m_outputDevice; }
-
-private slots:
- void windowFunctionChanged(int index);
- void inputDeviceChanged(int index);
- void outputDeviceChanged(int index);
-
-private:
- WindowFunction m_windowFunction;
- QAudioDeviceInfo m_inputDevice;
- QAudioDeviceInfo m_outputDevice;
-
- QComboBox *m_inputDeviceComboBox;
- QComboBox *m_outputDeviceComboBox;
- QComboBox *m_windowFunctionComboBox;
-};
-
-#endif // SETTINGSDIALOG_H
diff --git a/examples/multimedia/spectrum/app/spectrograph.h b/examples/multimedia/spectrum/app/spectrograph.h
deleted file mode 100644
index 0e7b11717..000000000
--- a/examples/multimedia/spectrum/app/spectrograph.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef SPECTROGRAPH_H
-#define SPECTROGRAPH_H
-
-#include "frequencyspectrum.h"
-
-#include <QWidget>
-
-/**
- * Widget which displays a spectrograph showing the frequency spectrum
- * of the window of audio samples most recently analyzed by the Engine.
- */
-class Spectrograph : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit Spectrograph(QWidget *parent = 0);
- ~Spectrograph();
-
- void setParams(int numBars, qreal lowFreq, qreal highFreq);
-
- // QObject
- void timerEvent(QTimerEvent *event) override;
-
- // QWidget
- void paintEvent(QPaintEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
-
-signals:
- void infoMessage(const QString &message, int intervalMs);
-
-public slots:
- void reset();
- void spectrumChanged(const FrequencySpectrum &spectrum);
-
-private:
- int barIndex(qreal frequency) const;
- QPair<qreal, qreal> barRange(int barIndex) const;
- void updateBars();
-
- void selectBar(int index);
-
-private:
- struct Bar {
- Bar() : value(0.0), clipped(false) { }
- qreal value;
- bool clipped;
- };
-
- QList<Bar> m_bars;
- int m_barSelected;
- int m_timerId;
- qreal m_lowFreq;
- qreal m_highFreq;
- FrequencySpectrum m_spectrum;
-};
-
-#endif // SPECTROGRAPH_H
diff --git a/examples/multimedia/spectrum/app/spectrum.h b/examples/multimedia/spectrum/app/spectrum.h
deleted file mode 100644
index aea9ce7c5..000000000
--- a/examples/multimedia/spectrum/app/spectrum.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef SPECTRUM_H
-#define SPECTRUM_H
-
-#include <qglobal.h>
-#include "utils.h"
-#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
-
-//-----------------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------------
-
-// Number of audio samples used to calculate the frequency spectrum
-const int SpectrumLengthSamples = PowerOfTwo<FFTLengthPowerOfTwo>::Result;
-
-// Number of bands in the frequency spectrum
-const int SpectrumNumBands = 10;
-
-// Lower bound of first band in the spectrum
-const qreal SpectrumLowFreq = 0.0; // Hz
-
-// Upper band of last band in the spectrum
-const qreal SpectrumHighFreq = 1000.0; // Hz
-
-// Waveform window size in microseconds
-const qint64 WaveformWindowDuration = 500 * 1000;
-
-// Length of waveform tiles in bytes
-// Ideally, these would match the QAudio*::bufferSize(), but that isn't
-// available until some time after QAudio*::start() has been called, and we
-// need this value in order to initialize the waveform display.
-// We therefore just choose a sensible value.
-const int WaveformTileLength = 4096;
-
-// Fudge factor used to calculate the spectrum bar heights
-const qreal SpectrumAnalyserMultiplier = 0.15;
-
-// Disable message timeout
-const int NullMessageTimeout = -1;
-
-
-//-----------------------------------------------------------------------------
-// Types and data structures
-//-----------------------------------------------------------------------------
-
-enum WindowFunction {
- NoWindow,
- HannWindow
-};
-
-const WindowFunction DefaultWindowFunction = HannWindow;
-
-struct Tone
-{
- Tone(qreal freq = 0.0, qreal amp = 0.0)
- : frequency(freq), amplitude(amp)
- { }
-
- // Start and end frequencies for swept tone generation
- qreal frequency;
-
- // Amplitude in range [0.0, 1.0]
- qreal amplitude;
-};
-
-struct SweptTone
-{
- SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
- : startFreq(start), endFreq(end), amplitude(amp)
- { Q_ASSERT(end >= start); }
-
- SweptTone(const Tone &tone)
- : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude)
- { }
-
- // Start and end frequencies for swept tone generation
- qreal startFreq;
- qreal endFreq;
-
- // Amplitude in range [0.0, 1.0]
- qreal amplitude;
-};
-
-// Handle some dependencies between macros defined in the .pro file
-
-#ifdef DISABLE_WAVEFORM
-#undef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
-#endif
-
-#endif // SPECTRUM_H
-
diff --git a/examples/multimedia/spectrum/app/spectrumanalyser.cpp b/examples/multimedia/spectrum/app/spectrumanalyser.cpp
deleted file mode 100644
index 6daa1c6aa..000000000
--- a/examples/multimedia/spectrum/app/spectrumanalyser.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "spectrumanalyser.h"
-#include "utils.h"
-#include "fftreal_wrapper.h"
-
-#include <qmath.h>
-#include <qmetatype.h>
-#include <QAudioFormat>
-#include <QThread>
-
-SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
- : QObject(parent)
-#ifndef DISABLE_FFT
- , m_fft(new FFTRealWrapper)
-#endif
- , m_numSamples(SpectrumLengthSamples)
- , m_windowFunction(DefaultWindowFunction)
- , m_window(SpectrumLengthSamples, 0.0)
- , m_input(SpectrumLengthSamples, 0.0)
- , m_output(SpectrumLengthSamples, 0.0)
- , m_spectrum(SpectrumLengthSamples)
-#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
- , m_thread(new QThread(this))
-#endif
-{
-#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
- // moveToThread() cannot be called on a QObject with a parent
- setParent(0);
- moveToThread(m_thread);
- m_thread->start();
-#endif
- calculateWindow();
-}
-
-SpectrumAnalyserThread::~SpectrumAnalyserThread()
-{
-#ifndef DISABLE_FFT
- delete m_fft;
-#endif
-}
-
-void SpectrumAnalyserThread::setWindowFunction(WindowFunction type)
-{
- m_windowFunction = type;
- calculateWindow();
-}
-
-void SpectrumAnalyserThread::calculateWindow()
-{
- for (int i=0; i<m_numSamples; ++i) {
- DataType x = 0.0;
-
- switch (m_windowFunction) {
- case NoWindow:
- x = 1.0;
- break;
- case HannWindow:
- x = 0.5 * (1 - qCos((2 * M_PI * i) / (m_numSamples - 1)));
- break;
- default:
- Q_ASSERT(false);
- }
-
- m_window[i] = x;
- }
-}
-
-void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer,
- int inputFrequency,
- int bytesPerSample)
-{
-#ifndef DISABLE_FFT
- Q_ASSERT(buffer.size() == m_numSamples * bytesPerSample);
-
- // Initialize data array
- const char *ptr = buffer.constData();
- for (int i=0; i<m_numSamples; ++i) {
- const qint16 pcmSample = *reinterpret_cast<const qint16*>(ptr);
- // Scale down to range [-1.0, 1.0]
- const DataType realSample = pcmToReal(pcmSample);
- const DataType windowedSample = realSample * m_window[i];
- m_input[i] = windowedSample;
- ptr += bytesPerSample;
- }
-
- // Calculate the FFT
- m_fft->calculateFFT(m_output.data(), m_input.data());
-
- // Analyze output to obtain amplitude and phase for each frequency
- for (int i=2; i<=m_numSamples/2; ++i) {
- // Calculate frequency of this complex sample
- m_spectrum[i].frequency = qreal(i * inputFrequency) / (m_numSamples);
-
- const qreal real = m_output[i];
- qreal imag = 0.0;
- if (i>0 && i<m_numSamples/2)
- imag = m_output[m_numSamples/2 + i];
-
- const qreal magnitude = qSqrt(real*real + imag*imag);
- qreal amplitude = SpectrumAnalyserMultiplier * qLn(magnitude);
-
- // Bound amplitude to [0.0, 1.0]
- m_spectrum[i].clipped = (amplitude > 1.0);
- amplitude = qMax(qreal(0.0), amplitude);
- amplitude = qMin(qreal(1.0), amplitude);
- m_spectrum[i].amplitude = amplitude;
- }
-#endif
-
- emit calculationComplete(m_spectrum);
-}
-
-
-//=============================================================================
-// SpectrumAnalyser
-//=============================================================================
-
-SpectrumAnalyser::SpectrumAnalyser(QObject *parent)
- : QObject(parent)
- , m_thread(new SpectrumAnalyserThread(this))
- , m_state(Idle)
-#ifdef DUMP_SPECTRUMANALYSER
- , m_count(0)
-#endif
-{
- connect(m_thread, &SpectrumAnalyserThread::calculationComplete,
- this, &SpectrumAnalyser::calculationComplete);
-}
-
-SpectrumAnalyser::~SpectrumAnalyser()
-{
-
-}
-
-#ifdef DUMP_SPECTRUMANALYSER
-void SpectrumAnalyser::setOutputPath(const QString &outputDir)
-{
- m_outputDir.setPath(outputDir);
- m_textFile.setFileName(m_outputDir.filePath("spectrum.txt"));
- m_textFile.open(QIODevice::WriteOnly | QIODevice::Text);
- m_textStream.setDevice(&m_textFile);
-}
-#endif
-
-//-----------------------------------------------------------------------------
-// Public functions
-//-----------------------------------------------------------------------------
-
-void SpectrumAnalyser::setWindowFunction(WindowFunction type)
-{
- const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction",
- Qt::AutoConnection,
- Q_ARG(WindowFunction, type));
- Q_ASSERT(b);
- Q_UNUSED(b); // suppress warnings in release builds
-}
-
-void SpectrumAnalyser::calculate(const QByteArray &buffer,
- const QAudioFormat &format)
-{
- // QThread::currentThread is marked 'for internal use only', but
- // we're only using it for debug output here, so it's probably OK :)
- SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate"
- << QThread::currentThread()
- << "state" << m_state;
-
- if (isReady()) {
- Q_ASSERT(isPCMS16LE(format));
-
- const int bytesPerSample = format.sampleSize() * format.channelCount() / 8;
-
-#ifdef DUMP_SPECTRUMANALYSER
- m_count++;
- const QString pcmFileName = m_outputDir.filePath(QString("spectrum_%1.pcm").arg(m_count, 4, 10, QChar('0')));
- QFile pcmFile(pcmFileName);
- pcmFile.open(QIODevice::WriteOnly);
- const int bufferLength = m_numSamples * bytesPerSample;
- pcmFile.write(buffer, bufferLength);
-
- m_textStream << "TimeDomain " << m_count << "\n";
- const qint16* input = reinterpret_cast<const qint16*>(buffer);
- for (int i=0; i<m_numSamples; ++i) {
- m_textStream << i << "\t" << *input << "\n";
- input += format.channels();
- }
-#endif
-
- m_state = Busy;
-
- // Invoke SpectrumAnalyserThread::calculateSpectrum using QMetaObject. If
- // m_thread is in a different thread from the current thread, the
- // calculation will be done in the child thread.
- // Once the calculation is finished, a calculationChanged signal will be
- // emitted by m_thread.
- const bool b = QMetaObject::invokeMethod(m_thread, "calculateSpectrum",
- Qt::AutoConnection,
- Q_ARG(QByteArray, buffer),
- Q_ARG(int, format.sampleRate()),
- Q_ARG(int, bytesPerSample));
- Q_ASSERT(b);
- Q_UNUSED(b); // suppress warnings in release builds
-
-#ifdef DUMP_SPECTRUMANALYSER
- m_textStream << "FrequencySpectrum " << m_count << "\n";
- FrequencySpectrum::const_iterator x = m_spectrum.begin();
- for (int i=0; i<m_numSamples; ++i, ++x)
- m_textStream << i << "\t"
- << x->frequency << "\t"
- << x->amplitude<< "\t"
- << x->phase << "\n";
-#endif
- }
-}
-
-bool SpectrumAnalyser::isReady() const
-{
- return (Idle == m_state);
-}
-
-void SpectrumAnalyser::cancelCalculation()
-{
- if (Busy == m_state)
- m_state = Cancelled;
-}
-
-
-//-----------------------------------------------------------------------------
-// Private slots
-//-----------------------------------------------------------------------------
-
-void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum)
-{
- Q_ASSERT(Idle != m_state);
- if (Busy == m_state)
- emit spectrumChanged(spectrum);
- m_state = Idle;
-}
diff --git a/examples/multimedia/spectrum/app/spectrumanalyser.h b/examples/multimedia/spectrum/app/spectrumanalyser.h
deleted file mode 100644
index 799143489..000000000
--- a/examples/multimedia/spectrum/app/spectrumanalyser.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef SPECTRUMANALYSER_H
-#define SPECTRUMANALYSER_H
-
-#include <QByteArray>
-#include <QObject>
-#include <QList>
-
-#ifdef DUMP_SPECTRUMANALYSER
-#include <QDir>
-#include <QFile>
-#include <QTextStream>
-#endif
-
-#include "frequencyspectrum.h"
-#include "spectrum.h"
-
-#ifndef DISABLE_FFT
-#include "FFTRealFixLenParam.h"
-#endif
-
-QT_FORWARD_DECLARE_CLASS(QAudioFormat)
-QT_FORWARD_DECLARE_CLASS(QThread)
-
-class FFTRealWrapper;
-
-class SpectrumAnalyserThreadPrivate;
-
-/**
- * Implementation of the spectrum analysis which can be run in a
- * separate thread.
- */
-class SpectrumAnalyserThread : public QObject
-{
- Q_OBJECT
-
-public:
- SpectrumAnalyserThread(QObject *parent);
- ~SpectrumAnalyserThread();
-
-public slots:
- void setWindowFunction(WindowFunction type);
- void calculateSpectrum(const QByteArray &buffer,
- int inputFrequency,
- int bytesPerSample);
-
-signals:
- void calculationComplete(const FrequencySpectrum &spectrum);
-
-private:
- void calculateWindow();
-
-private:
-#ifndef DISABLE_FFT
- FFTRealWrapper* m_fft;
-#endif
-
- const int m_numSamples;
-
- WindowFunction m_windowFunction;
-
-#ifdef DISABLE_FFT
- typedef qreal DataType;
-#else
- typedef FFTRealFixLenParam::DataType DataType;
-#endif
- QList<DataType> m_window;
-
- QList<DataType> m_input;
- QList<DataType> m_output;
-
- FrequencySpectrum m_spectrum;
-
-#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
- QThread* m_thread;
-#endif
-};
-
-/**
- * Class which performs frequency spectrum analysis on a window of
- * audio samples, provided to it by the Engine.
- */
-class SpectrumAnalyser : public QObject
-{
- Q_OBJECT
-
-public:
- SpectrumAnalyser(QObject *parent = 0);
- ~SpectrumAnalyser();
-
-#ifdef DUMP_SPECTRUMANALYSER
- void setOutputPath(const QString &outputPath);
-#endif
-
-public:
- /*
- * Set the windowing function which is applied before calculating the FFT
- */
- void setWindowFunction(WindowFunction type);
-
- /*
- * Calculate a frequency spectrum
- *
- * \param buffer Audio data
- * \param format Format of audio data
- *
- * Frequency spectrum is calculated asynchronously. The result is returned
- * via the spectrumChanged signal.
- *
- * An ongoing calculation can be cancelled by calling cancelCalculation().
- *
- */
- void calculate(const QByteArray &buffer, const QAudioFormat &format);
-
- /*
- * Check whether the object is ready to perform another calculation
- */
- bool isReady() const;
-
- /*
- * Cancel an ongoing calculation
- *
- * Note that cancelling is asynchronous.
- */
- void cancelCalculation();
-
-signals:
- void spectrumChanged(const FrequencySpectrum &spectrum);
-
-private slots:
- void calculationComplete(const FrequencySpectrum &spectrum);
-
-private:
- void calculateWindow();
-
-private:
-
- SpectrumAnalyserThread* m_thread;
-
- enum State {
- Idle,
- Busy,
- Cancelled
- };
-
- State m_state;
-
-#ifdef DUMP_SPECTRUMANALYSER
- QDir m_outputDir;
- int m_count;
- QFile m_textFile;
- QTextStream m_textStream;
-#endif
-};
-
-#endif // SPECTRUMANALYSER_H
-
diff --git a/examples/multimedia/spectrum/app/tonegenerator.cpp b/examples/multimedia/spectrum/app/tonegenerator.cpp
deleted file mode 100644
index 2e549ab4f..000000000
--- a/examples/multimedia/spectrum/app/tonegenerator.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "spectrum.h"
-#include "utils.h"
-#include <QByteArray>
-#include <QAudioFormat>
-#include <qmath.h>
-#include <qendian.h>
-
-void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer)
-{
- Q_ASSERT(isPCMS16LE(format));
-
- const int channelBytes = format.sampleSize() / 8;
- const int sampleBytes = format.channelCount() * channelBytes;
- int length = buffer.size();
- const int numSamples = buffer.size() / sampleBytes;
-
- Q_ASSERT(length % sampleBytes == 0);
- Q_UNUSED(sampleBytes); // suppress warning in release builds
-
- unsigned char *ptr = reinterpret_cast<unsigned char *>(buffer.data());
-
- qreal phase = 0.0;
-
- const qreal d = 2 * M_PI / format.sampleRate();
-
- // We can't generate a zero-frequency sine wave
- const qreal startFreq = tone.startFreq ? tone.startFreq : 1.0;
-
- // Amount by which phase increases on each sample
- qreal phaseStep = d * startFreq;
-
- // Amount by which phaseStep increases on each sample
- // If this is non-zero, the output is a frequency-swept tone
- const qreal phaseStepStep = d * (tone.endFreq - startFreq) / numSamples;
-
- while (length) {
- const qreal x = tone.amplitude * qSin(phase);
- const qint16 value = realToPcm(x);
- for (int i=0; i<format.channelCount(); ++i) {
- qToLittleEndian<qint16>(value, ptr);
- ptr += channelBytes;
- length -= channelBytes;
- }
-
- phase += phaseStep;
- while (phase > 2 * M_PI)
- phase -= 2 * M_PI;
- phaseStep += phaseStepStep;
- }
-}
diff --git a/examples/multimedia/spectrum/app/tonegenerator.h b/examples/multimedia/spectrum/app/tonegenerator.h
deleted file mode 100644
index af6efade2..000000000
--- a/examples/multimedia/spectrum/app/tonegenerator.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef TONEGENERATOR_H
-#define TONEGENERATOR_H
-
-#include <qglobal.h>
-#include "spectrum.h"
-
-QT_BEGIN_NAMESPACE
-class QAudioFormat;
-class QByteArray;
-QT_END_NAMESPACE
-
-/**
- * Generate a sine wave
- */
-void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer);
-
-#endif // TONEGENERATOR_H
-
diff --git a/examples/multimedia/spectrum/app/tonegeneratordialog.cpp b/examples/multimedia/spectrum/app/tonegeneratordialog.cpp
deleted file mode 100644
index 76fe5d2e3..000000000
--- a/examples/multimedia/spectrum/app/tonegeneratordialog.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "tonegeneratordialog.h"
-#include <QComboBox>
-#include <QDialogButtonBox>
-#include <QLabel>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QCheckBox>
-#include <QSlider>
-#include <QSpinBox>
-
-const int ToneGeneratorFreqMin = 1;
-const int ToneGeneratorFreqMax = 1000;
-const int ToneGeneratorFreqDefault = 440;
-const int ToneGeneratorAmplitudeDefault = 75;
-
-ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
- : QDialog(parent)
- , m_toneGeneratorSweepCheckBox(new QCheckBox(tr("Frequency sweep"), this))
- , m_frequencySweepEnabled(true)
- , m_toneGeneratorControl(new QWidget(this))
- , m_toneGeneratorFrequencyControl(new QWidget(this))
- , m_frequencySlider(new QSlider(Qt::Horizontal, this))
- , m_frequencySpinBox(new QSpinBox(this))
- , m_frequency(ToneGeneratorFreqDefault)
- , m_amplitudeSlider(new QSlider(Qt::Horizontal, this))
-{
- QVBoxLayout *dialogLayout = new QVBoxLayout(this);
-
- m_toneGeneratorSweepCheckBox->setChecked(true);
-
- // Configure tone generator controls
- m_frequencySlider->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax);
- m_frequencySlider->setValue(ToneGeneratorFreqDefault);
- m_frequencySpinBox->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax);
- m_frequencySpinBox->setValue(ToneGeneratorFreqDefault);
- m_amplitudeSlider->setRange(0, 100);
- m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault);
-
- // Add widgets to layout
- QGridLayout *frequencyControlLayout = new QGridLayout;
- QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this);
- frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1);
- frequencyControlLayout->addWidget(m_frequencySlider, 0, 1);
- frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1);
- m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout);
- m_toneGeneratorFrequencyControl->setEnabled(false);
-
- QGridLayout *toneGeneratorLayout = new QGridLayout;
- QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this);
- toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1);
- toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2);
- toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0);
- toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1);
- m_toneGeneratorControl->setLayout(toneGeneratorLayout);
- m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- dialogLayout->addWidget(m_toneGeneratorControl);
-
- // Connect
- connect(m_toneGeneratorSweepCheckBox, &QCheckBox::toggled,
- this, &ToneGeneratorDialog::frequencySweepEnabled);
- connect(m_frequencySlider, &QSlider::valueChanged,
- m_frequencySpinBox, &QSpinBox::setValue);
- connect(m_frequencySpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
- m_frequencySlider, &QSlider::setValue);
-
- // Add standard buttons to layout
- QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
- buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- dialogLayout->addWidget(buttonBox);
-
- // Connect standard buttons
- connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
- this, &ToneGeneratorDialog::accept);
- connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
- this, &ToneGeneratorDialog::reject);
-
- setLayout(dialogLayout);
-}
-
-ToneGeneratorDialog::~ToneGeneratorDialog()
-{
-
-}
-
-bool ToneGeneratorDialog::isFrequencySweepEnabled() const
-{
- return m_toneGeneratorSweepCheckBox->isChecked();
-}
-
-qreal ToneGeneratorDialog::frequency() const
-{
- return qreal(m_frequencySlider->value());
-}
-
-qreal ToneGeneratorDialog::amplitude() const
-{
- return qreal(m_amplitudeSlider->value()) / 100.0;
-}
-
-void ToneGeneratorDialog::frequencySweepEnabled(bool enabled)
-{
- m_frequencySweepEnabled = enabled;
- m_toneGeneratorFrequencyControl->setEnabled(!enabled);
-}
diff --git a/examples/multimedia/spectrum/app/tonegeneratordialog.h b/examples/multimedia/spectrum/app/tonegeneratordialog.h
deleted file mode 100644
index 48a44a152..000000000
--- a/examples/multimedia/spectrum/app/tonegeneratordialog.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef TONEGENERATORDIALOG_H
-#define TONEGENERATORDIALOG_H
-
-#include "spectrum.h"
-#include <QAudioDeviceInfo>
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QCheckBox;
-class QSlider;
-class QSpinBox;
-class QGridLayout;
-QT_END_NAMESPACE
-
-/**
- * Dialog which controls the parameters of the tone generator.
- */
-class ToneGeneratorDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ToneGeneratorDialog(QWidget *parent = 0);
- ~ToneGeneratorDialog();
-
- bool isFrequencySweepEnabled() const;
- qreal frequency() const;
- qreal amplitude() const;
-
-private slots:
- void frequencySweepEnabled(bool enabled);
-
-private:
- QCheckBox *m_toneGeneratorSweepCheckBox;
- bool m_frequencySweepEnabled;
- QWidget *m_toneGeneratorControl;
- QWidget *m_toneGeneratorFrequencyControl;
- QSlider *m_frequencySlider;
- QSpinBox *m_frequencySpinBox;
- qreal m_frequency;
- QSlider *m_amplitudeSlider;
-};
-
-#endif // TONEGENERATORDIALOG_H
diff --git a/examples/multimedia/spectrum/app/utils.cpp b/examples/multimedia/spectrum/app/utils.cpp
deleted file mode 100644
index fc8b9a448..000000000
--- a/examples/multimedia/spectrum/app/utils.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QAudioFormat>
-#include "utils.h"
-
-qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
-{
- return (bytes * 1000000) /
- (format.sampleRate() * format.channelCount() * (format.sampleSize() / 8));
-}
-
-qint64 audioLength(const QAudioFormat &format, qint64 microSeconds)
-{
- qint64 result = (format.sampleRate() * format.channelCount() * (format.sampleSize() / 8))
- * microSeconds / 1000000;
- result -= result % (format.channelCount() * format.sampleSize());
- return result;
-}
-
-qreal nyquistFrequency(const QAudioFormat &format)
-{
- return format.sampleRate() / 2;
-}
-
-QString formatToString(const QAudioFormat &format)
-{
- QString result;
-
- if (QAudioFormat() != format) {
- if (format.codec() == "audio/pcm") {
- Q_ASSERT(format.sampleType() == QAudioFormat::SignedInt);
-
- const QString formatEndian = (format.byteOrder() == QAudioFormat::LittleEndian)
- ? QString("LE") : QString("BE");
-
- QString formatType;
- switch (format.sampleType()) {
- case QAudioFormat::SignedInt:
- formatType = "signed";
- break;
- case QAudioFormat::UnSignedInt:
- formatType = "unsigned";
- break;
- case QAudioFormat::Float:
- formatType = "float";
- break;
- case QAudioFormat::Unknown:
- formatType = "unknown";
- break;
- }
-
- QString formatChannels = QString("%1 channels").arg(format.channelCount());
- switch (format.channelCount()) {
- case 1:
- formatChannels = "mono";
- break;
- case 2:
- formatChannels = "stereo";
- break;
- }
-
- result = QString("%1 Hz %2 bit %3 %4 %5")
- .arg(format.sampleRate())
- .arg(format.sampleSize())
- .arg(formatType)
- .arg(formatEndian)
- .arg(formatChannels);
- } else {
- result = format.codec();
- }
- }
-
- return result;
-}
-
-bool isPCM(const QAudioFormat &format)
-{
- return (format.codec() == "audio/pcm");
-}
-
-
-bool isPCMS16LE(const QAudioFormat &format)
-{
- return isPCM(format) &&
- format.sampleType() == QAudioFormat::SignedInt &&
- format.sampleSize() == 16 &&
- format.byteOrder() == QAudioFormat::LittleEndian;
-}
-
-const qint16 PCMS16MaxValue = 32767;
-const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768
-
-qreal pcmToReal(qint16 pcm)
-{
- return qreal(pcm) / PCMS16MaxAmplitude;
-}
-
-qint16 realToPcm(qreal real)
-{
- return real * PCMS16MaxValue;
-}
diff --git a/examples/multimedia/spectrum/app/utils.h b/examples/multimedia/spectrum/app/utils.h
deleted file mode 100644
index cd6357182..000000000
--- a/examples/multimedia/spectrum/app/utils.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef UTILS_H
-#define UTILS_H
-
-#include <QtCore/qglobal.h>
-#include <QDebug>
-
-QT_FORWARD_DECLARE_CLASS(QAudioFormat)
-
-//-----------------------------------------------------------------------------
-// Miscellaneous utility functions
-//-----------------------------------------------------------------------------
-
-qint64 audioDuration(const QAudioFormat &format, qint64 bytes);
-qint64 audioLength(const QAudioFormat &format, qint64 microSeconds);
-
-QString formatToString(const QAudioFormat &format);
-
-qreal nyquistFrequency(const QAudioFormat &format);
-
-// Scale PCM value to [-1.0, 1.0]
-qreal pcmToReal(qint16 pcm);
-
-// Scale real value in [-1.0, 1.0] to PCM
-qint16 realToPcm(qreal real);
-
-// Check whether the audio format is PCM
-bool isPCM(const QAudioFormat &format);
-
-// Check whether the audio format is signed, little-endian, 16-bit PCM
-bool isPCMS16LE(const QAudioFormat &format);
-
-// Compile-time calculation of powers of two
-
-template<int N> class PowerOfTwo
-{ public: static const int Result = PowerOfTwo<N-1>::Result * 2; };
-
-template<> class PowerOfTwo<0>
-{ public: static const int Result = 1; };
-
-
-//-----------------------------------------------------------------------------
-// Debug output
-//-----------------------------------------------------------------------------
-
-class NullDebug
-{
-public:
- template <typename T>
- NullDebug& operator<<(const T&) { return *this; }
-};
-
-inline NullDebug nullDebug() { return NullDebug(); }
-
-#ifdef LOG_ENGINE
-# define ENGINE_DEBUG qDebug()
-#else
-# define ENGINE_DEBUG nullDebug()
-#endif
-
-#ifdef LOG_SPECTRUMANALYSER
-# define SPECTRUMANALYSER_DEBUG qDebug()
-#else
-# define SPECTRUMANALYSER_DEBUG nullDebug()
-#endif
-
-#ifdef LOG_WAVEFORM
-# define WAVEFORM_DEBUG qDebug()
-#else
-# define WAVEFORM_DEBUG nullDebug()
-#endif
-
-#endif // UTILS_H
diff --git a/examples/multimedia/spectrum/app/wavfile.cpp b/examples/multimedia/spectrum/app/wavfile.cpp
deleted file mode 100644
index 475200db5..000000000
--- a/examples/multimedia/spectrum/app/wavfile.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <qendian.h>
-#include "wavfile.h"
-
-struct chunk
-{
- char id[4];
- quint32 size;
-};
-
-struct RIFFHeader
-{
- chunk descriptor; // "RIFF"
- char type[4]; // "WAVE"
-};
-
-struct WAVEHeader
-{
- chunk descriptor;
- quint16 audioFormat;
- quint16 numChannels;
- quint32 sampleRate;
- quint32 byteRate;
- quint16 blockAlign;
- quint16 bitsPerSample;
-};
-
-struct DATAHeader
-{
- chunk descriptor;
-};
-
-struct CombinedHeader
-{
- RIFFHeader riff;
- WAVEHeader wave;
-};
-
-WavFile::WavFile(QObject *parent)
- : QFile(parent)
- , m_headerLength(0)
-{
-
-}
-
-bool WavFile::open(const QString &fileName)
-{
- close();
- setFileName(fileName);
- return QFile::open(QIODevice::ReadOnly) && readHeader();
-}
-
-const QAudioFormat &WavFile::fileFormat() const
-{
- return m_fileFormat;
-}
-
-qint64 WavFile::headerLength() const
-{
- return m_headerLength;
-}
-
-bool WavFile::readHeader()
-{
- seek(0);
- CombinedHeader header;
- bool result = read(reinterpret_cast<char *>(&header), sizeof(CombinedHeader)) == sizeof(CombinedHeader);
- if (result) {
- if ((memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0
- || memcmp(&header.riff.descriptor.id, "RIFX", 4) == 0)
- && memcmp(&header.riff.type, "WAVE", 4) == 0
- && memcmp(&header.wave.descriptor.id, "fmt ", 4) == 0
- && (header.wave.audioFormat == 1 || header.wave.audioFormat == 0)) {
-
- // Read off remaining header information
- DATAHeader dataHeader;
-
- if (qFromLittleEndian<quint32>(header.wave.descriptor.size) > sizeof(WAVEHeader)) {
- // Extended data available
- quint16 extraFormatBytes;
- if (peek((char*)&extraFormatBytes, sizeof(quint16)) != sizeof(quint16))
- return false;
- const qint64 throwAwayBytes = sizeof(quint16) + qFromLittleEndian<quint16>(extraFormatBytes);
- if (read(throwAwayBytes).size() != throwAwayBytes)
- return false;
- }
-
- if (read((char*)&dataHeader, sizeof(DATAHeader)) != sizeof(DATAHeader))
- return false;
-
- // Establish format
- if (memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0)
- m_fileFormat.setByteOrder(QAudioFormat::LittleEndian);
- else
- m_fileFormat.setByteOrder(QAudioFormat::BigEndian);
-
- int bps = qFromLittleEndian<quint16>(header.wave.bitsPerSample);
- m_fileFormat.setChannelCount(qFromLittleEndian<quint16>(header.wave.numChannels));
- m_fileFormat.setCodec("audio/pcm");
- m_fileFormat.setSampleRate(qFromLittleEndian<quint32>(header.wave.sampleRate));
- m_fileFormat.setSampleSize(qFromLittleEndian<quint16>(header.wave.bitsPerSample));
- m_fileFormat.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt);
- } else {
- result = false;
- }
- }
- m_headerLength = pos();
- return result;
-}
diff --git a/examples/multimedia/spectrum/app/wavfile.h b/examples/multimedia/spectrum/app/wavfile.h
deleted file mode 100644
index a63bc5c93..000000000
--- a/examples/multimedia/spectrum/app/wavfile.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef WAVFILE_H
-#define WAVFILE_H
-
-#include <QObject>
-#include <QFile>
-#include <QAudioFormat>
-
-class WavFile : public QFile
-{
-public:
- WavFile(QObject *parent = 0);
-
- using QFile::open;
- bool open(const QString &fileName);
- const QAudioFormat &fileFormat() const;
- qint64 headerLength() const;
-
-private:
- bool readHeader();
-
-private:
- QAudioFormat m_fileFormat;
- qint64 m_headerLength;
-};
-
-#endif // WAVFILE_H
diff --git a/examples/multimedia/spectrum/doc/src/spectrum.qdoc b/examples/multimedia/spectrum/doc/src/spectrum.qdoc
index ad0ec984f..25e0760a4 100644
--- a/examples/multimedia/spectrum/doc/src/spectrum.qdoc
+++ b/examples/multimedia/spectrum/doc/src/spectrum.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example multimedia/spectrum
+ \example spectrum
\title Spectrum Example
\ingroup multimedia_examples
+ \examplecategory {Multimedia}
\brief Analyzing a raw audio stream using the FFTReal library.
\e Spectrum demonstrates how the \l{Qt Multimedia} module can be used to
@@ -58,8 +35,9 @@
Spectrum analysis is performed by calculating the Fast Fourier Transform
(FFT) of a segment of audio data. An open-source library,
- \l{http://ldesoras.free.fr/prod.html}{FFTReal}, against which the
- application is dynamically linked, is used to compute the transform.
+ \l{http://ldesoras.free.fr/prod.html}{FFTReal} is used to compute the
+ transform. FFTReal is available under the GNU Library General Public License
+ 2.0 or later.
\include examples-run.qdocinc
*/
diff --git a/examples/multimedia/spectrum/engine.cpp b/examples/multimedia/spectrum/engine.cpp
new file mode 100644
index 000000000..cb7aeadcb
--- /dev/null
+++ b/examples/multimedia/spectrum/engine.cpp
@@ -0,0 +1,750 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "engine.h"
+#include "tonegenerator.h"
+#include "utils.h"
+
+#include <QAudioSink>
+#include <QAudioSource>
+#include <QCoreApplication>
+#include <QDebug>
+#include <QFile>
+#include <QMetaObject>
+#include <QSet>
+#include <QThread>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
+#include <math.h>
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+const qint64 BufferDurationUs = 10 * 1000000;
+
+// Size of the level calculation window in microseconds
+const int LevelWindowUs = 0.1 * 1000000;
+
+//-----------------------------------------------------------------------------
+// Constructor and destructor
+//-----------------------------------------------------------------------------
+
+Engine::Engine(QObject *parent)
+ : QObject(parent),
+ m_mode(QAudioDevice::Input),
+ m_state(QAudio::StoppedState),
+ m_devices(new QMediaDevices(this)),
+ m_generateTone(false),
+ m_file(nullptr),
+ m_analysisFile(nullptr),
+ m_audioInput(nullptr),
+ m_audioInputIODevice(nullptr),
+ m_recordPosition(0),
+ m_audioOutput(nullptr),
+ m_playPosition(0),
+ m_bufferPosition(0),
+ m_bufferLength(0),
+ m_dataLength(0),
+ m_levelBufferLength(0),
+ m_rmsLevel(0.0),
+ m_peakLevel(0.0),
+ m_spectrumBufferLength(0),
+ m_spectrumPosition(0),
+ m_count(0)
+{
+ connect(&m_spectrumAnalyser,
+ QOverload<const FrequencySpectrum &>::of(&SpectrumAnalyser::spectrumChanged), this,
+ QOverload<const FrequencySpectrum &>::of(&Engine::spectrumChanged));
+
+ // This code might misinterpret things like "-something -category". But
+ // it's unlikely that that needs to be supported so we'll let it go.
+ QStringList arguments = QCoreApplication::instance()->arguments();
+ for (int i = 0; i < arguments.count(); ++i) {
+ if (arguments.at(i) == QStringLiteral("--"))
+ break;
+ }
+
+ initAudioDevices();
+
+ initialize();
+
+#ifdef DUMP_DATA
+ createOutputDir();
+#endif
+
+#ifdef DUMP_SPECTRUM
+ m_spectrumAnalyser.setOutputPath(outputPath());
+#endif
+
+ m_notifyTimer = new QTimer(this);
+ m_notifyTimer->setInterval(1000);
+ connect(m_notifyTimer, &QTimer::timeout, this, &Engine::audioNotify);
+}
+
+Engine::~Engine() = default;
+
+//-----------------------------------------------------------------------------
+// Public functions
+//-----------------------------------------------------------------------------
+
+bool Engine::loadFile(const QString &fileName)
+{
+ reset();
+ bool result = false;
+ Q_ASSERT(!m_generateTone);
+ Q_ASSERT(!m_file);
+ Q_ASSERT(!fileName.isEmpty());
+ QIODevice *file = new QFile(fileName);
+ if (file->open(QIODevice::ReadOnly)) {
+ m_file = new QWaveDecoder(file, this);
+ if (m_file->open(QIODevice::ReadOnly)) {
+ if (m_file->audioFormat().sampleFormat() == QAudioFormat::Int16) {
+ result = initialize();
+ } else {
+ emit errorMessage(tr("Audio format not supported"),
+ formatToString(m_file->audioFormat()));
+ }
+ } else
+ emit errorMessage(tr("Could not open WAV decoder for file"), fileName);
+ } else {
+ emit errorMessage(tr("Could not open file"), fileName);
+ }
+ if (result) {
+ file->close();
+ file->open(QIODevice::ReadOnly);
+ m_analysisFile = new QWaveDecoder(file, this);
+ m_analysisFile->open(QIODevice::ReadOnly);
+ }
+ return result;
+}
+
+bool Engine::generateTone(const Tone &tone)
+{
+ reset();
+ Q_ASSERT(!m_generateTone);
+ Q_ASSERT(!m_file);
+ m_generateTone = true;
+ m_tone = tone;
+ ENGINE_DEBUG << "Engine::generateTone"
+ << "startFreq" << m_tone.startFreq << "endFreq" << m_tone.endFreq << "amp"
+ << m_tone.amplitude;
+ return initialize();
+}
+
+bool Engine::generateSweptTone(qreal amplitude)
+{
+ Q_ASSERT(!m_generateTone);
+ Q_ASSERT(!m_file);
+ m_generateTone = true;
+ m_tone.startFreq = 1;
+ m_tone.endFreq = 0;
+ m_tone.amplitude = amplitude;
+ ENGINE_DEBUG << "Engine::generateSweptTone"
+ << "startFreq" << m_tone.startFreq << "amp" << m_tone.amplitude;
+ return initialize();
+}
+
+bool Engine::initializeRecord()
+{
+ reset();
+ ENGINE_DEBUG << "Engine::initializeRecord";
+ Q_ASSERT(!m_generateTone);
+ Q_ASSERT(!m_file);
+ m_generateTone = false;
+ m_tone = SweptTone();
+ return initialize();
+}
+
+qint64 Engine::bufferLength() const
+{
+ return m_file ? m_file->getDevice()->size() : m_bufferLength;
+}
+
+void Engine::setWindowFunction(WindowFunction type)
+{
+ m_spectrumAnalyser.setWindowFunction(type);
+}
+
+//-----------------------------------------------------------------------------
+// Public slots
+//-----------------------------------------------------------------------------
+
+void Engine::startRecording()
+{
+ if (m_audioInput) {
+ if (QAudioDevice::Input == m_mode && QAudio::SuspendedState == m_state) {
+ m_audioInput->resume();
+ } else {
+ m_spectrumAnalyser.cancelCalculation();
+ emit spectrumChanged(0, 0, FrequencySpectrum());
+
+ m_buffer.fill(0);
+ setRecordPosition(0, true);
+ stopPlayback();
+ m_mode = QAudioDevice::Input;
+ connect(m_audioInput, &QAudioSource::stateChanged, this, &Engine::audioStateChanged);
+
+ m_count = 0;
+ m_dataLength = 0;
+ emit dataLengthChanged(0);
+ m_audioInputIODevice = m_audioInput->start();
+ connect(m_audioInputIODevice, &QIODevice::readyRead, this, &Engine::audioDataReady);
+ }
+ m_notifyTimer->start();
+ }
+}
+
+void Engine::startPlayback()
+{
+ if (!m_audioOutput)
+ initialize();
+
+ if (m_audioOutput) {
+ if (QAudioDevice::Output == m_mode && QAudio::SuspendedState == m_state) {
+#ifdef Q_OS_WIN
+ // The Windows backend seems to internally go back into ActiveState
+ // while still returning SuspendedState, so to ensure that it doesn't
+ // ignore the resume() call, we first re-suspend
+ m_audioOutput->suspend();
+#endif
+ m_audioOutput->resume();
+ } else {
+ m_spectrumAnalyser.cancelCalculation();
+ emit spectrumChanged(0, 0, FrequencySpectrum());
+ setPlayPosition(0, true);
+ stopRecording();
+ m_mode = QAudioDevice::Output;
+ connect(m_audioOutput, &QAudioSink::stateChanged, this, &Engine::audioStateChanged);
+
+ m_count = 0;
+ if (m_file) {
+ m_file->seek(0);
+ m_bufferPosition = 0;
+ m_dataLength = 0;
+ m_audioOutput->start(m_file->getDevice());
+ } else {
+ m_audioOutputIODevice.close();
+ m_audioOutputIODevice.setBuffer(&m_buffer);
+ m_audioOutputIODevice.open(QIODevice::ReadOnly);
+ m_audioOutput->start(&m_audioOutputIODevice);
+ }
+ }
+ m_notifyTimer->start();
+ }
+}
+
+void Engine::suspend()
+{
+ if (QAudio::ActiveState == m_state || QAudio::IdleState == m_state) {
+ switch (m_mode) {
+ case QAudioDevice::Input:
+ m_audioInput->suspend();
+ break;
+ case QAudioDevice::Output:
+ m_audioOutput->suspend();
+ break;
+ default:
+ break;
+ }
+ m_notifyTimer->stop();
+ }
+}
+
+void Engine::setAudioInputDevice(const QAudioDevice &device)
+{
+ if (device.id() != m_audioInputDevice.id()) {
+ m_audioInputDevice = device;
+ initialize();
+ }
+}
+
+void Engine::setAudioOutputDevice(const QAudioDevice &device)
+{
+ if (device.id() != m_audioOutputDevice.id()) {
+ m_audioOutputDevice = device;
+ initialize();
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Private slots
+//-----------------------------------------------------------------------------
+
+void Engine::initAudioDevices()
+{
+#if QT_CONFIG(permissions)
+ QMicrophonePermission microphonePermission;
+ switch (qApp->checkPermission(microphonePermission)) {
+ case Qt::PermissionStatus::Undetermined:
+ qApp->requestPermission(microphonePermission, this, &Engine::initAudioDevices);
+ return;
+ case Qt::PermissionStatus::Denied:
+ qWarning("Microphone permission is not granted!");
+ return;
+ case Qt::PermissionStatus::Granted:
+ break;
+ }
+#endif
+ m_availableAudioInputDevices = m_devices->audioInputs();
+ m_audioInputDevice = m_devices->defaultAudioInput();
+ m_availableAudioOutputDevices = m_devices->audioOutputs();
+ m_audioOutputDevice = m_devices->defaultAudioOutput();
+}
+
+void Engine::audioNotify()
+{
+ switch (m_mode) {
+ case QAudioDevice::Input: {
+ const qint64 recordPosition =
+ qMin(m_bufferLength, m_format.bytesForDuration(m_audioInput->processedUSecs()));
+ setRecordPosition(recordPosition);
+ const qint64 levelPosition = m_dataLength - m_levelBufferLength;
+ if (levelPosition >= 0)
+ calculateLevel(levelPosition, m_levelBufferLength);
+ if (m_dataLength >= m_spectrumBufferLength) {
+ const qint64 spectrumPosition = m_dataLength - m_spectrumBufferLength;
+ calculateSpectrum(spectrumPosition);
+ }
+ emit bufferChanged(0, m_dataLength, m_buffer);
+ } break;
+ case QAudioDevice::Output: {
+ const qint64 playPosition = m_format.bytesForDuration(m_audioOutput->processedUSecs());
+ setPlayPosition(qMin(bufferLength(), playPosition));
+ const qint64 levelPosition = playPosition - m_levelBufferLength;
+ const qint64 spectrumPosition = playPosition - m_spectrumBufferLength;
+ if (m_file) {
+ if (levelPosition > m_bufferPosition || spectrumPosition > m_bufferPosition
+ || qMax(m_levelBufferLength, m_spectrumBufferLength) > m_dataLength) {
+ m_bufferPosition = 0;
+ m_dataLength = 0;
+ // Data needs to be read into m_buffer in order to be analysed
+ const qint64 readPos = qMax(qint64(0), qMin(levelPosition, spectrumPosition));
+ const qint64 readEnd = qMin(m_analysisFile->getDevice()->size(),
+ qMax(levelPosition + m_levelBufferLength,
+ spectrumPosition + m_spectrumBufferLength));
+ const qint64 readLen =
+ readEnd - readPos + m_format.bytesForDuration(WaveformWindowDuration);
+ qDebug() << "Engine::audioNotify [1]"
+ << "analysisFileSize" << m_analysisFile->getDevice()->size() << "readPos"
+ << readPos << "readLen" << readLen;
+ if (m_analysisFile->seek(readPos + m_analysisFile->headerLength())) {
+ m_buffer.resize(readLen);
+ m_bufferPosition = readPos;
+ m_dataLength = m_analysisFile->read(m_buffer.data(), readLen);
+ qDebug() << "Engine::audioNotify [2]"
+ << "bufferPosition" << m_bufferPosition << "dataLength"
+ << m_dataLength;
+ } else {
+ qDebug() << "Engine::audioNotify [2]"
+ << "file seek error";
+ }
+ emit bufferChanged(m_bufferPosition, m_dataLength, m_buffer);
+ }
+ } else {
+ if (playPosition >= m_dataLength)
+ stopPlayback();
+ }
+ if (levelPosition >= 0
+ && levelPosition + m_levelBufferLength < m_bufferPosition + m_dataLength)
+ calculateLevel(levelPosition, m_levelBufferLength);
+ if (spectrumPosition >= 0
+ && spectrumPosition + m_spectrumBufferLength < m_bufferPosition + m_dataLength)
+ calculateSpectrum(spectrumPosition);
+ } break;
+ default:
+ break;
+ }
+}
+
+void Engine::audioStateChanged(QAudio::State state)
+{
+ ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state << "to" << state;
+
+ if (QAudio::IdleState == state && m_file && m_file->pos() == m_file->getDevice()->size()) {
+ stopPlayback();
+ } else {
+ if (QAudio::StoppedState == state) {
+ // Check error
+ QAudio::Error error = QAudio::NoError;
+ switch (m_mode) {
+ case QAudioDevice::Input:
+ error = m_audioInput->error();
+ break;
+ case QAudioDevice::Output:
+ error = m_audioOutput->error();
+ break;
+ default:
+ break;
+ }
+ if (QAudio::NoError != error) {
+ emitError(error);
+ reset();
+ return;
+ }
+ }
+ setState(state);
+ }
+}
+
+void Engine::audioDataReady()
+{
+ Q_ASSERT(0 == m_bufferPosition);
+ const qint64 bytesReady = m_audioInput->bytesAvailable();
+ const qint64 bytesSpace = m_buffer.size() - m_dataLength;
+ const qint64 bytesToRead = qMin(bytesReady, bytesSpace);
+
+ const qint64 bytesRead =
+ m_audioInputIODevice->read(m_buffer.data() + m_dataLength, bytesToRead);
+
+ if (bytesRead) {
+ m_dataLength += bytesRead;
+ emit dataLengthChanged(dataLength());
+ }
+
+ if (m_buffer.size() == m_dataLength)
+ stopRecording();
+}
+
+void Engine::spectrumChanged(const FrequencySpectrum &spectrum)
+{
+ ENGINE_DEBUG << "Engine::spectrumChanged"
+ << "pos" << m_spectrumPosition;
+ emit spectrumChanged(m_spectrumPosition, m_spectrumBufferLength, spectrum);
+}
+
+//-----------------------------------------------------------------------------
+// Private functions
+//-----------------------------------------------------------------------------
+
+void Engine::resetAudioDevices()
+{
+ delete m_audioInput;
+ m_audioInput = nullptr;
+ m_audioInputIODevice = nullptr;
+ setRecordPosition(0);
+ delete m_audioOutput;
+ m_audioOutput = nullptr;
+ setPlayPosition(0);
+ m_spectrumPosition = 0;
+ setLevel(0.0, 0.0, 0);
+}
+
+void Engine::reset()
+{
+ stopRecording();
+ stopPlayback();
+ setState(QAudioDevice::Input, QAudio::StoppedState);
+ m_generateTone = false;
+ setFormat(QAudioFormat());
+ delete m_file;
+ m_file = nullptr;
+ delete m_analysisFile;
+ m_analysisFile = nullptr;
+ m_buffer.clear();
+ m_bufferPosition = 0;
+ m_bufferLength = 0;
+ m_dataLength = 0;
+ emit dataLengthChanged(0);
+ resetAudioDevices();
+}
+
+bool Engine::initialize()
+{
+ bool result = false;
+
+ QAudioFormat format = m_format;
+
+ if (selectFormat()) {
+ if (m_format != format) {
+ resetAudioDevices();
+ if (m_file) {
+ emit bufferLengthChanged(bufferLength());
+ emit dataLengthChanged(dataLength());
+ emit bufferChanged(0, 0, m_buffer);
+ setRecordPosition(bufferLength());
+ result = true;
+ } else {
+ m_bufferLength = m_format.bytesForDuration(BufferDurationUs);
+ m_buffer.resize(m_bufferLength);
+ m_buffer.fill(0);
+ emit bufferLengthChanged(bufferLength());
+ if (m_generateTone) {
+ if (0 == m_tone.endFreq) {
+ const qreal nyquist = nyquistFrequency(m_format);
+ m_tone.endFreq = qMin(qreal(SpectrumHighFreq), nyquist);
+ }
+ // Call function defined in utils.h, at global scope
+ ::generateTone(m_tone, m_format, m_buffer);
+ m_dataLength = m_bufferLength;
+ emit dataLengthChanged(dataLength());
+ emit bufferChanged(0, m_dataLength, m_buffer);
+ setRecordPosition(m_bufferLength);
+ result = true;
+ } else {
+ emit bufferChanged(0, 0, m_buffer);
+ m_audioInput = new QAudioSource(m_audioInputDevice, m_format, this);
+ result = true;
+ }
+ }
+ m_audioOutput = new QAudioSink(m_audioOutputDevice, m_format, this);
+ }
+ } else {
+ if (m_file)
+ emit errorMessage(tr("Audio format not supported"), formatToString(m_format));
+ else if (m_generateTone)
+ emit errorMessage(tr("No suitable format found"), "");
+ else
+ emit errorMessage(tr("No common input / output format found"), "");
+ }
+
+ ENGINE_DEBUG << "Engine::initialize"
+ << "m_bufferLength" << m_bufferLength;
+ ENGINE_DEBUG << "Engine::initialize"
+ << "m_dataLength" << m_dataLength;
+ ENGINE_DEBUG << "Engine::initialize"
+ << "format" << m_format;
+
+ return result;
+}
+
+bool Engine::selectFormat()
+{
+ bool foundSupportedFormat = false;
+
+ if (m_file || QAudioFormat() != m_format) {
+ QAudioFormat format = m_format;
+ if (m_file)
+ // Header is read from the WAV file; just need to check whether
+ // it is supported by the audio output device
+ format = m_file->audioFormat();
+ if (m_audioOutputDevice.isFormatSupported(format)) {
+ setFormat(format);
+ foundSupportedFormat = true;
+ }
+ } else {
+
+ int minSampleRate = qMin(m_audioInputDevice.minimumSampleRate(),
+ m_audioOutputDevice.minimumSampleRate());
+ int maxSampleRate = qMin(m_audioInputDevice.maximumSampleRate(),
+ m_audioOutputDevice.maximumSampleRate());
+ int minChannelCount = qMin(m_audioInputDevice.minimumChannelCount(),
+ m_audioOutputDevice.minimumChannelCount());
+ int maxChannelCount = qMin(m_audioInputDevice.maximumChannelCount(),
+ m_audioOutputDevice.maximumChannelCount());
+
+ QAudioFormat format;
+ format.setSampleFormat(QAudioFormat::Int16);
+ format.setSampleRate(qBound(minSampleRate, 48000, maxSampleRate));
+ format.setChannelCount(qBound(minChannelCount, 2, maxChannelCount));
+
+ const bool inputSupport = m_audioInputDevice.isFormatSupported(format);
+ const bool outputSupport = m_audioOutputDevice.isFormatSupported(format);
+ if (inputSupport && outputSupport)
+ foundSupportedFormat = true;
+
+ setFormat(format);
+ }
+
+ return foundSupportedFormat;
+}
+
+void Engine::stopRecording()
+{
+ if (m_audioInput) {
+ m_audioInput->stop();
+ QCoreApplication::instance()->processEvents();
+ m_audioInput->disconnect();
+ }
+ m_audioInputIODevice = nullptr;
+ m_notifyTimer->stop();
+
+#ifdef DUMP_AUDIO
+ dumpData();
+#endif
+}
+
+void Engine::stopPlayback()
+{
+ if (m_audioOutput) {
+ m_audioOutput->stop();
+ QCoreApplication::instance()->processEvents();
+ m_audioOutput->disconnect();
+ setPlayPosition(0);
+ }
+ m_notifyTimer->stop();
+}
+
+void Engine::setState(QAudio::State state)
+{
+ const bool changed = (m_state != state);
+ m_state = state;
+ if (changed)
+ emit stateChanged(m_mode, m_state);
+}
+
+void Engine::setState(QAudioDevice::Mode mode, QAudio::State state)
+{
+ const bool changed = (m_mode != mode || m_state != state);
+ m_mode = mode;
+ m_state = state;
+ if (changed)
+ emit stateChanged(m_mode, m_state);
+}
+
+void Engine::setRecordPosition(qint64 position, bool forceEmit)
+{
+ const bool changed = (m_recordPosition != position);
+ m_recordPosition = position;
+ if (changed || forceEmit)
+ emit recordPositionChanged(m_recordPosition);
+}
+
+void Engine::setPlayPosition(qint64 position, bool forceEmit)
+{
+ const bool changed = (m_playPosition != position);
+ m_playPosition = position;
+ if (changed || forceEmit)
+ emit playPositionChanged(m_playPosition);
+}
+
+void Engine::calculateLevel(qint64 position, qint64 length)
+{
+#ifdef DISABLE_LEVEL
+ Q_UNUSED(position);
+ Q_UNUSED(length);
+#else
+ Q_ASSERT(position + length <= m_bufferPosition + m_dataLength);
+
+ qreal peakLevel = 0.0;
+
+ qreal sum = 0.0;
+ const char *ptr = m_buffer.constData() + position - m_bufferPosition;
+ const char *const end = ptr + length;
+ while (ptr < end) {
+ const qint16 value = *reinterpret_cast<const qint16 *>(ptr);
+ const qreal fracValue = pcmToReal(value);
+ peakLevel = qMax(peakLevel, fracValue);
+ sum += fracValue * fracValue;
+ ptr += 2;
+ }
+ const int numSamples = length / 2;
+ qreal rmsLevel = sqrt(sum / numSamples);
+
+ rmsLevel = qMax(qreal(0.0), rmsLevel);
+ rmsLevel = qMin(qreal(1.0), rmsLevel);
+ setLevel(rmsLevel, peakLevel, numSamples);
+
+ ENGINE_DEBUG << "Engine::calculateLevel"
+ << "pos" << position << "len" << length << "rms" << rmsLevel << "peak"
+ << peakLevel;
+#endif
+}
+
+void Engine::calculateSpectrum(qint64 position)
+{
+#ifdef DISABLE_SPECTRUM
+ Q_UNUSED(position);
+#else
+ Q_ASSERT(position + m_spectrumBufferLength <= m_bufferPosition + m_dataLength);
+ Q_ASSERT(0 == m_spectrumBufferLength % 2); // constraint of FFT algorithm
+
+ // QThread::currentThread is marked 'for internal use only', but
+ // we're only using it for debug output here, so it's probably OK :)
+ ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread() << "count" << m_count
+ << "pos" << position << "len" << m_spectrumBufferLength
+ << "spectrumAnalyser.isReady" << m_spectrumAnalyser.isReady();
+
+ if (m_spectrumAnalyser.isReady()) {
+ m_spectrumBuffer = QByteArray::fromRawData(
+ m_buffer.constData() + position - m_bufferPosition, m_spectrumBufferLength);
+ m_spectrumPosition = position;
+ m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
+ }
+#endif
+}
+
+void Engine::setFormat(const QAudioFormat &format)
+{
+ const bool changed = (format != m_format);
+ m_format = format;
+ m_levelBufferLength = m_format.bytesForDuration(LevelWindowUs);
+ m_spectrumBufferLength = SpectrumLengthSamples * format.bytesPerFrame();
+ if (changed)
+ emit formatChanged(m_format);
+}
+
+void Engine::setLevel(qreal rmsLevel, qreal peakLevel, int numSamples)
+{
+ m_rmsLevel = rmsLevel;
+ m_peakLevel = peakLevel;
+ emit levelChanged(m_rmsLevel, m_peakLevel, numSamples);
+}
+
+void Engine::emitError(QAudio::Error error)
+{
+ QString errorString;
+ switch (error) {
+ case QAudio::NoError:
+ errorString = tr("NoError");
+ break;
+ case QAudio::OpenError:
+ errorString = tr("OpenError: An error occurred opening the audio device.");
+ break;
+ case QAudio::IOError:
+ errorString = tr("IOError: An error occurred during read/write of audio device.");
+ break;
+ case QAudio::UnderrunError:
+ errorString = tr("UnderrunError: Audio data is not being fed"
+ "to the audio device at a fast enough rate.");
+ break;
+ case QAudio::FatalError:
+ errorString = tr("FatalError: A non-recoverable error has occurred,"
+ "the audio device is not usable at this time.");
+ break;
+ }
+
+ emit errorMessage(tr("Audio Device"), errorString);
+}
+
+#ifdef DUMP_DATA
+void Engine::createOutputDir()
+{
+ m_outputDir.setPath("output");
+
+ // Ensure output directory exists and is empty
+ if (m_outputDir.exists()) {
+ const QStringList files = m_outputDir.entryList(QDir::Files);
+ for (const QString &file : files)
+ m_outputDir.remove(file);
+ } else {
+ QDir::current().mkdir("output");
+ }
+}
+#endif // DUMP_DATA
+
+#ifdef DUMP_AUDIO
+void Engine::dumpData()
+{
+ const QString txtFileName = m_outputDir.filePath("data.txt");
+ QFile txtFile(txtFileName);
+ txtFile.open(QFile::WriteOnly | QFile::Text);
+ QTextStream stream(&txtFile);
+ const qint16 *ptr = reinterpret_cast<const qint16 *>(m_buffer.constData());
+ const int numSamples = m_dataLength / (2 * m_format.channels());
+ for (int i = 0; i < numSamples; ++i) {
+ stream << i << "\t" << *ptr << "\n";
+ ptr += m_format.channels();
+ }
+
+ const QString pcmFileName = m_outputDir.filePath("data.pcm");
+ QFile pcmFile(pcmFileName);
+ pcmFile.open(QFile::WriteOnly);
+ pcmFile.write(m_buffer.constData(), m_dataLength);
+}
+#endif // DUMP_AUDIO
+
+#include "moc_engine.cpp"
diff --git a/examples/multimedia/spectrum/app/engine.h b/examples/multimedia/spectrum/engine.h
index 714af4d9d..9e8ba51d0 100644
--- a/examples/multimedia/spectrum/app/engine.h
+++ b/examples/multimedia/spectrum/engine.h
@@ -1,80 +1,35 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ENGINE_H
#define ENGINE_H
#include "spectrum.h"
#include "spectrumanalyser.h"
-#include "wavfile.h"
-#include <QAudioDeviceInfo>
+#include <QAudioDevice>
#include <QAudioFormat>
#include <QBuffer>
#include <QByteArray>
#include <QDir>
#include <QList>
+#include <QMediaDevices>
#include <QObject>
+#include <QTimer>
+#include <QWaveDecoder>
#ifdef DUMP_CAPTURED_AUDIO
-#define DUMP_DATA
+# define DUMP_DATA
#endif
#ifdef DUMP_SPECTRUM
-#define DUMP_DATA
+# define DUMP_DATA
#endif
class FrequencySpectrum;
QT_BEGIN_NAMESPACE
-class QAudioInput;
-class QAudioOutput;
+class QAudioSource;
+class QAudioSink;
QT_END_NAMESPACE
/**
@@ -88,29 +43,32 @@ class Engine : public QObject
Q_OBJECT
public:
- explicit Engine(QObject *parent = 0);
+ explicit Engine(QObject *parent = nullptr);
~Engine();
- const QList<QAudioDeviceInfo> &availableAudioInputDevices() const
- { return m_availableAudioInputDevices; }
+ const QList<QAudioDevice> &availableAudioInputDevices() const
+ {
+ return m_availableAudioInputDevices;
+ }
- const QList<QAudioDeviceInfo> &availableAudioOutputDevices() const
- { return m_availableAudioOutputDevices; }
+ const QList<QAudioDevice> &availableAudioOutputDevices() const
+ {
+ return m_availableAudioOutputDevices;
+ }
- QAudio::Mode mode() const { return m_mode; }
+ QAudioDevice::Mode mode() const { return m_mode; }
QAudio::State state() const { return m_state; }
/**
* \return Current audio format
* \note May be QAudioFormat() if engine is not initialized
*/
- const QAudioFormat& format() const { return m_format; }
+ const QAudioFormat &format() const { return m_format; }
/**
* Stop any ongoing recording or playback, and reset to ground state.
*/
void reset();
-
/**
* Load data from WAV file
*/
@@ -176,11 +134,11 @@ public slots:
void startRecording();
void startPlayback();
void suspend();
- void setAudioInputDevice(const QAudioDeviceInfo &device);
- void setAudioOutputDevice(const QAudioDeviceInfo &device);
+ void setAudioInputDevice(const QAudioDevice &device);
+ void setAudioOutputDevice(const QAudioDevice &device);
signals:
- void stateChanged(QAudio::Mode mode, QAudio::State state);
+ void stateChanged(QAudioDevice::Mode mode, QAudio::State state);
/**
* Informational message for non-modal display
@@ -245,6 +203,7 @@ signals:
void bufferChanged(qint64 position, qint64 length, const QByteArray &buffer);
private slots:
+ void initAudioDevices();
void audioNotify();
void audioStateChanged(QAudio::State state);
void audioDataReady();
@@ -257,17 +216,21 @@ private:
void stopRecording();
void stopPlayback();
void setState(QAudio::State state);
- void setState(QAudio::Mode mode, QAudio::State state);
+ void setState(QAudioDevice::Mode mode, QAudio::State state);
void setFormat(const QAudioFormat &format);
void setRecordPosition(qint64 position, bool forceEmit = false);
void setPlayPosition(qint64 position, bool forceEmit = false);
void calculateLevel(qint64 position, qint64 length);
void calculateSpectrum(qint64 position);
void setLevel(qreal rmsLevel, qreal peakLevel, int numSamples);
+ void emitError(QAudio::Error error);
#ifdef DUMP_DATA
void createOutputDir();
- QString outputPath() const { return m_outputDir.path(); }
+ QString outputPath() const
+ {
+ return m_outputDir.path();
+ }
#endif
#ifdef DUMP_CAPTURED_AUDIO
@@ -275,52 +238,52 @@ private:
#endif
private:
- QAudio::Mode m_mode;
- QAudio::State m_state;
+ QAudioDevice::Mode m_mode;
+ QAudio::State m_state;
+ QMediaDevices *m_devices;
- bool m_generateTone;
- SweptTone m_tone;
+ bool m_generateTone;
+ SweptTone m_tone;
- WavFile* m_file;
+ QWaveDecoder *m_file;
// We need a second file handle via which to read data into m_buffer
// for analysis
- WavFile* m_analysisFile;
+ QWaveDecoder *m_analysisFile;
- QAudioFormat m_format;
+ QAudioFormat m_format;
- const QList<QAudioDeviceInfo> m_availableAudioInputDevices;
- QAudioDeviceInfo m_audioInputDevice;
- QAudioInput* m_audioInput;
- QIODevice* m_audioInputIODevice;
- qint64 m_recordPosition;
+ QList<QAudioDevice> m_availableAudioInputDevices;
+ QAudioDevice m_audioInputDevice;
+ QAudioSource *m_audioInput;
+ QIODevice *m_audioInputIODevice;
+ qint64 m_recordPosition;
- const QList<QAudioDeviceInfo> m_availableAudioOutputDevices;
- QAudioDeviceInfo m_audioOutputDevice;
- QAudioOutput* m_audioOutput;
- QString m_audioOutputCategory;
- qint64 m_playPosition;
- QBuffer m_audioOutputIODevice;
+ QList<QAudioDevice> m_availableAudioOutputDevices;
+ QAudioDevice m_audioOutputDevice;
+ QAudioSink *m_audioOutput;
+ qint64 m_playPosition;
+ QBuffer m_audioOutputIODevice;
- QByteArray m_buffer;
- qint64 m_bufferPosition;
- qint64 m_bufferLength;
- qint64 m_dataLength;
+ QByteArray m_buffer;
+ qint64 m_bufferPosition;
+ qint64 m_bufferLength;
+ qint64 m_dataLength;
- int m_levelBufferLength;
- qreal m_rmsLevel;
- qreal m_peakLevel;
+ int m_levelBufferLength;
+ qreal m_rmsLevel;
+ qreal m_peakLevel;
- int m_spectrumBufferLength;
- QByteArray m_spectrumBuffer;
- SpectrumAnalyser m_spectrumAnalyser;
- qint64 m_spectrumPosition;
+ int m_spectrumBufferLength;
+ QByteArray m_spectrumBuffer;
+ SpectrumAnalyser m_spectrumAnalyser;
+ qint64 m_spectrumPosition;
- int m_count;
+ int m_count;
+ QTimer *m_notifyTimer = nullptr;
#ifdef DUMP_DATA
- QDir m_outputDir;
+ QDir m_outputDir;
#endif
-
};
#endif // ENGINE_H
diff --git a/examples/multimedia/spectrum/frequencyspectrum.cpp b/examples/multimedia/spectrum/frequencyspectrum.cpp
new file mode 100644
index 000000000..f271a04aa
--- /dev/null
+++ b/examples/multimedia/spectrum/frequencyspectrum.cpp
@@ -0,0 +1,48 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "frequencyspectrum.h"
+
+FrequencySpectrum::FrequencySpectrum(int numPoints) : m_elements(numPoints) { }
+
+void FrequencySpectrum::reset()
+{
+ iterator i = begin();
+ for (; i != end(); ++i)
+ *i = Element();
+}
+
+int FrequencySpectrum::count() const
+{
+ return m_elements.count();
+}
+
+FrequencySpectrum::Element &FrequencySpectrum::operator[](int index)
+{
+ return m_elements[index];
+}
+
+const FrequencySpectrum::Element &FrequencySpectrum::operator[](int index) const
+{
+ return m_elements[index];
+}
+
+FrequencySpectrum::iterator FrequencySpectrum::begin()
+{
+ return m_elements.begin();
+}
+
+FrequencySpectrum::iterator FrequencySpectrum::end()
+{
+ return m_elements.end();
+}
+
+FrequencySpectrum::const_iterator FrequencySpectrum::begin() const
+{
+ return m_elements.begin();
+}
+
+FrequencySpectrum::const_iterator FrequencySpectrum::end() const
+{
+ return m_elements.end();
+}
diff --git a/examples/multimedia/spectrum/frequencyspectrum.h b/examples/multimedia/spectrum/frequencyspectrum.h
new file mode 100644
index 000000000..9f3771571
--- /dev/null
+++ b/examples/multimedia/spectrum/frequencyspectrum.h
@@ -0,0 +1,60 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef FREQUENCYSPECTRUM_H
+#define FREQUENCYSPECTRUM_H
+
+#include <QList>
+
+/**
+ * Represents a frequency spectrum as a series of elements, each of which
+ * consists of a frequency, an amplitude and a phase.
+ */
+class FrequencySpectrum
+{
+public:
+ FrequencySpectrum(int numPoints = 0);
+
+ struct Element
+ {
+ Element() : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false) { }
+
+ /**
+ * Frequency in Hertz
+ */
+ qreal frequency;
+
+ /**
+ * Amplitude in range [0.0, 1.0]
+ */
+ qreal amplitude;
+
+ /**
+ * Phase in range [0.0, 2*PI]
+ */
+ qreal phase;
+
+ /**
+ * Indicates whether value has been clipped during spectrum analysis
+ */
+ bool clipped;
+ };
+
+ typedef QList<Element>::iterator iterator;
+ typedef QList<Element>::const_iterator const_iterator;
+
+ void reset();
+
+ int count() const;
+ Element &operator[](int index);
+ const Element &operator[](int index) const;
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
+
+private:
+ QList<Element> m_elements;
+};
+
+#endif // FREQUENCYSPECTRUM_H
diff --git a/examples/multimedia/spectrum/app/images/record.png b/examples/multimedia/spectrum/images/record.png
index 184fce809..184fce809 100644
--- a/examples/multimedia/spectrum/app/images/record.png
+++ b/examples/multimedia/spectrum/images/record.png
Binary files differ
diff --git a/examples/multimedia/spectrum/app/images/settings.png b/examples/multimedia/spectrum/images/settings.png
index 12179dc9a..12179dc9a 100644
--- a/examples/multimedia/spectrum/app/images/settings.png
+++ b/examples/multimedia/spectrum/images/settings.png
Binary files differ
diff --git a/examples/multimedia/spectrum/levelmeter.cpp b/examples/multimedia/spectrum/levelmeter.cpp
new file mode 100644
index 000000000..2c889c34d
--- /dev/null
+++ b/examples/multimedia/spectrum/levelmeter.cpp
@@ -0,0 +1,103 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "levelmeter.h"
+
+#include <QDebug>
+#include <QPainter>
+#include <QTimer>
+
+#include <math.h>
+
+// Constants
+const int RedrawInterval = 100; // ms
+const qreal PeakDecayRate = 0.001;
+const int PeakHoldLevelDuration = 2000; // ms
+
+LevelMeter::LevelMeter(QWidget *parent)
+ : QWidget(parent),
+ m_rmsLevel(0.0),
+ m_peakLevel(0.0),
+ m_decayedPeakLevel(0.0),
+ m_peakDecayRate(PeakDecayRate),
+ m_peakHoldLevel(0.0),
+ m_redrawTimer(new QTimer(this)),
+ m_rmsColor(Qt::red),
+ m_peakColor(255, 200, 200, 255)
+{
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+ setMinimumWidth(30);
+
+ connect(m_redrawTimer, &QTimer::timeout, this, &LevelMeter::redrawTimerExpired);
+ m_redrawTimer->start(RedrawInterval);
+}
+
+LevelMeter::~LevelMeter() = default;
+
+void LevelMeter::reset()
+{
+ m_rmsLevel = 0.0;
+ m_peakLevel = 0.0;
+ update();
+}
+
+void LevelMeter::levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples)
+{
+ // Smooth the RMS signal
+ const qreal smooth =
+ pow(qreal(0.9), static_cast<qreal>(numSamples) / 256); // TODO: remove this magic number
+ m_rmsLevel = (m_rmsLevel * smooth) + (rmsLevel * (1.0 - smooth));
+
+ if (peakLevel > m_decayedPeakLevel) {
+ m_peakLevel = peakLevel;
+ m_decayedPeakLevel = peakLevel;
+ m_peakLevelChanged.start();
+ }
+
+ if (peakLevel > m_peakHoldLevel) {
+ m_peakHoldLevel = peakLevel;
+ m_peakHoldLevelChanged.start();
+ }
+
+ update();
+}
+
+void LevelMeter::redrawTimerExpired()
+{
+ // Decay the peak signal
+ const int elapsedMs = m_peakLevelChanged.elapsed();
+ const qreal decayAmount = m_peakDecayRate * elapsedMs;
+ if (decayAmount < m_peakLevel)
+ m_decayedPeakLevel = m_peakLevel - decayAmount;
+ else
+ m_decayedPeakLevel = 0.0;
+
+ // Check whether to clear the peak hold level
+ if (m_peakHoldLevelChanged.elapsed() > PeakHoldLevelDuration)
+ m_peakHoldLevel = 0.0;
+
+ update();
+}
+
+void LevelMeter::paintEvent(QPaintEvent *event)
+{
+ Q_UNUSED(event);
+
+ QPainter painter(this);
+ painter.fillRect(rect(), Qt::black);
+
+ QRect bar = rect();
+
+ bar.setTop(rect().top() + (1.0 - m_peakHoldLevel) * rect().height());
+ bar.setBottom(bar.top() + 5);
+ painter.fillRect(bar, m_rmsColor);
+ bar.setBottom(rect().bottom());
+
+ bar.setTop(rect().top() + (1.0 - m_decayedPeakLevel) * rect().height());
+ painter.fillRect(bar, m_peakColor);
+
+ bar.setTop(rect().top() + (1.0 - m_rmsLevel) * rect().height());
+ painter.fillRect(bar, m_rmsColor);
+}
+
+#include "moc_levelmeter.cpp"
diff --git a/examples/multimedia/spectrum/levelmeter.h b/examples/multimedia/spectrum/levelmeter.h
new file mode 100644
index 000000000..e131bc904
--- /dev/null
+++ b/examples/multimedia/spectrum/levelmeter.h
@@ -0,0 +1,80 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef LEVELMETER_H
+#define LEVELMETER_H
+
+#include <QElapsedTimer>
+#include <QWidget>
+
+/**
+ * Widget which displays a vertical audio level meter, indicating the
+ * RMS and peak levels of the window of audio samples most recently analyzed
+ * by the Engine.
+ */
+class LevelMeter : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit LevelMeter(QWidget *parent = nullptr);
+ ~LevelMeter();
+
+ void paintEvent(QPaintEvent *event) override;
+
+public slots:
+ void reset();
+ void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
+
+private slots:
+ void redrawTimerExpired();
+
+private:
+ /**
+ * Height of RMS level bar.
+ * Range 0.0 - 1.0.
+ */
+ qreal m_rmsLevel;
+
+ /**
+ * Most recent peak level.
+ * Range 0.0 - 1.0.
+ */
+ qreal m_peakLevel;
+
+ /**
+ * Height of peak level bar.
+ * This is calculated by decaying m_peakLevel depending on the
+ * elapsed time since m_peakLevelChanged, and the value of m_decayRate.
+ */
+ qreal m_decayedPeakLevel;
+
+ /**
+ * Time at which m_peakLevel was last changed.
+ */
+ QElapsedTimer m_peakLevelChanged;
+
+ /**
+ * Rate at which peak level bar decays.
+ * Expressed in level units / millisecond.
+ */
+ qreal m_peakDecayRate;
+
+ /**
+ * High watermark of peak level.
+ * Range 0.0 - 1.0.
+ */
+ qreal m_peakHoldLevel;
+
+ /**
+ * Time at which m_peakHoldLevel was last changed.
+ */
+ QElapsedTimer m_peakHoldLevelChanged;
+
+ QTimer *m_redrawTimer;
+
+ QColor m_rmsColor;
+ QColor m_peakColor;
+};
+
+#endif // LEVELMETER_H
diff --git a/examples/multimedia/spectrum/main.cpp b/examples/multimedia/spectrum/main.cpp
new file mode 100644
index 000000000..31913b2f2
--- /dev/null
+++ b/examples/multimedia/spectrum/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwidget.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ app.setApplicationName("Qt Multimedia spectrum analyzer");
+
+ MainWidget w;
+ w.show();
+
+ return app.exec();
+}
diff --git a/examples/multimedia/spectrum/app/mainwidget.cpp b/examples/multimedia/spectrum/mainwidget.cpp
index d6163f7f9..214d317d9 100644
--- a/examples/multimedia/spectrum/app/mainwidget.cpp
+++ b/examples/multimedia/spectrum/mainwidget.cpp
@@ -1,101 +1,55 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#include "mainwidget.h"
#include "engine.h"
#include "levelmeter.h"
-#include "mainwidget.h"
-#include "waveform.h"
#include "progressbar.h"
#include "settingsdialog.h"
#include "spectrograph.h"
#include "tonegeneratordialog.h"
#include "utils.h"
+#include "waveform.h"
+#include <QFileDialog>
+#include <QHBoxLayout>
#include <QLabel>
+#include <QMenu>
+#include <QMessageBox>
#include <QPushButton>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
#include <QStyle>
-#include <QMenu>
-#include <QFileDialog>
#include <QTimerEvent>
-#include <QMessageBox>
+#include <QVBoxLayout>
const int NullTimerId = -1;
MainWidget::MainWidget(QWidget *parent)
- : QWidget(parent)
- , m_mode(NoMode)
- , m_engine(new Engine(this))
+ : QWidget(parent),
+ m_mode(NoMode),
+ m_engine(new Engine(this))
#ifndef DISABLE_WAVEFORM
- , m_waveform(new Waveform(this))
+ ,
+ m_waveform(new Waveform(this))
#endif
- , m_progressBar(new ProgressBar(this))
- , m_spectrograph(new Spectrograph(this))
- , m_levelMeter(new LevelMeter(this))
- , m_modeButton(new QPushButton(this))
- , m_recordButton(new QPushButton(this))
- , m_pauseButton(new QPushButton(this))
- , m_playButton(new QPushButton(this))
- , m_settingsButton(new QPushButton(this))
- , m_infoMessage(new QLabel(tr("Select a mode to begin"), this))
- , m_infoMessageTimerId(NullTimerId)
- , m_settingsDialog(new SettingsDialog(
- m_engine->availableAudioInputDevices(),
- m_engine->availableAudioOutputDevices(),
- this))
- , m_toneGeneratorDialog(new ToneGeneratorDialog(this))
- , m_modeMenu(new QMenu(this))
- , m_loadFileAction(0)
- , m_generateToneAction(0)
- , m_recordAction(0)
+ ,
+ m_progressBar(new ProgressBar(this)),
+ m_spectrograph(new Spectrograph(this)),
+ m_levelMeter(new LevelMeter(this)),
+ m_modeButton(new QPushButton(this)),
+ m_recordButton(new QPushButton(this)),
+ m_pauseButton(new QPushButton(this)),
+ m_playButton(new QPushButton(this)),
+ m_settingsButton(new QPushButton(this)),
+ m_infoMessage(new QLabel(tr("Select a mode to begin"), this)),
+ m_infoMessageTimerId(NullTimerId),
+ m_settingsDialog(new SettingsDialog(m_engine->availableAudioInputDevices(),
+ m_engine->availableAudioOutputDevices(), this)),
+ m_toneGeneratorDialog(new ToneGeneratorDialog(this)),
+ m_modeMenu(new QMenu(this)),
+ m_loadFileAction(nullptr),
+ m_generateToneAction(nullptr),
+ m_recordAction(nullptr),
+ m_errorOccurred(false)
{
m_spectrograph->setParams(SpectrumNumBands, SpectrumLowFreq, SpectrumHighFreq);
@@ -103,25 +57,19 @@ MainWidget::MainWidget(QWidget *parent)
connectUi();
}
-MainWidget::~MainWidget()
-{
-
-}
-
+MainWidget::~MainWidget() = default;
//-----------------------------------------------------------------------------
// Public slots
//-----------------------------------------------------------------------------
-void MainWidget::stateChanged(QAudio::Mode mode, QAudio::State state)
+void MainWidget::stateChanged(QAudioDevice::Mode mode, QAudio::State state)
{
Q_UNUSED(mode);
updateButtonStates();
- if (QAudio::ActiveState != state &&
- QAudio::SuspendedState != state &&
- QAudio::InterruptedState != state) {
+ if (QAudio::ActiveState != state && QAudio::SuspendedState != state) {
m_levelMeter->reset();
m_spectrograph->reset();
}
@@ -129,18 +77,16 @@ void MainWidget::stateChanged(QAudio::Mode mode, QAudio::State state)
void MainWidget::formatChanged(const QAudioFormat &format)
{
- infoMessage(formatToString(format), NullMessageTimeout);
+ infoMessage(formatToString(format), NullMessageTimeout);
#ifndef DISABLE_WAVEFORM
if (QAudioFormat() != format) {
- m_waveform->initialize(format, WaveformTileLength,
- WaveformWindowDuration);
+ m_waveform->initialize(format, WaveformTileLength, WaveformWindowDuration);
}
#endif
}
-void MainWidget::spectrumChanged(qint64 position, qint64 length,
- const FrequencySpectrum &spectrum)
+void MainWidget::spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum)
{
m_progressBar->windowChanged(position, length);
m_spectrograph->spectrumChanged(spectrum);
@@ -162,6 +108,8 @@ void MainWidget::infoMessage(const QString &message, int timeoutMs)
void MainWidget::errorMessage(const QString &heading, const QString &detail)
{
QMessageBox::warning(this, heading, detail, QMessageBox::Close);
+ m_errorOccurred = true;
+ reset();
}
void MainWidget::timerEvent(QTimerEvent *event)
@@ -187,15 +135,16 @@ void MainWidget::bufferLengthChanged(qint64 length)
m_progressBar->bufferLengthChanged(length);
}
-
//-----------------------------------------------------------------------------
// Private slots
//-----------------------------------------------------------------------------
void MainWidget::showFileDialog()
{
+ m_errorOccurred = false;
const QString dir;
- const QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav");
+ const QStringList fileNames =
+ QFileDialog::getOpenFileNames(this, tr("Open WAV file"), dir, "*.wav");
if (fileNames.count()) {
reset();
setMode(LoadFileMode);
@@ -218,6 +167,7 @@ void MainWidget::showSettingsDialog()
void MainWidget::showToneGeneratorDialog()
{
+ m_errorOccurred = false;
m_toneGeneratorDialog->exec();
if (m_toneGeneratorDialog->result() == QDialog::Accepted) {
reset();
@@ -232,19 +182,20 @@ void MainWidget::showToneGeneratorDialog()
updateButtonStates();
}
} else {
+ setMode(NoMode);
updateModeMenu();
}
}
void MainWidget::initializeRecord()
{
+ m_errorOccurred = false;
reset();
setMode(RecordMode);
if (m_engine->initializeRecord())
updateButtonStates();
}
-
//-----------------------------------------------------------------------------
// Private functions
//-----------------------------------------------------------------------------
@@ -262,27 +213,25 @@ void MainWidget::createUi()
windowLayout->addWidget(m_infoMessage);
#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
- QScopedPointer<QHBoxLayout> waveformLayout(new QHBoxLayout);
+ std::unique_ptr<QHBoxLayout> waveformLayout(new QHBoxLayout);
waveformLayout->addWidget(m_progressBar);
m_progressBar->setMinimumHeight(m_waveform->minimumHeight());
waveformLayout->setContentsMargins(0, 0, 0, 0);
- m_waveform->setLayout(waveformLayout.data());
- waveformLayout.take();
+ m_waveform->setLayout(waveformLayout.release());
windowLayout->addWidget(m_waveform);
#else
-#ifndef DISABLE_WAVEFORM
+# ifndef DISABLE_WAVEFORM
windowLayout->addWidget(m_waveform);
-#endif // DISABLE_WAVEFORM
+# endif // DISABLE_WAVEFORM
windowLayout->addWidget(m_progressBar);
#endif // SUPERIMPOSE_PROGRESS_ON_WAVEFORM
// Spectrograph and level meter
- QScopedPointer<QHBoxLayout> analysisLayout(new QHBoxLayout);
+ std::unique_ptr<QHBoxLayout> analysisLayout(new QHBoxLayout);
analysisLayout->addWidget(m_spectrograph);
analysisLayout->addWidget(m_levelMeter);
- windowLayout->addLayout(analysisLayout.data());
- analysisLayout.take();
+ windowLayout->addLayout(analysisLayout.release());
// Button panel
@@ -314,7 +263,7 @@ void MainWidget::createUi()
m_settingsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_settingsButton->setMinimumSize(buttonSize);
- QScopedPointer<QHBoxLayout> buttonPanelLayout(new QHBoxLayout);
+ std::unique_ptr<QHBoxLayout> buttonPanelLayout(new QHBoxLayout);
buttonPanelLayout->addStretch();
buttonPanelLayout->addWidget(m_modeButton);
buttonPanelLayout->addWidget(m_recordButton);
@@ -324,13 +273,11 @@ void MainWidget::createUi()
QWidget *buttonPanel = new QWidget(this);
buttonPanel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- buttonPanel->setLayout(buttonPanelLayout.data());
- buttonPanelLayout.take(); // ownership transferred to buttonPanel
+ buttonPanel->setLayout(buttonPanelLayout.release());
- QScopedPointer<QHBoxLayout> bottomPaneLayout(new QHBoxLayout);
+ std::unique_ptr<QHBoxLayout> bottomPaneLayout(new QHBoxLayout);
bottomPaneLayout->addWidget(buttonPanel);
- windowLayout->addLayout(bottomPaneLayout.data());
- bottomPaneLayout.take(); // ownership transferred to windowLayout
+ windowLayout->addLayout(bottomPaneLayout.release());
// Apply layout
@@ -339,62 +286,49 @@ void MainWidget::createUi()
void MainWidget::connectUi()
{
- connect(m_recordButton, &QPushButton::clicked,
- m_engine, &Engine::startRecording);
+ connect(m_recordButton, &QPushButton::clicked, m_engine, &Engine::startRecording);
- connect(m_pauseButton, &QPushButton::clicked,
- m_engine, &Engine::suspend);
+ connect(m_pauseButton, &QPushButton::clicked, m_engine, &Engine::suspend);
- connect(m_playButton, &QPushButton::clicked,
- m_engine, &Engine::startPlayback);
+ connect(m_playButton, &QPushButton::clicked, m_engine, &Engine::startPlayback);
- connect(m_settingsButton, &QPushButton::clicked,
- this, &MainWidget::showSettingsDialog);
+ connect(m_settingsButton, &QPushButton::clicked, this, &MainWidget::showSettingsDialog);
- connect(m_engine, &Engine::stateChanged,
- this, &MainWidget::stateChanged);
+ connect(m_engine, &Engine::stateChanged, this, &MainWidget::stateChanged);
- connect(m_engine, &Engine::formatChanged,
- this, &MainWidget::formatChanged);
+ connect(m_engine, &Engine::formatChanged, this, &MainWidget::formatChanged);
m_progressBar->bufferLengthChanged(m_engine->bufferLength());
- connect(m_engine, &Engine::bufferLengthChanged,
- this, &MainWidget::bufferLengthChanged);
+ connect(m_engine, &Engine::bufferLengthChanged, this, &MainWidget::bufferLengthChanged);
- connect(m_engine, &Engine::dataLengthChanged,
- this, &MainWidget::updateButtonStates);
+ connect(m_engine, &Engine::dataLengthChanged, this, &MainWidget::updateButtonStates);
- connect(m_engine, &Engine::recordPositionChanged,
- m_progressBar, &ProgressBar::recordPositionChanged);
+ connect(m_engine, &Engine::recordPositionChanged, m_progressBar,
+ &ProgressBar::recordPositionChanged);
- connect(m_engine, &Engine::playPositionChanged,
- m_progressBar, &ProgressBar::playPositionChanged);
+ connect(m_engine, &Engine::playPositionChanged, m_progressBar,
+ &ProgressBar::playPositionChanged);
- connect(m_engine, &Engine::recordPositionChanged,
- this, &MainWidget::audioPositionChanged);
+ connect(m_engine, &Engine::recordPositionChanged, this, &MainWidget::audioPositionChanged);
- connect(m_engine, &Engine::playPositionChanged,
- this, &MainWidget::audioPositionChanged);
+ connect(m_engine, &Engine::playPositionChanged, this, &MainWidget::audioPositionChanged);
- connect(m_engine, &Engine::levelChanged,
- m_levelMeter, &LevelMeter::levelChanged);
+ connect(m_engine, &Engine::levelChanged, m_levelMeter, &LevelMeter::levelChanged);
- connect(m_engine, QOverload<qint64, qint64, const FrequencySpectrum&>::of(&Engine::spectrumChanged),
- this, QOverload<qint64, qint64, const FrequencySpectrum&>::of(&MainWidget::spectrumChanged));
+ connect(m_engine,
+ QOverload<qint64, qint64, const FrequencySpectrum &>::of(&Engine::spectrumChanged),
+ this,
+ QOverload<qint64, qint64, const FrequencySpectrum &>::of(&MainWidget::spectrumChanged));
- connect(m_engine, &Engine::infoMessage,
- this, &MainWidget::infoMessage);
+ connect(m_engine, &Engine::infoMessage, this, &MainWidget::infoMessage);
- connect(m_engine, &Engine::errorMessage,
- this, &MainWidget::errorMessage);
+ connect(m_engine, &Engine::errorMessage, this, &MainWidget::errorMessage);
- connect(m_spectrograph, &Spectrograph::infoMessage,
- this, &MainWidget::infoMessage);
+ connect(m_spectrograph, &Spectrograph::infoMessage, this, &MainWidget::infoMessage);
#ifndef DISABLE_WAVEFORM
- connect(m_engine, &Engine::bufferChanged,
- m_waveform, &Waveform::bufferChanged);
+ connect(m_engine, &Engine::bufferChanged, m_waveform, &Waveform::bufferChanged);
#endif
}
@@ -417,22 +351,22 @@ void MainWidget::createMenus()
void MainWidget::updateButtonStates()
{
- const bool recordEnabled = ((QAudio::AudioOutput == m_engine->mode() ||
- (QAudio::ActiveState != m_engine->state() &&
- QAudio::IdleState != m_engine->state())) &&
- RecordMode == m_mode);
- m_recordButton->setEnabled(recordEnabled);
+ const bool recordEnabled = ((QAudioDevice::Output == m_engine->mode()
+ || (QAudio::ActiveState != m_engine->state()
+ && QAudio::IdleState != m_engine->state()))
+ && RecordMode == m_mode);
+ m_recordButton->setEnabled(m_errorOccurred ? false : recordEnabled);
- const bool pauseEnabled = (QAudio::ActiveState == m_engine->state() ||
- QAudio::IdleState == m_engine->state());
- m_pauseButton->setEnabled(pauseEnabled);
+ const bool pauseEnabled =
+ (QAudio::ActiveState == m_engine->state() || QAudio::IdleState == m_engine->state());
+ m_pauseButton->setEnabled(m_errorOccurred ? false : pauseEnabled);
const bool playEnabled = (/*m_engine->dataLength() &&*/
- (QAudio::AudioOutput != m_engine->mode() ||
- (QAudio::ActiveState != m_engine->state() &&
- QAudio::IdleState != m_engine->state() &&
- QAudio::InterruptedState != m_engine->state())));
- m_playButton->setEnabled(playEnabled);
+ (QAudioDevice::Output != m_engine->mode()
+ || (QAudio::ActiveState != m_engine->state()
+ && QAudio::IdleState != m_engine->state())));
+
+ m_playButton->setEnabled(m_errorOccurred ? false : playEnabled);
}
void MainWidget::reset()
@@ -444,6 +378,10 @@ void MainWidget::reset()
m_levelMeter->reset();
m_spectrograph->reset();
m_progressBar->reset();
+ if (m_errorOccurred) {
+ setMode(Mode::NoMode);
+ updateButtonStates();
+ }
}
void MainWidget::setMode(Mode mode)
@@ -458,3 +396,5 @@ void MainWidget::updateModeMenu()
m_generateToneAction->setChecked(GenerateToneMode == m_mode);
m_recordAction->setChecked(RecordMode == m_mode);
}
+
+#include "moc_mainwidget.cpp"
diff --git a/examples/multimedia/spectrum/mainwidget.h b/examples/multimedia/spectrum/mainwidget.h
new file mode 100644
index 000000000..789e312f5
--- /dev/null
+++ b/examples/multimedia/spectrum/mainwidget.h
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include <QAudioDevice>
+#include <QIcon>
+#include <QWidget>
+
+class Engine;
+class FrequencySpectrum;
+class LevelMeter;
+class ProgressBar;
+class SettingsDialog;
+class Spectrograph;
+class ToneGeneratorDialog;
+class Waveform;
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QAudioFormat;
+class QLabel;
+class QMenu;
+class QPushButton;
+QT_END_NAMESPACE
+
+/**
+ * Main application widget, responsible for connecting the various UI
+ * elements to the Engine.
+ */
+class MainWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MainWidget(QWidget *parent = nullptr);
+ ~MainWidget();
+
+ // QObject
+ void timerEvent(QTimerEvent *event) override;
+
+public slots:
+ void stateChanged(QAudioDevice::Mode mode, QAudio::State state);
+ void formatChanged(const QAudioFormat &format);
+ void spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum);
+ void infoMessage(const QString &message, int timeoutMs);
+ void errorMessage(const QString &heading, const QString &detail);
+ void audioPositionChanged(qint64 position);
+ void bufferLengthChanged(qint64 length);
+
+private slots:
+ void showFileDialog();
+ void showSettingsDialog();
+ void showToneGeneratorDialog();
+ void initializeRecord();
+ void updateModeMenu();
+ void updateButtonStates();
+
+private:
+ void createUi();
+ void createMenus();
+ void connectUi();
+ void reset();
+
+ enum Mode { NoMode, RecordMode, GenerateToneMode, LoadFileMode };
+
+ void setMode(Mode mode);
+
+private:
+ Mode m_mode;
+
+ Engine *m_engine;
+
+#ifndef DISABLE_WAVEFORM
+ Waveform *m_waveform;
+#endif
+ ProgressBar *m_progressBar;
+ Spectrograph *m_spectrograph;
+ LevelMeter *m_levelMeter;
+
+ QPushButton *m_modeButton;
+ QPushButton *m_recordButton;
+ QIcon m_recordIcon;
+ QPushButton *m_pauseButton;
+ QIcon m_pauseIcon;
+ QPushButton *m_playButton;
+ QIcon m_playIcon;
+ QPushButton *m_settingsButton;
+ QIcon m_settingsIcon;
+
+ QLabel *m_infoMessage;
+ int m_infoMessageTimerId;
+
+ SettingsDialog *m_settingsDialog;
+ ToneGeneratorDialog *m_toneGeneratorDialog;
+
+ QMenu *m_modeMenu;
+ QAction *m_loadFileAction;
+ QAction *m_generateToneAction;
+ QAction *m_recordAction;
+ bool m_errorOccurred;
+};
+
+#endif // MAINWIDGET_H
diff --git a/examples/multimedia/spectrum/progressbar.cpp b/examples/multimedia/spectrum/progressbar.cpp
new file mode 100644
index 000000000..1806097e2
--- /dev/null
+++ b/examples/multimedia/spectrum/progressbar.cpp
@@ -0,0 +1,101 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "progressbar.h"
+#include <QPainter>
+
+ProgressBar::ProgressBar(QWidget *parent)
+ : QWidget(parent),
+ m_bufferLength(0),
+ m_recordPosition(0),
+ m_playPosition(0),
+ m_windowPosition(0),
+ m_windowLength(0)
+{
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ setMinimumHeight(30);
+#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
+ setAutoFillBackground(false);
+#endif
+}
+
+ProgressBar::~ProgressBar() = default;
+
+void ProgressBar::reset()
+{
+ m_bufferLength = 0;
+ m_recordPosition = 0;
+ m_playPosition = 0;
+ m_windowPosition = 0;
+ m_windowLength = 0;
+ update();
+}
+
+void ProgressBar::paintEvent(QPaintEvent * /*event*/)
+{
+ QPainter painter(this);
+
+ QColor bufferColor(0, 0, 255);
+ QColor windowColor(0, 255, 0);
+
+#ifdef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
+ bufferColor.setAlphaF(0.5);
+ windowColor.setAlphaF(0.5);
+#else
+ painter.fillRect(rect(), Qt::black);
+#endif
+
+ if (m_bufferLength) {
+ QRect bar = rect();
+ const qreal play = qreal(m_playPosition) / m_bufferLength;
+ bar.setLeft(rect().left() + play * rect().width());
+ const qreal record = qreal(m_recordPosition) / m_bufferLength;
+ bar.setRight(rect().left() + record * rect().width());
+ painter.fillRect(bar, bufferColor);
+
+ QRect window = rect();
+ const qreal windowLeft = qreal(m_windowPosition) / m_bufferLength;
+ window.setLeft(rect().left() + windowLeft * rect().width());
+ const qreal windowWidth = qreal(m_windowLength) / m_bufferLength;
+ window.setWidth(windowWidth * rect().width());
+ painter.fillRect(window, windowColor);
+ }
+}
+
+void ProgressBar::bufferLengthChanged(qint64 bufferSize)
+{
+ m_bufferLength = bufferSize;
+ m_recordPosition = 0;
+ m_playPosition = 0;
+ m_windowPosition = 0;
+ m_windowLength = 0;
+ repaint();
+}
+
+void ProgressBar::recordPositionChanged(qint64 recordPosition)
+{
+ Q_ASSERT(recordPosition >= 0);
+ Q_ASSERT(recordPosition <= m_bufferLength);
+ m_recordPosition = recordPosition;
+ repaint();
+}
+
+void ProgressBar::playPositionChanged(qint64 playPosition)
+{
+ Q_ASSERT(playPosition >= 0);
+ Q_ASSERT(playPosition <= m_bufferLength);
+ m_playPosition = playPosition;
+ repaint();
+}
+
+void ProgressBar::windowChanged(qint64 position, qint64 length)
+{
+ Q_ASSERT(position >= 0);
+ Q_ASSERT(position <= m_bufferLength);
+ Q_ASSERT(position + length <= m_bufferLength);
+ m_windowPosition = position;
+ m_windowLength = length;
+ repaint();
+}
+
+#include "moc_progressbar.cpp"
diff --git a/examples/multimedia/spectrum/progressbar.h b/examples/multimedia/spectrum/progressbar.h
new file mode 100644
index 000000000..8b117c7e6
--- /dev/null
+++ b/examples/multimedia/spectrum/progressbar.h
@@ -0,0 +1,38 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PROGRESSBAR_H
+#define PROGRESSBAR_H
+
+#include <QWidget>
+
+/**
+ * Widget which displays a the current fill state of the Engine's internal
+ * buffer, and the current play/record position within that buffer.
+ */
+class ProgressBar : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit ProgressBar(QWidget *parent = nullptr);
+ ~ProgressBar();
+
+ void reset();
+ void paintEvent(QPaintEvent *event) override;
+
+public slots:
+ void bufferLengthChanged(qint64 length);
+ void recordPositionChanged(qint64 recordPosition);
+ void playPositionChanged(qint64 playPosition);
+ void windowChanged(qint64 position, qint64 length);
+
+private:
+ qint64 m_bufferLength;
+ qint64 m_recordPosition;
+ qint64 m_playPosition;
+ qint64 m_windowPosition;
+ qint64 m_windowLength;
+};
+
+#endif // PROGRESSBAR_H
diff --git a/examples/multimedia/spectrum/settingsdialog.cpp b/examples/multimedia/spectrum/settingsdialog.cpp
new file mode 100644
index 000000000..bdd52e123
--- /dev/null
+++ b/examples/multimedia/spectrum/settingsdialog.cpp
@@ -0,0 +1,102 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "settingsdialog.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDialogButtonBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QSlider>
+#include <QSpinBox>
+#include <QVBoxLayout>
+
+SettingsDialog::SettingsDialog(const QList<QAudioDevice> &availableInputDevices,
+ const QList<QAudioDevice> &availableOutputDevices, QWidget *parent)
+ : QDialog(parent),
+ m_windowFunction(DefaultWindowFunction),
+ m_inputDeviceComboBox(new QComboBox(this)),
+ m_outputDeviceComboBox(new QComboBox(this)),
+ m_windowFunctionComboBox(new QComboBox(this))
+{
+ QVBoxLayout *dialogLayout = new QVBoxLayout(this);
+
+ // Populate combo boxes
+
+ for (const QAudioDevice &device : availableInputDevices)
+ m_inputDeviceComboBox->addItem(device.description(), QVariant::fromValue(device));
+ for (const QAudioDevice &device : availableOutputDevices)
+ m_outputDeviceComboBox->addItem(device.description(), QVariant::fromValue(device));
+
+ m_windowFunctionComboBox->addItem(tr("None"), QVariant::fromValue(int(NoWindow)));
+ m_windowFunctionComboBox->addItem("Hann", QVariant::fromValue(int(HannWindow)));
+ m_windowFunctionComboBox->setCurrentIndex(m_windowFunction);
+
+ // Initialize default devices
+ if (!availableInputDevices.empty())
+ m_inputDevice = availableInputDevices.front();
+ if (!availableOutputDevices.empty())
+ m_outputDevice = availableOutputDevices.front();
+
+ // Add widgets to layout
+
+ std::unique_ptr<QHBoxLayout> inputDeviceLayout(new QHBoxLayout);
+ QLabel *inputDeviceLabel = new QLabel(tr("Input device"), this);
+ inputDeviceLayout->addWidget(inputDeviceLabel);
+ inputDeviceLayout->addWidget(m_inputDeviceComboBox);
+ dialogLayout->addLayout(inputDeviceLayout.release());
+
+ std::unique_ptr<QHBoxLayout> outputDeviceLayout(new QHBoxLayout);
+ QLabel *outputDeviceLabel = new QLabel(tr("Output device"), this);
+ outputDeviceLayout->addWidget(outputDeviceLabel);
+ outputDeviceLayout->addWidget(m_outputDeviceComboBox);
+ dialogLayout->addLayout(outputDeviceLayout.release());
+
+ std::unique_ptr<QHBoxLayout> windowFunctionLayout(new QHBoxLayout);
+ QLabel *windowFunctionLabel = new QLabel(tr("Window function"), this);
+ windowFunctionLayout->addWidget(windowFunctionLabel);
+ windowFunctionLayout->addWidget(m_windowFunctionComboBox);
+ dialogLayout->addLayout(windowFunctionLayout.release());
+
+ // Connect
+ connect(m_inputDeviceComboBox, QOverload<int>::of(&QComboBox::activated), this,
+ &SettingsDialog::inputDeviceChanged);
+ connect(m_outputDeviceComboBox, QOverload<int>::of(&QComboBox::activated), this,
+ &SettingsDialog::outputDeviceChanged);
+ connect(m_windowFunctionComboBox, QOverload<int>::of(&QComboBox::activated), this,
+ &SettingsDialog::windowFunctionChanged);
+
+ // Add standard buttons to layout
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+ buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ dialogLayout->addWidget(buttonBox);
+
+ // Connect standard buttons
+ connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this,
+ &SettingsDialog::accept);
+ connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this,
+ &SettingsDialog::reject);
+
+ setLayout(dialogLayout);
+}
+
+SettingsDialog::~SettingsDialog() = default;
+
+void SettingsDialog::windowFunctionChanged(int index)
+{
+ m_windowFunction =
+ static_cast<WindowFunction>(m_windowFunctionComboBox->itemData(index).value<int>());
+}
+
+void SettingsDialog::inputDeviceChanged(int index)
+{
+ m_inputDevice = m_inputDeviceComboBox->itemData(index).value<QAudioDevice>();
+}
+
+void SettingsDialog::outputDeviceChanged(int index)
+{
+ m_outputDevice = m_outputDeviceComboBox->itemData(index).value<QAudioDevice>();
+}
+
+#include "moc_settingsdialog.cpp"
diff --git a/examples/multimedia/spectrum/settingsdialog.h b/examples/multimedia/spectrum/settingsdialog.h
new file mode 100644
index 000000000..ac877d975
--- /dev/null
+++ b/examples/multimedia/spectrum/settingsdialog.h
@@ -0,0 +1,52 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include "spectrum.h"
+
+#include <QAudioDevice>
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QComboBox;
+class QCheckBox;
+class QSlider;
+class QSpinBox;
+class QGridLayout;
+QT_END_NAMESPACE
+
+/**
+ * Dialog used to control settings such as the audio input / output device
+ * and the windowing function.
+ */
+class SettingsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SettingsDialog(const QList<QAudioDevice> &availableInputDevices,
+ const QList<QAudioDevice> &availableOutputDevices, QWidget *parent = nullptr);
+ ~SettingsDialog();
+
+ WindowFunction windowFunction() const { return m_windowFunction; }
+ const QAudioDevice &inputDevice() const { return m_inputDevice; }
+ const QAudioDevice &outputDevice() const { return m_outputDevice; }
+
+private slots:
+ void windowFunctionChanged(int index);
+ void inputDeviceChanged(int index);
+ void outputDeviceChanged(int index);
+
+private:
+ WindowFunction m_windowFunction;
+ QAudioDevice m_inputDevice;
+ QAudioDevice m_outputDevice;
+
+ QComboBox *m_inputDeviceComboBox;
+ QComboBox *m_outputDeviceComboBox;
+ QComboBox *m_windowFunctionComboBox;
+};
+
+#endif // SETTINGSDIALOG_H
diff --git a/examples/multimedia/spectrum/app/spectrograph.cpp b/examples/multimedia/spectrum/spectrograph.cpp
index 6eaa097fc..96274b50b 100644
--- a/examples/multimedia/spectrum/app/spectrograph.cpp
+++ b/examples/multimedia/spectrum/spectrograph.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spectrograph.h"
+
#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
@@ -59,19 +13,16 @@ const int NullIndex = -1;
const int BarSelectionInterval = 2000;
Spectrograph::Spectrograph(QWidget *parent)
- : QWidget(parent)
- , m_barSelected(NullIndex)
- , m_timerId(NullTimerId)
- , m_lowFreq(0.0)
- , m_highFreq(0.0)
+ : QWidget(parent),
+ m_barSelected(NullIndex),
+ m_timerId(NullTimerId),
+ m_lowFreq(0.0),
+ m_highFreq(0.0)
{
setMinimumHeight(100);
}
-Spectrograph::~Spectrograph()
-{
-
-}
+Spectrograph::~Spectrograph() = default;
void Spectrograph::setParams(int numBars, qreal lowFreq, qreal highFreq)
{
@@ -134,8 +85,8 @@ void Spectrograph::paintEvent(QPaintEvent *event)
if (numBars) {
const int numHorizontalSections = numBars;
QLine line(rect().topLeft(), rect().bottomLeft());
- for (int i=1; i<numHorizontalSections; ++i) {
- line.translate(rect().width()/numHorizontalSections, 0);
+ for (int i = 1; i < numHorizontalSections; ++i) {
+ line.translate(rect().width() / numHorizontalSections, 0);
painter.drawLine(line);
}
}
@@ -143,8 +94,8 @@ void Spectrograph::paintEvent(QPaintEvent *event)
// Draw horizontal lines
const int numVerticalSections = 10;
QLine line(rect().topLeft(), rect().topRight());
- for (int i=1; i<numVerticalSections; ++i) {
- line.translate(0, rect().height()/numVerticalSections);
+ for (int i = 1; i < numVerticalSections; ++i) {
+ line.translate(0, rect().height() / numVerticalSections);
painter.drawLine(line);
}
@@ -163,7 +114,7 @@ void Spectrograph::paintEvent(QPaintEvent *event)
const int leftPaddingWidth = (paddingWidth + gapWidth) / 2;
const int barHeight = rect().height() - 2 * gapWidth;
- for (int i=0; i<numBars; ++i) {
+ for (int i = 0; i < numBars; ++i) {
const qreal value = m_bars[i].value;
Q_ASSERT(value >= 0.0 && value <= 1.0);
QRect bar = rect();
@@ -205,7 +156,7 @@ int Spectrograph::barIndex(qreal frequency) const
Q_ASSERT(frequency >= m_lowFreq && frequency < m_highFreq);
const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count();
const int index = (frequency - m_lowFreq) / bandWidth;
- if (index <0 || index >= m_bars.count())
+ if (index < 0 || index >= m_bars.count())
Q_ASSERT(false);
return index;
}
@@ -214,7 +165,7 @@ QPair<qreal, qreal> Spectrograph::barRange(int index) const
{
Q_ASSERT(index >= 0 && index < m_bars.count());
const qreal bandWidth = (m_highFreq - m_lowFreq) / m_bars.count();
- return QPair<qreal, qreal>(index * bandWidth, (index+1) * bandWidth);
+ return QPair<qreal, qreal>(index * bandWidth, (index + 1) * bandWidth);
}
void Spectrograph::updateBars()
@@ -222,7 +173,7 @@ void Spectrograph::updateBars()
m_bars.fill(Bar());
FrequencySpectrum::const_iterator i = m_spectrum.begin();
const FrequencySpectrum::const_iterator end = m_spectrum.end();
- for ( ; i != end; ++i) {
+ for (; i != end; ++i) {
const FrequencySpectrum::Element e = *i;
if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) {
Bar &bar = m_bars[barIndex(e.frequency)];
@@ -233,11 +184,11 @@ void Spectrograph::updateBars()
update();
}
-void Spectrograph::selectBar(int index) {
+void Spectrograph::selectBar(int index)
+{
const QPair<qreal, qreal> frequencyRange = barRange(index);
- const QString message = QString("%1 - %2 Hz")
- .arg(frequencyRange.first)
- .arg(frequencyRange.second);
+ const QString message =
+ QStringLiteral("%1 - %2 Hz").arg(frequencyRange.first).arg(frequencyRange.second);
emit infoMessage(message, BarSelectionInterval);
if (NullTimerId != m_timerId)
@@ -248,4 +199,4 @@ void Spectrograph::selectBar(int index) {
update();
}
-
+#include "moc_spectrograph.cpp"
diff --git a/examples/multimedia/spectrum/spectrograph.h b/examples/multimedia/spectrum/spectrograph.h
new file mode 100644
index 000000000..1344d3257
--- /dev/null
+++ b/examples/multimedia/spectrum/spectrograph.h
@@ -0,0 +1,62 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SPECTROGRAPH_H
+#define SPECTROGRAPH_H
+
+#include "frequencyspectrum.h"
+
+#include <QWidget>
+
+/**
+ * Widget which displays a spectrograph showing the frequency spectrum
+ * of the window of audio samples most recently analyzed by the Engine.
+ */
+class Spectrograph : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Spectrograph(QWidget *parent = nullptr);
+ ~Spectrograph();
+
+ void setParams(int numBars, qreal lowFreq, qreal highFreq);
+
+ // QObject
+ void timerEvent(QTimerEvent *event) override;
+
+ // QWidget
+ void paintEvent(QPaintEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+
+signals:
+ void infoMessage(const QString &message, int intervalMs);
+
+public slots:
+ void reset();
+ void spectrumChanged(const FrequencySpectrum &spectrum);
+
+private:
+ int barIndex(qreal frequency) const;
+ QPair<qreal, qreal> barRange(int barIndex) const;
+ void updateBars();
+
+ void selectBar(int index);
+
+private:
+ struct Bar
+ {
+ Bar() : value(0.0), clipped(false) { }
+ qreal value;
+ bool clipped;
+ };
+
+ QList<Bar> m_bars;
+ int m_barSelected;
+ int m_timerId;
+ qreal m_lowFreq;
+ qreal m_highFreq;
+ FrequencySpectrum m_spectrum;
+};
+
+#endif // SPECTROGRAPH_H
diff --git a/examples/multimedia/spectrum/spectrum.h b/examples/multimedia/spectrum/spectrum.h
new file mode 100644
index 000000000..e416e82bd
--- /dev/null
+++ b/examples/multimedia/spectrum/spectrum.h
@@ -0,0 +1,91 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SPECTRUM_H
+#define SPECTRUM_H
+
+#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
+#include "utils.h"
+
+#include <QtGlobal>
+
+//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+// Number of audio samples used to calculate the frequency spectrum
+const int SpectrumLengthSamples = PowerOfTwo<FFTLengthPowerOfTwo>::Result;
+
+// Number of bands in the frequency spectrum
+const int SpectrumNumBands = 10;
+
+// Lower bound of first band in the spectrum
+const qreal SpectrumLowFreq = 0.0; // Hz
+
+// Upper band of last band in the spectrum
+const qreal SpectrumHighFreq = 1000.0; // Hz
+
+// Waveform window size in microseconds
+const qint64 WaveformWindowDuration = 500 * 1000;
+
+// Length of waveform tiles in bytes
+// Ideally, these would match the QAudio*::bufferSize(), but that isn't
+// available until some time after QAudio*::start() has been called, and we
+// need this value in order to initialize the waveform display.
+// We therefore just choose a sensible value.
+const int WaveformTileLength = 4096;
+
+// Fudge factor used to calculate the spectrum bar heights
+const qreal SpectrumAnalyserMultiplier = 0.15;
+
+// Disable message timeout
+const int NullMessageTimeout = -1;
+
+//-----------------------------------------------------------------------------
+// Types and data structures
+//-----------------------------------------------------------------------------
+
+enum WindowFunction { NoWindow, HannWindow };
+Q_DECLARE_METATYPE(WindowFunction)
+
+const WindowFunction DefaultWindowFunction = HannWindow;
+
+struct Tone
+{
+ Tone(qreal freq = 0.0, qreal amp = 0.0) : frequency(freq), amplitude(amp) { }
+
+ // Start and end frequencies for swept tone generation
+ qreal frequency;
+
+ // Amplitude in range [0.0, 1.0]
+ qreal amplitude;
+};
+
+struct SweptTone
+{
+ SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
+ : startFreq(start), endFreq(end), amplitude(amp)
+ {
+ Q_ASSERT(end >= start);
+ }
+
+ SweptTone(const Tone &tone)
+ : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude)
+ {
+ }
+
+ // Start and end frequencies for swept tone generation
+ qreal startFreq;
+ qreal endFreq;
+
+ // Amplitude in range [0.0, 1.0]
+ qreal amplitude;
+};
+
+// Handle some dependencies between macros defined in the .pro file
+
+#ifdef DISABLE_WAVEFORM
+# undef SUPERIMPOSE_PROGRESS_ON_WAVEFORM
+#endif
+
+#endif // SPECTRUM_H
diff --git a/examples/multimedia/spectrum/spectrum.pri b/examples/multimedia/spectrum/spectrum.pri
index 38b3f1501..431d728ec 100644
--- a/examples/multimedia/spectrum/spectrum.pri
+++ b/examples/multimedia/spectrum/spectrum.pri
@@ -23,8 +23,6 @@ DEFINES += LOG_ENGINE
# If this macro is defined, the FFTReal DLL will not be built
#DEFINES += DISABLE_FFT
-static: DEFINES += DISABLE_FFT
-
# Disables rendering of the waveform
#DEFINES += DISABLE_WAVEFORM
@@ -48,4 +46,3 @@ win32 {
CONFIG(debug, release|debug): spectrum_build_dir = /debug
}
}
-
diff --git a/examples/multimedia/spectrum/spectrum.pro b/examples/multimedia/spectrum/spectrum.pro
index 0ca2ee554..782c00698 100644
--- a/examples/multimedia/spectrum/spectrum.pro
+++ b/examples/multimedia/spectrum/spectrum.pro
@@ -2,10 +2,10 @@ include(spectrum.pri)
TEMPLATE = subdirs
-# Ensure that library is built before application
-CONFIG += ordered
+SUBDIRS += 3rdparty/fftreal
-!contains(DEFINES, DISABLE_FFT): SUBDIRS += 3rdparty/fftreal
+app.file = app.pro
+app.depends = 3rdparty/fftreal
SUBDIRS += app
TARGET = spectrum
diff --git a/examples/multimedia/spectrum/app/spectrum.qrc b/examples/multimedia/spectrum/spectrum.qrc
index 61004791b..61004791b 100644
--- a/examples/multimedia/spectrum/app/spectrum.qrc
+++ b/examples/multimedia/spectrum/spectrum.qrc
diff --git a/examples/multimedia/spectrum/spectrumanalyser.cpp b/examples/multimedia/spectrum/spectrumanalyser.cpp
new file mode 100644
index 000000000..c309c6a73
--- /dev/null
+++ b/examples/multimedia/spectrum/spectrumanalyser.cpp
@@ -0,0 +1,233 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "spectrumanalyser.h"
+#include "fftreal_wrapper.h"
+#include "utils.h"
+
+#include <QAudioFormat>
+#include <QMetaType>
+#include <QThread>
+#include <QtMath>
+
+SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
+ : QObject(parent)
+#ifndef DISABLE_FFT
+ ,
+ m_fft(new FFTRealWrapper)
+#endif
+ ,
+ m_numSamples(SpectrumLengthSamples),
+ m_windowFunction(DefaultWindowFunction),
+ m_window(SpectrumLengthSamples, 0.0),
+ m_input(SpectrumLengthSamples, 0.0),
+ m_output(SpectrumLengthSamples, 0.0),
+ m_spectrum(SpectrumLengthSamples)
+#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
+ ,
+ m_thread(new QThread(this))
+#endif
+{
+#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
+ // moveToThread() cannot be called on a QObject with a parent
+ setParent(nullptr);
+ moveToThread(m_thread);
+ m_thread->start();
+#endif
+ calculateWindow();
+}
+
+SpectrumAnalyserThread::~SpectrumAnalyserThread()
+{
+#ifndef DISABLE_FFT
+ delete m_fft;
+#endif
+}
+
+void SpectrumAnalyserThread::setWindowFunction(WindowFunction type)
+{
+ m_windowFunction = type;
+ calculateWindow();
+}
+
+void SpectrumAnalyserThread::calculateWindow()
+{
+ for (int i = 0; i < m_numSamples; ++i) {
+ DataType x = 0.0;
+
+ switch (m_windowFunction) {
+ case NoWindow:
+ x = 1.0;
+ break;
+ case HannWindow:
+ x = 0.5 * (1 - qCos((2 * M_PI * i) / (m_numSamples - 1)));
+ break;
+ default:
+ Q_ASSERT(false);
+ }
+
+ m_window[i] = x;
+ }
+}
+
+void SpectrumAnalyserThread::calculateSpectrum(const QByteArray &buffer, int inputFrequency,
+ int bytesPerFrame)
+{
+#ifndef DISABLE_FFT
+ Q_ASSERT(buffer.size() == m_numSamples * bytesPerFrame);
+
+ // Initialize data array
+ const char *ptr = buffer.constData();
+ for (int i = 0; i < m_numSamples; ++i) {
+ const qint16 pcmSample = *reinterpret_cast<const qint16 *>(ptr);
+ // Scale down to range [-1.0, 1.0]
+ const DataType realSample = pcmToReal(pcmSample);
+ const DataType windowedSample = realSample * m_window[i];
+ m_input[i] = windowedSample;
+ ptr += bytesPerFrame;
+ }
+
+ // Calculate the FFT
+ m_fft->calculateFFT(m_output.data(), m_input.data());
+
+ // Analyze output to obtain amplitude and phase for each frequency
+ for (int i = 2; i <= m_numSamples / 2; ++i) {
+ // Calculate frequency of this complex sample
+ m_spectrum[i].frequency = qreal(i * inputFrequency) / (m_numSamples);
+
+ const qreal real = m_output[i];
+ qreal imag = 0.0;
+ if (i > 0 && i < m_numSamples / 2)
+ imag = m_output[m_numSamples / 2 + i];
+
+ const qreal magnitude = qSqrt(real * real + imag * imag);
+ qreal amplitude = SpectrumAnalyserMultiplier * qLn(magnitude);
+
+ // Bound amplitude to [0.0, 1.0]
+ m_spectrum[i].clipped = (amplitude > 1.0);
+ amplitude = qMax(qreal(0.0), amplitude);
+ amplitude = qMin(qreal(1.0), amplitude);
+ m_spectrum[i].amplitude = amplitude;
+ }
+#endif
+
+ emit calculationComplete(m_spectrum);
+}
+
+//=============================================================================
+// SpectrumAnalyser
+//=============================================================================
+
+SpectrumAnalyser::SpectrumAnalyser(QObject *parent)
+ : QObject(parent),
+ m_thread(new SpectrumAnalyserThread(this)),
+ m_state(Idle)
+#ifdef DUMP_SPECTRUMANALYSER
+ ,
+ m_count(0)
+#endif
+{
+ connect(m_thread, &SpectrumAnalyserThread::calculationComplete, this,
+ &SpectrumAnalyser::calculationComplete);
+}
+
+SpectrumAnalyser::~SpectrumAnalyser() = default;
+
+#ifdef DUMP_SPECTRUMANALYSER
+void SpectrumAnalyser::setOutputPath(const QString &outputDir)
+{
+ m_outputDir.setPath(outputDir);
+ m_textFile.setFileName(m_outputDir.filePath("spectrum.txt"));
+ m_textFile.open(QIODevice::WriteOnly | QIODevice::Text);
+ m_textStream.setDevice(&m_textFile);
+}
+#endif
+
+//-----------------------------------------------------------------------------
+// Public functions
+//-----------------------------------------------------------------------------
+
+void SpectrumAnalyser::setWindowFunction(WindowFunction type)
+{
+ const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction", Qt::AutoConnection,
+ Q_ARG(WindowFunction, type));
+ Q_ASSERT(b);
+ Q_UNUSED(b); // suppress warnings in release builds
+}
+
+void SpectrumAnalyser::calculate(const QByteArray &buffer, const QAudioFormat &format)
+{
+ // QThread::currentThread is marked 'for internal use only', but
+ // we're only using it for debug output here, so it's probably OK :)
+ SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate" << QThread::currentThread() << "state"
+ << m_state;
+
+ if (isReady()) {
+ Q_ASSERT(format.sampleFormat() == QAudioFormat::Int16);
+
+ const int bytesPerFrame = format.bytesPerFrame();
+
+#ifdef DUMP_SPECTRUMANALYSER
+ m_count++;
+ const QString pcmFileName =
+ m_outputDir.filePath(QStringLiteral("spectrum_%1.pcm").arg(m_count, 4, 10, QChar('0')));
+ QFile pcmFile(pcmFileName);
+ pcmFile.open(QIODevice::WriteOnly);
+ const int bufferLength = m_numSamples * bytesPerFrame;
+ pcmFile.write(buffer, bufferLength);
+
+ m_textStream << "TimeDomain " << m_count << "\n";
+ const qint16 *input = reinterpret_cast<const qint16 *>(buffer);
+ for (int i = 0; i < m_numSamples; ++i) {
+ m_textStream << i << "\t" << *input << "\n";
+ input += format.channels();
+ }
+#endif
+
+ m_state = Busy;
+
+ // Invoke SpectrumAnalyserThread::calculateSpectrum using QMetaObject. If
+ // m_thread is in a different thread from the current thread, the
+ // calculation will be done in the child thread.
+ // Once the calculation is finished, a calculationChanged signal will be
+ // emitted by m_thread.
+ const bool b = QMetaObject::invokeMethod(
+ m_thread, "calculateSpectrum", Qt::AutoConnection, Q_ARG(QByteArray, buffer),
+ Q_ARG(int, format.sampleRate()), Q_ARG(int, bytesPerFrame));
+ Q_ASSERT(b);
+ Q_UNUSED(b); // suppress warnings in release builds
+
+#ifdef DUMP_SPECTRUMANALYSER
+ m_textStream << "FrequencySpectrum " << m_count << "\n";
+ FrequencySpectrum::const_iterator x = m_spectrum.begin();
+ for (int i = 0; i < m_numSamples; ++i, ++x)
+ m_textStream << i << "\t" << x->frequency << "\t" << x->amplitude << "\t" << x->phase
+ << "\n";
+#endif
+ }
+}
+
+bool SpectrumAnalyser::isReady() const
+{
+ return (Idle == m_state);
+}
+
+void SpectrumAnalyser::cancelCalculation()
+{
+ if (Busy == m_state)
+ m_state = Cancelled;
+}
+
+//-----------------------------------------------------------------------------
+// Private slots
+//-----------------------------------------------------------------------------
+
+void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum)
+{
+ Q_ASSERT(Idle != m_state);
+ if (Busy == m_state)
+ emit spectrumChanged(spectrum);
+ m_state = Idle;
+}
+
+#include "moc_spectrumanalyser.cpp"
diff --git a/examples/multimedia/spectrum/spectrumanalyser.h b/examples/multimedia/spectrum/spectrumanalyser.h
new file mode 100644
index 000000000..202e602fe
--- /dev/null
+++ b/examples/multimedia/spectrum/spectrumanalyser.h
@@ -0,0 +1,151 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SPECTRUMANALYSER_H
+#define SPECTRUMANALYSER_H
+
+#include "frequencyspectrum.h"
+#include "spectrum.h"
+
+#include <QByteArray>
+#include <QList>
+#include <QObject>
+
+#ifdef DUMP_SPECTRUMANALYSER
+# include <QDir>
+# include <QFile>
+# include <QTextStream>
+#endif
+
+#ifndef DISABLE_FFT
+# include "FFTRealFixLenParam.h"
+#endif
+
+QT_FORWARD_DECLARE_CLASS(QAudioFormat)
+QT_FORWARD_DECLARE_CLASS(QThread)
+
+class FFTRealWrapper;
+
+class SpectrumAnalyserThreadPrivate;
+
+/**
+ * Implementation of the spectrum analysis which can be run in a
+ * separate thread.
+ */
+class SpectrumAnalyserThread : public QObject
+{
+ Q_OBJECT
+
+public:
+ SpectrumAnalyserThread(QObject *parent);
+ ~SpectrumAnalyserThread();
+
+public slots:
+ void setWindowFunction(WindowFunction type);
+ void calculateSpectrum(const QByteArray &buffer, int inputFrequency, int bytesPerSample);
+
+signals:
+ void calculationComplete(const FrequencySpectrum &spectrum);
+
+private:
+ void calculateWindow();
+
+private:
+#ifndef DISABLE_FFT
+ FFTRealWrapper *m_fft;
+#endif
+
+ const int m_numSamples;
+
+ WindowFunction m_windowFunction;
+
+#ifdef DISABLE_FFT
+ typedef qreal DataType;
+#else
+ typedef FFTRealFixLenParam::DataType DataType;
+#endif
+ QList<DataType> m_window;
+
+ QList<DataType> m_input;
+ QList<DataType> m_output;
+
+ FrequencySpectrum m_spectrum;
+
+#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD
+ QThread *m_thread;
+#endif
+};
+
+/**
+ * Class which performs frequency spectrum analysis on a window of
+ * audio samples, provided to it by the Engine.
+ */
+class SpectrumAnalyser : public QObject
+{
+ Q_OBJECT
+
+public:
+ SpectrumAnalyser(QObject *parent = nullptr);
+ ~SpectrumAnalyser();
+
+#ifdef DUMP_SPECTRUMANALYSER
+ void setOutputPath(const QString &outputPath);
+#endif
+
+public:
+ /*
+ * Set the windowing function which is applied before calculating the FFT
+ */
+ void setWindowFunction(WindowFunction type);
+
+ /*
+ * Calculate a frequency spectrum
+ *
+ * \param buffer Audio data
+ * \param format Format of audio data
+ *
+ * Frequency spectrum is calculated asynchronously. The result is returned
+ * via the spectrumChanged signal.
+ *
+ * An ongoing calculation can be cancelled by calling cancelCalculation().
+ *
+ */
+ void calculate(const QByteArray &buffer, const QAudioFormat &format);
+
+ /*
+ * Check whether the object is ready to perform another calculation
+ */
+ bool isReady() const;
+
+ /*
+ * Cancel an ongoing calculation
+ *
+ * Note that cancelling is asynchronous.
+ */
+ void cancelCalculation();
+
+signals:
+ void spectrumChanged(const FrequencySpectrum &spectrum);
+
+private slots:
+ void calculationComplete(const FrequencySpectrum &spectrum);
+
+private:
+ void calculateWindow();
+
+private:
+ SpectrumAnalyserThread *m_thread;
+
+ enum State { Idle, Busy, Cancelled };
+
+ State m_state;
+
+#ifdef DUMP_SPECTRUMANALYSER
+ QDir m_outputDir;
+ int m_count;
+ QFile m_textFile;
+ QTextStream m_textStream;
+#endif
+};
+
+#endif // SPECTRUMANALYSER_H
diff --git a/examples/multimedia/spectrum/tonegenerator.cpp b/examples/multimedia/spectrum/tonegenerator.cpp
new file mode 100644
index 000000000..5df1df44d
--- /dev/null
+++ b/examples/multimedia/spectrum/tonegenerator.cpp
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "spectrum.h"
+#include "utils.h"
+
+#include <QAudioFormat>
+#include <QByteArray>
+#include <QtEndian>
+#include <QtMath>
+
+void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer)
+{
+ Q_ASSERT(format.sampleFormat() == QAudioFormat::Int16);
+
+ const int channelBytes = format.bytesPerSample();
+ const int sampleBytes = format.channelCount() * channelBytes;
+ int length = buffer.size();
+ const int numSamples = buffer.size() / sampleBytes;
+
+ Q_ASSERT(length % sampleBytes == 0);
+ Q_UNUSED(sampleBytes); // suppress warning in release builds
+
+ unsigned char *ptr = reinterpret_cast<unsigned char *>(buffer.data());
+
+ qreal phase = 0.0;
+
+ const qreal d = 2 * M_PI / format.sampleRate();
+
+ // We can't generate a zero-frequency sine wave
+ const qreal startFreq = tone.startFreq ? tone.startFreq : 1.0;
+
+ // Amount by which phase increases on each sample
+ qreal phaseStep = d * startFreq;
+
+ // Amount by which phaseStep increases on each sample
+ // If this is non-zero, the output is a frequency-swept tone
+ const qreal phaseStepStep = d * (tone.endFreq - startFreq) / numSamples;
+
+ while (length) {
+ const qreal x = tone.amplitude * qSin(phase);
+ const qint16 value = realToPcm(x);
+ for (int i = 0; i < format.channelCount(); ++i) {
+ qToLittleEndian<qint16>(value, ptr);
+ ptr += channelBytes;
+ length -= channelBytes;
+ }
+
+ phase += phaseStep;
+ while (phase > 2 * M_PI)
+ phase -= 2 * M_PI;
+ phaseStep += phaseStepStep;
+ }
+}
diff --git a/examples/multimedia/spectrum/tonegenerator.h b/examples/multimedia/spectrum/tonegenerator.h
new file mode 100644
index 000000000..2c331fb3c
--- /dev/null
+++ b/examples/multimedia/spectrum/tonegenerator.h
@@ -0,0 +1,21 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TONEGENERATOR_H
+#define TONEGENERATOR_H
+
+#include "spectrum.h"
+
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE
+class QAudioFormat;
+class QByteArray;
+QT_END_NAMESPACE
+
+/**
+ * Generate a sine wave
+ */
+void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer);
+
+#endif // TONEGENERATOR_H
diff --git a/examples/multimedia/spectrum/tonegeneratordialog.cpp b/examples/multimedia/spectrum/tonegeneratordialog.cpp
new file mode 100644
index 000000000..1c98c2b86
--- /dev/null
+++ b/examples/multimedia/spectrum/tonegeneratordialog.cpp
@@ -0,0 +1,105 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "tonegeneratordialog.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDialogButtonBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QSlider>
+#include <QSpinBox>
+#include <QVBoxLayout>
+
+const int ToneGeneratorFreqMin = 1;
+const int ToneGeneratorFreqMax = 1000;
+const int ToneGeneratorFreqDefault = 440;
+const int ToneGeneratorAmplitudeDefault = 75;
+
+ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
+ : QDialog(parent),
+ m_toneGeneratorSweepCheckBox(new QCheckBox(tr("Frequency sweep"), this)),
+ m_frequencySweepEnabled(true),
+ m_toneGeneratorControl(new QWidget(this)),
+ m_toneGeneratorFrequencyControl(new QWidget(this)),
+ m_frequencySlider(new QSlider(Qt::Horizontal, this)),
+ m_frequencySpinBox(new QSpinBox(this)),
+ m_amplitudeSlider(new QSlider(Qt::Horizontal, this))
+{
+ QVBoxLayout *dialogLayout = new QVBoxLayout(this);
+
+ m_toneGeneratorSweepCheckBox->setChecked(true);
+
+ // Configure tone generator controls
+ m_frequencySlider->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax);
+ m_frequencySlider->setValue(ToneGeneratorFreqDefault);
+ m_frequencySpinBox->setRange(ToneGeneratorFreqMin, ToneGeneratorFreqMax);
+ m_frequencySpinBox->setValue(ToneGeneratorFreqDefault);
+ m_amplitudeSlider->setRange(0, 100);
+ m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault);
+
+ // Add widgets to layout
+ QGridLayout *frequencyControlLayout = new QGridLayout;
+ QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this);
+ frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1);
+ frequencyControlLayout->addWidget(m_frequencySlider, 0, 1);
+ frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1);
+ m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout);
+ m_toneGeneratorFrequencyControl->setEnabled(false);
+
+ QGridLayout *toneGeneratorLayout = new QGridLayout;
+ QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this);
+ toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1);
+ toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2);
+ toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0);
+ toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1);
+ m_toneGeneratorControl->setLayout(toneGeneratorLayout);
+ m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ dialogLayout->addWidget(m_toneGeneratorControl);
+
+ // Connect
+ connect(m_toneGeneratorSweepCheckBox, &QCheckBox::toggled, this,
+ &ToneGeneratorDialog::frequencySweepEnabled);
+ connect(m_frequencySlider, &QSlider::valueChanged, m_frequencySpinBox, &QSpinBox::setValue);
+ connect(m_frequencySpinBox, QOverload<int>::of(&QSpinBox::valueChanged), m_frequencySlider,
+ &QSlider::setValue);
+
+ // Add standard buttons to layout
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+ buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ dialogLayout->addWidget(buttonBox);
+
+ // Connect standard buttons
+ connect(buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this,
+ &ToneGeneratorDialog::accept);
+ connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this,
+ &ToneGeneratorDialog::reject);
+
+ setLayout(dialogLayout);
+}
+
+ToneGeneratorDialog::~ToneGeneratorDialog() = default;
+
+bool ToneGeneratorDialog::isFrequencySweepEnabled() const
+{
+ return m_toneGeneratorSweepCheckBox->isChecked();
+}
+
+qreal ToneGeneratorDialog::frequency() const
+{
+ return qreal(m_frequencySlider->value());
+}
+
+qreal ToneGeneratorDialog::amplitude() const
+{
+ return qreal(m_amplitudeSlider->value()) / 100.0;
+}
+
+void ToneGeneratorDialog::frequencySweepEnabled(bool enabled)
+{
+ m_frequencySweepEnabled = enabled;
+ m_toneGeneratorFrequencyControl->setEnabled(!enabled);
+}
+
+#include "moc_tonegeneratordialog.cpp"
diff --git a/examples/multimedia/spectrum/tonegeneratordialog.h b/examples/multimedia/spectrum/tonegeneratordialog.h
new file mode 100644
index 000000000..2b0aed501
--- /dev/null
+++ b/examples/multimedia/spectrum/tonegeneratordialog.h
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TONEGENERATORDIALOG_H
+#define TONEGENERATORDIALOG_H
+
+#include "spectrum.h"
+
+#include <QAudioDevice>
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+class QCheckBox;
+class QSlider;
+class QSpinBox;
+class QGridLayout;
+QT_END_NAMESPACE
+
+/**
+ * Dialog which controls the parameters of the tone generator.
+ */
+class ToneGeneratorDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ToneGeneratorDialog(QWidget *parent = nullptr);
+ ~ToneGeneratorDialog();
+
+ bool isFrequencySweepEnabled() const;
+ qreal frequency() const;
+ qreal amplitude() const;
+
+private slots:
+ void frequencySweepEnabled(bool enabled);
+
+private:
+ QCheckBox *m_toneGeneratorSweepCheckBox;
+ bool m_frequencySweepEnabled;
+ QWidget *m_toneGeneratorControl;
+ QWidget *m_toneGeneratorFrequencyControl;
+ QSlider *m_frequencySlider;
+ QSpinBox *m_frequencySpinBox;
+ QSlider *m_amplitudeSlider;
+};
+
+#endif // TONEGENERATORDIALOG_H
diff --git a/examples/multimedia/spectrum/utils.cpp b/examples/multimedia/spectrum/utils.cpp
new file mode 100644
index 000000000..3b4146a51
--- /dev/null
+++ b/examples/multimedia/spectrum/utils.cpp
@@ -0,0 +1,68 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "utils.h"
+#include <QAudioFormat>
+
+qreal nyquistFrequency(const QAudioFormat &format)
+{
+ return format.sampleRate() / 2;
+}
+
+QString formatToString(const QAudioFormat &format)
+{
+ QString result;
+
+ if (QAudioFormat() != format) {
+
+ QString formatType;
+ switch (format.sampleFormat()) {
+ case QAudioFormat::UInt8:
+ formatType = "Unsigned8";
+ break;
+ case QAudioFormat::Int16:
+ formatType = "Signed16";
+ break;
+ case QAudioFormat::Int32:
+ formatType = "Signed32";
+ break;
+ case QAudioFormat::Float:
+ formatType = "Float";
+ break;
+ default:
+ formatType = "Unknown";
+ break;
+ }
+
+ QString formatChannels = QStringLiteral("%1 channels").arg(format.channelCount());
+ switch (format.channelCount()) {
+ case 1:
+ formatChannels = "mono";
+ break;
+ case 2:
+ formatChannels = "stereo";
+ break;
+ }
+
+ result = QStringLiteral("%1 Hz %2 bit %3 %4")
+ .arg(format.sampleRate())
+ .arg(format.bytesPerSample() * 8)
+ .arg(formatType)
+ .arg(formatChannels);
+ }
+
+ return result;
+}
+
+const qint16 PCMS16MaxValue = 32767;
+const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768
+
+qreal pcmToReal(qint16 pcm)
+{
+ return qreal(pcm) / PCMS16MaxAmplitude;
+}
+
+qint16 realToPcm(qreal real)
+{
+ return real * PCMS16MaxValue;
+}
diff --git a/examples/multimedia/spectrum/utils.h b/examples/multimedia/spectrum/utils.h
new file mode 100644
index 000000000..da0711c66
--- /dev/null
+++ b/examples/multimedia/spectrum/utils.h
@@ -0,0 +1,79 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <QDebug>
+#include <QtGlobal>
+
+QT_FORWARD_DECLARE_CLASS(QAudioFormat)
+
+//-----------------------------------------------------------------------------
+// Miscellaneous utility functions
+//-----------------------------------------------------------------------------
+
+QString formatToString(const QAudioFormat &format);
+
+qreal nyquistFrequency(const QAudioFormat &format);
+
+// Scale PCM value to [-1.0, 1.0]
+qreal pcmToReal(qint16 pcm);
+
+// Scale real value in [-1.0, 1.0] to PCM
+qint16 realToPcm(qreal real);
+
+// Compile-time calculation of powers of two
+
+template<int N>
+class PowerOfTwo
+{
+public:
+ static const int Result = PowerOfTwo<N - 1>::Result * 2;
+};
+
+template<>
+class PowerOfTwo<0>
+{
+public:
+ static const int Result = 1;
+};
+
+//-----------------------------------------------------------------------------
+// Debug output
+//-----------------------------------------------------------------------------
+
+class NullDebug
+{
+public:
+ template<typename T>
+ NullDebug &operator<<(const T &)
+ {
+ return *this;
+ }
+};
+
+inline NullDebug nullDebug()
+{
+ return NullDebug();
+}
+
+#ifdef LOG_ENGINE
+# define ENGINE_DEBUG qDebug()
+#else
+# define ENGINE_DEBUG nullDebug()
+#endif
+
+#ifdef LOG_SPECTRUMANALYSER
+# define SPECTRUMANALYSER_DEBUG qDebug()
+#else
+# define SPECTRUMANALYSER_DEBUG nullDebug()
+#endif
+
+#ifdef LOG_WAVEFORM
+# define WAVEFORM_DEBUG qDebug()
+#else
+# define WAVEFORM_DEBUG nullDebug()
+#endif
+
+#endif // UTILS_H
diff --git a/examples/multimedia/spectrum/app/waveform.cpp b/examples/multimedia/spectrum/waveform.cpp
index 3e7462157..a3727a2a6 100644
--- a/examples/multimedia/spectrum/app/waveform.cpp
+++ b/examples/multimedia/spectrum/waveform.cpp
@@ -1,76 +1,30 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "waveform.h"
#include "utils.h"
+
+#include <QDebug>
#include <QPainter>
#include <QResizeEvent>
-#include <QDebug>
//#define PAINT_EVENT_TRACE
#ifdef PAINT_EVENT_TRACE
-# define WAVEFORM_PAINT_DEBUG qDebug()
+# define WAVEFORM_PAINT_DEBUG qDebug()
#else
-# define WAVEFORM_PAINT_DEBUG nullDebug()
+# define WAVEFORM_PAINT_DEBUG nullDebug()
#endif
Waveform::Waveform(QWidget *parent)
- : QWidget(parent)
- , m_bufferPosition(0)
- , m_bufferLength(0)
- , m_audioPosition(0)
- , m_active(false)
- , m_tileLength(0)
- , m_tileArrayStart(0)
- , m_windowPosition(0)
- , m_windowLength(0)
+ : QWidget(parent),
+ m_bufferPosition(0),
+ m_bufferLength(0),
+ m_audioPosition(0),
+ m_active(false),
+ m_tileLength(0),
+ m_tileArrayStart(0),
+ m_windowPosition(0),
+ m_windowLength(0)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
setMinimumHeight(50);
@@ -89,24 +43,23 @@ void Waveform::paintEvent(QPaintEvent * /*event*/)
if (m_active) {
WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
- << "windowPosition" << m_windowPosition
- << "windowLength" << m_windowLength;
+ << "windowPosition" << m_windowPosition << "windowLength"
+ << m_windowLength;
qint64 pos = m_windowPosition;
const qint64 windowEnd = m_windowPosition + m_windowLength;
int destLeft = 0;
int destRight = 0;
while (pos < windowEnd) {
const TilePoint point = tilePoint(pos);
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "pos" << pos
- << "tileIndex" << point.index
- << "positionOffset" << point.positionOffset
- << "pixelOffset" << point.pixelOffset;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "pos" << pos << "tileIndex" << point.index << "positionOffset"
+ << point.positionOffset << "pixelOffset" << point.pixelOffset;
if (point.index != NullIndex) {
const Tile &tile = m_tiles[point.index];
if (tile.painted) {
- const qint64 sectionLength = qMin((m_tileLength - point.positionOffset),
- (windowEnd - pos));
+ const qint64 sectionLength =
+ qMin((m_tileLength - point.positionOffset), (windowEnd - pos));
Q_ASSERT(sectionLength > 0);
const int sourceRight = tilePixelOffset(point.positionOffset + sectionLength);
@@ -120,9 +73,10 @@ void Waveform::paintEvent(QPaintEvent * /*event*/)
sourceRect.setLeft(point.pixelOffset);
sourceRect.setRight(sourceRight);
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "tileIndex" << point.index
- << "source" << point.pixelOffset << sourceRight
- << "dest" << destLeft << destRight;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "tileIndex" << point.index << "source"
+ << point.pixelOffset << sourceRight << "dest" << destLeft
+ << destRight;
painter.drawPixmap(destRect, *tile.pixmap, sourceRect);
@@ -130,25 +84,30 @@ void Waveform::paintEvent(QPaintEvent * /*event*/)
if (point.index < m_tiles.count()) {
pos = tilePosition(point.index + 1);
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "pos ->" << pos;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "pos ->" << pos;
} else {
// Reached end of tile array
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "reached end of tile array";
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "reached end of tile array";
break;
}
} else {
// Passed last tile which is painted
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "tile" << point.index << "not painted";
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "tile" << point.index << "not painted";
break;
}
} else {
// pos is past end of tile array
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "pos" << pos << "past end of tile array";
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "pos" << pos << "past end of tile array";
break;
}
}
- WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent" << "final pos" << pos << "final x" << destRight;
+ WAVEFORM_PAINT_DEBUG << "Waveform::paintEvent"
+ << "final pos" << pos << "final x" << destRight;
}
}
@@ -158,11 +117,12 @@ void Waveform::resizeEvent(QResizeEvent *event)
createPixmaps(event->size());
}
-void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qint64 windowDurationUs)
+void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize,
+ qint64 windowDurationUs)
{
WAVEFORM_DEBUG << "Waveform::initialize"
- << "audioBufferSize" << audioBufferSize
- << "windowDurationUs" << windowDurationUs;
+ << "audioBufferSize" << audioBufferSize << "windowDurationUs"
+ << windowDurationUs;
reset();
@@ -172,7 +132,7 @@ void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qi
m_tileLength = audioBufferSize;
// Calculate window size
- m_windowLength = audioLength(m_format, windowDurationUs);
+ m_windowLength = m_format.bytesForDuration(windowDurationUs);
// Calculate number of tiles required
int nTiles;
@@ -185,11 +145,10 @@ void Waveform::initialize(const QAudioFormat &format, qint64 audioBufferSize, qi
}
WAVEFORM_DEBUG << "Waveform::initialize"
- << "tileLength" << m_tileLength
- << "windowLength" << m_windowLength
- << "nTiles" << nTiles;
+ << "tileLength" << m_tileLength << "windowLength" << m_windowLength << "nTiles"
+ << nTiles;
- m_pixmaps.fill(0, nTiles);
+ m_pixmaps.fill(nullptr, nTiles);
m_tiles.resize(nTiles);
createPixmaps(rect().size());
@@ -217,8 +176,7 @@ void Waveform::reset()
void Waveform::bufferChanged(qint64 position, qint64 length, const QByteArray &buffer)
{
WAVEFORM_DEBUG << "Waveform::bufferChanged"
- << "audioPosition" << m_audioPosition
- << "bufferPosition" << position
+ << "audioPosition" << m_audioPosition << "bufferPosition" << position
<< "bufferLength" << length;
m_bufferPosition = position;
m_bufferLength = length;
@@ -229,8 +187,7 @@ void Waveform::bufferChanged(qint64 position, qint64 length, const QByteArray &b
void Waveform::audioPositionChanged(qint64 position)
{
WAVEFORM_DEBUG << "Waveform::audioPositionChanged"
- << "audioPosition" << position
- << "bufferPosition" << m_bufferPosition
+ << "audioPosition" << position << "bufferPosition" << m_bufferPosition
<< "bufferLength" << m_bufferLength;
if (position >= m_bufferPosition) {
@@ -243,7 +200,7 @@ void Waveform::audioPositionChanged(qint64 position)
void Waveform::deletePixmaps()
{
- qDeleteAll(qExchange(m_pixmaps, {}));
+ qDeleteAll(std::exchange(m_pixmaps, {}));
}
void Waveform::createPixmaps(const QSize &widgetSize)
@@ -252,20 +209,18 @@ void Waveform::createPixmaps(const QSize &widgetSize)
m_pixmapSize.setWidth(qreal(widgetSize.width()) * m_tileLength / m_windowLength);
WAVEFORM_DEBUG << "Waveform::createPixmaps"
- << "widgetSize" << widgetSize
- << "pixmapSize" << m_pixmapSize;
+ << "widgetSize" << widgetSize << "pixmapSize" << m_pixmapSize;
Q_ASSERT(m_tiles.count() == m_pixmaps.count());
// (Re)create pixmaps
- for (int i=0; i<m_pixmaps.size(); ++i) {
- delete m_pixmaps[i];
- m_pixmaps[i] = 0;
- m_pixmaps[i] = new QPixmap(m_pixmapSize);
+ for (auto &pixmap : m_pixmaps) {
+ delete pixmap;
+ pixmap = new QPixmap(m_pixmapSize);
}
// Update tile pixmap pointers, and mark for repainting
- for (int i=0; i<m_tiles.count(); ++i) {
+ for (int i = 0; i < m_tiles.count(); ++i) {
m_tiles[i].pixmap = m_pixmaps[i];
m_tiles[i].painted = false;
}
@@ -274,14 +229,14 @@ void Waveform::createPixmaps(const QSize &widgetSize)
void Waveform::setWindowPosition(qint64 position)
{
WAVEFORM_DEBUG << "Waveform::setWindowPosition"
- << "old" << m_windowPosition << "new" << position
- << "tileArrayStart" << m_tileArrayStart;
+ << "old" << m_windowPosition << "new" << position << "tileArrayStart"
+ << m_tileArrayStart;
const qint64 oldPosition = m_windowPosition;
m_windowPosition = position;
- if ((m_windowPosition >= oldPosition) &&
- (m_windowPosition - m_tileArrayStart < (m_tiles.count() * m_tileLength))) {
+ if ((m_windowPosition >= oldPosition)
+ && (m_windowPosition - m_tileArrayStart < (m_tiles.count() * m_tileLength))) {
// Work out how many tiles need to be shuffled
const qint64 offset = m_windowPosition - m_tileArrayStart;
const int nTiles = offset / m_tileLength;
@@ -336,7 +291,7 @@ bool Waveform::paintTiles()
WAVEFORM_DEBUG << "Waveform::paintTiles";
bool updateRequired = false;
- for (int i=0; i<m_tiles.count(); ++i) {
+ for (int i = 0; i < m_tiles.count(); ++i) {
const Tile &tile = m_tiles[i];
if (!tile.painted) {
const qint64 tileStart = m_tileArrayStart + i * m_tileLength;
@@ -359,11 +314,8 @@ void Waveform::paintTile(int index)
const qint64 tileStart = m_tileArrayStart + index * m_tileLength;
WAVEFORM_DEBUG << "Waveform::paintTile"
- << "index" << index
- << "bufferPosition" << m_bufferPosition
- << "bufferLength" << m_bufferLength
- << "start" << tileStart
- << "end" << tileStart + m_tileLength;
+ << "index" << index << "bufferPosition" << m_bufferPosition << "bufferLength"
+ << m_bufferLength << "start" << tileStart << "end" << tileStart + m_tileLength;
Q_ASSERT(m_bufferPosition <= tileStart);
Q_ASSERT(m_bufferPosition + m_bufferLength >= tileStart + m_tileLength);
@@ -371,8 +323,8 @@ void Waveform::paintTile(int index)
Tile &tile = m_tiles[index];
Q_ASSERT(!tile.painted);
- const qint16* base = reinterpret_cast<const qint16*>(m_buffer.constData());
- const qint16* buffer = base + ((tileStart - m_bufferPosition) / 2);
+ const qint16 *base = reinterpret_cast<const qint16 *>(m_buffer.constData());
+ const qint16 *buffer = base + ((tileStart - m_bufferPosition) / 2);
const int numSamples = m_tileLength / (2 * m_format.channelCount());
QPainter painter(tile.pixmap);
@@ -394,10 +346,10 @@ void Waveform::paintTile(int index)
QLine line(origin, origin);
- for (int i=0; i<numSamples; ++i) {
- const qint16* ptr = buffer + i * m_format.channelCount();
+ for (int i = 0; i < numSamples; ++i) {
+ const qint16 *ptr = buffer + i * m_format.channelCount();
- const int offset = reinterpret_cast<const char*>(ptr) - m_buffer.constData();
+ const int offset = reinterpret_cast<const char *>(ptr) - m_buffer.constData();
Q_ASSERT(offset >= 0);
Q_ASSERT(offset < m_bufferLength);
Q_UNUSED(offset);
@@ -418,7 +370,8 @@ void Waveform::paintTile(int index)
void Waveform::shuffleTiles(int n)
{
- WAVEFORM_DEBUG << "Waveform::shuffleTiles" << "n" << n;
+ WAVEFORM_DEBUG << "Waveform::shuffleTiles"
+ << "n" << n;
while (n--) {
Tile tile = m_tiles.first();
@@ -428,17 +381,20 @@ void Waveform::shuffleTiles(int n)
m_tileArrayStart += m_tileLength;
}
- WAVEFORM_DEBUG << "Waveform::shuffleTiles" << "tileArrayStart" << m_tileArrayStart;
+ WAVEFORM_DEBUG << "Waveform::shuffleTiles"
+ << "tileArrayStart" << m_tileArrayStart;
}
void Waveform::resetTiles(qint64 newStartPos)
{
- WAVEFORM_DEBUG << "Waveform::resetTiles" << "newStartPos" << newStartPos;
+ WAVEFORM_DEBUG << "Waveform::resetTiles"
+ << "newStartPos" << newStartPos;
QList<Tile>::iterator i = m_tiles.begin();
- for ( ; i != m_tiles.end(); ++i)
+ for (; i != m_tiles.end(); ++i)
i->painted = false;
m_tileArrayStart = newStartPos;
}
+#include "moc_waveform.cpp"
diff --git a/examples/multimedia/spectrum/app/waveform.h b/examples/multimedia/spectrum/waveform.h
index 8c26e99b2..86fda9962 100644
--- a/examples/multimedia/spectrum/app/waveform.h
+++ b/examples/multimedia/spectrum/waveform.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WAVEFORM_H
#define WAVEFORM_H
@@ -70,7 +23,7 @@ class Waveform : public QWidget
Q_OBJECT
public:
- explicit Waveform(QWidget *parent = 0);
+ explicit Waveform(QWidget *parent = nullptr);
~Waveform();
// QWidget
@@ -115,17 +68,18 @@ private:
struct TilePoint
{
TilePoint(int idx = 0, qint64 pos = 0, qint64 pix = 0)
- : index(idx), positionOffset(pos), pixelOffset(pix)
- { }
+ : index(idx), positionOffset(pos), pixelOffset(pix)
+ {
+ }
// Index of tile
- int index;
+ int index;
// Number of bytes from start of tile
- qint64 positionOffset;
+ qint64 positionOffset;
// Number of pixels from left of corresponding pixmap
- int pixelOffset;
+ int pixelOffset;
};
/*
@@ -177,36 +131,37 @@ private:
void resetTiles(qint64 newStartPos);
private:
- qint64 m_bufferPosition;
- qint64 m_bufferLength;
- QByteArray m_buffer;
+ qint64 m_bufferPosition;
+ qint64 m_bufferLength;
+ QByteArray m_buffer;
- qint64 m_audioPosition;
- QAudioFormat m_format;
+ qint64 m_audioPosition;
+ QAudioFormat m_format;
- bool m_active;
+ bool m_active;
- QSize m_pixmapSize;
- QList<QPixmap*> m_pixmaps;
+ QSize m_pixmapSize;
+ QList<QPixmap *> m_pixmaps;
- struct Tile {
+ struct Tile
+ {
// Pointer into parent m_pixmaps array
- QPixmap* pixmap;
+ QPixmap *pixmap;
// Flag indicating whether this tile has been painted
- bool painted;
+ bool painted;
};
- QList<Tile> m_tiles;
+ QList<Tile> m_tiles;
// Length of audio data in bytes depicted by each tile
- qint64 m_tileLength;
+ qint64 m_tileLength;
// Position in bytes of the first tile, relative to m_buffer
- qint64 m_tileArrayStart;
+ qint64 m_tileArrayStart;
- qint64 m_windowPosition;
- qint64 m_windowLength;
+ qint64 m_windowPosition;
+ qint64 m_windowLength;
};
#endif // WAVEFORM_H
diff --git a/examples/multimedia/video/CMakeLists.txt b/examples/multimedia/video/CMakeLists.txt
new file mode 100644
index 000000000..72e5d7e8a
--- /dev/null
+++ b/examples/multimedia/video/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+qt_internal_add_example(qmlvideo)
+if(TARGET Qt::QuickControls2)
+ if(TARGET Qt::Svg)
+ qt_internal_add_example(mediaplayer)
+ endif()
+ qt_internal_add_example(recorder)
+endif()
diff --git a/examples/multimedia/video/android/android.pro b/examples/multimedia/video/android/android.pro
deleted file mode 100644
index 95ed21e17..000000000
--- a/examples/multimedia/video/android/android.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-
-QT_FOR_CONFIG += multimedia-private
-
-qtConfig(gstreamer): SUBDIRS += gstreamer
diff --git a/examples/multimedia/video/android/gstreamer/gstreamer.pro b/examples/multimedia/video/android/gstreamer/gstreamer.pro
deleted file mode 100644
index edc040adc..000000000
--- a/examples/multimedia/video/android/gstreamer/gstreamer.pro
+++ /dev/null
@@ -1,23 +0,0 @@
-QT += quick multimedia multimediawidgets
-CONFIG += c++11
-
-SOURCES += main.cpp
-
-RESOURCES += qml.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/android/gstreamer
-INSTALLS += target
-
-GSTREAMER_ROOT_ANDROID = $$(GSTREAMER_ROOT_ANDROID)
-isEmpty(GSTREAMER_ROOT_ANDROID): error("GSTREAMER_ROOT_ANDROID is empty")
-
-INCLUDEPATH += $(GSTREAMER_ROOT_ANDROID)/armv7/include/ $(GSTREAMER_ROOT_ANDROID)/armv7/include/gstreamer-1.0 $(GSTREAMER_ROOT_ANDROID)/armv7/include/glib-2.0 $(GSTREAMER_ROOT_ANDROID)/armv7/lib/glib-2.0/include
-
-QT+=multimediagsttools-private
-LIBS += -L$(GSTREAMER_ROOT_ANDROID)/armv7/lib/ -L$(GSTREAMER_ROOT_ANDROID)/armv7/lib/gstreamer-1.0 \
--lgstcoreelements -lgstplayback -lgstvideotestsrc -lgstaudioconvert -lgstvideoconvert -lgstautodetect -lgsttypefindfunctions \
-#PLUGINS codecs
--lgstvorbis -lvorbis -lgstivorbisdec -lvorbisenc -lvorbisfile -lgstsubparse -lgstaudioparsers \
--lgstgio -lgstapp -lgstisomp4 -lgstavi -lgstogg -lgstwavenc -lgstwavpack -lgstwavparse -lgsttheora -lgstmpg123 -lgstx264 -lgstlibav \
--lgsttcp -lgstsoup -logg -ltheora -lmpg123 -lx264 -lavfilter -lavformat -lavcodec -lavutil -lbz2 -lswresample \
--lsoup-2.4 -lgio-2.0 -lgstrtp-1.0 -lgstriff-1.0 -lgstnet-1.0
diff --git a/examples/multimedia/video/android/gstreamer/main.cpp b/examples/multimedia/video/android/gstreamer/main.cpp
deleted file mode 100644
index 56037aece..000000000
--- a/examples/multimedia/video/android/gstreamer/main.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QGuiApplication>
-#include <QQmlApplicationEngine>
-
-#include <private/qgstutils_p.h>
-
-#include <gst/gstplugin.h>
-extern "C" {
-GST_PLUGIN_STATIC_DECLARE(coreelements);
-GST_PLUGIN_STATIC_DECLARE(playback);
-GST_PLUGIN_STATIC_DECLARE(videotestsrc);
-GST_PLUGIN_STATIC_DECLARE(audioconvert);
-GST_PLUGIN_STATIC_DECLARE(videoconvert);
-GST_PLUGIN_STATIC_DECLARE(autodetect);
-GST_PLUGIN_STATIC_DECLARE(gio);
-GST_PLUGIN_STATIC_DECLARE(soup);
-GST_PLUGIN_STATIC_DECLARE(app);
-GST_PLUGIN_STATIC_DECLARE(isomp4);
-GST_PLUGIN_STATIC_DECLARE(avi);
-GST_PLUGIN_STATIC_DECLARE(ogg);
-GST_PLUGIN_STATIC_DECLARE(vorbis);
-GST_PLUGIN_STATIC_DECLARE(tcp);
-GST_PLUGIN_STATIC_DECLARE(audioparsers);
-GST_PLUGIN_STATIC_DECLARE(theora);
-GST_PLUGIN_STATIC_DECLARE(mpg123);
-GST_PLUGIN_STATIC_DECLARE(typefindfunctions);
-GST_PLUGIN_STATIC_DECLARE(x264);
-GST_PLUGIN_STATIC_DECLARE(libav);
-};
-
-int main(int argc, char *argv[])
-{
- QGstUtils::initializeGst();
-
- GST_PLUGIN_STATIC_REGISTER(coreelements);
- GST_PLUGIN_STATIC_REGISTER(playback);
- GST_PLUGIN_STATIC_REGISTER(videotestsrc);
- GST_PLUGIN_STATIC_REGISTER(audioconvert);
- GST_PLUGIN_STATIC_REGISTER(videoconvert);
- GST_PLUGIN_STATIC_REGISTER(autodetect);
- GST_PLUGIN_STATIC_REGISTER(soup);
- GST_PLUGIN_STATIC_REGISTER(gio);
- GST_PLUGIN_STATIC_REGISTER(app);
- GST_PLUGIN_STATIC_REGISTER(isomp4);
- GST_PLUGIN_STATIC_REGISTER(avi);
- GST_PLUGIN_STATIC_REGISTER(ogg);
- GST_PLUGIN_STATIC_REGISTER(vorbis);
- GST_PLUGIN_STATIC_REGISTER(tcp);
- GST_PLUGIN_STATIC_REGISTER(audioparsers);
- GST_PLUGIN_STATIC_REGISTER(theora);
- GST_PLUGIN_STATIC_REGISTER(mpg123);
- GST_PLUGIN_STATIC_REGISTER(typefindfunctions);
- GST_PLUGIN_STATIC_REGISTER(x264);
- GST_PLUGIN_STATIC_REGISTER(libav);
-
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-
- QGuiApplication app(argc, argv);
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QLatin1String("qrc:/main.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
-
- return app.exec();
-}
diff --git a/examples/multimedia/video/android/gstreamer/main.qml b/examples/multimedia/video/android/gstreamer/main.qml
deleted file mode 100644
index 99acb558c..000000000
--- a/examples/multimedia/video/android/gstreamer/main.qml
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.7
-import QtQuick.Controls 2.0
-import QtQuick.Layouts 1.3
-import QtMultimedia 5.12
-
-ApplicationWindow {
- visible: true
- width: 640
- height: 480
-
- Video {
- id: video
- anchors.fill: parent
- autoPlay: true
- autoLoad: true
- source: "gst-pipeline: videotestsrc ! qtvideosink"
- }
-
- MouseArea {
- anchors.fill: video
- onClicked: {
- video.play()
- }
- }
-}
diff --git a/examples/multimedia/video/android/gstreamer/qml.qrc b/examples/multimedia/video/android/gstreamer/qml.qrc
deleted file mode 100644
index 5f6483ac3..000000000
--- a/examples/multimedia/video/android/gstreamer/qml.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/multimedia/video/doc/images/qmlvideofx-camera-glow.jpg b/examples/multimedia/video/doc/images/qmlvideofx-camera-glow.jpg
deleted file mode 100644
index 777ed4ffc..000000000
--- a/examples/multimedia/video/doc/images/qmlvideofx-camera-glow.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/doc/images/qmlvideofx-camera-wobble.jpg b/examples/multimedia/video/doc/images/qmlvideofx-camera-wobble.jpg
deleted file mode 100644
index 980ab0d15..000000000
--- a/examples/multimedia/video/doc/images/qmlvideofx-camera-wobble.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/doc/images/qmlvideofx-effects-menu.jpg b/examples/multimedia/video/doc/images/qmlvideofx-effects-menu.jpg
deleted file mode 100644
index eb5b90321..000000000
--- a/examples/multimedia/video/doc/images/qmlvideofx-effects-menu.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/doc/images/qmlvideofx-video-edgedetection.jpg b/examples/multimedia/video/doc/images/qmlvideofx-video-edgedetection.jpg
deleted file mode 100644
index 35b36c036..000000000
--- a/examples/multimedia/video/doc/images/qmlvideofx-video-edgedetection.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/doc/images/qmlvideofx-video-pagecurl.jpg b/examples/multimedia/video/doc/images/qmlvideofx-video-pagecurl.jpg
deleted file mode 100644
index 5cd8d2bd2..000000000
--- a/examples/multimedia/video/doc/images/qmlvideofx-video-pagecurl.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/doc/src/qmlvideofx.qdoc b/examples/multimedia/video/doc/src/qmlvideofx.qdoc
deleted file mode 100644
index c52f95f44..000000000
--- a/examples/multimedia/video/doc/src/qmlvideofx.qdoc
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\example multimedia/video/qmlvideofx
-\title QML Video Shader Effects Example
-\ingroup multimedia_examples
-
-\brief Applying shader effects on video and camera viewfinder content.
-
-\include examples-run.qdocinc
-
-\section1 Overview
-
-\e{QML Video Shader Effects} demonstrates how a \l ShaderEffect can be used to
-apply postprocessing effects, expressed in GLSL, to QML \l VideoOutput type.
-
-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 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://durian.blender.org/}{Sintel from blender.org}).
-\image qmlvideofx-video-edgedetection.jpg
-
-This image shows a page curl effect, applied to the same video clip.
-\image qmlvideofx-video-pagecurl.jpg
-
-Here we see a 'glow' effect (edge detection plus colour quantization) being
-applied to the camera viewfinder.
-\image qmlvideofx-camera-glow.jpg
-
-This image shows a 'wobble' effect applied to the viewfinder.
-\image qmlvideofx-camera-wobble.jpg
-
-The application includes many more effects than the ones shown here - look
-for Effect*.qml files in the list of files below to see the full range.
-
-\section1 Application Structure
-
-Shader effects can be applied to video or viewfinder content using
-\l{ShaderEffect}, as shown in the following example, which applies
-a wiggly effect to the content:
-
-\qml
-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.14159265358979323846 * wiggledTexCoord.t) * wiggleAmount;
- gl_FragColor = texture2D(source, wiggledTexCoord.st);
- }
- "
- }
-}
-\endqml
-
-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 \c Content, which uses a
-\l[QML]{Loader} to create either a \l[QML]{MediaPlayer}, \l[QML]{Camera}, or an
-\l[QML]{Image}:
-
-\quotefromfile multimedia/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 \c Effect, which in
-turn is based on the \l[QML]{ShaderEffect}:
-
-\quotefromfile multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml
-\skipto import
-\printuntil /^\}/
-
-The interface of 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 multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml
-\skipto import
-\printuntil /^\}/
-
-The main.qml file shows a \c FileOpen item, which allows
-the user to select the input source and an \c EffectSelectionList
-item, which lists each of the available shader effects. As described above, a
-\c Content item is used to load the appropriate input and effect type. A
-\c Divider item draws the vertical dividing line, which can be dragged left or
-right by the user. Finally, a \c ParameterPanel item renders the sliders
-corresponding to each effect parameter.
-
-\image qmlvideofx-effects-menu.jpg
-\caption The effect selection menu
-
-\section1 Calculating and Displaying QML Painting Rate
-
-\input multimedia/doc/src/examples/video-qml-paint-rate.qdocinc
-
-All that remains is to connect the afterRendering() signal of the QQuickView
-object to a JavaScript function, which will eventually call frequencyItem.notify():
-
-\quotefromfile multimedia/video/qmlvideofx/main.cpp
-\skipto QGuiApplication
-\printuntil ;
-\dots
-\skipto QQuickItem
-\printuntil ;
-\dots
-\skipto QObject::connect
-\printuntil SLOT(qmlFramePainted()));
-
-*/
diff --git a/examples/multimedia/video/mediaplayer/CMakeLists.txt b/examples/multimedia/video/mediaplayer/CMakeLists.txt
new file mode 100644
index 000000000..e33a20ad4
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/CMakeLists.txt
@@ -0,0 +1,69 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(mediaplayer LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/mediaplayer")
+
+find_package(Qt6 REQUIRED COMPONENTS Multimedia Core Quick QuickControls2 Svg)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(mediaplayerexample
+ main.cpp
+)
+
+set_target_properties(mediaplayerexample PROPERTIES
+ MACOSX_BUNDLE TRUE
+)
+
+qt_add_qml_module(mediaplayerexample
+ URI mediaplayer
+ QML_FILES
+ "Main.qml"
+ "controls/PlaybackControl.qml"
+ "controls/AudioControl.qml"
+ "controls/PlaybackSeekControl.qml"
+ "controls/SettingsPopup.qml"
+ "controls/UrlPopup.qml"
+ "controls/MetadataInfo.qml"
+ "controls/TracksInfo.qml"
+ RESOURCES
+ "images/backward10.svg"
+ "images/mute.svg"
+ "images/open_new.svg"
+ "images/pause_symbol.svg"
+ "images/play_symbol.svg"
+ "images/forward10.svg"
+ "images/more.svg"
+ "images/speaker.svg"
+ "images/stop_symbol.svg"
+ "images/volume.svg"
+ "images/volume_mute.svg"
+ "images/zoom_maximize.svg"
+ "images/zoom_minimize.svg"
+ "images/link.svg"
+ "images/loop.svg"
+)
+
+target_link_libraries(mediaplayerexample PRIVATE
+ Qt6::Core
+ Qt6::Multimedia
+ Qt6::Svg
+ Qt6::Quick
+ Qt6::Multimedia
+)
+
+install(TARGETS mediaplayerexample
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/mediaplayer/Main.qml b/examples/multimedia/video/mediaplayer/Main.qml
new file mode 100644
index 000000000..9ee9cf6c3
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/Main.qml
@@ -0,0 +1,178 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+import QtQuick.Dialogs
+import QtMultimedia
+import "controls"
+
+//! [0]
+ApplicationWindow {
+ id: root
+ title: qsTr("Multimedia Player")
+ width: 1280
+ height: 720
+ //! [0]
+ minimumWidth: 960
+ minimumHeight: 540
+ visible: true
+ color: "black"
+
+ property alias source: mediaPlayer.source
+ property alias playbackRate: mediaPlayer.playbackRate
+ property bool fullScreen: false
+
+ MessageDialog {
+ id: mediaError
+ buttons: MessageDialog.Ok
+ }
+
+ MouseArea {
+ // an activity listener to hide the playback contols when idle
+ id: activityListener
+ anchors.fill: parent
+ z: 1
+ propagateComposedEvents: true
+ hoverEnabled: true
+
+ property bool inactiveMouse: false
+
+ Timer {
+ id: timer
+ interval: 3000 // milliseconds
+ onTriggered: activityListener.inactiveMouse = true
+ }
+
+ function activityHandler(mouse) {
+ if (activityListener.inactiveMouse)
+ activityListener.inactiveMouse = false
+ timer.restart()
+ timer.start()
+ mouse.accepted = false
+ }
+
+ onPositionChanged: mouse => activityHandler(mouse)
+ onPressed: mouse => activityHandler(mouse)
+ onDoubleClicked: mouse => mouse.accepted = false
+ }
+
+ MetadataInfo {
+ id: metadataInfo
+ }
+
+ TracksInfo {
+ id: audioTracksInfo
+ onSelectedTrackChanged: {
+ mediaPlayer.activeAudioTrack = selectedTrack
+ mediaPlayer.updateMetadata()
+ }
+ }
+
+ TracksInfo {
+ id: videoTracksInfo
+ onSelectedTrackChanged: {
+ mediaPlayer.activeVideoTrack = selectedTrack
+ mediaPlayer.updateMetadata()
+ }
+ }
+
+ TracksInfo {
+ id: subtitleTracksInfo
+ onSelectedTrackChanged: {
+ mediaPlayer.activeSubtitleTrack = selectedTrack
+ mediaPlayer.updateMetadata()
+ }
+ }
+
+ //! [1]
+ MediaPlayer {
+ id: mediaPlayer
+ //! [1]
+ function updateMetadata() {
+ metadataInfo.clear()
+ metadataInfo.read(mediaPlayer.metaData)
+ metadataInfo.read(mediaPlayer.audioTracks[mediaPlayer.activeAudioTrack])
+ metadataInfo.read(mediaPlayer.videoTracks[mediaPlayer.activeVideoTrack])
+ metadataInfo.read(mediaPlayer.subtitleTracks[mediaPlayer.activeSubtitleTrack])
+ }
+ //! [2]
+ videoOutput: videoOutput
+ audioOutput: AudioOutput {
+ id: audio
+ muted: playbackController.muted
+ volume: playbackController.volume
+ }
+ //! [2]
+ //! [4]
+ onErrorOccurred: {
+ mediaError.open()
+ mediaError.text = mediaPlayer.errorString
+ }
+ //! [4]
+ onMetaDataChanged: { updateMetadata() }
+ //! [6]
+ onTracksChanged: {
+ audioTracksInfo.read(mediaPlayer.audioTracks)
+ videoTracksInfo.read(mediaPlayer.videoTracks)
+ subtitleTracksInfo.read(mediaPlayer.subtitleTracks, 6) /* QMediaMetaData::Language = 6 */
+ updateMetadata()
+ mediaPlayer.play()
+ }
+ //! [6]
+ source: new URL("https://download.qt.io/learning/videos/media-player-example/Qt_LogoMergeEffect.mp4")
+ }
+
+ //! [3]
+ VideoOutput {
+ id: videoOutput
+ anchors.fill: parent
+ visible: mediaPlayer.mediaStatus > 0
+
+ TapHandler {
+ onDoubleTapped: {
+ root.fullScreen ? root.showNormal() : root.showFullScreen()
+ root.fullScreen = !root.fullScreen
+ }
+ }
+ }
+ //! [3]
+
+ Rectangle {
+ anchors.fill: parent
+ visible: mediaPlayer.mediaStatus === 0
+ color: "black"
+
+ TapHandler {
+ onDoubleTapped: {
+ root.fullScreen ? root.showNormal() : root.showFullScreen()
+ root.fullScreen = !root.fullScreen
+ }
+ }
+ }
+
+ //! [5]
+ PlaybackControl {
+ id: playbackController
+ //! [5]
+
+ property bool showControls: !activityListener.inactiveMouse || busy
+ opacity: showControls
+ // onOpacityChanged can't be used as it is animated and therefore not immediate
+ onShowControlsChanged: activityListener.cursorShape = showControls ?
+ Qt.ArrowCursor : Qt.BlankCursor
+
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ //! [6]
+ mediaPlayer: mediaPlayer
+ audioTracksInfo: audioTracksInfo
+ videoTracksInfo: videoTracksInfo
+ subtitleTracksInfo: subtitleTracksInfo
+ metadataInfo: metadataInfo
+ }
+ //! [6]
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/AudioControl.qml b/examples/multimedia/video/mediaplayer/controls/AudioControl.qml
new file mode 100644
index 000000000..81ebe7f10
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/AudioControl.qml
@@ -0,0 +1,50 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+Item {
+ id: audioController
+
+ property alias busy: slider.pressed
+ //! [0]
+ property alias muted: muteButton.checked
+ property real volume: slider.value
+ //! [0]
+ property alias showSlider: slider.visible
+ property int iconDimension: 24
+
+ implicitHeight: 46
+ implicitWidth: mainLayout.width
+
+ RowLayout {
+ id: mainLayout
+ spacing: 10
+ anchors.verticalCenter: parent.verticalCenter
+
+ RoundButton {
+ id: muteButton
+ implicitHeight: 40
+ implicitWidth: 40
+ radius: 4
+ icon.source: audioController.muted ? "../images/volume_mute.svg" : "../images/volume.svg"
+ icon.width: audioController.iconDimension
+ icon.height: audioController.iconDimension
+ flat: true
+ checkable: true
+ }
+
+ Slider {
+ id: slider
+ visible: !audioController.showSlider
+ implicitWidth: 136
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignVCenter
+
+ enabled: !audioController.muted
+ value: 1
+ }
+ }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml b/examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml
new file mode 100644
index 000000000..3e68faa8e
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/MetadataInfo.qml
@@ -0,0 +1,30 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Item {
+ property alias metadata: listModel
+ property alias count: listModel.count
+
+ function clear() {
+ listModel.clear()
+ }
+
+ //! [0]
+ function read(metadata) {
+ if (!metadata)
+ return
+ for (const key of metadata.keys())
+ if (metadata.stringValue(key))
+ listModel.append({
+ name: metadata.metaDataKeyToString(key),
+ value: metadata.stringValue(key)
+ })
+ }
+
+ ListModel {
+ id: listModel
+ }
+ //! [0]
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml b/examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml
new file mode 100644
index 000000000..056cf50d0
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/PlaybackControl.qml
@@ -0,0 +1,318 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtMultimedia
+import QtQuick.Dialogs
+
+//! [0]
+Item {
+ id: playbackController
+
+ required property MediaPlayer mediaPlayer
+ required property MetadataInfo metadataInfo
+ required property TracksInfo audioTracksInfo
+ required property TracksInfo videoTracksInfo
+ required property TracksInfo subtitleTracksInfo
+ //! [0]
+
+ property alias muted: audioControl.muted
+ property alias volume: audioControl.volume
+
+ property bool landscapePlaybackControls: root.width >= 668
+ property bool busy: fileDialog.visible
+ || urlPopup.visible
+ || settingsPopup.visible
+ || audioControl.busy
+ || playbackSeekControl.busy
+ || !playbackController.mediaPlayer.playing
+
+ implicitHeight: landscapePlaybackControls ? 168 : 208
+
+ Behavior on opacity { NumberAnimation { duration: 300 } }
+
+ FileDialog {
+ id: fileDialog
+ title: "Please choose a file"
+ onAccepted: {
+ playbackController.mediaPlayer.stop()
+ playbackController.mediaPlayer.source = fileDialog.currentFile
+ playbackController.mediaPlayer.play()
+ }
+ }
+
+ UrlPopup {
+ id: urlPopup
+ anchors.centerIn: Overlay.overlay
+ mediaPlayer: playbackController.mediaPlayer
+ }
+
+ SettingsPopup {
+ id: settingsPopup
+ anchors.centerIn: Overlay.overlay
+
+ metadataInfo: playbackController.metadataInfo
+ mediaPlayer: playbackController.mediaPlayer
+ audioTracksInfo: playbackController.audioTracksInfo
+ videoTracksInfo: playbackController.videoTracksInfo
+ subtitleTracksInfo: playbackController.subtitleTracksInfo
+ }
+
+ component CustomButton: RoundButton {
+ implicitWidth: 40
+ implicitHeight: 40
+ radius: 4
+ icon.width: 24
+ icon.height: 24
+ flat: true
+ }
+
+ component CustomRoundButton: RoundButton {
+ property int diameter: 40
+ Layout.preferredWidth: diameter
+ Layout.preferredHeight: diameter
+ radius: diameter / 2
+ icon.width: 24
+ icon.height: 24
+ }
+
+ //! [1]
+ CustomButton {
+ id: fileDialogButton
+ icon.source: "../images/open_new.svg"
+ flat: false
+ onClicked: fileDialog.open()
+ }
+
+ CustomButton {
+ id: openUrlButton
+ icon.source: "../images/link.svg"
+ flat: false
+ onClicked: urlPopup.open()
+ }
+ //! [1]
+
+ CustomButton {
+ id: loopButton
+ icon.source: "../images/loop.svg"
+ icon.color: playbackController.mediaPlayer.loops === MediaPlayer.Once ? palette.buttonText : palette.accent
+ onClicked: playbackController.mediaPlayer.loops = playbackController.mediaPlayer.loops === MediaPlayer.Once
+ ? MediaPlayer.Infinite
+ : MediaPlayer.Once
+ }
+
+ CustomButton {
+ id: settingsButton
+ icon.source: "../images/more.svg"
+ onClicked: settingsPopup.open()
+ }
+
+ CustomButton {
+ id: fullScreenButton
+ icon.source: root.fullScreen ? "../images/zoom_minimize.svg"
+ : "../images/zoom_maximize.svg"
+ onClicked: {
+ root.fullScreen ? root.showNormal() : root.showFullScreen()
+ root.fullScreen = !root.fullScreen
+ }
+ }
+
+ RowLayout {
+ id: controlButtons
+ spacing: 16
+
+ CustomRoundButton {
+ id: backward10Button
+ icon.source: "../images/backward10.svg"
+ onClicked: {
+ const pos = Math.max(0, playbackController.mediaPlayer.position - 10000)
+ playbackController.mediaPlayer.setPosition(pos)
+ }
+ }
+
+ //! [2]
+ CustomRoundButton {
+ id: playButton
+ visible: playbackController.mediaPlayer.playbackState !== MediaPlayer.PlayingState
+ icon.source: "../images/play_symbol.svg"
+ onClicked: playbackController.mediaPlayer.play()
+ }
+
+ CustomRoundButton {
+ id: pauseButton
+ visible: playbackController.mediaPlayer.playbackState === MediaPlayer.PlayingState
+ icon.source: "../images/pause_symbol.svg"
+ onClicked: playbackController.mediaPlayer.pause()
+ }
+ //! [2]
+
+ //! [3]
+ CustomRoundButton {
+ id: forward10Button
+ icon.source: "../images/forward10.svg"
+ onClicked: {
+ const pos = Math.min(playbackController.mediaPlayer.duration,
+ playbackController.mediaPlayer.position + 10000)
+ playbackController.mediaPlayer.setPosition(pos)
+ }
+ }
+ //! [3]
+ } // RowLayout controlButtons
+
+ AudioControl {
+ id: audioControl
+ showSlider: root.width >= 960
+ }
+
+ PlaybackSeekControl {
+ id: playbackSeekControl
+ Layout.fillWidth: true
+ mediaPlayer: playbackController.mediaPlayer
+ }
+
+ Frame {
+ id: landscapeLayout
+ anchors.fill: parent
+ padding: 32
+ topPadding: 28
+ visible: landscapePlaybackControls
+ background: Rectangle {
+ color: "#F6F6F6"
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ spacing: 16
+
+ Item {
+ Layout.fillWidth: true
+ implicitHeight: 40
+
+ LayoutItemProxy {
+ id: fdbProxy
+ target: fileDialogButton
+ anchors.left: parent.left
+ }
+
+ LayoutItemProxy {
+ target: openUrlButton
+ anchors.left: fdbProxy.right
+ anchors.leftMargin: 12
+ }
+
+ LayoutItemProxy {
+ target: controlButtons
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ LayoutItemProxy {
+ target: loopButton
+ anchors.right: acProxy.left
+ anchors.rightMargin: 12
+ }
+
+ LayoutItemProxy {
+ id: acProxy
+ target: audioControl
+ anchors.right: sbProxy.left
+ anchors.rightMargin: 30
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ LayoutItemProxy {
+ id: sbProxy
+ target: settingsButton
+ anchors.right: fbProxy.left
+ anchors.rightMargin: 12
+ }
+
+ LayoutItemProxy {
+ id: fbProxy
+ target: fullScreenButton
+ anchors.right: parent.right
+ }
+ } // Item
+
+ LayoutItemProxy {
+ target: playbackSeekControl
+ Layout.topMargin: 16
+ Layout.bottomMargin: 16
+ }
+ }
+ } // Frame frame
+
+ Frame {
+ id: portraitLayout
+ anchors.fill: parent
+ padding: 32
+ topPadding: 28
+ visible: !landscapePlaybackControls
+ background: Rectangle {
+ color: "#F6F6F6"
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+ spacing: 16
+
+ Item {
+ Layout.fillWidth: true
+ implicitHeight: 40
+
+ LayoutItemProxy {
+ target: loopButton
+ anchors.right: cbProxy.left
+ anchors.rightMargin: 16
+ }
+
+ LayoutItemProxy {
+ id: cbProxy
+ target: controlButtons
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ LayoutItemProxy {
+ target: audioControl
+ anchors.left: cbProxy.right
+ anchors.leftMargin: 16
+ }
+ }
+ Item {
+ Layout.fillWidth: true
+ implicitHeight: 40
+
+ LayoutItemProxy {
+ id: fdbProxy_
+ target: fileDialogButton
+ anchors.left: parent.left
+ }
+
+ LayoutItemProxy {
+ target: openUrlButton
+ anchors.left: fdbProxy_.right
+ anchors.leftMargin: 12
+ }
+
+ LayoutItemProxy {
+ target: settingsButton
+ anchors.right: fbProxy_.left
+ anchors.rightMargin: 12
+ }
+
+ LayoutItemProxy {
+ id: fbProxy_
+ target: fullScreenButton
+ anchors.right: parent.right
+ }
+ }
+
+ LayoutItemProxy {
+ target: playbackSeekControl
+ Layout.topMargin: 8
+ Layout.bottomMargin: 8
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml b/examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml
new file mode 100644
index 000000000..c94d844f8
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/PlaybackSeekControl.qml
@@ -0,0 +1,56 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtMultimedia
+
+Item {
+ id: seekController
+ required property MediaPlayer mediaPlayer
+ property alias busy: slider.pressed
+
+ implicitHeight: 20
+
+ function formatToMinutes(milliseconds) {
+ const min = Math.floor(milliseconds / 60000)
+ const sec = ((milliseconds - min * 60000) / 1000).toFixed(1)
+ return `${min}:${sec.padStart(4, 0)}`
+ }
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: 22
+
+ //! [0]
+ Text {
+ id: currentTime
+ Layout.preferredWidth: 45
+ text: seekController.formatToMinutes(seekController.mediaPlayer.position)
+ horizontalAlignment: Text.AlignLeft
+ font.pixelSize: 11
+ }
+ //! [0]
+
+ Slider {
+ id: slider
+ Layout.fillWidth: true
+ //! [2]
+ enabled: seekController.mediaPlayer.seekable
+ value: seekController.mediaPlayer.position / seekController.mediaPlayer.duration
+ //! [2]
+ onMoved: seekController.mediaPlayer.setPosition(value * seekController.mediaPlayer.duration)
+ }
+
+ //! [1]
+ Text {
+ id: remainingTime
+ Layout.preferredWidth: 45
+ text: seekController.formatToMinutes(seekController.mediaPlayer.duration - seekController.mediaPlayer.position)
+ horizontalAlignment: Text.AlignRight
+ font.pixelSize: 11
+ }
+ //! [1]
+ }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml b/examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml
new file mode 100644
index 000000000..0f24c8503
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/SettingsPopup.qml
@@ -0,0 +1,204 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtMultimedia
+
+Popup {
+ id: settingsController
+ focus: true
+ closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
+
+ background: Rectangle {
+ color: "#F6F6F6"
+ }
+
+
+ required property MetadataInfo metadataInfo
+ required property MediaPlayer mediaPlayer
+ required property TracksInfo audioTracksInfo
+ required property TracksInfo videoTracksInfo
+ required property TracksInfo subtitleTracksInfo
+
+ property int vPadding: 20
+ property int hPadding: 26
+ property bool landscapeSettingsPopup: root.width >= settingsLayout.width + metadataLayout.width + 2 * hPadding + 20 + 24
+
+ padding: {
+ top: vPadding
+ bottom: vPadding
+ left: hPadding
+ right: hPadding
+ }
+
+ Flickable {
+ id: flickable
+ implicitWidth: mainLayout.width
+ implicitHeight: landscapeSettingsPopup ? 200 : 340
+ contentWidth: mainLayout.width
+ contentHeight: mainLayout.height
+ flickableDirection: Flickable.VerticalFlick
+ clip: true
+
+ GridLayout {
+ id: mainLayout
+
+ columns: landscapeSettingsPopup ? 2 : 1
+ columnSpacing: 24
+ rowSpacing: 24
+
+ ColumnLayout {
+ id: settingsLayout
+ spacing: 16
+ Layout.alignment: Qt.AlignTop
+
+ Label {
+ id: settingsLabel
+ text: qsTr("Settings")
+ font.pixelSize: 16
+ font.bold: true
+ }
+
+ GridLayout {
+ id: gridLayout
+ columns: 2
+ rowSpacing: 16
+ columnSpacing: 16
+
+ component CustomComboBox: ComboBox {
+ required property TracksInfo tracksInfo
+
+ model: tracksInfo.model
+ enabled: model.count > 0
+ textRole: "data"
+ currentIndex: model.count > 0 ? 0 : -1
+
+ onActivated: {
+ //! [1]
+ settingsController.mediaPlayer.pause()
+ tracksInfo.selectedTrack = currentIndex
+ settingsController.mediaPlayer.play()
+ //! [1]
+ }
+ }
+
+ Label {
+ text: qsTr("Playback Speed")
+ Layout.fillWidth: true
+ font.pixelSize: 14
+ }
+
+ ComboBox {
+ id: rateCb
+ model: ["0.25", "0.5", "0.75", "Normal", "1.25", "1.5", "1.75", "2"]
+ currentIndex: 3
+
+ onCurrentIndexChanged: {
+ //! [0]
+ settingsController.mediaPlayer.playbackRate = (currentIndex + 1) * 0.25
+ //! [0]
+ }
+ }
+
+ Label {
+ text: qsTr("Audio Tracks")
+ enabled: audioCb.enabled
+ Layout.fillWidth: true
+ font.pixelSize: 14
+ }
+
+ CustomComboBox {
+ id: audioCb
+ tracksInfo: settingsController.audioTracksInfo
+
+ }
+
+ Label {
+ text: qsTr("Video Tracks")
+ enabled: videoCb.enabled
+ Layout.fillWidth: true
+ font.pixelSize: 14
+ }
+
+ CustomComboBox {
+ id: videoCb
+ tracksInfo: settingsController.videoTracksInfo
+ }
+
+ Label {
+ text: qsTr("Subtitle Tracks")
+ enabled: subtitlesCb.enabled
+ font.pixelSize: 14
+ }
+
+ CustomComboBox {
+ id: subtitlesCb
+ tracksInfo: settingsController.subtitleTracksInfo
+ }
+ }
+ }
+
+ ColumnLayout {
+ id: metadataLayout
+ spacing: 16
+ Layout.alignment: Qt.AlignTop
+
+ Label {
+ id: metadataLabel
+ text: qsTr("Metadata")
+ font.pixelSize: 16
+ font.bold: true
+ }
+
+ Rectangle {
+ id: metadataRect
+ implicitWidth: 240
+ implicitHeight: metadataList.height
+ border.color: "#8E8E93"
+ radius: 6
+
+ Column {
+ id: metadataList
+ visible: settingsController.metadataInfo.count > 0
+
+ padding: 10
+ Repeater {
+ Row {
+ spacing: metadataList.padding
+ Text {
+ text: model.name
+ font.bold: true
+ width: (metadataRect.width - 3 * metadataList.padding) / 2
+ horizontalAlignment: Text.AlignRight
+ wrapMode: Text.WordWrap
+ font.pixelSize: 12
+ }
+
+ Text {
+ text: model.value
+ width: (metadataRect.width - 3 * metadataList.padding) / 2
+ horizontalAlignment: Text.AlignLeft
+ anchors.verticalCenter: parent.verticalCenter
+ wrapMode: Text.WrapAnywhere
+ font.pixelSize: 12
+ }
+ }
+ model: settingsController.metadataInfo.metadata
+ }
+ }
+
+ Text {
+ id: metadataNoList
+ visible: settingsController.metadataInfo.count === 0
+ anchors.centerIn: parent
+ text: qsTr("No metadata present")
+ font.pixelSize: 14
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/TracksInfo.qml b/examples/multimedia/video/mediaplayer/controls/TracksInfo.qml
new file mode 100644
index 000000000..a2ae96f02
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/TracksInfo.qml
@@ -0,0 +1,25 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Item {
+ property alias model: model
+ property int selectedTrack: 0
+
+ function read(tracks, key = 0) {
+ // language is the 6th index in the enum QMediaMetaData::Key
+ model.clear()
+
+ if (!tracks)
+ return
+
+ tracks.forEach((metadata, index) => {
+ const data = metadata.stringValue(key)
+ const label = data ? data : qsTr("track ") + (index + 1)
+ model.append({data: label, index: index})
+ })
+ }
+
+ ListModel { id: model }
+}
diff --git a/examples/multimedia/video/mediaplayer/controls/UrlPopup.qml b/examples/multimedia/video/mediaplayer/controls/UrlPopup.qml
new file mode 100644
index 000000000..5bc304178
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/controls/UrlPopup.qml
@@ -0,0 +1,54 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtMultimedia
+
+
+Popup {
+ id: popupController
+ width: Math.min(500, root.width - 40)
+
+ required property MediaPlayer mediaPlayer
+
+ function loadUrl(url) {
+ popupController.mediaPlayer.stop()
+ popupController.mediaPlayer.source = url
+ popupController.mediaPlayer.play()
+ }
+
+ RowLayout {
+ id: rowOpenUrl
+ anchors.fill: parent
+ Label {
+ text: qsTr("URL:");
+ }
+
+ TextField {
+ id: urlText
+ Layout.fillWidth: true
+ focus: true
+
+ placeholderText: qsTr("Enter text here...")
+ wrapMode: TextInput.WrapAnywhere
+
+ Keys.onReturnPressed: {
+ popupController.loadUrl(text)
+ urlText.text = ""
+ popupController.close()
+ }
+ }
+
+ Button {
+ text: qsTr("Load")
+ enabled: urlText.text !== ""
+ onClicked: {
+ popupController.loadUrl(urlText.text)
+ urlText.text = ""
+ popupController.close()
+ }
+ }
+ }
+ onOpened: { popupController.forceActiveFocus() }
+}
diff --git a/examples/multimedia/video/mediaplayer/doc/images/mediaplayer.png b/examples/multimedia/video/mediaplayer/doc/images/mediaplayer.png
new file mode 100644
index 000000000..857e70abd
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/doc/images/mediaplayer.png
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/images/settings.png b/examples/multimedia/video/mediaplayer/doc/images/settings.png
new file mode 100644
index 000000000..5cf175795
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/doc/images/settings.png
Binary files differ
diff --git a/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc b/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc
new file mode 100644
index 000000000..1cc681f8f
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/doc/src/mediaplayer.qdoc
@@ -0,0 +1,151 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example video/mediaplayer
+ \title QML Media Player Example
+ \ingroup multimedia_examples
+ \ingroup video_examples_qml
+ \examplecategory {Graphics & Multimedia}
+ \brief Playing audio and video using the QML \c MediaPlayer type.
+ \meta {tag} {quick}
+ \meta {tag} {player}
+ \image mediaplayer.png
+
+ This example demonstrates a simple multimedia player that can play
+ audio and video files using various codecs.
+
+ \include examples-run.qdocinc
+
+ \section1 Instantiating the MediaPlayer
+ The entry point for the QML code in this example is \c Main.qml. Here
+ an \c ApplicationWindow is created and properties such as the \c id, \c title,
+ \c width and \c height are set.
+
+ \snippet video/mediaplayer/Main.qml 0
+
+ Next the \c MediaPlayer is created and the two properties that are responsible for the video and
+ audio output are defined.
+ Firstly, \c videoOutput which renders the video viewfinder and secondly \c audioOutput which provides
+ the audio output for the player.
+
+ \snippet video/mediaplayer/Main.qml 1
+ \dots
+ \snippet video/mediaplayer/Main.qml 2
+ \dots
+ \snippet video/mediaplayer/Main.qml 3
+
+ The \c visible property of the \c VideoOutput type is set to \c true when the \c mediaStatus
+ property of the \c MediaPlayer is greater than 0. \c mediaStatus is of enumeration type
+ and is equal to 0 when \e {No media has been set}, and greater than 0 otherwise. Therefore,
+ the \c VideoOutput is visible when media has been set.
+
+ The \c MediaPlayer type has a signal property called \c onErrorOccurred that can be
+ overridden specifically to handle errors. In this case the signal opens a \c MessageDialog using
+ the method \c {open()} and sets its \c text property to a \c MediaPlayer property called
+ \c errorString.
+
+ \snippet video/mediaplayer/Main.qml 4
+
+ \section1 Playback Controls
+
+ In order to have a useable media player, there needs to be an interface to control the playback.
+ This is created in its own component file, \c PlaybackControl.qml, and instantiated in
+ \c Main.qml.
+
+ \snippet video/mediaplayer/Main.qml 5
+ \dots
+ \snippet video/mediaplayer/Main.qml 6
+
+ When created, objects are forwarded to this type such as track information,
+ metadata information and the \c MediaPlayer object itself. In \c PlaybackControl.qml,
+ each one of these objects have a \c {required property}, meaning that these properties must
+ be set when the \c PlaybackControl object is created.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 0
+
+ These playback controls can be broken down into sections. In the top left of the panel lies
+ a collection of buttons used to open a file, either by selecting a file from a file explorer or
+ entering a URL. The file is loaded into the \c MediaPlayer by setting the \c source property.
+ Both buttons are instantiated using a \c CustomButton \c {custom component}.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 1
+
+ Three buttons are created and centered on this panel, handling play, pause and seeking ten
+ seconds backwards or forwards. The media is played and paused using the methods \c {play()}
+ and \c {pause()}, respectively. To know when to draw a play or pause button, the \c playbackState
+ property is queried. For example, when it is equal to the enum value \c MediaPlayer.PlayingState
+ then the pause button is drawn.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 2
+
+ To navigate ten seconds forward or backwards, the \c position of the \c MediaPlayer type is
+ incremented by 10,000 milliseconds and set using the method \c {setPosition()}.
+
+ \snippet video/mediaplayer/controls/PlaybackControl.qml 3
+
+ \section1 Playback Seeking and Audio
+
+ In \c {PlaybackControl.qml}, an \c AudioControl and a \c PlaybackSeekControl type are instantiated.
+ These are both defined in their own component file and are responsible for volume control and
+ playback seeking, respectively. The \c AudioControl type defines a button to mute and a \c Slider,
+ from \c {QtQuick Controls}, to set the volume of the player. Both of these attributes are exposed by
+ defining a \c mute and \c volume property and are accessed from the \c AudioOutput definition in
+ \c {Main.qml}.
+
+ \snippet video/mediaplayer/controls/AudioControl.qml 0
+
+ The \c PlaybackSeekControl uses a \c RowLayout containing a \c Slider with a \c Text item either side.
+ The two \c Text items display the current time and the remaining time of the media being played. These
+ are both calculated using two properties of the \c MediaPlayer type, \c {position}, which gives the
+ current playback position in milliseconds, and \c {duration}, which gives the duration of the media
+ in milliseconds.
+
+ \snippet video/mediaplayer/controls/PlaybackSeekControl.qml 0
+ \dots
+ \snippet video/mediaplayer/controls/PlaybackSeekControl.qml 1
+
+ The \c Slider is only enabled when the media player is seekable and not, for example, live media.
+ The \c MediaPlayer type has a property for this called \c seekable. The \c value of the \c Slider
+ is calculated using the \c position and \c duration properties of the \c MediaPlayer.
+
+ \snippet video/mediaplayer/controls/PlaybackSeekControl.qml 2
+
+ \section1 Metadata and Track Information
+
+ The \c PlaybackControl type instantiates a \c SettingsPopup, which contains information about the
+ metadata of the currently loaded media and track selection, as well as the ability to update the
+ playback rate. This \c Popup is defined in \c SettingsPopup.qml.
+
+ \image settings.png
+
+ The metadata is contained in its own component file, \c MetadataInfo.qml. It contains a \c ListModel,
+ a function to clear it, \c {clear()}, and a function to populate it, \c {read(MediaMetadata metadata)}.
+ The \c {read(MediaMetadata metadata)} function takes as a parameter an object of type \c MediaMetaData,
+ and navigates its key-value structure to extract its data into the \c model of the \c {ListView}. The
+ methods used to do this are \c {keys()}, which returns all the keys of the \c MediaMetaData, and
+ {stringValue(Key key)}, which returns the \c value for a given \c key.
+
+ \snippet video/mediaplayer/controls/MetadataInfo.qml 0
+
+ The data is then displayed in \c {SettingsPopup.qml} in a \c ListView type. The \c delegate of this
+ \c ListView is a row of two \c Text items, corresponding to the key-value pairs abstracted from the
+ \c MediaMetaData item.
+
+ On the other side of the \c Popup there is playback rate controls and track selection for audio, video and
+ subtitles. The playback rate is chosen from a \c ComboBox and set using the property \c playbackRate.
+
+ \snippet video/mediaplayer/controls/SettingsPopup.qml 0
+
+ The type called \c TracksInfo, defined in \c {TracksInfo.qml}, contains the data about the tracks.
+ More specifically, a \c ListModel containing the titles of the tracks, or for subtitles specifically, the
+ langauges. This information is populated in \c Main.qml by calling the \c {read(MediaMetadata mediaMetadata)}
+ function defined in the \c TracksInfo type.
+
+ \snippet video/mediaplayer/Main.qml 6
+
+ The \c model defined in \c TracksInfo is then queried in the \c {ComboBox}es in the
+ \c SettingsPopup to select the current track.
+
+ \snippet video/mediaplayer/controls/SettingsPopup.qml 1
+*/
diff --git a/examples/multimedia/video/mediaplayer/images/backward10.svg b/examples/multimedia/video/mediaplayer/images/backward10.svg
new file mode 100644
index 000000000..9166343bd
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/backward10.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M4 13.2001C4 14.7428 4.46919 16.2508 5.34824 17.5335C6.22729 18.8162 7.47672 19.816 8.93853 20.4063C10.4003 20.9967 12.0089 21.1511 13.5607 20.8502C15.1126 20.5492 16.538 19.8063 17.6569 18.7155C18.7757 17.6247 19.5376 16.2348 19.8463 14.7218C20.155 13.2088 19.9965 11.6404 19.391 10.2152C18.7855 8.78993 17.7602 7.57175 16.4446 6.71468C15.129 5.85761 13.5822 5.40015 12 5.40015" stroke="black" stroke-width="2" stroke-linecap="round"/>
+<path d="M12.6152 3L10.1537 5.39999L12.6152 7.79997" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M9.16406 16V11.4766H9.09375L7.71094 12.4375V11.375L9.16797 10.3633H10.3438V16H9.16406ZM14.0469 16.1445C13.5833 16.1445 13.1836 16.0247 12.8477 15.7852C12.5143 15.543 12.2578 15.2005 12.0781 14.7578C11.8984 14.3151 11.8086 13.7904 11.8086 13.1836V13.1758C11.8086 12.5664 11.8984 12.0417 12.0781 11.6016C12.2578 11.1589 12.5143 10.8177 12.8477 10.5781C13.1836 10.3385 13.5833 10.2188 14.0469 10.2188C14.513 10.2188 14.9128 10.3385 15.2461 10.5781C15.5794 10.8177 15.8359 11.1589 16.0156 11.6016C16.1953 12.0417 16.2852 12.5664 16.2852 13.1758V13.1836C16.2852 13.7904 16.1953 14.3151 16.0156 14.7578C15.8359 15.2005 15.5794 15.543 15.2461 15.7852C14.9128 16.0247 14.513 16.1445 14.0469 16.1445ZM14.0469 15.2109C14.2708 15.2109 14.4596 15.1302 14.6133 14.9688C14.7695 14.8073 14.888 14.5755 14.9688 14.2734C15.0521 13.9714 15.0938 13.6081 15.0938 13.1836V13.1758C15.0938 12.7487 15.0521 12.3854 14.9688 12.0859C14.888 11.7839 14.7695 11.5534 14.6133 11.3945C14.4596 11.2331 14.2708 11.1523 14.0469 11.1523C13.8255 11.1523 13.6367 11.2331 13.4805 11.3945C13.3268 11.5534 13.2083 11.7839 13.125 12.0859C13.0443 12.3854 13.0039 12.7487 13.0039 13.1758V13.1836C13.0039 13.6081 13.0443 13.9714 13.125 14.2734C13.2083 14.5755 13.3268 14.8073 13.4805 14.9688C13.6367 15.1302 13.8255 15.2109 14.0469 15.2109Z" fill="black"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/ff.svg b/examples/multimedia/video/mediaplayer/images/ff.svg
new file mode 100644
index 000000000..7c907c4fa
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/ff.svg
@@ -0,0 +1,4 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M5.19465 16.8817C5.5198 17.0557 5.91435 17.0366 6.2212 16.832L12.2212 12.832C12.4994 12.6466 12.6665 12.3344 12.6665 12C12.6665 11.6656 12.4994 11.3534 12.2212 11.1679L6.2212 7.16795C5.91435 6.96338 5.5198 6.9443 5.19465 7.11832C4.86949 7.29234 4.6665 7.6312 4.6665 8V16C4.6665 16.3688 4.86949 16.7077 5.19465 16.8817ZM6.6665 14.1315V9.86852L9.86373 12L6.6665 14.1315Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M13.1946 16.8817C13.5198 17.0557 13.9143 17.0366 14.2212 16.832L20.2212 12.832C20.4994 12.6466 20.6665 12.3344 20.6665 12C20.6665 11.6656 20.4994 11.3534 20.2212 11.1679L14.2212 7.16795C13.9143 6.96338 13.5198 6.9443 13.1946 7.11832C12.8695 7.29234 12.6665 7.6312 12.6665 8V16C12.6665 16.3688 12.8695 16.7077 13.1946 16.8817ZM14.6665 14.1315V9.86852L17.8637 12L14.6665 14.1315Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/forward10.svg b/examples/multimedia/video/mediaplayer/images/forward10.svg
new file mode 100644
index 000000000..190a5aaab
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/forward10.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M20 13.2001C20 14.7428 19.5308 16.2508 18.6518 17.5335C17.7727 18.8162 16.5233 19.816 15.0615 20.4063C13.5997 20.9967 11.9911 21.1511 10.4393 20.8502C8.88743 20.5492 7.46197 19.8063 6.34315 18.7155C5.22433 17.6247 4.4624 16.2348 4.15372 14.7218C3.84504 13.2088 4.00347 11.6404 4.60897 10.2152C5.21447 8.78993 6.23985 7.57175 7.55544 6.71468C8.87103 5.85761 10.4178 5.40015 12 5.40015" stroke="black" stroke-width="2" stroke-linecap="round"/>
+<path d="M11.3838 3L13.8453 5.39999L11.3838 7.79997" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M9.16406 16V11.4766H9.09375L7.71094 12.4375V11.375L9.16797 10.3633H10.3438V16H9.16406ZM14.0469 16.1445C13.5833 16.1445 13.1836 16.0247 12.8477 15.7852C12.5143 15.543 12.2578 15.2005 12.0781 14.7578C11.8984 14.3151 11.8086 13.7904 11.8086 13.1836V13.1758C11.8086 12.5664 11.8984 12.0417 12.0781 11.6016C12.2578 11.1589 12.5143 10.8177 12.8477 10.5781C13.1836 10.3385 13.5833 10.2188 14.0469 10.2188C14.513 10.2188 14.9128 10.3385 15.2461 10.5781C15.5794 10.8177 15.8359 11.1589 16.0156 11.6016C16.1953 12.0417 16.2852 12.5664 16.2852 13.1758V13.1836C16.2852 13.7904 16.1953 14.3151 16.0156 14.7578C15.8359 15.2005 15.5794 15.543 15.2461 15.7852C14.9128 16.0247 14.513 16.1445 14.0469 16.1445ZM14.0469 15.2109C14.2708 15.2109 14.4596 15.1302 14.6133 14.9688C14.7695 14.8073 14.888 14.5755 14.9688 14.2734C15.0521 13.9714 15.0938 13.6081 15.0938 13.1836V13.1758C15.0938 12.7487 15.0521 12.3854 14.9688 12.0859C14.888 11.7839 14.7695 11.5534 14.6133 11.3945C14.4596 11.2331 14.2708 11.1523 14.0469 11.1523C13.8255 11.1523 13.6367 11.2331 13.4805 11.3945C13.3268 11.5534 13.2083 11.7839 13.125 12.0859C13.0443 12.3854 13.0039 12.7487 13.0039 13.1758V13.1836C13.0039 13.6081 13.0443 13.9714 13.125 14.2734C13.2083 14.5755 13.3268 14.8073 13.4805 14.9688C13.6367 15.1302 13.8255 15.2109 14.0469 15.2109Z" fill="black"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/link.svg b/examples/multimedia/video/mediaplayer/images/link.svg
new file mode 100644
index 000000000..6ce1b983d
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/link.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M11 16C11 16.5523 10.5523 17 10 17H7C5.61667 17 4.4375 16.5125 3.4625 15.5375C2.4875 14.5625 2 13.3833 2 12C2 10.6167 2.4875 9.4375 3.4625 8.4625C4.4375 7.4875 5.61667 7 7 7H10C10.5523 7 11 7.44772 11 8C11 8.55228 10.5523 9 10 9H7C6.16667 9 5.45833 9.29167 4.875 9.875C4.29167 10.4583 4 11.1667 4 12C4 12.8333 4.29167 13.5417 4.875 14.125C5.45833 14.7083 6.16667 15 7 15H10C10.5523 15 11 15.4477 11 16ZM9 13C8.44772 13 8 12.5523 8 12C8 11.4477 8.44772 11 9 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H9ZM14 17C13.4477 17 13 16.5523 13 16C13 15.4477 13.4477 15 14 15H17C17.8333 15 18.5417 14.7083 19.125 14.125C19.7083 13.5417 20 12.8333 20 12C20 11.1667 19.7083 10.4583 19.125 9.875C18.5417 9.29167 17.8333 9 17 9H14C13.4477 9 13 8.55228 13 8C13 7.44772 13.4477 7 14 7H17C18.3833 7 19.5625 7.4875 20.5375 8.4625C21.5125 9.4375 22 10.6167 22 12C22 13.3833 21.5125 14.5625 20.5375 15.5375C19.5625 16.5125 18.3833 17 17 17H14Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/loop.svg b/examples/multimedia/video/mediaplayer/images/loop.svg
new file mode 100644
index 000000000..8161ca867
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/loop.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7 17.5C5 17.5 7 17.5 5 17.5C3 17.5 3 17.5 3 15.5C3 13.5 3 8 3 6C3 4 3 4 5 4C7 4 17 4 19 4C21 4 21 4 21 6C21 8 21 13.5 21 15.5C21 17.5 21 17.5 19 17.5C17 17.5 11 17.5 11 17.5M11 17.5L13 15M11 17.5L13 20" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/more.svg b/examples/multimedia/video/mediaplayer/images/more.svg
new file mode 100644
index 000000000..fa8bddec8
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/more.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12Z" fill="black"/>
+<path d="M22 12C22 13.1046 21.1046 14 20 14C18.8954 14 18 13.1046 18 12C18 10.8954 18.8954 10 20 10C21.1046 10 22 10.8954 22 12Z" fill="black"/>
+<path d="M6 12C6 13.1046 5.10457 14 4 14C2.89543 14 2 13.1046 2 12C2 10.8954 2.89543 10 4 10C5.10457 10 6 10.8954 6 12Z" fill="black"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/mute.svg b/examples/multimedia/video/mediaplayer/images/mute.svg
new file mode 100644
index 000000000..b66b6d311
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/mute.svg
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="500" height="500" viewBox="0 0 75 75"
+stroke="#111" stroke-width="5">
+<path d="m39,14-17,15H6V48H22l17,15z" fill="#111" stroke-linejoin="round"/>
+<path d="m49,26 20,24m0-24-20,24" fill="none" stroke-linecap="round"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/open_new.svg b/examples/multimedia/video/mediaplayer/images/open_new.svg
new file mode 100644
index 000000000..6c62237f1
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/open_new.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="File /open_new">
+<path id="Layer01" d="M2 5C2 3.34315 3.34315 2 5 2H11C11.5523 2 12 2.44772 12 3C12 3.55228 11.5523 4 11 4H5C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V13.125C20 12.5727 20.4477 12.125 21 12.125C21.5523 12.125 22 12.5727 22 13.125V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5Z" fill="#0D0D0D"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M15 4C14.4477 4 14 3.55228 14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L8.76961 16.6446C8.37908 17.0351 7.74592 17.0351 7.35539 16.6446C6.96487 16.2541 6.96487 15.6209 7.35539 15.2304L18.5858 4H15Z" fill="#0D0D0D"/>
+</g>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/pause_symbol.svg b/examples/multimedia/video/mediaplayer/images/pause_symbol.svg
new file mode 100644
index 000000000..bdf6a9047
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/pause_symbol.svg
@@ -0,0 +1,4 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8.3335 7C8.3335 6.44772 8.66928 6 9.0835 6H10.5835C10.9977 6 11.3335 6.44772 11.3335 7V17C11.3335 17.5523 10.9977 18 10.5835 18H9.0835C8.66928 18 8.3335 17.5523 8.3335 17V7Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M13.3335 7C13.3335 6.44772 13.6693 6 14.0835 6H15.5835C15.9977 6 16.3335 6.44772 16.3335 7V17C16.3335 17.5523 15.9977 18 15.5835 18H14.0835C13.6693 18 13.3335 17.5523 13.3335 17V7Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/play_symbol.svg b/examples/multimedia/video/mediaplayer/images/play_symbol.svg
new file mode 100644
index 000000000..edb567226
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/play_symbol.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M16.8182 12L6.89091 6.14985L6.89091 17.8501L16.8182 12ZM18.2 13.4143C19.2667 12.7857 19.2667 11.2143 18.2 10.5857L7.4 4.22123C6.33333 3.59264 5 4.37838 5 5.63555L5 18.3644C5 19.6216 6.33333 20.4074 7.4 19.7788L18.2 13.4143Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/rewind.svg b/examples/multimedia/video/mediaplayer/images/rewind.svg
new file mode 100644
index 000000000..e9b34122c
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/rewind.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.4719 16.8817C19.1467 17.0557 18.7522 17.0366 18.4453 16.832L12.4453 12.832C12.1671 12.6466 12 12.3344 12 12C12 11.6656 12.1671 11.3534 12.4453 11.1679L18.4453 7.16795C18.7522 6.96338 19.1467 6.9443 19.4719 7.11832C19.797 7.29234 20 7.6312 20 8V16C20 16.3688 19.797 16.7077 19.4719 16.8817ZM18 14.1315V9.86852L14.8028 12L18 14.1315Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11.4719 16.8817C11.1467 17.0557 10.7522 17.0366 10.4453 16.832L4.4453 12.832C4.1671 12.6466 4 12.3344 4 12C4 11.6656 4.1671 11.3534 4.4453 11.1679L10.4453 7.16795C10.7522 6.96338 11.1467 6.9443 11.4719 7.11832C11.797 7.29234 12 7.6312 12 8V16C12 16.3688 11.797 16.7077 11.4719 16.8817ZM10 14.1315V9.86852L6.80278 12L10 14.1315Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/settings.svg b/examples/multimedia/video/mediaplayer/images/settings.svg
new file mode 100644
index 000000000..3a13ccae1
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/settings.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8.84998 4C8.84998 2.89543 9.74541 2 10.85 2H13.1222C14.2268 2 15.1222 2.89543 15.1222 4V4.59509C15.1229 4.59732 15.125 4.6023 15.1306 4.61031C15.1434 4.62838 15.1691 4.65242 15.2077 4.66935C15.852 4.95163 16.4515 5.31609 16.9931 5.74921C17.0261 5.77554 17.0594 5.787 17.0815 5.78982C17.0912 5.79106 17.0966 5.79055 17.0989 5.79008L17.9363 5.33741C18.8691 4.8332 20.0332 5.14455 20.5897 6.04706L21.6744 7.80604C22.2777 8.78435 21.9342 10.0686 20.9231 10.6152L19.9875 11.1209C19.9859 11.1226 19.9824 11.1269 19.9781 11.1358C19.9683 11.156 19.9595 11.1904 19.9636 11.2327C19.9877 11.4855 20 11.7414 20 12C20 12.2586 19.9877 12.5145 19.9636 12.7673C19.9595 12.8096 19.9683 12.844 19.9781 12.8642C19.9824 12.8732 19.9859 12.8774 19.9875 12.8791L20.923 13.3848C21.9341 13.9314 22.2776 15.2157 21.6743 16.194L20.5897 17.9529C20.0331 18.8554 18.869 19.1668 17.9362 18.6626L17.0989 18.2099C17.0966 18.2095 17.0912 18.209 17.0815 18.2102C17.0594 18.213 17.026 18.2245 16.9931 18.2508C16.4515 18.6839 15.852 19.0484 15.2077 19.3306C15.1691 19.3476 15.1434 19.3716 15.1306 19.3897C15.125 19.3977 15.1229 19.4027 15.1222 19.4049V20C15.1222 21.1046 14.2268 22 13.1222 22H10.85C9.74541 22 8.84998 21.1046 8.84998 20V19.3928C8.84931 19.3906 8.84725 19.3857 8.84163 19.3777C8.82894 19.3597 8.80351 19.3357 8.76508 19.3187C8.12675 19.0362 7.53272 18.6729 6.99586 18.242C6.96292 18.2156 6.92951 18.2041 6.90737 18.2012C6.89759 18.2 6.8922 18.2005 6.8899 18.201L6.03592 18.6626C5.10317 19.1668 3.93904 18.8554 3.38251 17.9529L2.29784 16.194C1.69457 15.2156 2.03805 13.9314 3.04914 13.3848L4.01099 12.8649C4.01265 12.8632 4.01607 12.859 4.02042 12.85C4.03023 12.8299 4.03897 12.7956 4.03503 12.7534C4.0118 12.5051 3.99995 12.2538 3.99995 12C3.99995 11.7462 4.0118 11.4949 4.03503 11.2466C4.03897 11.2045 4.03022 11.1701 4.02042 11.15C4.01607 11.1411 4.01265 11.1368 4.01098 11.1352L3.04909 10.6152C2.038 10.0686 1.69452 8.78435 2.29779 7.80604L3.38245 6.04707C3.93898 5.14456 5.10312 4.83322 6.03587 5.33742L6.88988 5.79907C6.89218 5.79953 6.89757 5.80005 6.90735 5.79879C6.92949 5.79594 6.9629 5.78441 6.99584 5.75797C7.53271 5.32709 8.12674 4.96379 8.76508 4.68128C8.80351 4.66427 8.82894 4.64029 8.84163 4.62231C8.84725 4.61434 8.84931 4.60938 8.84998 4.60716V4ZM8.85024 4.60578C8.85029 4.60578 8.85026 4.60619 8.85001 4.60703L8.85024 4.60578ZM6.88852 5.79864C6.88854 5.7986 6.88898 5.79869 6.88977 5.79904L6.88852 5.79864ZM4.00988 11.1343C4.00991 11.1342 4.01026 11.1344 4.0109 11.1351L4.00988 11.1343ZM4.00989 12.8658C4.00988 12.8657 4.01021 12.8654 4.01091 12.865L4.00989 12.8658ZM6.88854 18.2014C6.88851 18.2013 6.8889 18.2012 6.88979 18.201L6.88854 18.2014ZM19.9886 12.88C19.9885 12.88 19.9881 12.8797 19.9876 12.8792L19.9886 12.88ZM19.9886 11.12C19.9887 11.12 19.9883 11.1204 19.9876 11.1208L19.9886 11.12ZM17.1003 5.78965C17.1003 5.78968 17.0999 5.78986 17.099 5.79006L17.1003 5.78965ZM15.122 4.5937C15.122 4.59371 15.1221 4.59414 15.1222 4.59496L15.122 4.5937ZM13.1222 4L10.85 4V4.60808C10.85 5.49562 10.2774 6.19908 9.57449 6.51017C9.09654 6.7217 8.65096 6.99408 8.24769 7.31774C7.63839 7.80676 6.73261 7.98755 5.93958 7.55888L5.08481 7.09682L4.00015 8.8558L4.9628 9.37617C5.7538 9.80375 6.09888 10.6574 6.02633 11.4329C6.00889 11.6193 5.99995 11.8085 5.99995 12C5.99995 12.1915 6.00889 12.3807 6.02633 12.5671C6.09889 13.3426 5.75381 14.1963 4.9628 14.6239L4.0002 15.1442L5.08486 16.9032L5.9396 16.4411C6.73263 16.0125 7.63841 16.1933 8.2477 16.6823C8.65097 17.0059 9.09654 17.2783 9.57449 17.4898C10.2774 17.8009 10.85 18.5044 10.85 19.3919V20H13.1222V19.404C13.1222 18.5133 13.6987 17.8083 14.4051 17.4988C14.8875 17.2874 15.3372 17.0142 15.744 16.6889C16.3532 16.2017 17.2575 16.0222 18.0492 16.4501L18.8873 16.9032L19.972 15.1442L19.0357 14.6381C18.2434 14.2098 17.8986 13.3541 17.9726 12.5776C17.9907 12.3878 18 12.1951 18 12C18 11.8049 17.9907 11.6123 17.9726 11.4224C17.8986 10.6459 18.2434 9.79023 19.0357 9.36192L19.972 8.85579L18.8874 7.09681L18.0492 7.54989C17.2575 7.97786 16.3532 7.79836 15.744 7.31116C15.3372 6.98582 14.8875 6.71259 14.4051 6.50124C13.6987 6.19173 13.1222 5.48675 13.1222 4.596L13.1222 4Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14ZM12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/speaker.svg b/examples/multimedia/video/mediaplayer/images/speaker.svg
new file mode 100644
index 000000000..723e48b66
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/speaker.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="500" height="500" viewBox="0 0 75 75">
+<path d="M39.389,13.769 L22.235,28.606 L6,28.606 L6,47.699 L21.989,47.699 L39.389,62.75 L39.389,13.769z"
+style="stroke:#111;stroke-width:5;stroke-linejoin:round;fill:#111;"
+/>
+<path d="M48,27.6a19.5,19.5 0 0 1 0,21.4M55.1,20.5a30,30 0 0 1 0,35.6M61.6,14a38.8,38.8 0 0 1 0,48.6" style="fill:none;stroke:#111;stroke-width:5;stroke-linecap:round"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/stop_symbol.svg b/examples/multimedia/video/mediaplayer/images/stop_symbol.svg
new file mode 100644
index 000000000..99f00162f
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/stop_symbol.svg
@@ -0,0 +1,3 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M17.6665 7H7.6665L7.6665 17H17.6665V7ZM7.6665 5C6.56193 5 5.6665 5.89543 5.6665 7V17C5.6665 18.1046 6.56193 19 7.6665 19H17.6665C18.7711 19 19.6665 18.1046 19.6665 17V7C19.6665 5.89543 18.7711 5 17.6665 5H7.6665Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/url.svg b/examples/multimedia/video/mediaplayer/images/url.svg
new file mode 100644
index 000000000..44942911f
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/url.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7 10C7 10.5523 6.55228 11 6 11C5.44772 11 5 10.5523 5 10C5 9.44772 5.44772 9 6 9C6.55228 9 7 9.44772 7 10Z" fill="black"/>
+<path d="M7 14C7 14.5523 6.55228 15 6 15C5.44772 15 5 14.5523 5 14C5 13.4477 5.44772 13 6 13C6.55228 13 7 13.4477 7 14Z" fill="black"/>
+<path d="M13 6L9 18" stroke="black" stroke-width="2" stroke-linecap="round"/>
+<path d="M18 6L14 18" stroke="black" stroke-width="2" stroke-linecap="round"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/volume.svg b/examples/multimedia/video/mediaplayer/images/volume.svg
new file mode 100644
index 000000000..2cdc4df6b
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/volume.svg
@@ -0,0 +1,4 @@
+<svg width="25" height="24" viewBox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.98759 5.1163C11.1732 3.91192 13.2226 4.75139 13.2226 6.44139V17.5587C13.2226 19.2487 11.1732 20.0882 9.98759 18.8838L6.74406 15.5888C6.72318 15.5675 6.69465 15.5556 6.66488 15.5556H4.33371C3.29051 15.5556 2.44482 14.7099 2.44482 13.6667L2.44482 10.3334C2.44482 9.29016 3.29051 8.44448 4.33371 8.44448H6.66488C6.69465 8.44448 6.72318 8.43253 6.74406 8.41131L9.98759 5.1163ZM11.3101 6.32964C11.2992 6.3316 11.2809 6.33666 11.2545 6.36344L8.011 9.65845C7.65595 10.0191 7.171 10.2223 6.66488 10.2223H4.33371C4.27235 10.2223 4.2226 10.272 4.2226 10.3334L4.2226 13.6667C4.2226 13.7281 4.27235 13.7778 4.33371 13.7778H6.66488C7.171 13.7778 7.65595 13.9809 8.011 14.3416L11.2545 17.6366C11.2809 17.6634 11.2992 17.6685 11.3101 17.6704C11.326 17.6733 11.3496 17.6723 11.3758 17.6615C11.4021 17.6507 11.4196 17.6349 11.4289 17.6218C11.4353 17.6127 11.4448 17.5963 11.4448 17.5587V6.44139C11.4448 6.40381 11.4353 6.38737 11.4289 6.37829C11.4196 6.36513 11.4021 6.34932 11.3758 6.33857C11.3496 6.32781 11.326 6.3268 11.3101 6.32964Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.0329 4.37143C18.6857 4.0243 18.1229 4.0243 17.7758 4.37143C17.4287 4.71857 17.4287 5.28138 17.7758 5.62851C21.3339 9.18662 21.3339 14.9555 17.7758 18.5136C17.4287 18.8607 17.4287 19.4235 17.7758 19.7706C18.1229 20.1178 18.6857 20.1178 19.0329 19.7706C23.2852 15.5183 23.2852 8.62381 19.0329 4.37143ZM16.2044 7.37146C15.8573 7.02433 15.2945 7.02433 14.9474 7.37146C14.6002 7.71859 14.6002 8.28141 14.9474 8.62854C16.9434 10.6246 16.9434 13.8607 14.9474 15.8567C14.6002 16.2039 14.6002 16.7667 14.9474 17.1138C15.2945 17.461 15.8573 17.461 16.2044 17.1138C18.8947 14.4235 18.8947 10.0617 16.2044 7.37146Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/volume_mute.svg b/examples/multimedia/video/mediaplayer/images/volume_mute.svg
new file mode 100644
index 000000000..635c308e9
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/volume_mute.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M9.6541 5.1163C10.8397 3.91192 12.8891 4.75139 12.8891 6.44139V17.5587C12.8891 19.2487 10.8397 20.0882 9.6541 18.8838L6.41057 15.5888C6.38968 15.5675 6.36116 15.5556 6.33138 15.5556H4.00022C2.95701 15.5556 2.11133 14.7099 2.11133 13.6667L2.11133 10.3334C2.11133 9.29016 2.95701 8.44448 4.00022 8.44448H6.33138C6.36116 8.44448 6.38968 8.43253 6.41057 8.41131L9.6541 5.1163ZM10.9766 6.32964C10.9657 6.3316 10.9474 6.33666 10.921 6.36344L7.67751 9.65845C7.32245 10.0191 6.8375 10.2223 6.33138 10.2223H4.00022C3.93885 10.2223 3.88911 10.272 3.88911 10.3334L3.88911 13.6667C3.88911 13.7281 3.93885 13.7778 4.00022 13.7778H6.33138C6.8375 13.7778 7.32245 13.9809 7.67751 14.3416L10.921 17.6366C10.9474 17.6634 10.9657 17.6685 10.9766 17.6704C10.9925 17.6733 11.0161 17.6723 11.0423 17.6615C11.0686 17.6507 11.0861 17.6349 11.0954 17.6218C11.1018 17.6127 11.1113 17.5963 11.1113 17.5587V6.44139C11.1113 6.40381 11.1018 6.38737 11.0954 6.37829C11.0861 6.36513 11.0686 6.34932 11.0423 6.33857C11.0161 6.32781 10.9925 6.3268 10.9766 6.32964Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M15.7071 15.7071C15.3166 16.0976 14.6834 16.0976 14.2929 15.7071C13.9024 15.3166 13.9024 14.6834 14.2929 14.2929L16.5858 12L14.2929 9.70711C13.9024 9.31658 13.9024 8.68342 14.2929 8.29289C14.6834 7.90237 15.3166 7.90237 15.7071 8.29289L18 10.5858L20.2929 8.29289C20.6834 7.90237 21.3166 7.90237 21.7071 8.29289C22.0976 8.68342 22.0976 9.31658 21.7071 9.70711L19.4142 12L21.7071 14.2929C22.0976 14.6834 22.0976 15.3166 21.7071 15.7071C21.3166 16.0976 20.6834 16.0976 20.2929 15.7071L18 13.4142L15.7071 15.7071Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/zoom_maximize.svg b/examples/multimedia/video/mediaplayer/images/zoom_maximize.svg
new file mode 100644
index 000000000..9c7fb8ebb
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/zoom_maximize.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.071 3.92892C19.6233 3.92892 20.071 4.37664 20.071 4.92892V9.17157C20.071 9.72385 19.6233 10.1716 19.071 10.1716C18.5188 10.1716 18.071 9.72385 18.071 9.17157V7.34314L16.1716 9.24263C15.781 9.63315 15.1479 9.63315 14.7573 9.24263C14.3668 8.8521 14.3668 8.21894 14.7573 7.82841L16.6568 5.92892L14.8284 5.92892C14.2761 5.92892 13.8284 5.48121 13.8284 4.92892C13.8284 4.37664 14.2761 3.92892 14.8284 3.92892H19.071ZM4.92892 13.8284C5.48121 13.8284 5.92892 14.2761 5.92892 14.8284V16.6569L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L7.34314 18.0711L9.17157 18.0711C9.72385 18.0711 10.1716 18.5188 10.1716 19.0711C10.1716 19.6234 9.72385 20.0711 9.17157 20.0711H4.92892C4.37664 20.0711 3.92892 19.6234 3.92892 19.0711V14.8284C3.92892 14.2761 4.37664 13.8284 4.92892 13.8284Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1716 4.92892C10.1716 5.48121 9.72388 5.92892 9.1716 5.92892L7.34316 5.92892L9.24265 7.82841C9.63318 8.21894 9.63318 8.8521 9.24265 9.24263C8.85213 9.63315 8.21896 9.63315 7.82844 9.24263L5.92896 7.34314V9.17157C5.92896 9.72385 5.48124 10.1716 4.92896 10.1716C4.37667 10.1716 3.92896 9.72385 3.92896 9.17157V4.92892C3.92896 4.37664 4.37667 3.92892 4.92896 3.92892H9.1716C9.72388 3.92892 10.1716 4.37664 10.1716 4.92892ZM19.0711 13.8284C19.6234 13.8284 20.0711 14.2761 20.0711 14.8284V19.0711C20.0711 19.6234 19.6234 20.0711 19.0711 20.0711H14.8284C14.2761 20.0711 13.8284 19.6234 13.8284 19.0711C13.8284 18.5188 14.2761 18.0711 14.8284 18.0711H16.6569L14.2929 15.7071C13.9024 15.3166 13.9024 14.6834 14.2929 14.2929C14.6834 13.9024 15.3166 13.9024 15.7071 14.2929L18.0711 16.6569V14.8284C18.0711 14.2761 18.5188 13.8284 19.0711 13.8284Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/images/zoom_minimize.svg b/examples/multimedia/video/mediaplayer/images/zoom_minimize.svg
new file mode 100644
index 000000000..3d6ae65aa
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/images/zoom_minimize.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M15.1213 10C14.502 10 14 9.49797 14 8.87868L14 4.12132C14 3.50203 14.502 3 15.1213 3C15.7406 3 16.2426 3.50203 16.2426 4.12132V6.17158L18.3726 4.04163C18.8105 3.60372 19.5205 3.60372 19.9584 4.04163C20.3963 4.47953 20.3963 5.18951 19.9584 5.62741L17.8284 7.75736L19.8787 7.75736C20.498 7.75736 21 8.25939 21 8.87868C21 9.49797 20.498 10 19.8787 10L15.1213 10ZM8.87868 21C8.25939 21 7.75736 20.498 7.75736 19.8787V17.8284L5.10659 20.4792C4.66869 20.9171 3.95871 20.9171 3.52081 20.4792C3.0829 20.0413 3.0829 19.3313 3.52081 18.8934L6.17157 16.2426H4.12132C3.50203 16.2426 3 15.7406 3 15.1213C3 14.502 3.50203 14 4.12132 14L8.87868 14C9.49797 14 10 14.502 10 15.1213L10 19.8787C10 20.498 9.49797 21 8.87868 21Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M3.00002 8.87867C3.00002 8.25939 3.50205 7.75735 4.12134 7.75735H6.1716L4.04166 5.62741C3.60375 5.1895 3.60375 4.47952 4.04166 4.04162C4.47956 3.60372 5.18954 3.60372 5.62744 4.04162L7.75737 6.17155V4.12131C7.75737 3.50203 8.25941 2.99999 8.87869 2.99999C9.49798 2.99999 10 3.50203 10 4.12131L10 8.87867C10 9.49796 9.49798 9.99999 8.87869 9.99999L4.12134 9.99999C3.50205 9.99999 3.00002 9.49796 3.00002 8.87867ZM15.1213 21C14.502 21 14 20.498 14 19.8787V15.1213C14 14.502 14.502 14 15.1213 14L19.8787 14C20.498 14 21 14.502 21 15.1213C21 15.7406 20.498 16.2426 19.8787 16.2426H17.8284L20.4792 18.8934C20.9171 19.3313 20.9171 20.0413 20.4792 20.4792C20.0413 20.9171 19.3313 20.9171 18.8934 20.4792L16.2426 17.8284V19.8787C16.2426 20.498 15.7406 21 15.1213 21Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/multimedia/video/mediaplayer/main.cpp b/examples/multimedia/video/mediaplayer/main.cpp
new file mode 100644
index 000000000..3df4d6027
--- /dev/null
+++ b/examples/multimedia/video/mediaplayer/main.cpp
@@ -0,0 +1,38 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QCommandLineParser>
+#include <QDir>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("MediaPlayer Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt Quick MediaPlayer Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL(s) to open.");
+ parser.process(app);
+
+ QQmlApplicationEngine engine;
+ const QUrl url(QStringLiteral("qrc:/Main.qml"));
+
+ if (!parser.positionalArguments().isEmpty()) {
+ QUrl source = QUrl::fromUserInput(parser.positionalArguments().at(0), QDir::currentPath());
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
+ &engine, [source](QObject *object, const QUrl &) {
+ qDebug() << "setting source";
+ object->setProperty("source", source);
+ });
+ }
+
+ engine.loadFromModule("mediaplayer", "Main");
+
+ return app.exec();
+}
diff --git a/examples/multimedia/video/qmlvideo/CMakeLists.txt b/examples/multimedia/video/qmlvideo/CMakeLists.txt
new file mode 100644
index 000000000..43975d584
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/CMakeLists.txt
@@ -0,0 +1,58 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(qmlvideoexample LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia Qml Quick)
+
+qt_standard_project_setup(REQUIRES 6.5)
+
+qt_add_executable(qmlvideoexample
+ frequencymonitor.cpp frequencymonitor.h
+ frequencymonitordeclarative.cpp
+ performancemonitor.cpp performancemonitor.h
+ performancemonitordeclarative.cpp performancemonitordeclarative.h
+ main.cpp
+ trace.h
+)
+
+set_target_properties(qmlvideoexample PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+)
+
+target_compile_definitions(qmlvideoexample PUBLIC
+ FREQUENCYMONITOR_SUPPORT
+ PERFORMANCEMONITOR_SUPPORT
+)
+
+add_subdirectory(qmlvideo)
+add_subdirectory(performancemonitor)
+add_subdirectory(frequencymonitor)
+
+target_link_libraries(qmlvideoexample PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::Qml
+ Qt::Quick
+ qmlvideo
+ performancemonitor
+ frequencymonitor
+)
+
+install(TARGETS qmlvideoexample
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/qmlvideo/Info.plist.in b/examples/multimedia/video/qmlvideo/Info.plist.in
new file mode 100644
index 000000000..85aa9c26e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/Info.plist.in
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+
+ <key>NSCameraUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/video/doc/images/qmlvideo-menu.jpg b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-menu.jpg
index 54ab877a1..54ab877a1 100644
--- a/examples/multimedia/video/doc/images/qmlvideo-menu.jpg
+++ b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-menu.jpg
Binary files differ
diff --git a/examples/multimedia/video/doc/images/qmlvideo-overlay.jpg b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-overlay.jpg
index 6a0d48ae6..6a0d48ae6 100644
--- a/examples/multimedia/video/doc/images/qmlvideo-overlay.jpg
+++ b/examples/multimedia/video/qmlvideo/doc/images/qmlvideo-overlay.jpg
Binary files differ
diff --git a/examples/multimedia/video/doc/src/qmlvideo.qdoc b/examples/multimedia/video/qmlvideo/doc/src/qmlvideo.qdoc
index b8ab25d03..81f7cf05c 100644
--- a/examples/multimedia/video/doc/src/qmlvideo.qdoc
+++ b/examples/multimedia/video/qmlvideo/doc/src/qmlvideo.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
-\example multimedia/video/qmlvideo
+\example video/qmlvideo
\title QML Video Example
\ingroup multimedia_examples
+\examplecategory {Multimedia}
\brief Transforming video and camera viewfinder content.
\e{QML Video} demonstrates the various transformations (move; resize; rotate;
@@ -50,11 +27,11 @@ which moves across the \l{VideoOutput} item.
\section1 Application Structure
-The \c main.qml file creates a UI which includes the following items:
+The \c Main.qml file creates a UI which includes the following items:
\list
\li Two \c Button instances, each of which displays a filename, and can be
- used to launch a \c FileBrowser.
+ used to launch a \c FileDialog.
\li An exit \c Button.
\li A \c SceneSelectionPanel, which is a flickable list displaying the
available scenes.
@@ -71,13 +48,13 @@ in the center of the screen) is implemented in the \c VideoBasic.qml file. As
you can see from the code, this makes use of a type of inheritance; a
\c VideoBasic item ...
-\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
-\skipto import
+\quotefromfile video/qmlvideo/qmlvideo/VideoBasic.qml
+\skipto SceneBasic
\printuntil /^\}/
... is of type \c SceneBasic ...
-\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
+\quotefromfile video/qmlvideo/qmlvideo/SceneBasic.qml
\skipto import
\printuntil contentType
\dots
@@ -89,7 +66,7 @@ you can see from the code, this makes use of a type of inheritance; a
... which itself is a \c Scene:
-\quotefromfile multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
+\quotefromfile video/qmlvideo/qmlvideo/Scene.qml
\skipto import
\printuntil root
\dots
@@ -122,8 +99,11 @@ All that remains is to connect the afterRendering() signal of the QQuickView
object to a JavaScript function, which will eventually call
\c frequencyItem.notify():
-\quotefromfile multimedia/video/qmlvideo/main.cpp
-\skipto QGuiApplication
+\quotefromfile video/qmlvideo/main.cpp
+\skipto int main(
+\printuntil ;
+\dots
+\skipto QQuickView
\printuntil ;
\dots
\skipto QQuickItem
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp b/examples/multimedia/video/qmlvideo/frequencymonitor.cpp
index d611497fe..d6f1953f6 100644
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.cpp
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "frequencymonitor.h"
+
#include <QDebug>
#include <QElapsedTimer>
#include <QString>
@@ -57,11 +11,20 @@
//#define VERBOSE_TRACE
-inline QDebug qtTrace() { return qDebug() << "[frequencymonitor]"; }
+inline QDebug qtTrace()
+{
+ return qDebug() << "[frequencymonitor]";
+}
#ifdef VERBOSE_TRACE
-inline QDebug qtVerboseTrace() { return qtTrace(); }
+inline QDebug qtVerboseTrace()
+{
+ return qtTrace();
+}
#else
-inline QNoDebug qtVerboseTrace() { return QNoDebug(); }
+inline QNoDebug qtVerboseTrace()
+{
+ return QNoDebug();
+}
#endif
static const int DefaultSamplingInterval = 100;
@@ -94,29 +57,27 @@ public:
};
FrequencyMonitorPrivate::FrequencyMonitorPrivate(FrequencyMonitor *parent)
-: QObject(parent)
-, q_ptr(parent)
-, m_active(false)
-, m_instantaneousFrequency(0)
-, m_averageTimer(new QTimer(this))
-, m_count(0)
-, m_averageFrequency(0)
-, m_traceTimer(new QTimer(this))
-, m_stalledTimer(new QTimer(this))
+ : QObject(parent),
+ q_ptr(parent),
+ m_active(false),
+ m_instantaneousFrequency(0),
+ m_averageTimer(new QTimer(this)),
+ m_count(0),
+ m_averageFrequency(0),
+ m_traceTimer(new QTimer(this)),
+ m_stalledTimer(new QTimer(this))
{
m_instantaneousElapsed.start();
- connect(m_averageTimer, &QTimer::timeout,
- this, &FrequencyMonitorPrivate::calculateAverageFrequency);
+ connect(m_averageTimer, &QTimer::timeout, this,
+ &FrequencyMonitorPrivate::calculateAverageFrequency);
if (DefaultSamplingInterval)
m_averageTimer->start(DefaultSamplingInterval);
m_averageElapsed.start();
- connect(m_traceTimer, &QTimer::timeout,
- q_ptr, &FrequencyMonitor::trace);
+ connect(m_traceTimer, &QTimer::timeout, q_ptr, &FrequencyMonitor::trace);
if (DefaultTraceInterval)
m_traceTimer->start(DefaultTraceInterval);
m_stalledTimer->setSingleShot(true);
- connect(m_stalledTimer, &QTimer::timeout,
- this, &FrequencyMonitorPrivate::stalled);
+ connect(m_stalledTimer, &QTimer::timeout, this, &FrequencyMonitorPrivate::stalled);
}
void FrequencyMonitorPrivate::calculateInstantaneousFrequency()
@@ -148,16 +109,12 @@ void FrequencyMonitorPrivate::stalled()
}
}
-FrequencyMonitor::FrequencyMonitor(QObject *parent)
-: QObject(parent)
+FrequencyMonitor::FrequencyMonitor(QObject *parent) : QObject(parent)
{
d_ptr = new FrequencyMonitorPrivate(this);
}
-FrequencyMonitor::~FrequencyMonitor()
-{
-
-}
+FrequencyMonitor::~FrequencyMonitor() = default;
QString FrequencyMonitor::label() const
{
@@ -199,13 +156,14 @@ void FrequencyMonitor::notify()
void FrequencyMonitor::trace()
{
Q_D(FrequencyMonitor);
- const QString value = QString::fromLatin1("instant %1 average %2")
- .arg(d->m_instantaneousFrequency, 0, 'f', 2)
- .arg(d->m_averageFrequency, 0, 'f', 2);
+ const QString value = QStringLiteral("instant %1 average %2")
+ .arg(d->m_instantaneousFrequency, 0, 'f', 2)
+ .arg(d->m_averageFrequency, 0, 'f', 2);
if (d->m_label.isEmpty())
qtTrace() << "FrequencyMonitor::trace" << value;
else
- qtTrace() << "FrequencyMonitor::trace" << "label" << d->m_label << value;
+ qtTrace() << "FrequencyMonitor::trace"
+ << "label" << d->m_label << value;
}
void FrequencyMonitor::setLabel(const QString &value)
@@ -255,3 +213,4 @@ void FrequencyMonitor::setTraceInterval(int value)
}
#include "frequencymonitor.moc"
+#include "moc_frequencymonitor.cpp"
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor.h b/examples/multimedia/video/qmlvideo/frequencymonitor.h
new file mode 100644
index 000000000..a1756dc88
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor.h
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef FREQUENCYMONITOR_H
+#define FREQUENCYMONITOR_H
+
+#include <QObject>
+#include <QTimer>
+
+class FrequencyMonitorPrivate;
+
+/**
+ * Class for measuring frequency of events
+ *
+ * Occurrence of the event is notified by the client via the notify() slot.
+ * On a regular interval, both an instantaneous and a rolling average
+ * event frequency are calculated.
+ */
+class FrequencyMonitor : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(FrequencyMonitor)
+ Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
+ Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY
+ samplingIntervalChanged)
+ Q_PROPERTY(
+ int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged)
+ Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY
+ instantaneousFrequencyChanged)
+ Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged)
+
+public:
+ FrequencyMonitor(QObject *parent = nullptr);
+ ~FrequencyMonitor();
+
+ static void qmlRegisterType();
+
+ QString label() const;
+ bool active() const;
+ int samplingInterval() const;
+ int traceInterval() const;
+ qreal instantaneousFrequency() const;
+ qreal averageFrequency() const;
+
+signals:
+ void labelChanged(const QString &value);
+ void activeChanged(bool);
+ void samplingIntervalChanged(int value);
+ void traceIntervalChanged(int value);
+ void frequencyChanged();
+ void instantaneousFrequencyChanged(qreal value);
+ void averageFrequencyChanged(qreal value);
+
+public slots:
+ Q_INVOKABLE void notify();
+ Q_INVOKABLE void trace();
+ void setActive(bool value);
+ void setLabel(const QString &value);
+ void setSamplingInterval(int value);
+ void setTraceInterval(int value);
+
+private:
+ FrequencyMonitorPrivate *d_ptr;
+};
+
+#endif // FREQUENCYMONITOR_H
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt b/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt
new file mode 100644
index 000000000..4a205fa28
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor/CMakeLists.txt
@@ -0,0 +1,30 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/frequencymonitor")
+
+qt_add_qml_module(frequencymonitor
+ URI frequencymonitor
+ QML_FILES
+ "FrequencyItem.qml"
+)
+
+target_link_libraries(frequencymonitor PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Quick
+)
+
+install(TARGETS frequencymonitor
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml
new file mode 100644
index 000000000..49a7eea9b
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor/FrequencyItem.qml
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import FrequencyMonitor 1.0
+
+Rectangle {
+ id: root
+ property bool logging: true
+ property bool displayed: true
+ property bool enabled: logging || displayed
+ property alias active: monitor.active
+ property int samplingInterval: 500
+ property color textColor: "yellow"
+ property int textSize: 20
+ property alias label: monitor.label
+
+ border.width: 1
+ border.color: "yellow"
+ width: 5.5 * root.textSize
+ height: 3.0 * root.textSize
+ color: "black"
+ opacity: 0.5
+ radius: 10
+ visible: displayed && active
+
+ // This should ensure that the monitor is on top of all other content
+ z: 999
+
+ function notify() {
+ monitor.notify()
+ }
+
+ FrequencyMonitor {
+ id: monitor
+ samplingInterval: root.enabled ? root.samplingInterval : 0
+ onAverageFrequencyChanged: {
+ if (root.logging) trace()
+ averageFrequencyText.text = monitor.averageFrequency.toFixed(2)
+ }
+ }
+
+ Text {
+ id: labelText
+ anchors {
+ left: parent.left
+ top: parent.top
+ margins: 10
+ }
+ color: root.textColor
+ font.pixelSize: 0.6 * root.textSize
+ text: root.label
+ width: root.width - 2*anchors.margins
+ elide: Text.ElideRight
+ }
+
+ Text {
+ id: averageFrequencyText
+ anchors {
+ right: parent.right
+ bottom: parent.bottom
+ margins: 10
+ }
+ color: root.textColor
+ font.pixelSize: root.textSize
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir b/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir
new file mode 100644
index 000000000..a935d2c53
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitor/qmldir
@@ -0,0 +1,3 @@
+module frequencymonitor
+
+FrequencyItem 1.0 FrequencyItem.qml
diff --git a/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp b/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp
new file mode 100644
index 000000000..6ed2019ff
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/frequencymonitordeclarative.cpp
@@ -0,0 +1,10 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "frequencymonitor.h"
+#include <qqml.h>
+
+void FrequencyMonitor::qmlRegisterType()
+{
+ ::qmlRegisterType<FrequencyMonitor>("FrequencyMonitor", 1, 0, "FrequencyMonitor");
+}
diff --git a/examples/multimedia/video/qmlvideo/main.cpp b/examples/multimedia/video/qmlvideo/main.cpp
index 01178acaa..94c5bfea0 100644
--- a/examples/multimedia/video/qmlvideo/main.cpp
+++ b/examples/multimedia/video/qmlvideo/main.cpp
@@ -1,82 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QtCore/QStandardPaths>
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtQml/QQmlContext>
-#include <QtQml/QQmlEngine>
-#include <QtGui/QGuiApplication>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
+#include "performancemonitor.h"
#include "trace.h"
-
+#include "qmlvideo/videosingleton.h"
#ifdef PERFORMANCEMONITOR_SUPPORT
-#include "performancemonitordeclarative.h"
+# include "performancemonitordeclarative.h"
#endif
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
-#include <QtAndroid>
-
-bool requestStoragePermission() {
- using namespace QtAndroid;
-
- QString permission = QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE");
- const QHash<QString, PermissionResult> results = requestPermissionsSync(QStringList({permission}));
- if (!results.contains(permission) || results[permission] == PermissionResult::Denied) {
- qWarning() << "Couldn't get permission: " << permission;
- return false;
- }
-
- return true;
-}
+#include <QGuiApplication>
+#include <QQmlContext>
+#include <QQmlEngine>
+#include <QQuickItem>
+#include <QQuickView>
+#include <QStandardPaths>
+#include <QString>
+#include <QStringList>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
#endif
static const QString DefaultFileName1 = "";
@@ -89,10 +31,6 @@ int main(int argc, char *argv[])
#ifdef PERFORMANCEMONITOR_SUPPORT
PerformanceMonitor::qmlRegisterTypes();
#endif
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
- if (!requestStoragePermission())
- return -1;
-#endif
QString source1, source2;
qreal volume = 0.5;
@@ -105,7 +43,7 @@ int main(int argc, char *argv[])
const QByteArray arg = args.at(i).toUtf8();
if (arg.startsWith('-')) {
if ("-volume" == arg) {
- if (i+1 < args.count())
+ if (i + 1 < args.count())
volume = 0.01 * args.at(++i).toInt();
else
qtTrace() << "Option \"-volume\" takes a value";
@@ -141,36 +79,47 @@ int main(int argc, char *argv[])
url2 = QUrl::fromLocalFile(source2);
}
+ const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
+ const QUrl videoPath = QUrl::fromLocalFile(moviesLocation.isEmpty() ? app.applicationDirPath()
+ : moviesLocation.front());
+
QQuickView viewer;
- viewer.setSource(QUrl("qrc:///qml/qmlvideo/main.qml"));
+ VideoSingleton* singleton = viewer.engine()->singletonInstance<VideoSingleton*>("qmlvideo", "VideoSingleton");
+ singleton->setVideoPath(videoPath);
+ singleton->setSource1(source1);
+ singleton->setSource2(source2);
+ singleton->setVolume(volume);
+ viewer.loadFromModule("qmlvideo", "Main");
QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QQuickView::close);
- QQuickItem *rootObject = viewer.rootObject();
- rootObject->setProperty("source1", url1);
- rootObject->setProperty("source2", url2);
- rootObject->setProperty("volume", volume);
-
#ifdef PERFORMANCEMONITOR_SUPPORT
+ QQuickItem *rootObject = viewer.rootObject();
if (performanceMonitorState.valid) {
rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging);
rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible);
}
- QObject::connect(&viewer, SIGNAL(afterRendering()),
- rootObject, SLOT(qmlFramePainted()));
+ QObject::connect(&viewer, SIGNAL(afterRendering()), rootObject, SLOT(qmlFramePainted()));
#endif
- const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
- const QUrl videoPath =
- QUrl::fromLocalFile(moviesLocation.isEmpty() ?
- app.applicationDirPath() :
- moviesLocation.front());
- viewer.rootContext()->setContextProperty("videoPath", videoPath);
-
QMetaObject::invokeMethod(rootObject, "init");
- viewer.setMinimumSize(QSize(640, 360));
- viewer.show();
+ auto setupView = [&viewer]() {
+ viewer.setMinimumSize(QSize(640, 360));
+ viewer.show();
+ };
+
+#if QT_CONFIG(permissions)
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&setupView](const QPermission &permission) {
+ // Show UI in any case. If there is no permission, the UI will just
+ // be disabled.
+ if (permission.status() != Qt::PermissionStatus::Granted)
+ qWarning("Camera permission is not granted! Camera will not be available.");
+ setupView();
+ });
+#else
+ setupView();
+#endif
return app.exec();
}
-
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor.cpp b/examples/multimedia/video/qmlvideo/performancemonitor.cpp
new file mode 100644
index 000000000..26f0fae2a
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor.cpp
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "performancemonitor.h"
+
+namespace PerformanceMonitor {
+
+bool State::parseArgument(const QByteArray &arg)
+{
+ bool result = false;
+ if (arg == "-log-perf") {
+ logging = true;
+ valid = true;
+ result = true;
+ } else if (arg == "-no-log-perf") {
+ logging = false;
+ valid = true;
+ result = true;
+ } else if (arg == "-show-perf") {
+ visible = true;
+ valid = true;
+ result = true;
+ } else if (arg == "-hide-perf") {
+ visible = false;
+ valid = true;
+ result = true;
+ }
+ return result;
+}
+
+} // namespace PerformanceMonitor
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor.h b/examples/multimedia/video/qmlvideo/performancemonitor.h
new file mode 100644
index 000000000..683468619
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor.h
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PERFORMANCEMONITOR_H
+#define PERFORMANCEMONITOR_H
+
+#include <QByteArray>
+
+namespace PerformanceMonitor {
+
+struct State
+{
+ State() : valid(true), logging(false), visible(true) { }
+ State(bool l, bool v) : valid(true), logging(l), visible(v) { }
+ bool operator==(const State &other) const
+ {
+ return logging == other.logging && visible == other.visible;
+ }
+ bool operator!=(const State &other) const
+ {
+ return logging != other.logging || visible != other.visible;
+ }
+
+ bool parseArgument(const QByteArray &arg);
+
+ bool valid;
+ bool logging;
+ bool visible;
+};
+
+} // namespace PerformanceMonitor
+
+#endif // PERFORMANCEMONITOR_H
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt b/examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt
new file mode 100644
index 000000000..beb9e2e08
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor/CMakeLists.txt
@@ -0,0 +1,31 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/performancemonitor")
+
+qt_add_qml_module(performancemonitor
+ URI performancemonitor
+ QML_FILES
+ "PerformanceItem.qml"
+)
+
+target_link_libraries(performancemonitor PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Quick
+)
+
+install(TARGETS performancemonitor
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml
new file mode 100644
index 000000000..5b501b104
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor/PerformanceItem.qml
@@ -0,0 +1,100 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ id: root
+ property bool logging: true
+ property bool displayed: true
+ property bool videoActive
+ property int margins: 5
+ property bool enabled: true
+
+ color: "transparent"
+
+ // This should ensure that the monitor is on top of all other content
+ z: 999
+
+ Column {
+ id: column
+ anchors {
+ fill: root
+ margins: 10
+ }
+ spacing: 10
+ }
+
+ QtObject {
+ id: d
+ property Item qmlFrameRateItem: null
+ property Item videoFrameRateItem: null
+ }
+
+ Connections {
+ id: videoFrameRateActiveConnections
+ ignoreUnknownSignals: true
+ function onActiveChanged() { root.videoActive = videoFrameRateActiveConnections.target.active }
+ }
+
+ states: [
+ State {
+ name: "hidden"
+ PropertyChanges {
+ root.opacity: 0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ easing.type: Easing.OutQuart
+ duration: 500
+ }
+ }
+ ]
+
+ state: enabled ? "baseState" : "hidden"
+
+ function createQmlFrameRateItem() {
+ let component = Qt.createComponent("frequencymonitor", "FrequencyItem")
+ if (component.status === Component.Ready)
+ d.qmlFrameRateItem = component.createObject(column, { label: qsTr("QML frame rate"),
+ displayed: root.displayed,
+ logging: root.logging
+ });
+ }
+
+ function createVideoFrameRateItem() {
+ let component = Qt.createComponent("frequencymonitor", "FrequencyItem")
+ if (component.status === Component.Ready)
+ d.videoFrameRateItem = component.createObject(column, { label: qsTr("Video frame rate"),
+ displayed: root.displayed,
+ logging: root.logging
+ });
+ videoFrameRateActiveConnections.target = d.videoFrameRateItem
+ }
+
+
+ function init() {
+ createQmlFrameRateItem()
+ createVideoFrameRateItem()
+ }
+
+ function videoFramePainted() {
+ d.videoFrameRateItem?.notify()
+ }
+
+ function qmlFramePainted() {
+ d.qmlFrameRateItem?.notify()
+ }
+
+ onVideoActiveChanged: {
+ if (d.videoFrameRateItem)
+ d.videoFrameRateItem.active = root.videoActive
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/performancemonitor/qmldir b/examples/multimedia/video/qmlvideo/performancemonitor/qmldir
new file mode 100644
index 000000000..636abaf99
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitor/qmldir
@@ -0,0 +1,3 @@
+module performancemonitor
+
+PerformanceItem 1.0 PerformanceItem.qml
diff --git a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp
new file mode 100644
index 000000000..a2ad1ca82
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.cpp
@@ -0,0 +1,12 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "frequencymonitor.h"
+
+namespace PerformanceMonitor {
+
+void qmlRegisterTypes()
+{
+ FrequencyMonitor::qmlRegisterType();
+}
+}
diff --git a/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h
new file mode 100644
index 000000000..4514d5041
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/performancemonitordeclarative.h
@@ -0,0 +1,11 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PERFORMANCEMONITORDECLARATIVE_H
+#define PERFORMANCEMONITORDECLARATIVE_H
+
+namespace PerformanceMonitor {
+void qmlRegisterTypes();
+}
+
+#endif // PERFORMANCEMONITORDECLARATIVE_H
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml
deleted file mode 100644
index e2d296e98..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Button.qml
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: root
-
- property string text
- property color bgColor: "#757575"
- property color bgColorSelected: "#bdbdbd"
- property color textColor: "white"
- property color textColorSelected: "black"
- property alias enabled: mouseArea.enabled
- property alias radius: bgr.radius
-
- signal clicked
-
- Rectangle {
- id: bgr
- anchors.fill: parent
- color: mouseArea.pressed ? bgColorSelected : bgColor
- radius: height / 15
-
- Text {
- id: text
- anchors.centerIn: parent
- text: root.text
- font.pixelSize: 0.4 * parent.height
- color: mouseArea.pressed ? textColorSelected : textColor
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- root.clicked()
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml
deleted file mode 100644
index c17f90162..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraBasic.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneBasic {
- contentType: "camera"
- started: true
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml
deleted file mode 100644
index 395261c1b..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDrag.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneDrag {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml
deleted file mode 100644
index 6439bea16..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraDummy.qml
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-// Item which is loaded by CameraItem if Qt Multimedia is not available
-Rectangle {
- id: root
- color: "grey"
- height: width
-
- signal fatalError
- signal sizeChanged
- signal framePainted
-
- Text {
- anchors.fill: parent
- anchors.margins: 10
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- text: "Failed to create Camera item\n\nCheck that Qt Multimedia is installed"
- verticalAlignment: Text.AlignVCenter
- wrapMode: Text.Wrap
- }
-
- onWidthChanged: height = width
- onHeightChanged: root.sizeChanged()
-
- function start() { }
- function stop() { }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml
deleted file mode 100644
index 125d18246..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreen.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneFullScreen {
- contentType: "camera"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml
deleted file mode 100644
index e7372b2c3..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraFullScreenInverted.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneFullScreenInverted {
- contentType: "camera"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml
deleted file mode 100644
index 9fd3f9cfa..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraItem.qml
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.0
-
-VideoOutput {
- id: root
- height: width
- source: camera
-
- signal fatalError
- signal sizeChanged
-
- onHeightChanged: root.sizeChanged()
-
- Camera {
- id: camera
-
- onError: {
- if (Camera.NoError != error) {
- console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
- root.fatalError()
- }
- }
- }
-
- function start() { camera.start() }
- function stop() { camera.stop() }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml
deleted file mode 100644
index 39d18cf4f..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraMove.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneMove {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml
deleted file mode 100644
index 5401a51f2..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraOverlay.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneOverlay {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml
deleted file mode 100644
index d9719659c..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraResize.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneResize {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml
deleted file mode 100644
index 5b02392b7..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraRotate.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneRotate {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml
deleted file mode 100644
index a81652e7c..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/CameraSpin.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneSpin {
- contentType: "camera"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml
deleted file mode 100644
index ffa04e200..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Content.qml
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- border.color: "white"
- border.width: showBorder ? 1 : 0
- color: "transparent"
- property string contentType // "camera" or "video"
- property string source
- property real volume
- property bool dummy: false
- property bool autoStart: true
- property bool started: false
- property bool showFrameRate: false
- property bool showBorder: false
-
- signal initialized
- signal error
- signal videoFramePainted
-
- Loader {
- id: contentLoader
- }
-
- Connections {
- id: framePaintedConnection
- onFramePainted: {
- if (frameRateLoader.item)
- frameRateLoader.item.notify()
- root.videoFramePainted()
- }
- ignoreUnknownSignals: true
- }
-
- Connections {
- id: errorConnection
- onFatalError: {
- console.log("[qmlvideo] Content.onFatalError")
- stop()
- root.error()
- }
- ignoreUnknownSignals: true
- }
-
- Loader {
- id: frameRateLoader
- source: root.showFrameRate ? "../frequencymonitor/FrequencyItem.qml" : ""
- onLoaded: {
- item.parent = root
- item.anchors.top = root.top
- item.anchors.right = root.right
- item.anchors.margins = 10
- }
- }
-
- onWidthChanged: {
- if (contentItem())
- contentItem().width = width
- }
-
- onHeightChanged: {
- if (contentItem())
- contentItem().height = height
- }
-
- function initialize() {
- if ("video" == contentType) {
- contentLoader.source = "VideoItem.qml"
- if (Loader.Error == contentLoader.status) {
- contentLoader.source = "VideoDummy.qml"
- dummy = true
- }
- contentLoader.item.volume = volume
- } else if ("camera" == contentType) {
- contentLoader.source = "CameraItem.qml"
- if (Loader.Error == contentLoader.status) {
- contentLoader.source = "CameraDummy.qml"
- dummy = true
- }
- } else {
- console.log("[qmlvideo] Content.initialize: error: invalid contentType")
- }
- if (contentLoader.item) {
- contentLoader.item.sizeChanged.connect(updateRootSize)
- contentLoader.item.parent = root
- contentLoader.item.width = root.width
- framePaintedConnection.target = contentLoader.item
- errorConnection.target = contentLoader.item
- if (root.autoStart)
- root.start()
- }
- root.initialized()
- }
-
- function start() {
- if (contentLoader.item) {
- if (root.contentType == "video")
- contentLoader.item.mediaSource = root.source
- contentLoader.item.start()
- root.started = true
- }
- }
-
- function stop() {
- if (contentLoader.item) {
- contentLoader.item.stop()
- if (root.contentType == "video")
- contentLoader.item.mediaSource = ""
- root.started = false
- }
- }
-
- function contentItem() { return contentLoader.item }
- function updateRootSize() { root.height = contentItem().height }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml
deleted file mode 100644
index 442eb42c1..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/ErrorDialog.qml
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- color: "transparent"
- opacity: 0.0
- property alias enabled: mouseArea.enabled
- property int dialogWidth: 300
- property int dialogHeight: 200
- state: enabled ? "on" : "baseState"
-
- states: [
- State {
- name: "on"
- PropertyChanges {
- target: root
- opacity: 1.0
- }
- }
- ]
-
- transitions: [
- Transition {
- from: "*"
- to: "*"
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.OutQuart
- duration: 500
- }
- }
- ]
-
- Rectangle {
- anchors.fill: parent
- color: "black"
- opacity: 0.75
- }
-
- Rectangle {
- anchors.centerIn: parent
- width: dialogWidth
- height: dialogHeight
- radius: 5
- color: "white"
-
- Text {
- id: text
- anchors.fill: parent
- anchors.margins: 10
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- color: "black"
- wrapMode: Text.WordWrap
- }
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: root.enabled = false
- }
-
- function show(msg) {
- text.text = "<b>Error</b><br><br>" + msg
- root.enabled = true
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
deleted file mode 100644
index 3fe5a5204..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/FileBrowser.qml
+++ /dev/null
@@ -1,419 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import Qt.labs.folderlistmodel 2.0
-
-Rectangle {
- id: fileBrowser
- color: "transparent"
-
- property string folder
-
- property int itemHeight: Math.min(parent.width, parent.height) / 15
- property int buttonHeight: Math.min(parent.width, parent.height) / 12
-
- signal fileSelected(string file)
-
- function selectFile(file) {
- if (file !== "") {
- folder = loader.item.folders.folder
- fileBrowser.fileSelected(file)
- }
- loader.sourceComponent = undefined
- }
-
- Loader {
- id: loader
- }
-
- function show() {
- loader.sourceComponent = fileBrowserComponent
- loader.item.parent = fileBrowser
- loader.item.anchors.fill = fileBrowser
- loader.item.folder = fileBrowser.folder
- }
-
- Component {
- id: fileBrowserComponent
-
- Rectangle {
- id: root
- color: "black"
- property bool showFocusHighlight: false
- property variant folders: folders1
- property variant view: view1
- property alias folder: folders1.folder
- property color textColor: "white"
-
- FolderListModel {
- id: folders1
- folder: folder
- }
-
- FolderListModel {
- id: folders2
- folder: folder
- }
-
- SystemPalette {
- id: palette
- }
-
- Component {
- id: folderDelegate
-
- Rectangle {
- id: wrapper
- function launch() {
- var path = "file://";
- if (filePath.length > 2 && filePath[1] === ':') // Windows drive logic, see QUrl::fromLocalFile()
- path += '/';
- path += filePath;
- if (folders.isFolder(index))
- down(path);
- else
- fileBrowser.selectFile(path)
- }
- width: root.width
- height: folderImage.height
- color: "transparent"
-
- Rectangle {
- id: highlight
- visible: false
- anchors.fill: parent
- anchors.leftMargin: 5
- anchors.rightMargin: 5
- color: "#212121"
- }
-
- Item {
- id: folderImage
- width: itemHeight
- height: itemHeight
- Image {
- id: folderPicture
- source: "qrc:/folder.png"
- width: itemHeight * 0.9
- height: itemHeight * 0.9
- anchors.left: parent.left
- anchors.margins: 5
- visible: folders.isFolder(index)
- }
- }
-
- Text {
- id: nameText
- anchors.fill: parent;
- verticalAlignment: Text.AlignVCenter
- text: fileName
- anchors.leftMargin: itemHeight + 10
- color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor
- elide: Text.ElideRight
- }
-
- MouseArea {
- id: mouseRegion
- anchors.fill: parent
- onPressed: {
- root.showFocusHighlight = false;
- wrapper.ListView.view.currentIndex = index;
- }
- onClicked: { if (folders === wrapper.ListView.view.model) launch() }
- }
-
- states: [
- State {
- name: "pressed"
- when: mouseRegion.pressed
- PropertyChanges { target: highlight; visible: true }
- PropertyChanges { target: nameText; color: palette.highlightedText }
- }
- ]
- }
- }
-
- ListView {
- id: view1
- anchors.top: titleBar.bottom
- anchors.bottom: cancelButton.top
- width: parent.width
- model: folders1
- delegate: folderDelegate
- highlight: Rectangle {
- color: "#212121"
- visible: root.showFocusHighlight && view1.count != 0
- width: view1.currentItem == null ? 0 : view1.currentItem.width
- }
- highlightMoveVelocity: 1000
- pressDelay: 100
- focus: true
- state: "current"
- states: [
- State {
- name: "current"
- PropertyChanges { target: view1; x: 0 }
- },
- State {
- name: "exitLeft"
- PropertyChanges { target: view1; x: -root.width }
- },
- State {
- name: "exitRight"
- PropertyChanges { target: view1; x: root.width }
- }
- ]
- transitions: [
- Transition {
- to: "current"
- SequentialAnimation {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- },
- Transition {
- NumberAnimation { properties: "x"; duration: 250 }
- NumberAnimation { properties: "x"; duration: 250 }
- }
- ]
- Keys.onPressed: root.keyPressed(event.key)
- }
-
- ListView {
- id: view2
- anchors.top: titleBar.bottom
- anchors.bottom: parent.bottom
- x: parent.width
- width: parent.width
- model: folders2
- delegate: folderDelegate
- highlight: Rectangle {
- color: "#212121"
- visible: root.showFocusHighlight && view2.count != 0
- width: view1.currentItem == null ? 0 : view1.currentItem.width
- }
- highlightMoveVelocity: 1000
- pressDelay: 100
- states: [
- State {
- name: "current"
- PropertyChanges { target: view2; x: 0 }
- },
- State {
- name: "exitLeft"
- PropertyChanges { target: view2; x: -root.width }
- },
- State {
- name: "exitRight"
- PropertyChanges { target: view2; x: root.width }
- }
- ]
- transitions: [
- Transition {
- to: "current"
- SequentialAnimation {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- },
- Transition {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- ]
- Keys.onPressed: root.keyPressed(event.key)
- }
-
- Rectangle {
- width: parent.width
- height: buttonHeight + 10
- anchors.bottom: parent.bottom
- color: "black"
- }
-
- Rectangle {
- id: cancelButton
- width: parent.width
- height: buttonHeight
- color: "#212121"
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: 5
- radius: buttonHeight / 15
-
- Text {
- anchors.fill: parent
- text: "Cancel"
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: fileBrowser.selectFile("")
- }
- }
-
- Keys.onPressed: {
- root.keyPressed(event.key);
- if (event.key === Qt.Key_Return || event.key === Qt.Key_Select || event.key === Qt.Key_Right) {
- view.currentItem.launch();
- event.accepted = true;
- } else if (event.key === Qt.Key_Left) {
- up();
- }
- }
-
-
- Rectangle {
- id: titleBar
- width: parent.width
- height: buttonHeight + 10
- anchors.top: parent.top
- color: "black"
-
- Rectangle {
- width: parent.width;
- height: buttonHeight
- color: "#212121"
- anchors.margins: 5
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- radius: buttonHeight / 15
-
- Rectangle {
- id: upButton
- width: buttonHeight
- height: buttonHeight
- color: "transparent"
- Image {
- width: itemHeight
- height: itemHeight
- anchors.centerIn: parent
- source: "qrc:/up.png"
- }
- MouseArea { id: upRegion; anchors.centerIn: parent
- width: buttonHeight
- height: buttonHeight
- onClicked: up()
- }
- states: [
- State {
- name: "pressed"
- when: upRegion.pressed
- PropertyChanges { target: upButton; color: palette.highlight }
- }
- ]
- }
-
- Text {
- anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
- anchors.leftMargin: 5; anchors.rightMargin: 5
- text: folders.folder
- color: "white"
- elide: Text.ElideLeft;
- horizontalAlignment: Text.AlignLeft;
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
-
- function down(path) {
- if (folders == folders1) {
- view = view2
- folders = folders2;
- view1.state = "exitLeft";
- } else {
- view = view1
- folders = folders1;
- view2.state = "exitLeft";
- }
- view.x = root.width;
- view.state = "current";
- view.focus = true;
- folders.folder = path;
- }
-
- function up() {
- var path = folders.parentFolder;
- if (path.toString().length === 0 || path.toString() === 'file:')
- return;
- if (folders == folders1) {
- view = view2
- folders = folders2;
- view1.state = "exitRight";
- } else {
- view = view1
- folders = folders1;
- view2.state = "exitRight";
- }
- view.x = -root.width;
- view.state = "current";
- view.focus = true;
- folders.folder = path;
- }
-
- function keyPressed(key) {
- switch (key) {
- case Qt.Key_Up:
- case Qt.Key_Down:
- case Qt.Key_Left:
- case Qt.Key_Right:
- root.showFocusHighlight = true;
- break;
- default:
- // do nothing
- break;
- }
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
deleted file mode 100644
index 4f98241a6..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/Scene.qml
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- color: "black"
- property alias buttonHeight: closeButton.height
- property string source1
- property string source2
- property int contentWidth: parent.width / 2
- property real volume: 0.25
- property int margins: 5
- property QtObject content
-
- signal close
- signal videoFramePainted
-
- Button {
- id: closeButton
- anchors {
- top: parent.top
- right: parent.right
- margins: root.margins
- }
- width: Math.max(parent.width, parent.height) / 12
- height: Math.min(parent.width, parent.height) / 12
- z: 2.0
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- text: "Back"
- onClicked: root.close()
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
deleted file mode 100644
index 6c9c3ae2a..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneBasic.qml
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property string contentType
- property bool autoStart: false
- property bool started: false
-
- Content {
- id: content
- autoStart: parent.autoStart
- started: parent.started
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: parent.contentType
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Text {
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- margins: 20
- }
- text: content.started ? "Tap the screen to stop content"
- : "Tap the screen to start content"
- color: "#e0e0e0"
- z: 2.0
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (content.started)
- content.stop()
- else
- content.start()
- }
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml
deleted file mode 100644
index 0c7444e02..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneDrag.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Image {
- id: background
- source: "qrc:/images/leaves.jpg"
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
-
- Content {
- id: content
- anchors.centerIn: parent
- width: root.contentWidth
- contentType: root.contentType
- source: root.source1
- volume: root.volume
- onVideoFramePainted: root.videoFramePainted()
- }
- }
-
- MouseArea {
- anchors.fill: parent
- drag.target: background
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml
deleted file mode 100644
index 2ce10ce39..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreen.qml
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- state: "left"
-
- states: [
- State {
- name: "fullScreen"
- PropertyChanges { target: content; width: content.parent.width }
- PropertyChanges { target: content; height: content.parent.height }
- }
- ]
-
- transitions: [
- Transition {
- ParallelAnimation {
- PropertyAnimation {
- property: "width"
- easing.type: Easing.Linear
- duration: 250
- }
- PropertyAnimation {
- property: "height"
- easing.type: Easing.Linear
- duration: 250
- }
- }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: content.state = (content.state == "fullScreen") ? "baseState" : "fullScreen"
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Text {
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- margins: 20
- }
- text: "Tap on the content to toggle full-screen mode"
- color: "#e0e0e0"
- z: 2.0
- }
-
- Component.onCompleted: root.content = content
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml
deleted file mode 100644
index 7e7eb7039..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneFullScreenInverted.qml
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.width
- height: parent.height
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- state: "left"
-
- states: [
- State {
- name: "nonFullScreen"
- PropertyChanges { target: content; width: content.parent.contentWidth }
- }
- ]
-
- transitions: [
- Transition {
- ParallelAnimation {
- PropertyAnimation {
- property: "width"
- easing.type: Easing.Linear
- duration: 250
- }
- PropertyAnimation {
- property: "height"
- easing.type: Easing.Linear
- duration: 250
- }
- }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: content.state = (content.state == "nonFullScreen") ? "baseState" : "nonFullScreen"
- }
-
- onVideoFramePainted: root.videoFramePainted()
-
- onInitialized: {
- width = parent.width
- height = parent.height
- }
- }
-
- Text {
- anchors {
- horizontalCenter: parent.horizontalCenter
- bottom: parent.bottom
- margins: 20
- }
- text: "Tap on the content to toggle full-screen mode"
- color: "#e0e0e0"
- z: 2.0
- }
-
- Component.onCompleted: root.content = content
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml
deleted file mode 100644
index adf414daa..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMove.qml
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Content {
- id: content
- anchors.verticalCenter: parent.verticalCenter
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
-
- SequentialAnimation on x {
- id: animation
- loops: Animation.Infinite
- property int from: margin
- property int to: 100
- property int duration: 1500
- running: false
- PropertyAnimation {
- from: animation.from
- to: animation.to
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: animation.to
- to: animation.from
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
- onWidthChanged: {
- animation.to = root.width - content.width - margin
- animation.start()
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml
deleted file mode 100644
index b3f7350eb..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneOverlay.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Rectangle {
- id: overlay
- y: 0.5 * parent.height
- width: content.width
- height: content.height
- color: "#e0e0e0"
- opacity: 0.5
-
- SequentialAnimation on x {
- id: xAnimation
- loops: Animation.Infinite
- property int from: margin
- property int to: 100
- property int duration: 1500
- running: false
- PropertyAnimation {
- from: xAnimation.from
- to: xAnimation.to
- duration: xAnimation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: xAnimation.to
- to: xAnimation.from
- duration: xAnimation.duration
- easing.type: Easing.InOutCubic
- }
- }
-
- SequentialAnimation on y {
- id: yAnimation
- loops: Animation.Infinite
- property int from: margin
- property int to: 180
- property int duration: 1500
- running: false
- PropertyAnimation {
- from: yAnimation.from
- to: yAnimation.to
- duration: yAnimation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: yAnimation.to
- to: yAnimation.from
- duration: yAnimation.duration
- easing.type: Easing.InOutCubic
- }
- }
- }
-
- onWidthChanged: {
- xAnimation.to = root.width - content.width - margin
- xAnimation.start()
- }
-
- onHeightChanged: {
- //yAnimation.to = root.height - content.height - margin
- yAnimation.start()
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml
deleted file mode 100644
index 778d81dd5..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneResize.qml
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
-
- SequentialAnimation on scale {
- id: animation
- loops: Animation.Infinite
- property int duration: 1500
- running: true
- PropertyAnimation {
- from: 1.5
- to: 0.5
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- PropertyAnimation {
- from: 0.5
- to: 1.5
- duration: animation.duration
- easing.type: Easing.InOutCubic
- }
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml
deleted file mode 100644
index f9549fdca..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneRotate.qml
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property int margin: 20
- property int delta: 30
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Button {
- id: rotatePositiveButton
- anchors {
- right: parent.right
- bottom: rotateNegativeButton.top
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Rotate +" + delta
- onClicked: content.rotation = content.rotation + delta
- }
-
- Button {
- id: rotateNegativeButton
- anchors {
- right: parent.right
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Rotate -" + delta
- onClicked: content.rotation = content.rotation - delta
- }
-
- Button {
- id: rotateValueButton
- anchors {
- left: parent.left
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 25
- height: root.buttonHeight
- enabled: false
- text: content.rotation % 360
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml
deleted file mode 100644
index e36fe6045..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSelectionPanel.qml
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- property int itemHeight: 25
- property string sceneSource: ""
-
- ListModel {
- id: videolist
- ListElement { name: "Multi"; source: "SceneMulti.qml" }
- ListElement { name: "Video"; source: "VideoBasic.qml" }
- ListElement { name: "Drag"; source: "VideoDrag.qml" }
- ListElement { name: "Fillmode"; source: "VideoFillMode.qml" }
- ListElement { name: "Fullscreen"; source: "VideoFullScreen.qml" }
- ListElement { name: "Fullscreen-inverted"; source: "VideoFullScreenInverted.qml" }
- ListElement { name: "Metadata"; source: "VideoMetadata.qml" }
- ListElement { name: "Move"; source: "VideoMove.qml" }
- ListElement { name: "Overlay"; source: "VideoOverlay.qml" }
- ListElement { name: "Playback Rate"; source: "VideoPlaybackRate.qml" }
- ListElement { name: "Resize"; source: "VideoResize.qml" }
- ListElement { name: "Rotate"; source: "VideoRotate.qml" }
- ListElement { name: "Spin"; source: "VideoSpin.qml" }
- ListElement { name: "Seek"; source: "VideoSeek.qml" }
- }
-
- ListModel {
- id: cameralist
- ListElement { name: "Camera"; source: "CameraBasic.qml" }
- ListElement { name: "Drag"; source: "CameraDrag.qml" }
- ListElement { name: "Fullscreen"; source: "CameraFullScreen.qml" }
- ListElement { name: "Fullscreen-inverted"; source: "CameraFullScreenInverted.qml" }
- ListElement { name: "Move"; source: "CameraMove.qml" }
- ListElement { name: "Overlay"; source: "CameraOverlay.qml" }
- ListElement { name: "Resize"; source: "CameraResize.qml" }
- ListElement { name: "Rotate"; source: "CameraRotate.qml" }
- ListElement { name: "Spin"; source: "CameraSpin.qml" }
- }
-
- Component {
- id: leftDelegate
- Item {
- width: root.width / 2
- height: 0.8 * itemHeight
-
- Button {
- anchors.fill: parent
- anchors.margins: 5
- anchors.rightMargin: 2.5
- anchors.bottomMargin: 0
- text: name
- onClicked: root.sceneSource = source
- }
- }
- }
-
- Component {
- id: rightDelegate
- Item {
- width: root.width / 2
- height: 0.8 * itemHeight
-
- Button {
- anchors.fill: parent
- anchors.margins: 5
- anchors.leftMargin: 2.5
- anchors.bottomMargin: 0
- text: name
- onClicked: root.sceneSource = source
- }
- }
- }
-
- Flickable {
- anchors.fill: parent
- contentHeight: (itemHeight * videolist.count) + 10
- clip: true
-
- Row {
- id: layout
- anchors {
- fill: parent
- topMargin: 5
- bottomMargin: 5
- }
-
- Column {
- Repeater {
- model: videolist
- delegate: leftDelegate
- }
- }
-
- Column {
- Repeater {
- model: cameralist
- delegate: rightDelegate
- }
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml
deleted file mode 100644
index 925b92566..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneSpin.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property int margin: 20
- property string contentType
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: root.contentType
- source: parent.source1
- volume: parent.volume
-
- PropertyAnimation on rotation {
- id: animation
- loops: Animation.Infinite
- running: true
- from: 0
- to: 360
- duration: 3000
- easing.type: Easing.Linear
- }
-
- onVideoFramePainted: root.videoFramePainted()
- }
-
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
deleted file mode 100644
index 09f890670..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoBasic.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneBasic {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml
deleted file mode 100644
index b24bb4517..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDrag.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneDrag {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml
deleted file mode 100644
index 371173973..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoDummy.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-// Item which is loaded by VideoItem if Qt Multimedia is not available
-Rectangle {
- id: root
- color: "grey"
- height: width
- property int duration: 0
- property int position: 0
- property string source
- property real volume: 1.0
- property real playbackRate: 1.0
-
- signal fatalError
- signal sizeChanged
- signal framePainted
-
- Text {
- anchors.fill: parent
- anchors.margins: 10
- color: "white"
- horizontalAlignment: Text.AlignHCenter
- text: "Failed to create Video item\n\nCheck that Qt Multimedia is installed"
- verticalAlignment: Text.AlignVCenter
- wrapMode: Text.Wrap
- }
-
- onWidthChanged: height = width
- onHeightChanged: root.sizeChanged()
-
- function start() { }
- function stop() { }
- function seek() { }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml
deleted file mode 100644
index 68157584e..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFillMode.qml
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.0
-
-Scene {
- id: root
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Button {
- id: button
- anchors {
- right: parent.right
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 5
- height: root.buttonHeight
- text: "PreserveAspectFit"
- onClicked: {
- if (!content.dummy) {
- var video = content.contentItem()
- if (video.fillMode === VideoOutput.Stretch) {
- video.fillMode = VideoOutput.PreserveAspectFit
- text = "PreserveAspectFit"
- } else if (video.fillMode === VideoOutput.PreserveAspectFit) {
- video.fillMode = VideoOutput.PreserveAspectCrop
- text = "PreserveAspectCrop"
- } else {
- video.fillMode = VideoOutput.Stretch
- text = "Stretch"
- }
- }
- }
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml
deleted file mode 100644
index 480d6824d..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreen.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneFullScreen {
- contentType: "video"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml
deleted file mode 100644
index c65c33872..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoFullScreenInverted.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneFullScreenInverted {
- contentType: "video"
-}
-
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml
deleted file mode 100644
index 8372acb7e..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoItem.qml
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.0
-
-VideoOutput {
- id: root
- height: width
- source: mediaPlayer
-
- property alias duration: mediaPlayer.duration
- property alias mediaSource: mediaPlayer.source
- property alias metaData: mediaPlayer.metaData
- property alias playbackRate: mediaPlayer.playbackRate
- property alias position: mediaPlayer.position
- property alias volume: mediaPlayer.volume
-
- signal sizeChanged
- signal fatalError
-
- onHeightChanged: root.sizeChanged()
-
- MediaPlayer {
- id: mediaPlayer
- autoLoad: false
- loops: Audio.Infinite
-
- onError: {
- if (MediaPlayer.NoError != error) {
- console.log("[qmlvideo] VideoItem.onError error " + error + " errorString " + errorString)
- root.fatalError()
- }
- }
- }
-
- function start() { mediaPlayer.play() }
- function stop() { mediaPlayer.stop() }
- function seek(position) { mediaPlayer.seek(position); }
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml
deleted file mode 100644
index b9672f1c5..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMetadata.qml
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property string contentType: "video"
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onInitialized: {
- if (!dummy)
- metadata.createObject(root)
- }
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Component {
- id: metadata
- Column {
- anchors.fill: parent
- Text {
- color: "#e0e0e0"
- text: "Title:" + content.contentItem().metaData.title
- }
- Text {
- color: "#e0e0e0"
- text: "Size:" + content.contentItem().metaData.size
- }
- Text {
- color: "#e0e0e0"
- text: "Resolution:" + content.contentItem().metaData.resolution
- }
- Text {
- color: "#e0e0e0"
- text: "Media type:" + content.contentItem().metaData.mediaType
- }
- Text {
- color: "#e0e0e0"
- text: "Video codec:" + content.contentItem().metaData.videoCodec
- }
- Text {
- color: "#e0e0e0"
- text: "Video bit rate:" + content.contentItem().metaData.videoBitRate
- }
- Text {
- color: "#e0e0e0"
- text: "Video frame rate:" +content.contentItem().metaData.videoFrameRate
- }
- Text {
- color: "#e0e0e0"
- text: "Audio codec:" + content.contentItem().metaData.audioCodec
- }
- Text {
- color: "#e0e0e0"
- text: "Audio bit rate:" + content.contentItem().metaData.audioBitRate
- }
- Text {
- color: "#e0e0e0"
- text: "Date:" + content.contentItem().metaData.date
- }
- Text {
- color: "#e0e0e0"
- text: "Description:" + content.contentItem().metaData.description
- }
- Text {
- color: "#e0e0e0"
- text: "Copyright:" + content.contentItem().metaData.copyright
- }
- Text {
- color: "#e0e0e0"
- text: "Seekable:" + content.contentItem().metaData.seekable
- }
- Text {
- color: "#e0e0e0"
- text: "Orientation:" + content.contentItem().metaData.orientation
- }
- }
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml
deleted file mode 100644
index 56e3a96b9..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoMove.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneMove {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml
deleted file mode 100644
index 4313a33db..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoOverlay.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneOverlay {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml
deleted file mode 100644
index 80a12d3db..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoPlaybackRate.qml
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property int margin: 20
- property real delta: 0.1
- property string contentType: "video"
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- Button {
- id: increaseButton
- anchors {
- right: parent.right
- bottom: decreaseButton.top
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Increase"
- onClicked: {
- var video = content.contentItem()
- video.playbackRate += delta
- }
- }
-
- Button {
- id: decreaseButton
- anchors {
- right: parent.right
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 10
- height: root.buttonHeight
- text: "Decrease"
- onClicked: {
- var video = content.contentItem()
- video.playbackRate -= delta
- }
- }
-
- Button {
- id: valueButton
- anchors {
- left: parent.left
- verticalCenter: parent.verticalCenter
- margins: parent.margins
- }
- width: Math.max(parent.width, parent.height) / 25
- height: root.buttonHeight
- enabled: false
- text: Math.round(10 * content.contentItem().playbackRate) / 10
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml
deleted file mode 100644
index f83465f48..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoResize.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneResize {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml
deleted file mode 100644
index 0eb198d20..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoRotate.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneRotate {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml
deleted file mode 100644
index 8e3575920..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSeek.qml
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Scene {
- id: root
- property string contentType: "video"
- contentWidth: parent.width
-
- Content {
- id: content
- anchors.centerIn: parent
- width: parent.contentWidth
- contentType: "video"
- source: parent.source1
- volume: parent.volume
- onVideoFramePainted: root.videoFramePainted()
- }
-
- SeekControl {
- anchors {
- left: parent.left
- right: parent.right
- margins: 10
- bottom: parent.bottom
- }
- duration: content.contentItem() ? content.contentItem().duration : 0
- playPosition: content.contentItem() ? content.contentItem().position : 0
- onSeekPositionChanged: content.contentItem().seek(seekPosition);
- }
-
- Component.onCompleted: root.content = content
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml
deleted file mode 100644
index cb46797f6..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/VideoSpin.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-SceneSpin {
- contentType: "video"
-}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml b/examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml
deleted file mode 100644
index 43f827e97..000000000
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/main.qml
+++ /dev/null
@@ -1,284 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- anchors.fill: parent
- color: "black"
-
- property string source1
- property string source2
- property color bgColor: "black"
- property real volume: 0.25
- property bool perfMonitorsLogging: false
- property bool perfMonitorsVisible: false
-
- QtObject {
- id: d
- property int itemHeight: root.height > root.width ? root.width / 10 : root.height / 10
- property int buttonHeight: 0.8 * itemHeight
- property int margins: 5
- }
-
- Loader {
- id: performanceLoader
-
- Connections {
- target: inner
- onVisibleChanged:
- if (performanceLoader.item)
- performanceLoader.item.enabled = !inner.visible
- ignoreUnknownSignals: true
- }
-
- function init() {
- var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
- source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
- }
-
- onLoaded: {
- item.parent = root
- item.anchors.fill = root
- item.logging = root.perfMonitorsLogging
- item.displayed = root.perfMonitorsVisible
- item.enabled = false
- item.init()
- }
- }
-
- Rectangle {
- id: inner
- anchors.fill: parent
- color: root.bgColor
-
- Button {
- id: openFile1Button
- anchors {
- top: parent.top
- left: parent.left
- right: exitButton.left
- margins: d.margins
- }
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- height: d.buttonHeight
- text: (root.source1 == "") ? "Select file 1" : root.source1
- onClicked: fileBrowser1.show()
- }
-
- Button {
- id: openFile2Button
- anchors {
- top: openFile1Button.bottom
- left: parent.left
- right: exitButton.left
- margins: d.margins
- }
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- height: d.buttonHeight
- text: (root.source2 == "") ? "Select file 2" : root.source2
- onClicked: fileBrowser2.show()
- }
-
- Button {
- id: exitButton
- anchors {
- top: parent.top
- right: parent.right
- margins: d.margins
- }
- bgColor: "#212121"
- bgColorSelected: "#757575"
- textColorSelected: "white"
- width: parent.width / 10
- height: d.buttonHeight
- text: "Exit"
- onClicked: Qt.quit()
- }
-
- Row {
- id: modes
- anchors.top: openFile2Button.bottom
- anchors.margins: 0
- anchors.topMargin: 5
- Button {
- width: root.width / 2
- height: 0.8 * d.itemHeight
- bgColor: "#212121"
- radius: 0
- text: "Video Modes"
- enabled: false
- }
- Button {
- width: root.width / 2
- height: 0.8 * d.itemHeight
- bgColor: "#212121"
- radius: 0
- text: "Camera Modes"
- enabled: false
- }
- }
-
- Rectangle {
- id: divider
- height: 1
- width: parent.width
- color: "black"
- anchors.top: modes.bottom
- }
-
- SceneSelectionPanel {
- id: sceneSelectionPanel
- itemHeight: d.itemHeight
- color: "#212121"
- anchors {
- top: divider.bottom
- left: parent.left
- right: parent.right
- bottom: parent.bottom
- }
- radius: 0
- onSceneSourceChanged: {
- sceneLoader.source = sceneSource
- var scene = null
- var innerVisible = true
- if (sceneSource == "") {
- if (performanceLoader.item)
- performanceLoader.item.videoActive = false
- } else {
- scene = sceneLoader.item
- if (scene) {
- if (scene.contentType === "video" && source1 === "") {
- errorDialog.show("You must first select a video file")
- sceneSource = ""
- } else {
- scene.parent = root
- scene.color = root.bgColor
- scene.buttonHeight = d.buttonHeight
- scene.source1 = source1
- scene.source2 = source2
- scene.volume = volume
- scene.anchors.fill = root
- scene.close.connect(closeScene)
- scene.content.initialize()
- innerVisible = false
- }
- }
- }
- videoFramePaintedConnection.target = scene
- inner.visible = innerVisible
- }
- }
- }
-
- Loader {
- id: sceneLoader
- }
-
- Connections {
- id: videoFramePaintedConnection
- onVideoFramePainted: {
- if (performanceLoader.item)
- performanceLoader.item.videoFramePainted()
- }
- ignoreUnknownSignals: true
- }
-
- FileBrowser {
- id: fileBrowser1
- anchors.fill: root
- onFolderChanged: fileBrowser2.folder = folder
- Component.onCompleted: fileSelected.connect(root.openFile1)
- }
-
- FileBrowser {
- id: fileBrowser2
- anchors.fill: root
- onFolderChanged: fileBrowser1.folder = folder
- Component.onCompleted: fileSelected.connect(root.openFile2)
- }
-
- function openFile1(path) {
- root.source1 = path
- }
-
- function openFile2(path) {
- root.source2 = path
- }
-
- ErrorDialog {
- id: errorDialog
- anchors.fill: root
- dialogWidth: d.itemHeight * 5
- dialogHeight: d.itemHeight * 3
- enabled: false
- }
-
- // Called from main() once root properties have been set
- function init() {
- performanceLoader.init()
- fileBrowser1.folder = videoPath
- fileBrowser2.folder = videoPath
- }
-
- function qmlFramePainted() {
- if (performanceLoader.item)
- performanceLoader.item.qmlFramePainted()
- }
-
- function closeScene() {
- sceneSelectionPanel.sceneSource = ""
- }
-}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.pro b/examples/multimedia/video/qmlvideo/qmlvideo.pro
index dbd3a42a1..b61339264 100644
--- a/examples/multimedia/video/qmlvideo/qmlvideo.pro
+++ b/examples/multimedia/video/qmlvideo/qmlvideo.pro
@@ -7,15 +7,88 @@ android: qtHaveModule(androidextras) {
DEFINES += REQUEST_PERMISSIONS_ON_ANDROID
}
-LOCAL_SOURCES = main.cpp
-LOCAL_HEADERS = trace.h
+DEFINES += \
+ FREQUENCYMONITOR_SUPPORT \
+ PERFORMANCEMONITOR_SUPPORT
-SOURCES += $$LOCAL_SOURCES
-HEADERS += $$LOCAL_HEADERS
-RESOURCES += qmlvideo.qrc
+SOURCES += \
+ frequencymonitor.cpp \
+ frequencymonitordeclarative.cpp \
+ main.cpp \
+ performancemonitor.cpp \
+ performancemonitordeclarative.cpp \
+ qmlvideo/videosingleton.cpp
-SNIPPETS_PATH = ../snippets
-include($$SNIPPETS_PATH/performancemonitor/performancemonitordeclarative.pri)
+INCLUDEPATH += qmlvideo
+
+DEFINES += QMLVIDEO_LIB
+
+HEADERS += \
+ frequencymonitor.h \
+ performancemonitor.h \
+ performancemonitordeclarative.h \
+ trace.h \
+ qmlvideo/videosingleton.h
+
+resources.files = \
+ frequencymonitor/FrequencyItem.qml \
+ frequencymonitor/qmldir \
+ performancemonitor/PerformanceItem.qml \
+ performancemonitor/qmldir \
+ qmlvideo/CameraBasic.qml \
+ qmlvideo/CameraDrag.qml \
+ qmlvideo/CameraDummy.qml \
+ qmlvideo/CameraFullScreen.qml \
+ qmlvideo/CameraFullScreenInverted.qml \
+ qmlvideo/CameraItem.qml \
+ qmlvideo/CameraMove.qml \
+ qmlvideo/CameraOverlay.qml \
+ qmlvideo/CameraResize.qml \
+ qmlvideo/CameraRotate.qml \
+ qmlvideo/CameraSpin.qml \
+ qmlvideo/Content.qml \
+ qmlvideo/ErrorDialog.qml \
+ qmlvideo/Main.qml \
+ qmlvideo/Scene.qml \
+ qmlvideo/SceneBasic.qml \
+ qmlvideo/SceneDrag.qml \
+ qmlvideo/SceneFullScreen.qml \
+ qmlvideo/SceneFullScreenInverted.qml \
+ qmlvideo/SceneMove.qml \
+ qmlvideo/SceneMulti.qml \
+ qmlvideo/SceneOverlay.qml \
+ qmlvideo/SceneResize.qml \
+ qmlvideo/SceneRotate.qml \
+ qmlvideo/SceneSelectionPanel.qml \
+ qmlvideo/SceneSpin.qml \
+ qmlvideo/SeekControl.qml \
+ qmlvideo/VideoBasic.qml \
+ qmlvideo/VideoDrag.qml \
+ qmlvideo/VideoDummy.qml \
+ qmlvideo/VideoFillMode.qml \
+ qmlvideo/VideoFullScreen.qml \
+ qmlvideo/VideoFullScreenInverted.qml \
+ qmlvideo/VideoItem.qml \
+ qmlvideo/VideoMetadata.qml \
+ qmlvideo/VideoMove.qml \
+ qmlvideo/VideoOverlay.qml \
+ qmlvideo/VideoPlaybackRate.qml \
+ qmlvideo/VideoResize.qml \
+ qmlvideo/VideoRotate.qml \
+ qmlvideo/VideoSeek.qml \
+ qmlvideo/VideoSpin.qml \
+ qmlvideo/images/folder.png \
+ qmlvideo/images/leaves.jpg \
+ qmlvideo/images/up.png \
+ qmlvideo/qmldir
+
+resources.prefix = /qt/qml/
+
+RESOURCES += resources
+
+CONFIG += qmltypes
+QML_IMPORT_NAME = qmlvideo
+QML_IMPORT_MAJOR_VERSION = 1
target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideo
INSTALLS += target
@@ -23,3 +96,4 @@ INSTALLS += target
EXAMPLE_FILES += \
qmlvideo.png \
qmlvideo.svg
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo.qrc b/examples/multimedia/video/qmlvideo/qmlvideo.qrc
deleted file mode 100644
index 6418215d0..000000000
--- a/examples/multimedia/video/qmlvideo/qmlvideo.qrc
+++ /dev/null
@@ -1,51 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="leaves.jpg">images/leaves.jpg</file>
- <file alias="folder.png">images/folder.png</file>
- <file alias="up.png">images/up.png</file>
- <file>qml/qmlvideo/Button.qml</file>
- <file>qml/qmlvideo/CameraBasic.qml</file>
- <file>qml/qmlvideo/CameraDrag.qml</file>
- <file>qml/qmlvideo/CameraDummy.qml</file>
- <file>qml/qmlvideo/CameraFullScreen.qml</file>
- <file>qml/qmlvideo/CameraFullScreenInverted.qml</file>
- <file>qml/qmlvideo/CameraItem.qml</file>
- <file>qml/qmlvideo/CameraMove.qml</file>
- <file>qml/qmlvideo/CameraOverlay.qml</file>
- <file>qml/qmlvideo/CameraResize.qml</file>
- <file>qml/qmlvideo/CameraRotate.qml</file>
- <file>qml/qmlvideo/CameraSpin.qml</file>
- <file>qml/qmlvideo/Content.qml</file>
- <file>qml/qmlvideo/ErrorDialog.qml</file>
- <file>qml/qmlvideo/FileBrowser.qml</file>
- <file>qml/qmlvideo/main.qml</file>
- <file>qml/qmlvideo/Scene.qml</file>
- <file>qml/qmlvideo/SceneBasic.qml</file>
- <file>qml/qmlvideo/SceneDrag.qml</file>
- <file>qml/qmlvideo/SceneFullScreen.qml</file>
- <file>qml/qmlvideo/SceneFullScreenInverted.qml</file>
- <file>qml/qmlvideo/SceneMove.qml</file>
- <file>qml/qmlvideo/SceneMulti.qml</file>
- <file>qml/qmlvideo/SceneOverlay.qml</file>
- <file>qml/qmlvideo/SceneResize.qml</file>
- <file>qml/qmlvideo/SceneRotate.qml</file>
- <file>qml/qmlvideo/SceneSelectionPanel.qml</file>
- <file>qml/qmlvideo/SceneSpin.qml</file>
- <file>qml/qmlvideo/SeekControl.qml</file>
- <file>qml/qmlvideo/VideoBasic.qml</file>
- <file>qml/qmlvideo/VideoDrag.qml</file>
- <file>qml/qmlvideo/VideoDummy.qml</file>
- <file>qml/qmlvideo/VideoFillMode.qml</file>
- <file>qml/qmlvideo/VideoFullScreen.qml</file>
- <file>qml/qmlvideo/VideoFullScreenInverted.qml</file>
- <file>qml/qmlvideo/VideoItem.qml</file>
- <file>qml/qmlvideo/VideoMetadata.qml</file>
- <file>qml/qmlvideo/VideoMove.qml</file>
- <file>qml/qmlvideo/VideoOverlay.qml</file>
- <file>qml/qmlvideo/VideoPlaybackRate.qml</file>
- <file>qml/qmlvideo/VideoResize.qml</file>
- <file>qml/qmlvideo/VideoRotate.qml</file>
- <file>qml/qmlvideo/VideoSeek.qml</file>
- <file>qml/qmlvideo/VideoSpin.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt b/examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt
new file mode 100644
index 000000000..84a65710e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CMakeLists.txt
@@ -0,0 +1,81 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "This module is part of the 'qmlvideo' example, and should not be built independently.")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/qmlvideo/qmlvideo")
+
+qt_add_qml_module(qmlvideo
+ URI qmlvideo
+ SOURCES
+ videosingleton.cpp
+ videosingleton.h
+ qmlvideo_global.h
+ QML_FILES
+ "CameraBasic.qml"
+ "CameraDrag.qml"
+ "CameraDummy.qml"
+ "CameraFullScreen.qml"
+ "CameraFullScreenInverted.qml"
+ "CameraItem.qml"
+ "CameraMove.qml"
+ "CameraOverlay.qml"
+ "CameraResize.qml"
+ "CameraRotate.qml"
+ "CameraSpin.qml"
+ "Content.qml"
+ "ErrorDialog.qml"
+ "Main.qml"
+ "Scene.qml"
+ "SceneBasic.qml"
+ "SceneDrag.qml"
+ "SceneFullScreen.qml"
+ "SceneFullScreenInverted.qml"
+ "SceneMove.qml"
+ "SceneMulti.qml"
+ "SceneOverlay.qml"
+ "SceneResize.qml"
+ "SceneRotate.qml"
+ "SceneSelectionPanel.qml"
+ "SceneSpin.qml"
+ "SeekControl.qml"
+ "VideoBasic.qml"
+ "VideoDrag.qml"
+ "VideoDummy.qml"
+ "VideoFillMode.qml"
+ "VideoFullScreen.qml"
+ "VideoFullScreenInverted.qml"
+ "VideoItem.qml"
+ "VideoMetadata.qml"
+ "VideoMove.qml"
+ "VideoOverlay.qml"
+ "VideoPlaybackRate.qml"
+ "VideoResize.qml"
+ "VideoRotate.qml"
+ "VideoSeek.qml"
+ "VideoSpin.qml"
+ RESOURCES
+ "images/folder.png"
+ "images/leaves.jpg"
+ "images/up.png"
+)
+
+target_compile_definitions(qmlvideo PRIVATE QMLVIDEO_LIB)
+
+target_link_libraries(qmlvideo PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Quick
+)
+
+install(TARGETS qmlvideo
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml
new file mode 100644
index 000000000..77072c6c9
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraBasic.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneBasic {
+ contentType: "camera"
+ started: true
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml
new file mode 100644
index 000000000..2ea3672c6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDrag.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneDrag {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml
new file mode 100644
index 000000000..c9d14e595
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraDummy.qml
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+// Item which is loaded by CameraItem if Qt Multimedia is not available
+Rectangle {
+ id: root
+ color: "grey"
+ height: width
+
+ signal fatalError
+ signal sizeChanged
+ signal framePainted
+
+ Label {
+ anchors.fill: parent
+ anchors.margins: 10
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("Failed to create Camera item\n\nCheck that Qt Multimedia is installed")
+ verticalAlignment: Text.AlignVCenter
+ wrapMode: Text.Wrap
+ }
+
+ onWidthChanged: height = width
+ onHeightChanged: root.sizeChanged()
+
+ function start() { }
+ function stop() { }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml
new file mode 100644
index 000000000..b204e74ab
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreen.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreen {
+ contentType: "camera"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml
new file mode 100644
index 000000000..ff7a40253
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraFullScreenInverted.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreenInverted {
+ contentType: "camera"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml
new file mode 100644
index 000000000..d6e4b85b5
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraItem.qml
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+
+Item {
+ id: root
+ height: width
+
+ signal fatalError
+ signal sizeChanged
+
+ onHeightChanged: root.sizeChanged()
+
+ CaptureSession {
+ camera: Camera {
+ id: camera
+
+ onErrorOccurred: function(error, errorString) {
+ if (Camera.NoError !== error) {
+ console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
+ root.fatalError()
+ }
+ }
+ }
+ imageCapture: ImageCapture {
+ id: imageCapture
+ }
+
+ recorder: MediaRecorder {
+ id: recorder
+// resolution: "640x480"
+// frameRate: 30
+ }
+ videoOutput: videoOutput
+ }
+
+ VideoOutput {
+ id: videoOutput
+ anchors.fill: parent
+ }
+
+
+ function start() { camera.start() }
+ function stop() { camera.stop() }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml
new file mode 100644
index 000000000..c4c5da914
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraMove.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneMove {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml
new file mode 100644
index 000000000..13136be00
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraOverlay.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneOverlay {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml
new file mode 100644
index 000000000..d89eef3ad
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraResize.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneResize {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml
new file mode 100644
index 000000000..8394fb6fd
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraRotate.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneRotate {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml b/examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml
new file mode 100644
index 000000000..642a0edfd
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/CameraSpin.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneSpin {
+ contentType: "camera"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/Content.qml b/examples/multimedia/video/qmlvideo/qmlvideo/Content.qml
new file mode 100644
index 000000000..b08d19325
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/Content.qml
@@ -0,0 +1,125 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import frequencymonitor
+
+Rectangle {
+ id: root
+ border.color: palette.window
+ border.width: showBorder ? 1 : 0
+ color: "transparent"
+ property string contentType // "camera" or "video"
+ property string source
+ property real volume
+ property bool dummy: false
+ property bool autoStart: true
+ property bool started: false
+ property bool showFrameRate: false
+ property bool showBorder: false
+ property alias contentItem: contentLoader.item
+
+ signal initialized
+ signal error
+ signal videoFramePainted
+
+ Loader {
+ id: contentLoader
+ }
+
+ Connections {
+ id: framePaintedConnection
+ function onFramePainted() {
+ (frameRateLoader.item as FrequencyItem)?.notify()
+ root.videoFramePainted()
+ }
+ ignoreUnknownSignals: true
+ }
+
+ Connections {
+ id: errorConnection
+ function onFatalError() {
+ console.log("[qmlvideo] Content.onFatalError")
+ root.stop()
+ root.error()
+ }
+ ignoreUnknownSignals: true
+ }
+
+ Component {
+ id: frequencyItem
+ FrequencyItem {}
+ }
+
+ Loader {
+ id: frameRateLoader
+ sourceComponent: root.showFrameRate ? frequencyItem : undefined
+ onLoaded: {
+ item.parent = root
+ item.anchors.top = root.top
+ item.anchors.right = root.right
+ item.anchors.margins = 10
+ }
+ }
+
+ onWidthChanged: {
+ if (root.contentItem)
+ root.contentItem.width = width
+ }
+
+ onHeightChanged: {
+ if (root.contentItem)
+ root.contentItem.height = height
+ }
+
+ function initialize() {
+ if ("video" == contentType) {
+ contentLoader.source = "VideoItem.qml"
+ if (Loader.Error == contentLoader.status) {
+ contentLoader.source = "VideoDummy.qml"
+ dummy = true
+ }
+ contentLoader.item.volume = volume
+ } else if ("camera" == contentType) {
+ contentLoader.source = "CameraItem.qml"
+ if (Loader.Error == contentLoader.status) {
+ contentLoader.source = "CameraDummy.qml"
+ dummy = true
+ }
+ } else {
+ console.log("[qmlvideo] Content.initialize: error: invalid contentType")
+ }
+ if (contentLoader.item) {
+ contentLoader.item.sizeChanged.connect(updateRootSize)
+ contentLoader.item.parent = root
+ contentLoader.item.width = root.width
+ framePaintedConnection.target = contentLoader.item
+ errorConnection.target = contentLoader.item
+ if (root.autoStart)
+ root.start()
+ }
+ root.initialized()
+ }
+
+ function start() {
+ if (contentLoader.item) {
+ if (root.contentType == "video")
+ contentLoader.item.mediaSource = root.source
+ contentLoader.item.start()
+ root.started = true
+ }
+ }
+
+ // qmllint disable
+ function stop() {
+ if (contentLoader.item) {
+ contentLoader.item.stop()
+ if (root.contentType == "video")
+ contentLoader.item.mediaSource = ""
+ root.started = false
+ }
+ }
+ // qmllint enable
+
+ function updateRootSize() { root.height = (root.contentItem as Item).height }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml b/examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml
new file mode 100644
index 000000000..f06079a35
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/ErrorDialog.qml
@@ -0,0 +1,70 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ id: root
+ color: "transparent"
+ opacity: 0.0
+ property alias enabled: mouseArea.enabled
+ property int dialogWidth: 300
+ property int dialogHeight: 200
+ state: enabled ? "on" : "baseState"
+
+ states: [
+ State {
+ name: "on"
+ PropertyChanges {
+ root.opacity: 1.0
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: "*"
+ to: "*"
+ NumberAnimation {
+ properties: "opacity"
+ easing.type: Easing.OutQuart
+ duration: 500
+ }
+ }
+ ]
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ opacity: 0.75
+ }
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: root.dialogWidth
+ height: root.dialogHeight
+ radius: 5
+ color: "white"
+
+ Text {
+ id: text
+ anchors.fill: parent
+ anchors.margins: 10
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "black"
+ wrapMode: Text.WordWrap
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: root.enabled = false
+ }
+
+ function show(msg) {
+ text.text = "<b>Error</b><br><br>" + msg
+ root.enabled = true
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/Main.qml b/examples/multimedia/video/qmlvideo/qmlvideo/Main.qml
new file mode 100644
index 000000000..49b94590c
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/Main.qml
@@ -0,0 +1,188 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtQuick.Dialogs
+import performancemonitor
+
+Rectangle {
+ id: root
+ anchors.fill: parent
+ color: palette.window
+
+ property bool perfMonitorsLogging: false
+ property bool perfMonitorsVisible: false
+
+ Loader {
+ id: performanceLoader
+
+ Connections {
+ target: columnLayout
+ function onVisibleChanged() {
+ if (performanceLoader.item)
+ performanceLoader.item.enabled = !columnLayout.visible
+ }
+ ignoreUnknownSignals: true
+ }
+
+ Component {
+ id: performanceItem
+ PerformanceItem {}
+ }
+
+ function init() {
+ var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
+ sourceComponent = enabled ? performanceItem : undefined
+ }
+
+ onLoaded: {
+ item.parent = root
+ item.anchors.fill = root
+ item.logging = root.perfMonitorsLogging
+ item.displayed = root.perfMonitorsVisible
+ item.enabled = false
+ item.init()
+ }
+ }
+
+ ColumnLayout {
+ id: columnLayout
+ anchors.fill: parent
+ spacing: 5
+
+ Button {
+ id: openFile1Button
+ text: (VideoSingleton.source1 == '') ? qsTr("Select file 1") : VideoSingleton.source1
+ Component.onCompleted: console.log("source1: " + VideoSingleton.source1)
+ onClicked: {
+ fileDialog.setFirstSource = true
+ fileDialog.open()
+ }
+
+ Layout.fillWidth: true
+ }
+
+ Button {
+ id: openFile2Button
+ text: (VideoSingleton.source2 == '') ? qsTr("Select file 2") : VideoSingleton.source2
+ Component.onCompleted: console.log("source2: " + VideoSingleton.source2)
+ onClicked: {
+ fileDialog.setFirstSource = false
+ fileDialog.open()
+ }
+
+ Layout.fillWidth: true
+ }
+
+ RowLayout {
+ Layout.fillWidth: true
+
+ Label {
+ text: qsTr("Video Modes")
+
+ horizontalAlignment: Qt.AlignHCenter
+ Layout.preferredWidth: 50
+ Layout.fillWidth: true
+ }
+ Label {
+ text: qsTr("Camera Modes")
+
+ horizontalAlignment: Qt.AlignHCenter
+ Layout.preferredWidth: 50
+ Layout.fillWidth: true
+ }
+ }
+
+ SceneSelectionPanel {
+ id: sceneSelectionPanel
+ itemHeight: Math.min(width / 10, height / 10)
+ color: palette.dark
+ radius: 0
+ onSceneSourceChanged: {
+ sceneLoader.source = sceneSource
+ var scene = null
+ var innerVisible = true
+ if (sceneSource == "") {
+ if (performanceLoader.item)
+ performanceLoader.item.videoActive = false
+ } else {
+ scene = sceneLoader.item
+ if (scene) {
+ if (scene.contentType === "video" && VideoSingleton.source1 === "") {
+ errorDialog.show(qsTr("You must first select a video file"))
+ sceneSource = ""
+ } else {
+ scene.parent = root
+ scene.color = root.palette.window
+ scene.source1 = VideoSingleton.source1
+ scene.source2 = VideoSingleton.source2
+ scene.volume = VideoSingleton.volume
+ scene.anchors.fill = root
+ scene.close.connect(closeScene)
+ scene.content.initialize()
+ innerVisible = false
+ }
+ }
+ }
+ videoFramePaintedConnection.target = scene
+ columnLayout.visible = innerVisible
+ }
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+
+ Loader {
+ id: sceneLoader
+ }
+
+ Connections {
+ id: videoFramePaintedConnection
+ // qmllint disable
+ function onVideoFramePainted() {
+ if (performanceLoader.item)
+ performanceLoader.item.videoFramePainted()
+ }
+ // qmllint enable
+ ignoreUnknownSignals: true
+ }
+
+ FileDialog {
+ id: fileDialog
+ property bool setFirstSource
+ onAccepted: function() {
+ if (setFirstSource)
+ VideoSingleton.source1 = selectedFile
+ else
+ VideoSingleton.source2 = selectedFile
+ }
+ }
+
+ ErrorDialog {
+ id: errorDialog
+ anchors.fill: root
+ dialogWidth: Math.min(root.width, root.height) * 0.5
+ dialogHeight: Math.min(root.width, root.height) * 0.3
+ enabled: false
+ }
+
+ // Called from main() once root properties have been set
+ function init() {
+ performanceLoader.init()
+ fileDialog.currentFolder = VideoSingleton.videoPath
+ }
+
+ // qmllint disable
+ function qmlFramePainted() {
+ if (performanceLoader.item)
+ performanceLoader.item.qmlFramePainted()
+ }
+ // qmllint enable
+
+ function closeScene() {
+ sceneSelectionPanel.sceneSource = ""
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml b/examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml
new file mode 100644
index 000000000..e16478d41
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/Scene.qml
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Rectangle {
+ id: root
+ color: palette.window
+ property string source1
+ property string source2
+ property int contentWidth: parent.width / 2
+ property real volume: 0.25
+ property int margins: 5
+ property QtObject content
+
+ signal close
+ signal videoFramePainted
+
+ Button {
+ id: closeButton
+ anchors {
+ top: parent.top
+ right: parent.right
+ margins: root.margins
+ }
+ z: 2.0
+ text: qsTr("Back")
+ onClicked: root.close()
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml
new file mode 100644
index 000000000..8ad6c99b8
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneBasic.qml
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property string contentType
+ property bool autoStart: false
+ property bool started: false
+
+ Content {
+ id: content
+ autoStart: parent.autoStart
+ started: parent.started
+ anchors.fill: parent
+ width: parent.contentWidth
+ contentType: parent.contentType
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Label {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ margins: 20
+ }
+ text: content.started ? qsTr("Tap the screen to stop content")
+ : qsTr("Tap the screen to start content")
+ z: 2.0
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (content.started)
+ content.stop()
+ else
+ content.start()
+ }
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml
new file mode 100644
index 000000000..99a7cb7f1
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneDrag.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Image {
+ id: background
+ source: "images/leaves.jpg"
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: root.contentWidth
+ contentType: root.contentType
+ source: root.source1
+ volume: root.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: background
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml
new file mode 100644
index 000000000..ec8564311
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreen.qml
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ state: "left"
+
+ states: [
+ State {
+ name: "fullScreen"
+ PropertyChanges {
+ content.width: content.parent.width
+ content.height: content.parent.height
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParallelAnimation {
+ PropertyAnimation {
+ property: "width"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ PropertyAnimation {
+ property: "height"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ }
+ }
+ ]
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: content.state = (content.state == "fullScreen") ? "baseState" : "fullScreen"
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Label {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ margins: 20
+ }
+ text: qsTr("Tap on the content to toggle full-screen mode")
+ z: 2.0
+ }
+
+ Component.onCompleted: root.content = content
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml
new file mode 100644
index 000000000..cb96ac134
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneFullScreenInverted.qml
@@ -0,0 +1,70 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.width
+ height: parent.height
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ state: "left"
+
+ states: [
+ State {
+ name: "nonFullScreen"
+ PropertyChanges { content.width: root.contentWidth }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ ParallelAnimation {
+ PropertyAnimation {
+ property: "width"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ PropertyAnimation {
+ property: "height"
+ easing.type: Easing.Linear
+ duration: 250
+ }
+ }
+ }
+ ]
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: content.state = (content.state === "nonFullScreen") ? "baseState" : "nonFullScreen"
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+
+ onInitialized: {
+ width = parent.width
+ height = parent.height
+ }
+ }
+
+ Label {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ margins: 20
+ }
+ text: qsTr("Tap on the content to toggle full-screen mode")
+ z: 2.0
+ }
+
+ Component.onCompleted: root.content = content
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml
new file mode 100644
index 000000000..d1512831e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMove.qml
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Content {
+ id: content
+ anchors.verticalCenter: parent.verticalCenter
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+
+ SequentialAnimation on x {
+ id: animation
+ loops: Animation.Infinite
+ property int from: root.margin
+ property int to: 100
+ property int duration: 1500
+ running: false
+ PropertyAnimation {
+ from: animation.from
+ to: animation.to
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: animation.to
+ to: animation.from
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ onWidthChanged: {
+ animation.to = root.width - content.width - margin
+ animation.start()
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMulti.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMulti.qml
index 01d82ac33..f93dabcdd 100644
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SceneMulti.qml
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneMulti.qml
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
Scene {
id: root
@@ -71,28 +25,30 @@ Scene {
id: root
color: "transparent"
- function content() {
- return root.parent
- }
+ signal start
+ signal stop
- Text {
+ Label {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
margins: 20
}
- text: content() ? content().started ? "Tap to stop" : "Tap to start" : ""
- color: "#e0e0e0"
+ // qmllint disable
+ text: root.started ? qsTr("Tap to stop") : qsTr("Tap to start")
+ // qmllint enable
}
MouseArea {
anchors.fill: parent
+ // qmllint disable
onClicked: {
- if (content().started)
- content().stop()
+ if (root.started)
+ root.stop()
else
- content().start()
+ root.start()
}
+ // qmllint enable
}
}
}
@@ -110,14 +66,19 @@ Scene {
showBorder: true
showFrameRate: started
source: parent.source1
- width: itemWidth
+ width: root.itemWidth
volume: parent.volume
Loader {
id: video1StartStopLoader
+
+ property bool started: parent.started
+
onLoaded: {
item.parent = video1
item.anchors.fill = video1
+ item.start.connect(video1.start)
+ item.stop.connect(video1.stop)
}
}
@@ -126,26 +87,28 @@ Scene {
Rectangle {
id: cameraHolder
+
+ property bool started: false
+
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: root.itemTopMargin
}
border.width: 1
- border.color: "white"
+ border.color: palette.base
color: "transparent"
- width: itemWidth
+ width: root.itemWidth
height: width
- property bool started: false
Loader {
id: cameraLoader
onLoaded: {
item.parent = cameraHolder
- item.centerIn = cameraHolder
+ item.anchors.centerIn = cameraHolder
item.contentType = "camera"
item.showFrameRate = true
- item.width = itemWidth
+ item.width = root.itemWidth
item.z = 1.0
cameraErrorConnection.target = item
item.initialize()
@@ -154,20 +117,26 @@ Scene {
Loader {
id: cameraStartStopLoader
+
+ property bool started: parent.started
+
sourceComponent: startStopComponent
onLoaded: {
item.parent = cameraHolder
item.anchors.fill = cameraHolder
item.z = 2.0
+ item.start.connect(cameraHolder.start)
+ item.stop.connect(cameraHolder.stop)
}
}
Connections {
id: cameraErrorConnection
- onError: {
+ function onError() {
console.log("[qmlvideo] SceneMulti.camera.onError")
cameraHolder.stop()
}
+ ignoreUnknownSignals: true
}
function start() {
@@ -194,14 +163,19 @@ Scene {
showBorder: true
showFrameRate: started
source: parent.source2
- width: itemWidth
+ width: root.itemWidth
volume: parent.volume
Loader {
id: video2StartStopLoader
+
+ property bool started: parent.started
+
onLoaded: {
item.parent = video2
item.anchors.fill = video2
+ item.start.connect(video2.start)
+ item.stop.connect(video2.stop)
}
}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml
new file mode 100644
index 000000000..5863d618c
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneOverlay.qml
@@ -0,0 +1,83 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Rectangle {
+ id: overlay
+ y: 0.5 * parent.height
+ width: content.width
+ height: content.height
+ color: "#e0e0e0"
+ opacity: 0.5
+
+ SequentialAnimation on x {
+ id: xAnimation
+ loops: Animation.Infinite
+ property int from: root.margin
+ property int to: 100
+ property int duration: 1500
+ running: false
+ PropertyAnimation {
+ from: xAnimation.from
+ to: xAnimation.to
+ duration: xAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: xAnimation.to
+ to: xAnimation.from
+ duration: xAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ SequentialAnimation on y {
+ id: yAnimation
+ loops: Animation.Infinite
+ property int from: root.margin
+ property int to: 180
+ property int duration: 1500
+ running: false
+ PropertyAnimation {
+ from: yAnimation.from
+ to: yAnimation.to
+ duration: yAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: yAnimation.to
+ to: yAnimation.from
+ duration: yAnimation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+ }
+
+ onWidthChanged: {
+ xAnimation.to = root.width - content.width - margin
+ xAnimation.start()
+ }
+
+ onHeightChanged: {
+ //yAnimation.to = root.height - content.height - margin
+ yAnimation.start()
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml
new file mode 100644
index 000000000..4e2f15588
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneResize.qml
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+
+ SequentialAnimation on scale {
+ id: animation
+ loops: Animation.Infinite
+ property int duration: 1500
+ running: true
+ PropertyAnimation {
+ from: 1.5
+ to: 0.5
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ PropertyAnimation {
+ from: 0.5
+ to: 1.5
+ duration: animation.duration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml
new file mode 100644
index 000000000..1362522e6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneRotate.qml
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property int margin: 20
+ property int delta: 30
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Button {
+ id: rotatePositiveButton
+ anchors {
+ right: parent.right
+ bottom: rotateNegativeButton.top
+ margins: parent.margins
+ }
+ text: qsTr("Rotate +%1").arg(root.delta)
+ onClicked: content.rotation = content.rotation + root.delta
+ }
+
+ Button {
+ id: rotateNegativeButton
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ text: qsTr("Rotate -%1").arg(root.delta)
+ onClicked: content.rotation = content.rotation - root.delta
+ }
+
+ Button {
+ id: rotateValueButton
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ enabled: false
+ text: content.rotation % 360
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml
new file mode 100644
index 000000000..91e7c6ad4
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSelectionPanel.qml
@@ -0,0 +1,88 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+pragma ComponentBehavior: Bound
+
+Rectangle {
+ id: root
+ property int itemHeight: 25
+ property string sceneSource: ""
+
+ ListModel {
+ id: videolist
+ ListElement { name: qsTr("Multi"); source: "SceneMulti.qml" }
+ ListElement { name: qsTr("Video"); source: "VideoBasic.qml" }
+ ListElement { name: qsTr("Drag"); source: "VideoDrag.qml" }
+ ListElement { name: qsTr("Fillmode"); source: "VideoFillMode.qml" }
+ ListElement { name: qsTr("Fullscreen"); source: "VideoFullScreen.qml" }
+ ListElement { name: qsTr("Fullscreen-inverted"); source: "VideoFullScreenInverted.qml" }
+ ListElement { name: qsTr("Metadata"); source: "VideoMetadata.qml" }
+ ListElement { name: qsTr("Move"); source: "VideoMove.qml" }
+ ListElement { name: qsTr("Overlay"); source: "VideoOverlay.qml" }
+ ListElement { name: qsTr("Playback Rate"); source: "VideoPlaybackRate.qml" }
+ ListElement { name: qsTr("Resize"); source: "VideoResize.qml" }
+ ListElement { name: qsTr("Rotate"); source: "VideoRotate.qml" }
+ ListElement { name: qsTr("Spin"); source: "VideoSpin.qml" }
+ ListElement { name: qsTr("Seek"); source: "VideoSeek.qml" }
+ }
+
+ ListModel {
+ id: cameralist
+ ListElement { name: qsTr("Camera"); source: "CameraBasic.qml" }
+ ListElement { name: qsTr("Drag"); source: "CameraDrag.qml" }
+ ListElement { name: qsTr("Fullscreen"); source: "CameraFullScreen.qml" }
+ ListElement { name: qsTr("Fullscreen-inverted"); source: "CameraFullScreenInverted.qml" }
+ ListElement { name: qsTr("Move"); source: "CameraMove.qml" }
+ ListElement { name: qsTr("Overlay"); source: "CameraOverlay.qml" }
+ ListElement { name: qsTr("Resize"); source: "CameraResize.qml" }
+ ListElement { name: qsTr("Rotate"); source: "CameraRotate.qml" }
+ ListElement { name: qsTr("Spin"); source: "CameraSpin.qml" }
+ }
+
+ Component {
+ id: buttonDelegate
+ Button {
+ required property string name
+ required property string source
+
+ width: root.width / 2
+ height: root.itemHeight
+
+ text: name
+ padding: 3
+ onClicked: root.sceneSource = source
+ }
+ }
+
+ Flickable {
+ anchors.fill: parent
+ contentHeight: (root.itemHeight * videolist.count) + 10
+ clip: true
+
+ Row {
+ id: layout
+ anchors {
+ fill: parent
+ topMargin: 5
+ bottomMargin: 5
+ }
+
+ Column {
+ Repeater {
+ model: videolist
+ delegate: buttonDelegate
+ }
+ }
+
+ Column {
+ Repeater {
+ model: cameralist
+ delegate: buttonDelegate
+ }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml
new file mode 100644
index 000000000..3e280d3b1
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SceneSpin.qml
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property int margin: 20
+ property string contentType
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: root.contentType
+ source: parent.source1
+ volume: parent.volume
+
+ PropertyAnimation on rotation {
+ id: animation
+ loops: Animation.Infinite
+ running: true
+ from: 0
+ to: 360
+ duration: 3000
+ easing.type: Easing.Linear
+ }
+
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SeekControl.qml b/examples/multimedia/video/qmlvideo/qmlvideo/SeekControl.qml
index fbba32903..646e5e8ef 100644
--- a/examples/multimedia/video/qmlvideo/qml/qmlvideo/SeekControl.qml
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/SeekControl.qml
@@ -1,54 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
+import QtQuick
Item {
id: seekControl
@@ -62,7 +15,7 @@ Item {
Rectangle {
id: background
anchors.fill: parent
- color: "white"
+ color: palette.base
opacity: 0.3
radius: parent.height / 15
}
@@ -71,7 +24,7 @@ Item {
id: progressBar
anchors { left: parent.left; top: parent.top; bottom: parent.bottom }
width: seekControl.duration == 0 ? 0 : background.width * seekControl.playPosition / seekControl.duration
- color: "black"
+ color: palette.highlight
opacity: 0.7
}
@@ -80,9 +33,9 @@ Item {
anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 10 }
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
- color: "white"
+ color: palette.windowText
smooth: true
- text: formatTime(playPosition)
+ text: seekControl.formatTime(seekControl.playPosition)
}
Text {
@@ -90,16 +43,16 @@ Item {
anchors { right: parent.right; top: parent.top; bottom: parent.bottom; rightMargin: 10 }
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
- color: "white"
+ color: palette.windowText
smooth: true
- text: formatTime(duration)
+ text: seekControl.formatTime(seekControl.duration)
}
Rectangle {
id: progressHandle
height: parent.height
width: parent.height / 2
- color: "white"
+ color: palette.accent
opacity: 0.5
anchors.verticalCenter: progressBar.verticalCenter
x: seekControl.duration == 0 ? 0 : seekControl.playPosition / seekControl.duration * background.width
@@ -123,7 +76,7 @@ Item {
seekControl.seekPosition = progressHandle.x * seekControl.duration / background.width
seekControl.seeking = false
}
- onReleased: {
+ onReleased: (mouse) => {
seekControl.seekPosition = progressHandle.x * seekControl.duration / background.width
seekControl.seeking = false
mouse.accepted = true
@@ -143,8 +96,8 @@ Item {
function formatTime(timeInMs) {
if (!timeInMs || timeInMs <= 0) return "0:00"
- var seconds = timeInMs / 1000;
- var minutes = Math.floor(seconds / 60)
+ let seconds = timeInMs / 1000;
+ let minutes = Math.floor(seconds / 60)
seconds = Math.floor(seconds % 60)
if (seconds < 10) seconds = "0" + seconds;
return minutes + ":" + seconds
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml
new file mode 100644
index 000000000..15c25c978
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoBasic.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneBasic {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml
new file mode 100644
index 000000000..4a5c5d49b
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDrag.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneDrag {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml
new file mode 100644
index 000000000..a30b9ebf6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoDummy.qml
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+// Item which is loaded by VideoItem if Qt Multimedia is not available
+Rectangle {
+ id: root
+ color: "grey"
+ height: width
+ property int duration: 0
+ property int position: 0
+ property string source
+ property real volume: 1.0
+ property real playbackRate: 1.0
+
+ signal fatalError
+ signal sizeChanged
+ signal framePainted
+
+ Label {
+ anchors.fill: parent
+ anchors.margins: 10
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("Failed to create Video item\n\nCheck that Qt Multimedia is installed")
+ verticalAlignment: Text.AlignVCenter
+ wrapMode: Text.Wrap
+ }
+
+ onWidthChanged: height = width
+ onHeightChanged: root.sizeChanged()
+
+ function start() { }
+ function stop() { }
+ function seek() { }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml
new file mode 100644
index 000000000..af950c735
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFillMode.qml
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Scene {
+ id: root
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Button {
+ id: button
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ text: qsTr("PreserveAspectFit")
+ // qmllint disable
+ onClicked: {
+ if (!content.dummy) {
+ let video = content.contentItem
+ if (video.fillMode === VideoOutput.Stretch) {
+ video.fillMode = VideoOutput.PreserveAspectFit
+ text = qsTr("PreserveAspectFit")
+ } else if (video.fillMode === VideoOutput.PreserveAspectFit) {
+ video.fillMode = VideoOutput.PreserveAspectCrop
+ text = qsTr("PreserveAspectCrop")
+ } else {
+ video.fillMode = VideoOutput.Stretch
+ text = qsTr("Stretch")
+ }
+ }
+ }
+ // qmllint enable
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml
new file mode 100644
index 000000000..e49faadb6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreen.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreen {
+ contentType: "video"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml
new file mode 100644
index 000000000..0bf82941e
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoFullScreenInverted.qml
@@ -0,0 +1,7 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneFullScreenInverted {
+ contentType: "video"
+}
+
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml
new file mode 100644
index 000000000..2ea796de8
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoItem.qml
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+
+VideoOutput {
+ id: root
+ height: width
+
+ property alias duration: mediaPlayer.duration
+ property alias mediaSource: mediaPlayer.source
+ property alias metaData: mediaPlayer.metaData
+ property alias playbackRate: mediaPlayer.playbackRate
+ property alias position: mediaPlayer.position
+ property alias seekable: mediaPlayer.seekable
+ property alias volume: audioOutput.volume
+
+ signal sizeChanged
+ signal fatalError
+
+ onHeightChanged: root.sizeChanged()
+
+ MediaPlayer {
+ id: mediaPlayer
+ videoOutput: root;
+ audioOutput: AudioOutput {
+ id: audioOutput
+ }
+
+ onErrorOccurred: function(error, errorString) {
+ if (MediaPlayer.NoError !== error) {
+ console.log("[qmlvideo] VideoItem.onError error " + error + " errorString " + errorString)
+ root.fatalError()
+ }
+ }
+ }
+
+ function start() { mediaPlayer.play() }
+ function stop() { mediaPlayer.stop() }
+ function seek(position) { mediaPlayer.setPosition(position); }
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml
new file mode 100644
index 000000000..f83cbffe9
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMetadata.qml
@@ -0,0 +1,80 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+pragma ComponentBehavior: Bound
+
+Scene {
+ id: root
+ property string contentType: "video"
+
+ Content {
+ id: videoContent
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onInitialized: {
+ if (!dummy)
+ metadata.createObject(root)
+ }
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Component {
+ id: metadata
+ Column {
+ anchors.fill: parent
+ // qmllint disable
+ property var videoMetaData: videoContent.contentItem?.metaData
+ // qmllint enable
+ Label {
+ text: qsTr("Title: %1").arg(parent.videoMetaData?.value(MediaMetaData.Title) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Resolution: %1").arg(parent.videoMetaData?.value(MediaMetaData.Resolution) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Media type: %1").arg(parent.videoMetaData?.value(MediaMetaData.MediaType) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Video codec: %1").arg(parent.videoMetaData?.value(MediaMetaData.VideoCodec) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Video bit rate: %1").arg(parent.videoMetaData?.value(MediaMetaData.VideoBitRate) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Video frame rate: %1").arg(parent.videoMetaData?.value(MediaMetaData.VideoFrameRate) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Audio codec: %1").arg(parent.videoMetaData?.value(MediaMetaData.AudioCodec) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Audio bit rate: %1").arg(parent.videoMetaData?.value(MediaMetaData.AudioBitRate) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Date: %1").arg(parent.videoMetaData?.value(MediaMetaData.Date) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Description: %1").arg(parent.videoMetaData?.value(MediaMetaData.Description) ?? qsTr("Unknown"))
+ }
+ Label {
+ text: qsTr("Copyright: %1").arg(parent.videoMetaData?.value(MediaMetaData.Copyright) ?? qsTr("Unknown"))
+ }
+ Label {
+ // qmllint disable
+ text: qsTr("Seekable: %1").arg(videoContent.contentItem?.seekable ?? qsTr("Unknown"))
+ // qmllint enable
+ }
+ Label {
+ text: qsTr("Orientation: %1").arg(parent.videoMetaData?.value(MediaMetaData.Orientation) ?? qsTr("Unknown"))
+ }
+ }
+ }
+
+ Component.onCompleted: root.content = videoContent
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml
new file mode 100644
index 000000000..2b9230f3c
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoMove.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneMove {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml
new file mode 100644
index 000000000..576b33ff9
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoOverlay.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneOverlay {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml
new file mode 100644
index 000000000..55e38ef19
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoPlaybackRate.qml
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Scene {
+ id: root
+ property int margin: 20
+ property real delta: 0.1
+ property string contentType: "video"
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ Button {
+ id: increaseButton
+ anchors {
+ right: parent.right
+ bottom: decreaseButton.top
+ margins: parent.margins
+ }
+ text: qsTr("Increase")
+ onClicked: {
+ let video = (content.contentItem as VideoItem)
+ video.playbackRate += root.delta
+ }
+ }
+
+ Button {
+ id: decreaseButton
+ anchors {
+ right: parent.right
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ text: qsTr("Decrease")
+ onClicked: {
+ let video = (content.contentItem as VideoItem)
+ video.playbackRate -= root.delta
+ }
+ }
+
+ Button {
+ id: valueButton
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ margins: parent.margins
+ }
+ enabled: false
+ // qmllint disable
+ text: Math.round(10 * content.contentItem?.playbackRate ?? 1) / 10
+ // qmllint enable
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml
new file mode 100644
index 000000000..88fe7a2d2
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoResize.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneResize {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml
new file mode 100644
index 000000000..d429ec413
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoRotate.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneRotate {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml
new file mode 100644
index 000000000..5e2584fb6
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSeek.qml
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Scene {
+ id: root
+ property string contentType: "video"
+ contentWidth: parent.width
+
+ Content {
+ id: content
+ anchors.centerIn: parent
+ width: parent.contentWidth
+ contentType: "video"
+ source: parent.source1
+ volume: parent.volume
+ onVideoFramePainted: root.videoFramePainted()
+ }
+
+ SeekControl {
+ anchors {
+ left: parent.left
+ right: parent.right
+ margins: 10
+ bottom: parent.bottom
+ }
+ // qmllint disable
+ duration: content.contentItem?.duration ?? 0
+ playPosition: content.contentItem?.position ?? 0
+ onSeekPositionChanged: content.contentItem?.seek(seekPosition);
+ // qmllint enable
+ }
+
+ Component.onCompleted: root.content = content
+}
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml
new file mode 100644
index 000000000..7c365ddc7
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/VideoSpin.qml
@@ -0,0 +1,6 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+SceneSpin {
+ contentType: "video"
+}
diff --git a/examples/multimedia/video/qmlvideo/images/folder.png b/examples/multimedia/video/qmlvideo/qmlvideo/images/folder.png
index 62d97004f..62d97004f 100644
--- a/examples/multimedia/video/qmlvideo/images/folder.png
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/images/folder.png
Binary files differ
diff --git a/examples/multimedia/video/qmlvideo/images/leaves.jpg b/examples/multimedia/video/qmlvideo/qmlvideo/images/leaves.jpg
index 66533b34a..66533b34a 100644
--- a/examples/multimedia/video/qmlvideo/images/leaves.jpg
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/images/leaves.jpg
Binary files differ
diff --git a/examples/multimedia/video/qmlvideo/images/up.png b/examples/multimedia/video/qmlvideo/qmlvideo/images/up.png
index 6823de004..6823de004 100644
--- a/examples/multimedia/video/qmlvideo/images/up.png
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/images/up.png
Binary files differ
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/qmldir b/examples/multimedia/video/qmlvideo/qmlvideo/qmldir
new file mode 100644
index 000000000..1cba13d95
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/qmldir
@@ -0,0 +1,44 @@
+module qmlvideo
+
+CameraBasic 1.0 CameraBasic.qml
+CameraDrag 1.0 CameraDrag.qml
+CameraDummy 1.0 CameraDummy.qml
+CameraFullScreen 1.0 CameraFullScreen.qml
+CameraFullScreenInverted 1.0 CameraFullScreenInverted.qml
+CameraItem 1.0 CameraItem.qml
+CameraMove 1.0 CameraMove.qml
+CameraOverlay 1.0 CameraOverlay.qml
+CameraResize 1.0 CameraResize.qml
+CameraRotate 1.0 CameraRotate.qml
+CameraSpin 1.0 CameraSpin.qml
+CameraContent 1.0 Content.qml
+ErrorDialog 1.0 ErrorDialog.qml
+Scene 1.0 Scene.qml
+SceneBasic 1.0 SceneBasic.qml
+SceneDrag 1.0 SceneDrag.qml
+SceneFullScreen 1.0 SceneFullScreen.qml
+SceneFullScreeninverted 1.0 SceneFullScreenInverted.qml
+SceneMoved 1.0 SceneMove.qml
+SceneMulti 1.0 SceneMulti.qml
+SceneOverlay 1.0 SceneOverlay.qml
+SceneResize 1.0 SceneResize.qml
+SceneRotate 1.0 SceneRotate.qml
+SceneSelectionPanel 1.0 SceneSelectionPanel.qml
+SceneSpin 1.0 SceneSpin.qml
+SeekControl 1.0 SeekControl.qml
+VideoBasic 1.0 VideoBasic.qml
+VideoDrag 1.0 VideoDrag.qml
+VideoDummy 1.0 VideoDummy.qml
+VideoFillMode 1.0 VideoFillMode.qml
+VideoFullScreen 1.0 VideoFullScreen.qml
+VideoFullScreenInverted 1.0 VideoFullScreenInverted.qml
+VideoItem 1.0 VideoItem.qml
+VideoMetadata 1.0 VideoMetadata.qml
+VideoMove 1.0 VideoMove.qml
+VideoOverlay 1.0 VideoOverlay.qml
+VideoPlaybackRate 1.0 VideoPlaybackRate.qml
+VideoResize 1.0 VideoResize.qml
+VideoRotate 1.0 VideoRotate.qml
+VideoSeek 1.0 VideoSeek.qml
+VideoSpin 1.0 VideoSpin.qml
+Main 1.0 Main.qml
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h b/examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h
new file mode 100644
index 000000000..8df5b5b64
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/qmlvideo_global.h
@@ -0,0 +1,10 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/QtGlobal>
+
+#if defined(QMLVIDEO_LIB)
+#define QMLVIDEO_LIB_EXPORT Q_DECL_EXPORT
+#else
+#define QMLVIDEO_LIB_EXPORT Q_DECL_IMPORT
+#endif
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp
new file mode 100644
index 000000000..2b02fa505
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.cpp
@@ -0,0 +1,54 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videosingleton.h"
+
+VideoSingleton::VideoSingleton(QObject * parent) : QObject(parent)
+{ }
+
+QUrl VideoSingleton::source1() const
+{
+ return m_source1;
+}
+void VideoSingleton::setSource1(const QUrl &source1)
+{
+ if (source1 == m_source1)
+ return;
+ m_source1 = source1;
+ emit source1Changed();
+}
+QUrl VideoSingleton::source2() const
+{
+ return m_source2;
+}
+void VideoSingleton::setSource2(const QUrl &source2)
+{
+ if (source2 == m_source2)
+ return;
+ m_source2 = source2;
+ emit source2Changed();
+}
+qreal VideoSingleton::volume() const
+{
+ return m_volume;
+}
+void VideoSingleton::setVolume(qreal volume)
+{
+ if (volume == m_volume)
+ return;
+ m_volume = volume;
+ emit volumeChanged();
+}
+QUrl VideoSingleton::videoPath() const
+{
+ return m_videoPath;
+}
+void VideoSingleton::setVideoPath(const QUrl &videoPath)
+{
+ if (m_videoPath == videoPath)
+ return;
+ m_videoPath = videoPath;
+ emit videoPathChanged();
+}
+
+#include "moc_videosingleton.cpp"
diff --git a/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h
new file mode 100644
index 000000000..3e0d56247
--- /dev/null
+++ b/examples/multimedia/video/qmlvideo/qmlvideo/videosingleton.h
@@ -0,0 +1,48 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef QMLVIDEOSINGLETON_H
+#define QMLVIDEOSINGLETON_H
+
+#include "qmlvideo_global.h"
+
+#include <QtQml/qqml.h>
+
+class QMLVIDEO_LIB_EXPORT VideoSingleton : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl source1 READ source1 WRITE setSource1 NOTIFY source1Changed FINAL)
+ Q_PROPERTY(QUrl source2 READ source2 WRITE setSource2 NOTIFY source2Changed FINAL)
+ Q_PROPERTY(QUrl videoPath READ videoPath WRITE setVideoPath NOTIFY videoPathChanged FINAL)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged FINAL)
+ QML_SINGLETON
+ QML_ELEMENT
+
+public:
+ explicit VideoSingleton(QObject *parent = nullptr);
+
+ QUrl source1() const;
+ void setSource1(const QUrl &source1);
+ QUrl source2() const;
+ void setSource2(const QUrl &source2);
+ QUrl videoPath() const;
+ void setVideoPath(const QUrl &videoPath);
+ qreal volume() const;
+ void setVolume(qreal volume);
+
+Q_SIGNALS:
+ void source1Changed();
+ void source2Changed();
+ void volumeChanged();
+ void videoPathChanged();
+
+private:
+ QUrl m_source1;
+ QUrl m_source2;
+ QUrl m_videoPath;
+ qreal m_volume = 0.5;
+};
+
+QML_DECLARE_TYPE(VideoSingleton);
+
+#endif // QMLVIDEOSINGLETON_H
diff --git a/examples/multimedia/video/qmlvideo/trace.h b/examples/multimedia/video/qmlvideo/trace.h
index 0ad9b5167..bd7f63b68 100644
--- a/examples/multimedia/video/qmlvideo/trace.h
+++ b/examples/multimedia/video/qmlvideo/trace.h
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TRACE_H
#define TRACE_H
-#include <QtCore/QDebug>
+#include <QDebug>
#define ENABLE_TRACE
//#define VERBOSE_TRACE
@@ -61,13 +14,19 @@ namespace Trace {
class NullDebug
{
public:
- template <typename T>
- NullDebug& operator<<(const T&) { return *this; }
+ template<typename T>
+ NullDebug &operator<<(const T &)
+ {
+ return *this;
+ }
};
-inline NullDebug nullDebug() { return NullDebug(); }
+inline NullDebug nullDebug()
+{
+ return NullDebug();
+}
-template <typename T>
+template<typename T>
struct PtrWrapper
{
PtrWrapper(const T *ptr) : m_ptr(ptr) { }
@@ -76,8 +35,8 @@ struct PtrWrapper
} // namespace Trace
-template <typename T>
-inline QDebug& operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
+template<typename T>
+inline QDebug &operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
{
QDebugStateSaver saver(debug);
debug.nospace() << '[' << static_cast<const void *>(wrapper.m_ptr) << ']';
@@ -86,20 +45,37 @@ inline QDebug& operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
template<typename T>
inline const void *qtVoidPtr(const T *ptr)
-{ return static_cast<const void *>(ptr); }
+{
+ return static_cast<const void *>(ptr);
+}
#define qtThisPtr() qtVoidPtr(this)
#ifdef ENABLE_TRACE
- inline QDebug qtTrace() { return qDebug() << "[qmlvideo]"; }
+inline QDebug qtTrace()
+{
+ return qDebug() << "[qmlvideo]";
+}
# ifdef VERBOSE_TRACE
- inline QDebug qtVerboseTrace() { return qtTrace(); }
+inline QDebug qtVerboseTrace()
+{
+ return qtTrace();
+}
# else
- inline Trace::NullDebug qtVerboseTrace() { return Trace::nullDebug(); }
+inline Trace::NullDebug qtVerboseTrace()
+{
+ return Trace::nullDebug();
+}
# endif
#else
- inline Trace::NullDebug qtTrace() { return Trace::nullDebug(); }
- inline Trace::NullDebug qtVerboseTrace() { return Trace::nullDebug(); }
+inline Trace::NullDebug qtTrace()
+{
+ return Trace::nullDebug();
+}
+inline Trace::NullDebug qtVerboseTrace()
+{
+ return Trace::nullDebug();
+}
#endif
#endif // TRACE_H
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/README b/examples/multimedia/video/qmlvideofilter_opencl/README
deleted file mode 100644
index cc351e430..000000000
--- a/examples/multimedia/video/qmlvideofilter_opencl/README
+++ /dev/null
@@ -1,15 +0,0 @@
-This example performs some simple OpenCL operations on camera or video input
-which is assumed to be provided in RGB format. The OpenCL operation is done on
-an OpenGL texture using CL-GL interop, without any further readbacks or copies
-(except for the initial texture upload, when necessary).
-
-Currently OS X, Windows with real OpenGL (opengl32.dll) and Linux (GLX) are
-supported. Note that an OpenCL implementation with GPU support is required. The
-platform and device selection logic supports NVIDIA, AMD and Intel. Porting to
-other platforms is probably simple, see clCreateContextFromType.
-
-YUV formats are not supported in this example. This is probably not an issue an
-OS X and Windows, but will most likely disable the example on Linux.
-
-Pass the name of a video file to perform video playback or launch without
-arguments to use the camera.
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp
deleted file mode 100644
index 255c0b61b..000000000
--- a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp
+++ /dev/null
@@ -1,526 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Multimedia module.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QGuiApplication>
-#include <QQuickView>
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QAbstractVideoFilter>
-#include <QQmlContext>
-#include <QFileInfo>
-
-#ifdef Q_OS_OSX
-#include <OpenCL/opencl.h>
-#include <OpenGL/OpenGL.h>
-#else
-#include <CL/opencl.h>
-#endif
-
-#ifdef Q_OS_LINUX
-#include <QtPlatformHeaders/QGLXNativeContext>
-#endif
-
-#include "rgbframehelper.h"
-
-static const char *openclSrc =
- "__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;\n"
- "__kernel void Emboss(__read_only image2d_t imgIn, __write_only image2d_t imgOut, float factor) {\n"
- " const int2 pos = { get_global_id(0), get_global_id(1) };\n"
- " float4 diff = read_imagef(imgIn, sampler, pos + (int2)(1,1)) - read_imagef(imgIn, sampler, pos - (int2)(1,1));\n"
- " float color = (diff.x + diff.y + diff.z) / factor + 0.5f;\n"
- " write_imagef(imgOut, pos, (float4)(color, color, color, 1.0f));\n"
- "}\n";
-
-class CLFilter : public QAbstractVideoFilter
-{
- Q_OBJECT
- Q_PROPERTY(qreal factor READ factor WRITE setFactor NOTIFY factorChanged)
-
-public:
- CLFilter() : m_factor(1) { }
- qreal factor() const { return m_factor; }
- void setFactor(qreal v);
-
- QVideoFilterRunnable *createFilterRunnable() override;
-
-signals:
- void factorChanged();
-
-private:
- qreal m_factor;
-};
-
-class CLFilterRunnable : public QVideoFilterRunnable
-{
-public:
- CLFilterRunnable(CLFilter *filter);
- ~CLFilterRunnable();
- QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) override;
-
-private:
- void releaseTextures();
- uint newTexture();
-
- CLFilter *m_filter;
- QSize m_size;
- uint m_tempTexture;
- uint m_outTexture;
- uint m_lastInputTexture;
- cl_context m_clContext;
- cl_device_id m_clDeviceId;
- cl_mem m_clImage[2];
- cl_command_queue m_clQueue;
- cl_program m_clProgram;
- cl_kernel m_clKernel;
-};
-
-QVideoFilterRunnable *CLFilter::createFilterRunnable()
-{
- return new CLFilterRunnable(this);
-}
-
-CLFilterRunnable::CLFilterRunnable(CLFilter *filter) :
- m_filter(filter),
- m_tempTexture(0),
- m_outTexture(0),
- m_lastInputTexture(0),
- m_clContext(0),
- m_clQueue(0),
- m_clProgram(0),
- m_clKernel(0)
-{
- m_clImage[0] = m_clImage[1] = 0;
-
- // Set up OpenCL.
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- cl_uint n;
- cl_int err = clGetPlatformIDs(0, 0, &n);
- if (err != CL_SUCCESS) {
- qWarning("Failed to get platform ID count (error %d)", err);
- if (err == -1001) {
- qDebug("Could not find OpenCL implementation. ICD missing?"
-#ifdef Q_OS_LINUX
- " Check /etc/OpenCL/vendors."
-#endif
- );
- }
- return;
- }
- if (n == 0) {
- qWarning("No OpenCL platform found");
- return;
- }
- QList<cl_platform_id> platformIds;
- platformIds.resize(n);
- if (clGetPlatformIDs(n, platformIds.data(), 0) != CL_SUCCESS) {
- qWarning("Failed to get platform IDs");
- return;
- }
- cl_platform_id platform = platformIds[0];
- const char *vendor = (const char *) f->glGetString(GL_VENDOR);
- qDebug("GL_VENDOR: %s", vendor);
- const bool isNV = vendor && strstr(vendor, "NVIDIA");
- const bool isIntel = vendor && strstr(vendor, "Intel");
- const bool isAMD = vendor && strstr(vendor, "ATI");
- qDebug("Found %u OpenCL platforms:", n);
- for (cl_uint i = 0; i < n; ++i) {
- QByteArray name;
- name.resize(1024);
- clGetPlatformInfo(platformIds[i], CL_PLATFORM_NAME, name.size(), name.data(), 0);
- qDebug("Platform %p: %s", platformIds[i], name.constData());
- // Running with an OpenCL platform without GPU support is not going
- // to cut it. In practice we want the platform for the GPU which we
- // are using with OpenGL.
- if (isNV && name.contains(QByteArrayLiteral("NVIDIA")))
- platform = platformIds[i];
- else if (isIntel && name.contains(QByteArrayLiteral("Intel")))
- platform = platformIds[i];
- else if (isAMD && name.contains(QByteArrayLiteral("AMD")))
- platform = platformIds[i];
- }
- qDebug("Using platform %p", platform);
-
- // Set up the context with OpenCL/OpenGL interop.
-#if defined (Q_OS_OSX)
- cl_context_properties contextProps[] = { CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
- (cl_context_properties) CGLGetShareGroup(CGLGetCurrentContext()),
- 0 };
-#elif defined(Q_OS_WIN)
- cl_context_properties contextProps[] = { CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
- CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(),
- CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(),
- 0 };
-#elif defined(Q_OS_LINUX)
- QVariant nativeGLXHandle = QOpenGLContext::currentContext()->nativeHandle();
- QGLXNativeContext nativeGLXContext;
- if (!nativeGLXHandle.isNull() && nativeGLXHandle.canConvert<QGLXNativeContext>())
- nativeGLXContext = nativeGLXHandle.value<QGLXNativeContext>();
- else
- qWarning("Failed to get the underlying GLX context from the current QOpenGLContext");
- cl_context_properties contextProps[] = { CL_CONTEXT_PLATFORM, (cl_context_properties) platform,
- CL_GL_CONTEXT_KHR, (cl_context_properties) nativeGLXContext.context(),
- CL_GLX_DISPLAY_KHR, (cl_context_properties) glXGetCurrentDisplay(),
- 0 };
-#endif
-
- m_clContext = clCreateContextFromType(contextProps, CL_DEVICE_TYPE_GPU, 0, 0, &err);
- if (!m_clContext) {
- qWarning("Failed to create OpenCL context: %d", err);
- return;
- }
-
- // Get the GPU device id
-#if defined(Q_OS_OSX)
- // On OS X, get the "online" device/GPU. This is required for OpenCL/OpenGL context sharing.
- err = clGetGLContextInfoAPPLE(m_clContext, CGLGetCurrentContext(),
- CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE,
- sizeof(cl_device_id), &m_clDeviceId, 0);
- if (err != CL_SUCCESS) {
- qWarning("Failed to get OpenCL device for current screen: %d", err);
- return;
- }
-#else
- clGetGLContextInfoKHR_fn getGLContextInfo = (clGetGLContextInfoKHR_fn) clGetExtensionFunctionAddress("clGetGLContextInfoKHR");
- if (!getGLContextInfo || getGLContextInfo(contextProps, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR,
- sizeof(cl_device_id), &m_clDeviceId, 0) != CL_SUCCESS) {
- err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &m_clDeviceId, 0);
- if (err != CL_SUCCESS) {
- qWarning("Failed to get OpenCL device: %d", err);
- return;
- }
- }
-#endif
-
- m_clQueue = clCreateCommandQueue(m_clContext, m_clDeviceId, 0, &err);
- if (!m_clQueue) {
- qWarning("Failed to create OpenCL command queue: %d", err);
- return;
- }
- // Build the program.
- m_clProgram = clCreateProgramWithSource(m_clContext, 1, &openclSrc, 0, &err);
- if (!m_clProgram) {
- qWarning("Failed to create OpenCL program: %d", err);
- return;
- }
- if (clBuildProgram(m_clProgram, 1, &m_clDeviceId, 0, 0, 0) != CL_SUCCESS) {
- qWarning("Failed to build OpenCL program");
- QByteArray log;
- log.resize(2048);
- clGetProgramBuildInfo(m_clProgram, m_clDeviceId, CL_PROGRAM_BUILD_LOG, log.size(), log.data(), 0);
- qDebug("Build log: %s", log.constData());
- return;
- }
- m_clKernel = clCreateKernel(m_clProgram, "Emboss", &err);
- if (!m_clKernel) {
- qWarning("Failed to create emboss OpenCL kernel: %d", err);
- return;
- }
-}
-
-CLFilterRunnable::~CLFilterRunnable()
-{
- releaseTextures();
- if (m_clKernel)
- clReleaseKernel(m_clKernel);
- if (m_clProgram)
- clReleaseProgram(m_clProgram);
- if (m_clQueue)
- clReleaseCommandQueue(m_clQueue);
- if (m_clContext)
- clReleaseContext(m_clContext);
-}
-
-void CLFilterRunnable::releaseTextures()
-{
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- if (m_tempTexture)
- f->glDeleteTextures(1, &m_tempTexture);
- if (m_outTexture)
- f->glDeleteTextures(1, &m_outTexture);
- m_tempTexture = m_outTexture = m_lastInputTexture = 0;
- if (m_clImage[0])
- clReleaseMemObject(m_clImage[0]);
- if (m_clImage[1])
- clReleaseMemObject(m_clImage[1]);
- m_clImage[0] = m_clImage[1] = 0;
-}
-
-uint CLFilterRunnable::newTexture()
-{
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- GLuint texture;
- f->glGenTextures(1, &texture);
- f->glBindTexture(GL_TEXTURE_2D, texture);
- f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_size.width(), m_size.height(),
- 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- return texture;
-}
-
-QVideoFrame CLFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags)
-{
- Q_UNUSED(surfaceFormat);
- Q_UNUSED(flags);
-
- // This example supports RGB data only, either in system memory (typical with cameras on all
- // platforms) or as an OpenGL texture (e.g. video playback on OS X).
- // The latter is the fast path where everything happens on GPU. THe former involves a texture upload.
-
- if (!input->isValid()
- || (input->handleType() != QAbstractVideoBuffer::NoHandle
- && input->handleType() != QAbstractVideoBuffer::GLTextureHandle)) {
- qWarning("Invalid input format");
- return *input;
- }
-
- if (input->pixelFormat() == QVideoFrame::Format_YUV420P
- || input->pixelFormat() == QVideoFrame::Format_YV12) {
- qWarning("YUV data is not supported");
- return *input;
- }
-
- if (m_size != input->size()) {
- releaseTextures();
- m_size = input->size();
- }
-
- // Create a texture from the image data.
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- GLuint texture;
- if (input->handleType() == QAbstractVideoBuffer::NoHandle) {
- // Upload.
- if (m_tempTexture)
- f->glBindTexture(GL_TEXTURE_2D, m_tempTexture);
- else
- m_tempTexture = newTexture();
- input->map(QAbstractVideoBuffer::ReadOnly);
- // glTexImage2D only once and use TexSubImage later on. This avoids the need
- // to recreate the CL image object on every frame.
- f->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_size.width(), m_size.height(),
- GL_RGBA, GL_UNSIGNED_BYTE, input->bits());
- input->unmap();
- texture = m_tempTexture;
- } else {
- // Already an OpenGL texture.
- texture = input->handle().toUInt();
- f->glBindTexture(GL_TEXTURE_2D, texture);
- // Unlike on the other branch, the input texture may change, so m_clImage[0] may need to be recreated.
- if (m_lastInputTexture && m_lastInputTexture != texture && m_clImage[0]) {
- clReleaseMemObject(m_clImage[0]);
- m_clImage[0] = 0;
- }
- m_lastInputTexture = texture;
- }
-
- // OpenCL image objects cannot be read and written at the same time. So use
- // a separate texture for the result.
- if (!m_outTexture)
- m_outTexture = newTexture();
-
- // Create the image objects if not yet done.
- cl_int err;
- if (!m_clImage[0]) {
- m_clImage[0] = clCreateFromGLTexture2D(m_clContext, CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, texture, &err);
- if (!m_clImage[0]) {
- qWarning("Failed to create OpenGL image object from OpenGL texture: %d", err);
- return *input;
- }
- cl_image_format fmt;
- if (clGetImageInfo(m_clImage[0], CL_IMAGE_FORMAT, sizeof(fmt), &fmt, 0) != CL_SUCCESS) {
- qWarning("Failed to query image format");
- return *input;
- }
- if (fmt.image_channel_order != CL_RGBA)
- qWarning("OpenCL image is not RGBA, expect errors");
- }
- if (!m_clImage[1]) {
- m_clImage[1] = clCreateFromGLTexture2D(m_clContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, m_outTexture, &err);
- if (!m_clImage[1]) {
- qWarning("Failed to create output OpenGL image object from OpenGL texture: %d", err);
- return *input;
- }
- }
-
- // We are all set. Queue acquiring the image objects.
- f->glFinish();
- clEnqueueAcquireGLObjects(m_clQueue, 2, m_clImage, 0, 0, 0);
-
- // Set up the kernel arguments.
- clSetKernelArg(m_clKernel, 0, sizeof(cl_mem), &m_clImage[0]);
- clSetKernelArg(m_clKernel, 1, sizeof(cl_mem), &m_clImage[1]);
- // Accessing dynamic properties on the filter element is simple:
- cl_float factor = m_filter->factor();
- clSetKernelArg(m_clKernel, 2, sizeof(cl_float), &factor);
-
- // And queue the kernel.
- const size_t workSize[] = { size_t(m_size.width()), size_t(m_size.height()) };
- err = clEnqueueNDRangeKernel(m_clQueue, m_clKernel, 2, 0, workSize, 0, 0, 0, 0);
- if (err != CL_SUCCESS)
- qWarning("Failed to enqueue kernel: %d", err);
-
- // Return the texture from our output image object.
- // We return a texture even when the original video frame had pixel data in system memory.
- // Qt Multimedia is smart enough to handle this. Once the data is on the GPU, it stays there. No readbacks, no copies.
- clEnqueueReleaseGLObjects(m_clQueue, 2, m_clImage, 0, 0, 0);
- clFinish(m_clQueue);
- return frameFromTexture(m_outTexture, m_size, input->pixelFormat());
-}
-
-// InfoFilter will just provide some information about the video frame, to demonstrate
-// passing arbitrary data to QML via its finished() signal.
-class InfoFilter : public QAbstractVideoFilter
-{
- Q_OBJECT
-
-public:
- QVideoFilterRunnable *createFilterRunnable() override;
-
-signals:
- void finished(QObject *result);
-
-private:
- friend class InfoFilterRunnable;
-};
-
-class InfoFilterRunnable : public QVideoFilterRunnable
-{
-public:
- InfoFilterRunnable(InfoFilter *filter) : m_filter(filter) { }
- QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) override;
-
-private:
- InfoFilter *m_filter;
-};
-
-class InfoFilterResult : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QSize frameResolution READ frameResolution)
- Q_PROPERTY(QString handleType READ handleType)
- Q_PROPERTY(int pixelFormat READ pixelFormat)
-
-public:
- InfoFilterResult() : m_pixelFormat(0) { }
- QSize frameResolution() const { return m_frameResolution; }
- QString handleType() const { return m_handleType; }
- int pixelFormat() const { return m_pixelFormat; }
-
-private:
- QSize m_frameResolution;
- QString m_handleType;
- int m_pixelFormat;
- friend class InfoFilterRunnable;
-};
-
-void CLFilter::setFactor(qreal v)
-{
- if (m_factor != v) {
- m_factor = v;
- emit factorChanged();
- }
-}
-
-QVideoFilterRunnable *InfoFilter::createFilterRunnable()
-{
- return new InfoFilterRunnable(this);
-}
-
-QVideoFrame InfoFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags)
-{
- Q_UNUSED(surfaceFormat);
- Q_UNUSED(flags);
- InfoFilterResult *result = new InfoFilterResult;
- result->m_frameResolution = input->size();
- switch (input->handleType()) {
- case QAbstractVideoBuffer::NoHandle:
- result->m_handleType = QLatin1String("pixel data");
- result->m_pixelFormat = input->pixelFormat();
- break;
- case QAbstractVideoBuffer::GLTextureHandle:
- result->m_handleType = QLatin1String("OpenGL texture");
- break;
- default:
- result->m_handleType = QLatin1String("unknown");
- break;
- }
- emit m_filter->finished(result); // parent-less QObject -> ownership transferred to the JS engine
- return *input;
-}
-
-int main(int argc, char **argv)
-{
-#ifdef Q_OS_WIN // avoid ANGLE on Windows
- QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
-#endif
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<CLFilter>("qmlvideofilter.cl.test", 1, 0, "CLFilter");
- qmlRegisterType<InfoFilter>("qmlvideofilter.cl.test", 1, 0, "InfoFilter");
-
- QQuickView view;
- QString fn;
- if (argc > 1) {
- fn = QUrl::fromLocalFile(QFileInfo(QString::fromUtf8(argv[1])).absoluteFilePath()).toString();
- qDebug("Playing video %s", qPrintable(fn));
- } else {
- qDebug("No video file specified, using camera instead.");
- }
- view.rootContext()->setContextProperty("videoFilename", fn);
- view.setSource(QUrl("qrc:///main.qml"));
-
- view.show();
-
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/main.qml b/examples/multimedia/video/qmlvideofilter_opencl/main.qml
deleted file mode 100644
index 3d3205398..000000000
--- a/examples/multimedia/video/qmlvideofilter_opencl/main.qml
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Multimedia module.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtMultimedia 5.5
-import qmlvideofilter.cl.test 1.0
-
-Item {
- width: 1024
- height: 768
-
- Camera {
- id: camera
- }
-
- MediaPlayer {
- id: player
- autoPlay: true
- source: videoFilename
- }
-
- VideoOutput {
- id: output
- source: videoFilename !== "" ? player : camera
- filters: [ infofilter, clfilter ]
- anchors.fill: parent
- }
-
- CLFilter {
- id: clfilter
- // Animate a property which is passed to the OpenCL kernel.
- SequentialAnimation on factor {
- loops: Animation.Infinite
- NumberAnimation {
- from: 1
- to: 20
- duration: 6000
- }
- NumberAnimation {
- from: 20
- to: 1
- duration: 3000
- }
- }
- }
-
- InfoFilter {
- // This filter does not change the image. Instead, it provides some results calculated from the frame.
- id: infofilter
- onFinished: {
- info.res = result.frameResolution.width + "x" + result.frameResolution.height;
- info.type = result.handleType;
- info.fmt = result.pixelFormat;
- }
- }
-
- Column {
- Text {
- font.pointSize: 20
- color: "green"
- text: "Transformed with OpenCL on GPU\nClick to disable and enable the emboss filter"
- }
- Text {
- font.pointSize: 12
- color: "green"
- text: "Emboss factor " + Math.round(clfilter.factor)
- visible: clfilter.active
- }
- Text {
- id: info
- font.pointSize: 12
- color: "green"
- property string res
- property string type
- property int fmt
- text: "Input resolution: " + res + " Input frame type: " + type + (fmt ? " Pixel format: " + fmt : "")
- }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: clfilter.active = !clfilter.active
- }
-}
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro b/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro
deleted file mode 100644
index f7f191d2b..000000000
--- a/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TEMPLATE = app
-TARGET = qmlvideofilter_opencl
-
-QT += quick multimedia
-
-SOURCES = main.cpp
-HEADERS = rgbframehelper.h
-
-RESOURCES = qmlvideofilter_opencl.qrc
-OTHER_FILES = main.qml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideofilter_opencl
-INSTALLS += target
-
-osx: LIBS += -framework OpenCL
-unix: !osx: LIBS += -lOpenCL
-win32:!winrt: LIBS += -lopengl32 -lOpenCL
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.qrc b/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.qrc
deleted file mode 100644
index 5f6483ac3..000000000
--- a/examples/multimedia/video/qmlvideofilter_opencl/qmlvideofilter_opencl.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h b/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h
deleted file mode 100644
index 1c8dbd857..000000000
--- a/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Multimedia module.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef RGBFRAMEHELPER_H
-#define RGBFRAMEHELPER_H
-
-#include <QImage>
-#include <QAbstractVideoBuffer>
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QOpenGLFramebufferObject>
-
-/*
- Returns a QImage that wraps the given video frame.
-
- This is suitable only for QAbstractVideoBuffer::NoHandle frames with RGB (or BGR)
- data. YUV is not supported here.
-
- The QVideoFrame must be mapped and kept mapped as long as the wrapping QImage
- exists.
-
- As a convenience the function also supports frames with a handle type of
- QAbstractVideoBuffer::GLTextureHandle. This allows creating a system memory backed
- QVideoFrame containing the image data from an OpenGL texture. However, readback is a
- slow operation and may stall the GPU pipeline and should be avoided in production code.
-*/
-QImage imageWrapper(const QVideoFrame &frame)
-{
-#ifndef QT_NO_OPENGL
- if (frame.handleType() == QAbstractVideoBuffer::GLTextureHandle) {
- // Slow and inefficient path. Ideally what's on the GPU should remain on the GPU, instead of readbacks like this.
- QImage img(frame.width(), frame.height(), QImage::Format_RGBA8888);
- GLuint textureId = frame.handle().toUInt();
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- QOpenGLFunctions *f = ctx->functions();
- GLuint fbo;
- f->glGenFramebuffers(1, &fbo);
- GLuint prevFbo;
- f->glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *) &prevFbo);
- f->glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- f->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);
- f->glReadPixels(0, 0, frame.width(), frame.height(), GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
- f->glBindFramebuffer(GL_FRAMEBUFFER, prevFbo);
- return img;
- } else
-#endif // QT_NO_OPENGL
- {
- if (!frame.isReadable()) {
- qWarning("imageFromVideoFrame: No mapped image data available for read");
- return QImage();
- }
-
- QImage::Format fmt = QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat());
- if (fmt != QImage::Format_Invalid)
- return QImage(frame.bits(), frame.width(), frame.height(), fmt);
-
- qWarning("imageFromVideoFrame: No matching QImage format");
- }
-
- return QImage();
-}
-
-#ifndef QT_NO_OPENGL
-class TextureBuffer : public QAbstractVideoBuffer
-{
-public:
- TextureBuffer(uint id) : QAbstractVideoBuffer(GLTextureHandle), m_id(id) { }
- MapMode mapMode() const { return NotMapped; }
- uchar *map(MapMode, int *, int *) { return 0; }
- void unmap() { }
- QVariant handle() const { return QVariant::fromValue<uint>(m_id); }
-
-private:
- GLuint m_id;
-};
-#endif // QT_NO_OPENGL
-
-/*
- Creates and returns a new video frame wrapping the OpenGL texture textureId. The size
- must be passed in size, together with the format of the underlying image data in
- format. When the texture originates from a QImage, use
- QVideoFrame::imageFormatFromPixelFormat() to get a suitable format. Ownership is not
- altered, the new QVideoFrame will not destroy the texture.
-*/
-QVideoFrame frameFromTexture(uint textureId, const QSize &size, QVideoFrame::PixelFormat format)
-{
-#ifndef QT_NO_OPENGL
- return QVideoFrame(new TextureBuffer(textureId), size, format);
-#else
- return QVideoFrame();
-#endif // QT_NO_OPENGL
-}
-
-#endif
diff --git a/examples/multimedia/video/qmlvideofx/Info.plist b/examples/multimedia/video/qmlvideofx/Info.plist
deleted file mode 100644
index 5fbe35f1c..000000000
--- a/examples/multimedia/video/qmlvideofx/Info.plist
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>UISupportedInterfaceOrientations</key>
- <array>
- <string>UIInterfaceOrientationLandscapeRight</string>
- </array>
- <key>UIInterfaceOrientation</key>
- <string>UIInterfaceOrientationLandscapeRight</string>
- <key>CFBundleIconFile</key>
- <string></string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleExecutable</key>
- <string>qmlvideofx</string>
- <key>CFBundleIdentifier</key>
- <string>com.digia.${PRODUCT_NAME:rfc1034identifier}</string>
- <key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
- <key>NSCameraUsageDescription</key>
- <string>Qt Multimedia Example</string>
-</dict>
-</plist>
diff --git a/examples/multimedia/video/qmlvideofx/filereader.cpp b/examples/multimedia/video/qmlvideofx/filereader.cpp
deleted file mode 100644
index af74899f9..000000000
--- a/examples/multimedia/video/qmlvideofx/filereader.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "filereader.h"
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QFile>
-#include <QFileInfo>
-#include <QTextStream>
-
-QString FileReader::readFile(const QString &fileName)
-{
- QString content;
- QFile file(fileName);
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream stream(&file);
- content = stream.readAll();
- }
- return content;
-}
-
diff --git a/examples/multimedia/video/qmlvideofx/filereader.h b/examples/multimedia/video/qmlvideofx/filereader.h
deleted file mode 100644
index 019317a1a..000000000
--- a/examples/multimedia/video/qmlvideofx/filereader.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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>
-
-class FileReader : public QObject
-{
- Q_OBJECT
-public:
- Q_INVOKABLE QString readFile(const QString &fileName);
-};
-
diff --git a/examples/multimedia/video/qmlvideofx/images/Dropdown_arrows.png b/examples/multimedia/video/qmlvideofx/images/Dropdown_arrows.png
deleted file mode 100644
index 0a9e25ce2..000000000
--- a/examples/multimedia/video/qmlvideofx/images/Dropdown_arrows.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/Slider_bar.png b/examples/multimedia/video/qmlvideofx/images/Slider_bar.png
deleted file mode 100644
index 84be50fae..000000000
--- a/examples/multimedia/video/qmlvideofx/images/Slider_bar.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/Slider_handle.png b/examples/multimedia/video/qmlvideofx/images/Slider_handle.png
deleted file mode 100644
index aebecdf19..000000000
--- a/examples/multimedia/video/qmlvideofx/images/Slider_handle.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/Triangle_Top.png b/examples/multimedia/video/qmlvideofx/images/Triangle_Top.png
deleted file mode 100644
index 5768e9536..000000000
--- a/examples/multimedia/video/qmlvideofx/images/Triangle_Top.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/Triangle_bottom.png b/examples/multimedia/video/qmlvideofx/images/Triangle_bottom.png
deleted file mode 100644
index 509409666..000000000
--- a/examples/multimedia/video/qmlvideofx/images/Triangle_bottom.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/icon_BackArrow.png b/examples/multimedia/video/qmlvideofx/images/icon_BackArrow.png
deleted file mode 100644
index 6823de004..000000000
--- a/examples/multimedia/video/qmlvideofx/images/icon_BackArrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/icon_Folder.png b/examples/multimedia/video/qmlvideofx/images/icon_Folder.png
deleted file mode 100644
index 62d97004f..000000000
--- a/examples/multimedia/video/qmlvideofx/images/icon_Folder.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/icon_Menu.png b/examples/multimedia/video/qmlvideofx/images/icon_Menu.png
deleted file mode 100644
index bc078612e..000000000
--- a/examples/multimedia/video/qmlvideofx/images/icon_Menu.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/images/qt-logo.png b/examples/multimedia/video/qmlvideofx/images/qt-logo.png
deleted file mode 100644
index ecbff0ca3..000000000
--- a/examples/multimedia/video/qmlvideofx/images/qt-logo.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/main.cpp b/examples/multimedia/video/qmlvideofx/main.cpp
deleted file mode 100644
index ec547795f..000000000
--- a/examples/multimedia/video/qmlvideofx/main.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 <QtCore/QStandardPaths>
-#include <QtCore/QStringList>
-#include <QtQml/QQmlContext>
-#include <QtGui/QGuiApplication>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
-#include "filereader.h"
-#include "trace.h"
-
-#ifdef PERFORMANCEMONITOR_SUPPORT
-#include "performancemonitordeclarative.h"
-#endif
-
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
-#include <QtAndroid>
-
-bool requestStoragePermission() {
- using namespace QtAndroid;
-
- QString permission = QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE");
- const QHash<QString, PermissionResult> results = requestPermissionsSync(QStringList({permission}));
- if (!results.contains(permission) || results[permission] == PermissionResult::Denied) {
- qWarning() << "Couldn't get permission: " << permission;
- return false;
- }
-
- return true;
-}
-#endif
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
-#ifdef PERFORMANCEMONITOR_SUPPORT
- PerformanceMonitor::qmlRegisterTypes();
-#endif
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
- if (!requestStoragePermission())
- return -1;
-#endif
-
- QUrl fileName;
- qreal volume = 0.5;
- QStringList args = app.arguments();
-#ifdef PERFORMANCEMONITOR_SUPPORT
- PerformanceMonitor::State performanceMonitorState;
-#endif
- for (int i = 1; i < args.size(); ++i) {
- const QByteArray arg = args.at(i).toUtf8();
- if (arg.startsWith('-')) {
- if ("-volume" == arg) {
- if (i + 1 < args.size())
- volume = 0.01 * args.at(++i).toInt();
- else
- qtTrace() << "Option \"-volume\" takes a value";
- }
-#ifdef PERFORMANCEMONITOR_SUPPORT
- else if (performanceMonitorState.parseArgument(arg)) {
- // Do nothing
- }
-#endif
- else {
- qtTrace() << "Option" << arg << "ignored";
- }
- } else {
- if (fileName.isEmpty())
- fileName = QUrl::fromLocalFile(arg);
- else
- qtTrace() << "Argument" << arg << "ignored";
- }
- }
-
- QQuickView viewer;
-
- viewer.setSource(QUrl(QLatin1String("qrc:///qml/qmlvideofx/Main.qml")));
- QQuickItem *rootObject = viewer.rootObject();
- rootObject->setProperty("fileName", fileName);
- viewer.rootObject()->setProperty("volume", volume);
-
-#ifdef PERFORMANCEMONITOR_SUPPORT
- if (performanceMonitorState.valid) {
- rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging);
- rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible);
- }
- QObject::connect(&viewer, SIGNAL(afterRendering()),
- rootObject, SLOT(qmlFramePainted()));
-#endif
-
- FileReader fileReader;
- viewer.rootContext()->setContextProperty("fileReader", &fileReader);
-
- const QUrl appPath(QUrl::fromLocalFile(app.applicationDirPath()));
- const QStringList picturesLocation = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
- const QUrl imagePath = picturesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(picturesLocation.first());
- viewer.rootContext()->setContextProperty("imagePath", imagePath);
-
- const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation);
- const QUrl videoPath = moviesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(moviesLocation.first());
- viewer.rootContext()->setContextProperty("videoPath", videoPath);
-
- viewer.setTitle("qmlvideofx");
- viewer.setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint |
- Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
- viewer.setMinimumSize(QSize(1280, 720));
- viewer.setResizeMode(QQuickView::SizeRootObjectToView);
-
- viewer.show();
-
- // Delay invocation of init until the event loop has started, to work around
- // a GL context issue on Harmattan: without this, we get the following error
- // when the first ShaderEffectItem is created:
- // "QGLShaderProgram::addShader: Program and shader are not associated with same context"
- QMetaObject::invokeMethod(viewer.rootObject(), "init", Qt::QueuedConnection);
-
- return app.exec();
-}
-
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Button.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Button.qml
deleted file mode 100644
index 326c64ace..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Button.qml
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- color: "transparent"
- height: itemHeight
- width: itemWidth
-
- property string text
- property color bgColor: "transparent"
- property color bgColorSelected: "#14aaff"
- property color textColor: "white"
- property alias enabled: mouseArea.enabled
- property bool active: true
- property alias horizontalAlign: text.horizontalAlignment
-
- signal clicked
-
- Rectangle {
- anchors { fill: parent; margins: 1 }
- color: mouseArea.pressed ? bgColorSelected : bgColor
-
- Text {
- id: text
- clip: true
- text: root.text
- anchors { fill: parent; margins: scaledMargin }
- font.pixelSize: fontSize
- color: textColor
- horizontalAlignment: Text.AlignLeft
- verticalAlignment: Text.AlignVCenter
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- onClicked: {
- root.clicked()
- }
- enabled: active
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Content.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Content.qml
deleted file mode 100644
index 8e109b9be..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Content.qml
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-
-Rectangle {
- id: root
- property alias effect: effectLoader.item
- property alias gripSize: divider.gripSize
- property string effectSource
- property real volume: 0.5
-
- signal videoFramePainted
-
- Divider {
- id: divider
- visible: false
- z: 1.0
- onValueChanged: updateDivider()
- }
-
- ShaderEffectSource {
- id: theSource
- smooth: true
- hideSource: true
- }
-
- Loader {
- id: contentLoader
- }
-
- Loader {
- id: effectLoader
- source: effectSource
- }
-
- Connections {
- id: videoFramePaintedConnection
- onFramePainted: {
- if (performanceLoader.item)
- root.videoFramePainted()
- }
- ignoreUnknownSignals: true
- }
-
- onWidthChanged: {
- if (effectLoader.item)
- effectLoader.item.targetWidth = root.width
- }
-
- onHeightChanged: {
- if (effectLoader.item)
- effectLoader.item.targetHeight = root.height
- }
-
- onEffectSourceChanged: {
- effectLoader.source = effectSource
- effectLoader.item.parent = root
- effectLoader.item.targetWidth = root.width
- effectLoader.item.targetHeight = root.height
- updateSource()
- effectLoader.item.source = theSource
- divider.visible = effectLoader.item.divider
- updateDivider()
- }
-
- function init() {
- openImage("qrc:/images/qt-logo.png")
- root.effectSource = "EffectPassThrough.qml"
- }
-
- function updateDivider() {
- if (effectLoader.item && effectLoader.item.divider)
- effectLoader.item.dividerValue = divider.value
- }
-
- function updateSource() {
- if (contentLoader.item) {
- contentLoader.item.parent = root
- contentLoader.item.anchors.fill = root
- theSource.sourceItem = contentLoader.item
- if (effectLoader.item)
- effectLoader.item.anchors.fill = contentLoader.item
- }
- }
-
- function openImage(path) {
- stop()
- contentLoader.source = "ContentImage.qml"
- videoFramePaintedConnection.target = null
- contentLoader.item.source = path
- updateSource()
- }
-
- function openVideo(path) {
- stop()
- contentLoader.source = "ContentVideo.qml"
- videoFramePaintedConnection.target = contentLoader.item
- contentLoader.item.mediaSource = path
- contentLoader.item.volume = volume
- contentLoader.item.play()
- updateSource()
- }
-
- function openCamera() {
- stop()
- contentLoader.source = "ContentCamera.qml"
- videoFramePaintedConnection.target = contentLoader.item
- updateSource()
- }
-
- function stop() {
- if (contentLoader.source == "ContentVideo.qml")
- contentLoader.item.stop()
- theSource.sourceItem = null
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentCamera.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentCamera.qml
deleted file mode 100644
index c448a5fe4..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentCamera.qml
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import QtMultimedia 5.0
-
-VideoOutput {
- source: camera
-
- Camera {
- id: camera
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml
deleted file mode 100644
index d243c8b3e..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentImage.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-
-Image {
- fillMode: Image.PreserveAspectFit
- smooth: true
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentVideo.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentVideo.qml
deleted file mode 100644
index ade7012b1..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ContentVideo.qml
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import QtMultimedia 5.0
-
-VideoOutput {
- source: mediaPlayer
- property alias mediaSource: mediaPlayer.source
- property alias volume: mediaPlayer.volume
- property bool isRunning: true
-
- MediaPlayer {
- id: mediaPlayer
- autoPlay: true
- volume: 0.5
- loops: Audio.Infinite
- }
-
- function play() { mediaPlayer.play() }
- function pause() { mediaPlayer.pause() }
- function stop() { mediaPlayer.stop() }
-
- function toggleplay() {
- if (isRunning) {
- pause()
- isRunning = false
- } else {
- play()
- isRunning = true
- }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: toggleplay()
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Curtain.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Curtain.qml
deleted file mode 100644
index 691db5c6d..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Curtain.qml
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- color: "transparent"
- radius: 5
- property alias value: grip.value
- property color gripColor: "transparent"
- property real gripSize: 20
- property real gripTolerance: 3.0
- property real increment: 0.1
- property bool enabled: true
- property string imageSource: "qrc:/images/Triangle_Top.png"
-
- Rectangle {
- id: grip
- property real value: 0.5
- x: (value * parent.width) - width/2
- anchors.verticalCenter: parent.verticalCenter
- width: root.gripTolerance * root.gripSize
- height: width
- radius: width/2
- color: "transparent"
-
- Image {
- id: sliderhandleimage
- source: imageSource
- anchors.centerIn: parent
- }
-
- MouseArea {
- id: mouseArea
- enabled: root.enabled
- anchors.fill: parent
- drag {
- target: grip
- axis: Drag.XAxis
- minimumX: -parent.width/2
- maximumX: root.width - parent.width/2
- }
- onPositionChanged: {
- if (drag.active)
- updatePosition()
- }
- onReleased: {
- updatePosition()
- }
- function updatePosition() {
- value = (grip.x + grip.width/2) / grip.parent.width
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Divider.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Divider.qml
deleted file mode 100644
index e098d4861..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Divider.qml
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-
-Rectangle {
- id: root
- anchors.fill: parent
- color: "transparent"
- property alias value: slider.value
- property alias lineWidth: line.width
- property alias gripSize: slider.gripSize
-
- Rectangle {
- id: line
- anchors { top: parent.top; bottom: parent.bottom }
- x: parent.value * parent.width - (width / 2)
- width: 4
- color: "#14aaff"
- }
-
- // topgrip
- Curtain {
- id: slider
- increment: 0.0
- anchors {
- top: parent.top
- topMargin: (gripSize / 2) + 5
- left: parent.left
- right: parent.right
- }
- onValueChanged: slider2.value = slider.value
- }
-
- // bottomgrip
- Curtain {
- id: slider2
- increment: 0.0
- anchors {
- bottom: parent.bottom
- bottomMargin: (gripSize / 2) + 5
- left: parent.left
- right: parent.right
- }
- imageSource: "qrc:/images/Triangle_bottom.png"
- onValueChanged: slider.value = slider2.value
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml
deleted file mode 100644
index 66a6b919f..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Effect.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-ShaderEffect {
- property variant source
- property ListModel parameters: ListModel { }
- property bool divider: true
- property real dividerValue: 0.5
- property real targetWidth: 0
- property real targetHeight: 0
- property string fragmentShaderFilename
- property string vertexShaderFilename
-
- QtObject {
- id: d
- property string fragmentShaderCommon: "
- #ifdef GL_ES
- precision mediump float;
- #else
- # define lowp
- # define mediump
- # define highp
- #endif // GL_ES
- "
- }
-
- // The following is a workaround for the fact that ShaderEffect
- // doesn't provide a way for shader programs to be read from a file,
- // rather than being inline in the QML file
-
- onFragmentShaderFilenameChanged:
- fragmentShader = d.fragmentShaderCommon + fileReader.readFile(":shaders/" + fragmentShaderFilename)
- onVertexShaderFilenameChanged:
- vertexShader = fileReader.readFile(vertexShaderFilename)
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml
deleted file mode 100644
index 4087c8520..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBillboard.qml
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Grid Spacing"
- value: 0.5
- }
- onDataChanged: updateGrid()
- }
-
- function updateGrid()
- {
- grid = parameters.get(0).value * 10;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real grid: 5.0
-
- property real step_x: 0.0015625
- property real step_y: targetHeight ? (step_x * targetWidth / targetHeight) : 0.0
-
- fragmentShaderFilename: "billboard.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml
deleted file mode 100644
index 90e27184d..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectBlackAndWhite.qml
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Threshold"
- value: 0.5
- }
- onDataChanged: updateThreshold()
- }
-
- function updateThreshold()
- {
- threshold = parameters.get(0).value;
- }
- // Transform slider values, and bind result to shader uniforms
- property real threshold: 0.5
-
- fragmentShaderFilename: "blackandwhite.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml
deleted file mode 100644
index a4e981917..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectEmboss.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- fragmentShaderFilename: "emboss.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml
deleted file mode 100644
index 6a0c711f5..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGaussianBlur.qml
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://www.geeks3d.com/20100909/shader-library-gaussian-blur-post-processing-filter-in-glsl/
-
-import QtQuick 2.0
-
-Item {
- id: root
- property bool divider: true
- property real dividerValue: 0.5
- property ListModel parameters: ListModel {
- ListElement {
- name: "Radius"
- value: 0.5
- }
- onDataChanged: updateBlurSize()
- }
-
- function updateBlurSize()
- {
- if ((targetHeight > 0) && (targetWidth > 0))
- {
- verticalBlurSize = 4.0 * parameters.get(0).value / targetHeight;
- horizontalBlurSize = 4.0 * parameters.get(0).value / targetWidth;
- }
- }
-
- property alias targetWidth: verticalShader.targetWidth
- property alias targetHeight: verticalShader.targetHeight
- property alias source: verticalShader.source
- property alias horizontalBlurSize: horizontalShader.blurSize
- property alias verticalBlurSize: verticalShader.blurSize
-
-
- Effect {
- id: verticalShader
- anchors.fill: parent
- dividerValue: parent.dividerValue
- property real blurSize: 0.0
-
- onTargetHeightChanged: {
- updateBlurSize()
- }
- onTargetWidthChanged: {
- updateBlurSize()
- }
- fragmentShaderFilename: "gaussianblur_v.fsh"
- }
-
- Effect {
- id: horizontalShader
- anchors.fill: parent
- dividerValue: parent.dividerValue
- property real blurSize: 0.0
- fragmentShaderFilename: "gaussianblur_h.fsh"
- source: horizontalShaderSource
-
- ShaderEffectSource {
- id: horizontalShaderSource
- sourceItem: verticalShader
- smooth: true
- hideSource: true
- }
- }
-}
-
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml
deleted file mode 100644
index 3f9e3e771..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectGlow.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- fragmentShaderFilename: "glow.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml
deleted file mode 100644
index f04e29deb..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectIsolate.qml
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Hue"
- value: 0.5
- }
- ListElement {
- name: "Width"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- targetHue = parameters.get(0).value * 360
- windowWidth = parameters.get(1).value * 60
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real targetHue: 0.5 * 360
- property real windowWidth: 0.5 * 60
-
- fragmentShaderFilename: "isolate.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml
deleted file mode 100644
index ae21d93e4..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectMagnify.qml
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import QtQuick.Window 2.1
-
-Effect {
- id: root
- divider: false
- parameters: ListModel {
- ListElement {
- name: "Radius"
- value: 0.5
- }
- ListElement {
- name: "Diffraction"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- radius = parameters.get(0).value * 100;
- diffractionIndex = parameters.get(1).value;
- }
-
- property real posX: -1
- property real posY: -1
- property real pixDens: Screen.pixelDensity
-
- QtObject {
- id: d
- property real oldTargetWidth: root.targetWidth
- property real oldTargetHeight: root.targetHeight
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real radius: 0.5 * 100
- property real diffractionIndex: 0.5
-
- onTargetWidthChanged: {
- if (posX == -1)
- posX = targetWidth / 2
- else if (d.oldTargetWidth != 0)
- posX *= (targetWidth / d.oldTargetWidth)
- d.oldTargetWidth = targetWidth
- }
-
- onTargetHeightChanged: {
- if (posY == -1)
- posY = targetHeight / 2
- else if (d.oldTargetHeight != 0)
- posY *= (targetHeight / d.oldTargetHeight)
- d.oldTargetHeight = targetHeight
- }
-
- fragmentShaderFilename: "magnify.fsh"
-
- MouseArea {
- anchors.fill: parent
- onPositionChanged: { root.posX = mouse.x; root.posY = root.targetHeight - mouse.y }
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml
deleted file mode 100644
index 4a208a95f..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPageCurl.qml
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- divider: false
- parameters: ListModel {
- ListElement {
- name: "Extent"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- curlExtent = 1.0 - parameters.get(0).value;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real curlExtent: 0.5
-
- fragmentShaderFilename: "pagecurl.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml
deleted file mode 100644
index 20395a967..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPassThrough.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- divider: false
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml
deleted file mode 100644
index 79c1f21e2..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPixelate.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Granularity"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- granularity = parameters.get(0).value * 20.0;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real granularity: 0.5 * 20
-
- fragmentShaderFilename: "pixelate.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml
deleted file mode 100644
index 90c531d2c..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectPosterize.qml
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Gamma"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- gamma = parameters.get(0).value;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real gamma: 0.5
-
- property real numColors: 8.0
-
- fragmentShaderFilename: "posterize.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml
deleted file mode 100644
index 0fe25b61d..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectRipple.qml
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import QtQuick.Window 2.1
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Amplitude"
- value: 0.5
- }
- ListElement {
- name: "Frequency"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- amplitude = parameters.get(0).value * 0.03;
- n = parameters.get(1).value * 7;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real amplitude: 0.5 * 0.03
- property real n: 0.5 * 7
- property real pixDens: Screen.pixelDensity
-
- property real time: 0
- NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
-
- fragmentShaderFilename: "ripple.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSelectionList.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSelectionList.qml
deleted file mode 100644
index 593b764a8..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSelectionList.qml
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-ListModel {
- id: sources
- ListElement { name: "No effect"; source: "EffectPassThrough.qml" }
- ListElement { name: "Billboard"; source: "EffectBillboard.qml" }
- ListElement { name: "Black & white"; source: "EffectBlackAndWhite.qml" }
- ListElement { name: "Blur"; source: "EffectGaussianBlur.qml" }
- ListElement { name: "Edge detection"; source: "EffectSobelEdgeDetection1.qml" }
- ListElement { name: "Emboss"; source: "EffectEmboss.qml" }
- ListElement { name: "Glow"; source: "EffectGlow.qml" }
- ListElement { name: "Isolate"; source: "EffectIsolate.qml" }
- ListElement { name: "Magnify"; source: "EffectMagnify.qml" }
- ListElement { name: "Page curl"; source: "EffectPageCurl.qml" }
- ListElement { name: "Pixelate"; source: "EffectPixelate.qml" }
- ListElement { name: "Posterize"; source: "EffectPosterize.qml" }
- ListElement { name: "Ripple"; source: "EffectRipple.qml" }
- ListElement { name: "Sepia"; source: "EffectSepia.qml" }
- ListElement { name: "Sharpen"; source: "EffectSharpen.qml" }
- ListElement { name: "Shockwave"; source: "EffectShockwave.qml" }
- ListElement { name: "Tilt shift"; source: "EffectTiltShift.qml" }
- ListElement { name: "Toon"; source: "EffectToon.qml" }
- ListElement { name: "Warhol"; source: "EffectWarhol.qml" }
- ListElement { name: "Wobble"; source: "EffectWobble.qml" }
- ListElement { name: "Vignette"; source: "EffectVignette.qml" }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml
deleted file mode 100644
index ffacb1d01..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSepia.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- fragmentShaderFilename: "sepia.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml
deleted file mode 100644
index bfcfa8b80..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSharpen.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Sharpness"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- amount = parameters.get(0).value * 18;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real amount: 0.5 * 18
-
- fragmentShaderFilename: "sharpen.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml
deleted file mode 100644
index 875c23b79..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectShockwave.qml
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- id: root
- parameters: ListModel {
- ListElement {
- name: "Amplitude"
- value: 0.5
- }
- onDataChanged: updateParameters()
- }
-
- function updateParameters()
- {
- granularity = parameters.get(0).value * 20;
- weight = parameters.get(0).value;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real granularity: 0.5 * 20
- property real weight: 0.5
-
- property real centerX
- property real centerY
- property real time
-
- SequentialAnimation {
- running: true
- loops: Animation.Infinite
- ScriptAction {
- script: {
- centerX = Math.random()
- centerY = Math.random()
- }
- }
- NumberAnimation {
- target: root
- property: "time"
- from: 0
- to: 1
- duration: 1000
- }
- }
-
- fragmentShaderFilename: "shockwave.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml
deleted file mode 100644
index babd09afa..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectSobelEdgeDetection1.qml
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Threshold"
- value: 0.5
- }
- onDataChanged: updateMixLevel()
- }
-
- function updateMixLevel()
- {
- mixLevel = parameters.get(0).value;
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real mixLevel: 0.5
- property real targetSize: 250 - (200 * mixLevel) // TODO: fix ...
- property real resS: targetSize
- property real resT: targetSize
-
- fragmentShaderFilename: "sobeledgedetection1.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml
deleted file mode 100644
index cdc7713f0..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectTiltShift.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- fragmentShaderFilename: "tiltshift.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml
deleted file mode 100644
index 244d465a5..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectToon.qml
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Threshold"
- value: 0.5
- }
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real threshold: parameters.get(0).value
- property real targetSize: 250 - (200 * threshold) // TODO: fix ...
- property real resS: targetSize
- property real resT: targetSize
-
- // TODO
- property real magTol: 0.3
- property real quantize: 8.0
-
- fragmentShaderFilename: "toon.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml
deleted file mode 100644
index 2b16c2a01..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectVignette.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- fragmentShaderFilename: "vignette.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml
deleted file mode 100644
index 2b88b8409..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWarhol.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- fragmentShaderFilename: "warhol.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml
deleted file mode 100644
index f4640be1e..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/EffectWobble.qml
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Effect {
- parameters: ListModel {
- ListElement {
- name: "Amplitude"
- value: 0.5
- }
- }
-
- // Transform slider values, and bind result to shader uniforms
- property real amplitude: parameters.get(0).value * 0.05
-
- property real frequency: 20
- property real time: 0
-
- NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
-
- fragmentShaderFilename: "wobble.fsh"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml
deleted file mode 100644
index 003f8736b..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileBrowser.qml
+++ /dev/null
@@ -1,392 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import Qt.labs.folderlistmodel 2.1
-
-Rectangle {
- id: fileBrowser
- color: "transparent"
- z: 4
-
- property string folder
- property bool shown: loader.sourceComponent
-
- signal fileSelected(string file)
-
- function selectFile(file) {
- if (file !== "") {
- folder = loader.item.folders.folder
- fileBrowser.fileSelected(file)
- }
- loader.sourceComponent = undefined
- }
-
- Loader {
- id: loader
- }
-
- function show() {
- loader.sourceComponent = fileBrowserComponent
- loader.item.parent = fileBrowser
- loader.item.anchors.fill = fileBrowser
- loader.item.folder = fileBrowser.folder
- }
-
- Component {
- id: fileBrowserComponent
-
- Rectangle {
- id: root
- color: "black"
- property bool showFocusHighlight: false
- property variant folders: folders1
- property variant view: view1
- property alias folder: folders1.folder
- property color textColor: "white"
-
- FolderListModel {
- id: folders1
- folder: folder
- }
-
- FolderListModel {
- id: folders2
- folder: folder
- }
-
- SystemPalette {
- id: palette
- }
-
- Component {
- id: folderDelegate
-
- Rectangle {
- id: wrapper
- function launch() {
- var path = "file://";
- if (filePath.length > 2 && filePath[1] === ':') // Windows drive logic, see QUrl::fromLocalFile()
- path += '/';
- path += filePath;
- if (folders.isFolder(index))
- down(path);
- else
- fileBrowser.selectFile(path)
- }
- width: root.width
- height: itemHeight
- color: "transparent"
-
- Rectangle {
- id: highlight; visible: false
- anchors.fill: parent
- color: palette.highlight
- gradient: Gradient {
- GradientStop { id: t1; position: 0.0; color: palette.highlight }
- GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
- }
- }
-
- Item {
- width: itemHeight; height: itemHeight
- Image {
- source: "qrc:/images/icon_Folder.png"
- fillMode: Image.PreserveAspectFit
- anchors.fill: parent
- anchors.margins: scaledMargin
- visible: folders.isFolder(index)
- }
- }
-
- Text {
- id: nameText
- anchors.fill: parent; verticalAlignment: Text.AlignVCenter
- text: fileName
- anchors.leftMargin: itemHeight + scaledMargin
- font.pixelSize: fontSize
- color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : textColor
- elide: Text.ElideRight
- }
-
- MouseArea {
- id: mouseRegion
- anchors.fill: parent
- onPressed: {
- root.showFocusHighlight = false;
- wrapper.ListView.view.currentIndex = index;
- }
- onClicked: { if (folders == wrapper.ListView.view.model) launch() }
- }
-
- states: [
- State {
- name: "pressed"
- when: mouseRegion.pressed
- PropertyChanges { target: highlight; visible: true }
- PropertyChanges { target: nameText; color: palette.highlightedText }
- }
- ]
- }
- }
-
- ListView {
- id: view1
- anchors.top: titleBar.bottom
- anchors.bottom: cancelButton.top
- x: 0
- width: parent.width
- model: folders1
- delegate: folderDelegate
- highlight: Rectangle {
- color: palette.highlight
- visible: root.showFocusHighlight && view1.count != 0
- gradient: Gradient {
- GradientStop { id: t1; position: 0.0; color: palette.highlight }
- GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
- }
- width: view1.currentItem == null ? 0 : view1.currentItem.width
- }
- highlightMoveVelocity: 1000
- pressDelay: 100
- focus: true
- state: "current"
- states: [
- State {
- name: "current"
- PropertyChanges { target: view1; x: 0 }
- },
- State {
- name: "exitLeft"
- PropertyChanges { target: view1; x: -root.width }
- },
- State {
- name: "exitRight"
- PropertyChanges { target: view1; x: root.width }
- }
- ]
- transitions: [
- Transition {
- to: "current"
- SequentialAnimation {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- },
- Transition {
- NumberAnimation { properties: "x"; duration: 250 }
- NumberAnimation { properties: "x"; duration: 250 }
- }
- ]
- Keys.onPressed: root.keyPressed(event.key)
- }
-
- ListView {
- id: view2
- anchors.top: titleBar.bottom
- anchors.bottom: parent.bottom
- x: parent.width
- width: parent.width
- model: folders2
- delegate: folderDelegate
- highlight: Rectangle {
- color: palette.highlight
- visible: root.showFocusHighlight && view2.count != 0
- gradient: Gradient {
- GradientStop { id: t1; position: 0.0; color: palette.highlight }
- GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
- }
- width: view1.currentItem == null ? 0 : view1.currentItem.width
- }
- highlightMoveVelocity: 1000
- pressDelay: 100
- states: [
- State {
- name: "current"
- PropertyChanges { target: view2; x: 0 }
- },
- State {
- name: "exitLeft"
- PropertyChanges { target: view2; x: -root.width }
- },
- State {
- name: "exitRight"
- PropertyChanges { target: view2; x: root.width }
- }
- ]
- transitions: [
- Transition {
- to: "current"
- SequentialAnimation {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- },
- Transition {
- NumberAnimation { properties: "x"; duration: 250 }
- }
- ]
- Keys.onPressed: root.keyPressed(event.key)
- }
-
- Button {
- id: cancelButton
- width: itemWidth
- height: itemHeight
- color: "#353535"
- anchors { bottom: parent.bottom; right: parent.right; margins: 5 * scaledMargin }
- text: "Cancel"
- horizontalAlign: Text.AlignHCenter
- onClicked: fileBrowser.selectFile("")
- }
-
- Keys.onPressed: {
- root.keyPressed(event.key);
- if (event.key === Qt.Key_Return || event.key === Qt.Key_Select || event.key === Qt.Key_Right) {
- view.currentItem.launch();
- event.accepted = true;
- } else if (event.key === Qt.Key_Left) {
- up();
- }
- }
-
- // titlebar
- Rectangle {
- color: "black"
- width: parent.width;
- height: itemHeight
- id: titleBar
-
- Rectangle {
- id: upButton
- width: titleBar.height
- height: titleBar.height
- color: "transparent"
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: scaledMargin
-
- Image { anchors.fill: parent; anchors.margins: scaledMargin; source: "qrc:/images/icon_BackArrow.png" }
- MouseArea { id: upRegion; anchors.fill: parent; onClicked: up() }
- states: [
- State {
- name: "pressed"
- when: upRegion.pressed
- PropertyChanges { target: upButton; color: palette.highlight }
- }
- ]
- }
-
- Text {
- anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
- anchors.leftMargin: 10; anchors.rightMargin: 4
- text: folders.folder
- color: "white"
- elide: Text.ElideLeft; horizontalAlignment: Text.AlignLeft; verticalAlignment: Text.AlignVCenter
- font.pixelSize: fontSize
- }
- }
-
- Rectangle {
- color: "#353535"
- width: parent.width
- height: 1
- anchors.top: titleBar.bottom
- }
-
- function down(path) {
- if (folders == folders1) {
- view = view2
- folders = folders2;
- view1.state = "exitLeft";
- } else {
- view = view1
- folders = folders1;
- view2.state = "exitLeft";
- }
- view.x = root.width;
- view.state = "current";
- view.focus = true;
- folders.folder = path;
- }
-
- function up() {
- var path = folders.parentFolder;
- if (path.toString().length === 0 || path.toString() === 'file:')
- return;
- if (folders == folders1) {
- view = view2
- folders = folders2;
- view1.state = "exitRight";
- } else {
- view = view1
- folders = folders1;
- view2.state = "exitRight";
- }
- view.x = -root.width;
- view.state = "current";
- view.focus = true;
- folders.folder = path;
- }
-
- function keyPressed(key) {
- switch (key) {
- case Qt.Key_Up:
- case Qt.Key_Down:
- case Qt.Key_Left:
- case Qt.Key_Right:
- root.showFocusHighlight = true;
- break;
- default:
- // do nothing
- break;
- }
- }
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml
deleted file mode 100644
index 62b60765e..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/FileOpen.qml
+++ /dev/null
@@ -1,162 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-
-Rectangle {
- id: root
- color: "#151515"
- signal openCamera
- signal openImage
- signal openVideo
- signal close
-
-
- Rectangle {
- id: menuField
- height: itemHeight
- width: itemHeight
- color: "transparent"
- anchors.right: parent.right
- Image {
- id: menu
- source: "qrc:///images/icon_Menu.png"
- anchors {
- right: parent.right
- top: parent.top
- margins: scaledMargin
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked: fileOpen.state == "expanded" ? fileOpen.state = "collapsed" : fileOpen.state = "expanded"
- }
- }
-
- Column {
- anchors {
- top: menuField.bottom
- right: parent.right
- left: parent.left
- bottom: parent.bottom
- topMargin: 10
- }
-
- spacing: 10
- visible: fileOpen.state == "expanded"
-
- Rectangle {
- width: 0.9 * parent.width
- height: 1
- color: "#353535"
- anchors.left: parent.left
- }
- Button {
- text: "Start camera"
- height: itemHeight
- width: parent.width
- onClicked: {
- fileOpen.state = "collapsed"
- root.openCamera()
- }
- }
- Rectangle {
- width: 0.9 * parent.width
- height: 1
- color: "#353535"
- anchors.left: parent.left
- }
- Button {
- text: "Open image"
- height: itemHeight
- width: parent.width
- onClicked: {
- fileOpen.state = "collapsed"
- root.openImage()
- }
- }
- Rectangle {
- width: 0.9 * parent.width
- height: 1
- color: "#353535"
- anchors.left: parent.left
- }
- Button {
- text: "Open video"
- height: itemHeight
- width: parent.width
- onClicked: {
- fileOpen.state = "collapsed"
- root.openVideo()
- }
- }
- Rectangle {
- width: 0.9 * parent.width
- height: 1
- color: "#353535"
- anchors.left: parent.left
- }
- Button {
- text: "Reset"
- height: itemHeight
- width: parent.width
- onClicked: {
- fileOpen.state = "collapsed"
- root.close()
- }
- }
- Rectangle {
- width: 0.9 * parent.width
- height: 1
- color: "#353535"
- anchors.left: parent.left
- }
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/HintedMouseArea.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/HintedMouseArea.qml
deleted file mode 100644
index 86750ff90..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/HintedMouseArea.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Mouse area which flashes to indicate its location on the screen
-
-import QtQuick 2.0
-
-MouseArea {
- property alias hintColor: hintRect.color
- property bool hintEnabled: true
-
- Rectangle {
- id: hintRect
- anchors.fill: parent
- color: "yellow"
- opacity: 0
-
- states: [
- State {
- name: "high"
- PropertyChanges {
- target: hintRect
- opacity: 0.8
- }
- },
- State {
- name: "low"
- PropertyChanges {
- target: hintRect
- opacity: 0.4
- }
- }
- ]
-
- transitions: [
- Transition {
- from: "low"
- to: "high"
- SequentialAnimation {
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.InOutSine
- duration: 500
- }
- ScriptAction { script: hintRect.state = "low" }
- }
- },
- Transition {
- from: "*"
- to: "low"
- SequentialAnimation {
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.InOutSine
- duration: 500
- }
- ScriptAction { script: hintRect.state = "high" }
- }
- },
- Transition {
- from: "*"
- to: "baseState"
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.InOutSine
- duration: 500
- }
- }
- ]
- }
-
- onHintEnabledChanged: hintRect.state = hintEnabled ? "low" : "baseState"
-
- Component.onCompleted: hintRect.state = "low"
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Main.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Main.qml
deleted file mode 100644
index e6da715f4..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Main.qml
+++ /dev/null
@@ -1,296 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-import QtQuick.Window 2.1
-
-Rectangle {
- id: root
- color: "black"
- property string fileName
- property alias volume: content.volume
- property bool perfMonitorsLogging: false
- property bool perfMonitorsVisible: false
- property int pixDens: Math.ceil(Screen.pixelDensity)
- property int itemWidth: 25 * pixDens
- property int itemHeight: 10 * pixDens
- property int windowWidth: Screen.desktopAvailableWidth
- property int windowHeight: Screen.desktopAvailableHeight
- property int scaledMargin: 2 * pixDens
- property int fontSize: 5 * pixDens
-
- QtObject {
- id: d
- property real gripSize: 20
- }
-
- Content {
- id: content
- color: "transparent"
- anchors {
- top: parent.top
- left: parent.left
- right: parent.right
- bottom: parameterPanel.top
- margins: scaledMargin
- leftMargin: scaledMargin + itemHeight
- }
- gripSize: d.gripSize
- }
-
- ParameterPanel {
- id: parameterPanel
- anchors {
- left: parent.left
- right: effectName.left
- bottom: parent.bottom
- margins: scaledMargin
- leftMargin: scaledMargin + itemHeight
- }
- gripSize: d.gripSize
- height: root.itemHeight * 2.5
- width: root.itemWidth * 3
- }
-
- Button {
- id: effectName
- anchors {
- right: parent.right
- bottom: perfHolder.top
- margins: scaledMargin
- }
-
- text: "No effect"
- width: itemWidth * 2
- height: itemHeight
- onClicked: {
- effectName.visible = false
- listview.visible = true
- lvbg.visible = true
- }
- color: "#303030"
- }
-
- Rectangle {
- id: lvbg
- width: itemWidth * 2
- color: "black"
- opacity: 0.8
- visible: false
-
- anchors {
- right: parent.right
- bottom: perfHolder.top
- top: parent.top
- margins: scaledMargin
- }
-
- ListView {
- id: listview
- width: itemWidth * 2
- anchors.fill: parent
- visible: false
-
- model: EffectSelectionList {}
- delegate: effectDelegate
-
- clip: true
- focus: true
-
- Component {
- id: effectDelegate
- Button {
- text: name
- width: itemWidth * 2
- onClicked: {
- content.effectSource = source
- listview.visible = false
- lvbg.visible = false
- effectName.text = name
- effectName.visible = true
- parameterPanel.model = content.effect.parameters
-
- }
- }
- }
- }
- }
-
- Rectangle {
- id: perfHolder
- color: "transparent"
- anchors {
- right: parent.right
- bottom: parent.bottom
- margins: scaledMargin
- }
- height: root.itemHeight * 1.5
- width: root.itemWidth
-
- Loader {
- id: performanceLoader
- function init() {
- var enabled = root.perfMonitorsLogging || root.perfMonitorsVisible
- source = enabled ? "../performancemonitor/PerformanceItem.qml" : ""
- }
- onLoaded: {
- item.parent = perfHolder
- item.anchors.top = perfHolder.top
- item.anchors.bottom = perfHolder.bottom
- item.anchors.left = perfHolder.left
- item.anchors.right = perfHolder.right
- item.logging = root.perfMonitorsLogging
- item.displayed = root.perfMonitorsVisible
- item.init()
- }
- }
- }
-
- FileOpen {
- id: fileOpen
- state: "collapsed"
- anchors {
- left: parent.left
- top: parent.top
- bottom: parent.bottom
- margins: scaledMargin
- }
- width: itemHeight + scaledMargin
- z: 2
- opacity: 0.9
-
- states: [
- State {
- name: "expanded"
- PropertyChanges {
- target: fileOpen
- width: itemWidth * 1.5
- opacity: 0.8
- }
- },
- State {
- name: "collapsed"
- PropertyChanges {
- target: fileOpen
- width: itemHeight + scaledMargin
- opacity: 0.9
- }
- }
- ]
-
- transitions: [
- Transition {
- NumberAnimation { target: fileOpen; property: "width"; duration: 100 }
- NumberAnimation { target: fileOpen; property: "opacity"; duration: 100 }
- }
- ]
- }
-
- FileBrowser {
- id: imageFileBrowser
- anchors.fill: root
- Component.onCompleted: fileSelected.connect(content.openImage)
- }
-
- FileBrowser {
- id: videoFileBrowser
- anchors.fill: root
- Component.onCompleted: fileSelected.connect(content.openVideo)
- }
-
- Component.onCompleted: {
- fileOpen.openImage.connect(openImage)
- fileOpen.openVideo.connect(openVideo)
- fileOpen.openCamera.connect(openCamera)
- fileOpen.close.connect(close)
- }
-
- function init() {
- if (Qt.platform.os === "linux" || Qt.platform.os === "windows" || Qt.platform.os === "osx" || Qt.platform.os === "unix") {
- if (Screen.desktopAvailableWidth > 1280) {
- windowWidth = 1280
- }
- if (Screen.desktopAvailableHeight > 720) {
- windowHeight = 720
- }
- }
-
- height = windowHeight
- width = windowWidth
-
- imageFileBrowser.folder = imagePath
- videoFileBrowser.folder = videoPath
- content.init()
- performanceLoader.init()
- if (fileName != "")
- content.openVideo(fileName)
- }
-
- function qmlFramePainted() {
- if (performanceLoader.item)
- performanceLoader.item.qmlFramePainted()
- }
-
- function openImage() {
- imageFileBrowser.show()
- }
-
- function openVideo() {
- videoFileBrowser.show()
- }
-
- function openCamera() {
- content.openCamera()
- }
-
- function close() {
- content.init()
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml
deleted file mode 100644
index 7d6b2af97..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/ParameterPanel.qml
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- color: "transparent"
- height: view.model.count * sliderHeight
- property color lineColor: "black"
- property real gripSize: 25
- property real spacing: 20
- property real sliderHeight: 60
-
- property ListModel model: ListModel { }
-
- anchors.topMargin: 10
-
- Component {
- id: editDelegate
-
- Rectangle {
- id: delegate
- width: parent.width
- height: root.sliderHeight
- color: "transparent"
-
- Text {
- id: text
- text: name
- color: "white"
- anchors {
- top: parent.top
- bottom: parent.bottom
- left: parent.left
- }
- font.pixelSize: fontSize
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- width: 8 * fontSize
- }
-
- Slider {
- anchors {
- top: parent.top
- bottom: parent.bottom
- left: text.right
- leftMargin: 20
- right: parent.right
- rightMargin: 20
- }
- gripSize: root.gripSize
- value: model.value
- onValueChanged: view.model.setProperty(index, "value", value)
- }
- }
- }
-
- ListView {
- id: view
- anchors.fill: parent
- model: root.model
- delegate: editDelegate
- interactive: false
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Slider.qml b/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Slider.qml
deleted file mode 100644
index e359c639d..000000000
--- a/examples/multimedia/video/qmlvideofx/qml/qmlvideofx/Slider.qml
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.1
-
-Rectangle {
- id: root
- color: "transparent"
- radius: 5
- property alias value: grip.value
- property color fillColor: "#14aaff"
- property real gripSize: 40
- property real gripTolerance: 3.0
- property real increment: 0.1
- property bool enabled: true
-
- Rectangle {
- id: slider
- anchors {
- left: parent.left
- right: parent.right
- verticalCenter: parent.verticalCenter
- }
- height: 10
- color: "transparent"
-
- BorderImage {
- id: sliderbarimage
- source: "qrc:/images/Slider_bar.png"
- anchors { fill: parent; margins: 1 }
- border.right: 5
- border.left: 5
- }
- Rectangle {
- height: parent.height -2
- anchors.left: parent.left
- anchors.right: grip.horizontalCenter
- color: root.fillColor
- radius: 3
- border.width: 1
- border.color: Qt.darker(color, 1.3)
- opacity: 0.8
- }
- Rectangle {
- id: grip
- property real value: 0.5
- x: (value * parent.width) - width/2
- anchors.verticalCenter: parent.verticalCenter
- width: root.gripTolerance * root.gripSize
- height: width
- radius: width/2
- color: "transparent"
-
- Image {
- id: sliderhandleimage
- source: "qrc:/images/Slider_handle.png"
- anchors.centerIn: parent
- }
-
- MouseArea {
- id: mouseArea
- enabled: root.enabled
- anchors.fill: parent
- drag {
- target: grip
- axis: Drag.XAxis
- minimumX: -parent.width/2
- maximumX: root.width - parent.width/2
- }
- onPositionChanged: {
- if (drag.active)
- updatePosition()
- }
- onReleased: {
- updatePosition()
- }
- function updatePosition() {
- value = (grip.x + grip.width/2) / slider.width
- }
- }
- }
-
- }
-}
diff --git a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp
deleted file mode 100644
index 27102b0c5..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "qmlapplicationviewer.h"
-
-#include <QtCore/QDir>
-#include <QtCore/QFileInfo>
-#include <QtQml/QQmlComponent>
-#include <QtQml/QQmlEngine>
-#include <QtQml/QQmlContext>
-#include <QtGui/QGuiApplication>
-
-class QmlApplicationViewerPrivate
-{
- QmlApplicationViewerPrivate(QQuickView *view_) : view(view_) {}
-
- QString mainQmlFile;
- QQuickView *view;
- friend class QmlApplicationViewer;
- QString adjustPath(const QString &path);
-};
-
-QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
-{
-#ifdef Q_OS_UNIX
-#ifdef Q_OS_MAC
- if (!QDir::isAbsolutePath(path))
- return QCoreApplication::applicationDirPath()
- + QLatin1String("/../Resources/") + path;
-#else
- QString pathInInstallDir;
- const QString applicationDirPath = QCoreApplication::applicationDirPath();
- pathInInstallDir = QString::fromLatin1("%1/../%2").arg(applicationDirPath, path);
-
- if (QFileInfo(pathInInstallDir).exists())
- return pathInInstallDir;
-#endif
-#endif
- return path;
-}
-
-QmlApplicationViewer::QmlApplicationViewer(QWindow *parent)
- : QQuickView(parent)
- , d(new QmlApplicationViewerPrivate(this))
-{
- connect(engine(), &QQmlEngine::quit, QCoreApplication::instance(), &QCoreApplication::quit);
- setResizeMode(QQuickView::SizeRootObjectToView);
-}
-
-QmlApplicationViewer::QmlApplicationViewer(QQuickView *view, QWindow *parent)
- : QQuickView(parent)
- , d(new QmlApplicationViewerPrivate(view))
-{
- connect(view->engine(), &QQmlEngine::quit, QCoreApplication::instance(), &QCoreApplication::quit);
- view->setResizeMode(QQuickView::SizeRootObjectToView);
-}
-
-QmlApplicationViewer::~QmlApplicationViewer()
-{
- delete d;
-}
-
-QmlApplicationViewer *QmlApplicationViewer::create()
-{
- return new QmlApplicationViewer();
-}
-
-void QmlApplicationViewer::setMainQmlFile(const QString &file)
-{
- d->mainQmlFile = d->adjustPath(file);
- d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
-}
-
-void QmlApplicationViewer::addImportPath(const QString &path)
-{
- d->view->engine()->addImportPath(d->adjustPath(path));
-}
-
-void QmlApplicationViewer::showExpanded()
-{
-#if defined(Q_WS_SIMULATOR)
- d->view->showFullScreen();
-#else
- d->view->show();
-#endif
-}
-
-QGuiApplication *createApplication(int &argc, char **argv)
-{
- return new QGuiApplication(argc, argv);
-}
diff --git a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.h b/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.h
deleted file mode 100644
index 8af12477f..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef QMLAPPLICATIONVIEWER_H
-#define QMLAPPLICATIONVIEWER_H
-
-#include <QtQuick/QQuickView>
-#include <QtGui/QGuiApplication>
-
-class QmlApplicationViewer : public QQuickView
-{
- Q_OBJECT
-
-public:
- explicit QmlApplicationViewer(QWindow *parent = 0);
- virtual ~QmlApplicationViewer();
-
- static QmlApplicationViewer *create();
-
- void setMainQmlFile(const QString &file);
- void addImportPath(const QString &path);
-
- void showExpanded();
-
-private:
- explicit QmlApplicationViewer(QQuickView *view, QWindow *parent);
- class QmlApplicationViewerPrivate *d;
-};
-
-QGuiApplication *createApplication(int &argc, char **argv);
-
-#endif // QMLAPPLICATIONVIEWER_H
diff --git a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.pri b/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.pri
deleted file mode 100644
index d9807943e..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlapplicationviewer/qmlapplicationviewer.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-QT += quick
-
-SOURCES += $$PWD/qmlapplicationviewer.cpp
-HEADERS += $$PWD/qmlapplicationviewer.h
-INCLUDEPATH += $$PWD
-
-
diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.png b/examples/multimedia/video/qmlvideofx/qmlvideofx.png
deleted file mode 100644
index 707d5c4e8..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlvideofx.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro b/examples/multimedia/video/qmlvideofx/qmlvideofx.pro
deleted file mode 100644
index 07047aec8..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlvideofx.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-TEMPLATE = app
-TARGET = qmlvideofx
-
-QT += quick multimedia
-android: qtHaveModule(androidextras) {
- QT += androidextras
- DEFINES += REQUEST_PERMISSIONS_ON_ANDROID
-}
-
-SOURCES += filereader.cpp main.cpp
-HEADERS += filereader.h trace.h
-
-RESOURCES += qmlvideofx.qrc
-
-include($$PWD/../snippets/performancemonitor/performancemonitordeclarative.pri)
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/qmlvideofx
-INSTALLS += target
-
-QMAKE_INFO_PLIST = Info.plist
-
-EXAMPLE_FILES += \
- qmlvideofx.png \
- qmlvideofx.svg
diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc b/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc
deleted file mode 100644
index f3ad27704..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlvideofx.qrc
+++ /dev/null
@@ -1,71 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>images/qt-logo.png</file>
- <file>qml/qmlvideofx/Button.qml</file>
- <file>qml/qmlvideofx/Content.qml</file>
- <file>qml/qmlvideofx/ContentCamera.qml</file>
- <file>qml/qmlvideofx/ContentImage.qml</file>
- <file>qml/qmlvideofx/ContentVideo.qml</file>
- <file>qml/qmlvideofx/Divider.qml</file>
- <file>qml/qmlvideofx/Effect.qml</file>
- <file>qml/qmlvideofx/EffectBillboard.qml</file>
- <file>qml/qmlvideofx/EffectBlackAndWhite.qml</file>
- <file>qml/qmlvideofx/EffectEmboss.qml</file>
- <file>qml/qmlvideofx/EffectGaussianBlur.qml</file>
- <file>qml/qmlvideofx/EffectGlow.qml</file>
- <file>qml/qmlvideofx/EffectIsolate.qml</file>
- <file>qml/qmlvideofx/EffectMagnify.qml</file>
- <file>qml/qmlvideofx/EffectPageCurl.qml</file>
- <file>qml/qmlvideofx/EffectPassThrough.qml</file>
- <file>qml/qmlvideofx/EffectPixelate.qml</file>
- <file>qml/qmlvideofx/EffectPosterize.qml</file>
- <file>qml/qmlvideofx/EffectRipple.qml</file>
- <file>qml/qmlvideofx/EffectSepia.qml</file>
- <file>qml/qmlvideofx/EffectSharpen.qml</file>
- <file>qml/qmlvideofx/EffectShockwave.qml</file>
- <file>qml/qmlvideofx/EffectSobelEdgeDetection1.qml</file>
- <file>qml/qmlvideofx/EffectTiltShift.qml</file>
- <file>qml/qmlvideofx/EffectToon.qml</file>
- <file>qml/qmlvideofx/EffectVignette.qml</file>
- <file>qml/qmlvideofx/EffectWarhol.qml</file>
- <file>qml/qmlvideofx/EffectWobble.qml</file>
- <file>qml/qmlvideofx/FileBrowser.qml</file>
- <file>qml/qmlvideofx/FileOpen.qml</file>
- <file>qml/qmlvideofx/HintedMouseArea.qml</file>
- <file>qml/qmlvideofx/ParameterPanel.qml</file>
- <file>qml/qmlvideofx/Slider.qml</file>
- <file>shaders/billboard.fsh</file>
- <file>shaders/blackandwhite.fsh</file>
- <file>shaders/emboss.fsh</file>
- <file>shaders/gaussianblur_h.fsh</file>
- <file>shaders/gaussianblur_v.fsh</file>
- <file>shaders/glow.fsh</file>
- <file>shaders/isolate.fsh</file>
- <file>shaders/magnify.fsh</file>
- <file>shaders/pagecurl.fsh</file>
- <file>shaders/pixelate.fsh</file>
- <file>shaders/posterize.fsh</file>
- <file>shaders/ripple.fsh</file>
- <file>shaders/selectionpanel.fsh</file>
- <file>shaders/sepia.fsh</file>
- <file>shaders/sharpen.fsh</file>
- <file>shaders/shockwave.fsh</file>
- <file>shaders/sobeledgedetection1.fsh</file>
- <file>shaders/tiltshift.fsh</file>
- <file>shaders/toon.fsh</file>
- <file>shaders/vignette.fsh</file>
- <file>shaders/warhol.fsh</file>
- <file>shaders/wobble.fsh</file>
- <file>images/Slider_handle.png</file>
- <file>images/Slider_bar.png</file>
- <file>qml/qmlvideofx/Curtain.qml</file>
- <file>images/Triangle_bottom.png</file>
- <file>images/Triangle_Top.png</file>
- <file>images/Dropdown_arrows.png</file>
- <file>images/icon_Folder.png</file>
- <file>images/icon_BackArrow.png</file>
- <file>qml/qmlvideofx/Main.qml</file>
- <file>images/icon_Menu.png</file>
- <file>qml/qmlvideofx/EffectSelectionList.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/multimedia/video/qmlvideofx/qmlvideofx.svg b/examples/multimedia/video/qmlvideofx/qmlvideofx.svg
deleted file mode 100644
index 566acfada..000000000
--- a/examples/multimedia/video/qmlvideofx/qmlvideofx.svg
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- height="44px"
- version="1.1"
- viewBox="0 0 44 44"
- width="44px"
- x="0px"
- y="0px"
- id="svg2"
- inkscape:version="0.47 r22583"
- sodipodi:docname="qt.svg">
- <metadata
- id="metadata18">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs16">
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 22 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="44 : 22 : 1"
- inkscape:persp3d-origin="22 : 14.666667 : 1"
- id="perspective2836" />
- </defs>
- <sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1920"
- inkscape:window-height="1020"
- id="namedview14"
- showgrid="false"
- inkscape:zoom="21.454545"
- inkscape:cx="49.412871"
- inkscape:cy="21.894358"
- inkscape:window-x="-4"
- inkscape:window-y="-4"
- inkscape:window-maximized="1"
- inkscape:current-layer="g3" />
- <g
- transform="matrix(0.18308778,0,0,0.18308778,6.6100946,3.2385199)"
- id="g3">
- <path
- d="M 43.09,0.3586 C 40.94,0.0036 38.84,-0.0824 36.81,0.0776 31.968136,0.39505671 27.122677,0.73638425 22.28,1.0696 9.62,2.0816 0,12.4996 0,26.8896 l 0,169.7 14.19,13.2 28.87,-209.42 0.03,-0.011 z"
- style="fill:#006225"
- id="path5"
- sodipodi:nodetypes="cccccccc" />
- <path
- d="m 174.4,160 c 0,12.5 -7.75,24.07 -17.57,25.77 L 14.23,209.73 V 25.93 C 14.23,9.21 27.57,-2.27 43.12,0.3 l 131.3,21.52 v 138.2 z"
- style="fill:#80c342"
- id="path7" />
- <path
- d="m 154.9,80.96 -12.96,-0.598 0,0.278 6.945,0.32 6.016,0 z"
- style="fill:#006225"
- id="path11" />
- <path
- d="m 144.6,135.6 c 0.66,0.328 1.43,0.476 2.351,0.476 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 h -6.015 c -1.821,0.832 -3.532,1.457 -5.176,1.848 z"
- style="fill:#006225"
- id="path13" />
- <path
- id="path17"
- style="fill:#ffffff"
- d="m 91.15,132.4 c 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -4.34,0 -7.68,2.535 -10.01,7.625 -2.52,5.543 -3.793,17.04 -3.793,34.44 0,16.82 1.238,28.75 3.734,35.75 2.356,6.672 5.879,9.976 10.5,9.976 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 m 17.98,3.75 c -4.117,9.707 -10.39,16.06 -18.99,19 0.867,4.449 2.176,7.441 3.922,9.019 1.351,1.211 3.433,1.821 6.222,1.821 0.805,0 1.668,-0.055 2.59,-0.157 v 13.12 l -5.961,0.782 c -1.758,0.23 -3.426,0.343 -5.004,0.343 -5.218,0 -9.445,-1.265 -12.62,-3.824 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 1.629,0 3.309,0.102 5.043,0.305 11.95,1.375 20.62,7.016 26.26,16.79 5.535,9.562 8.254,23.27 8.254,41.26 0,16.48 -2,29.45 -6.043,39.02 z M 130.4,45.91 l 11.52,1.238 0,20.21 12.96,0.914 0,12.68 -12.96,-0.598 0,46.33 c 0,4.032 0.445,6.625 1.34,7.789 0.8,1.067 2.046,1.594 3.71,1.594 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 v 11.65 c -5.136,2.258 -10.18,3.598 -15.12,4.02 -0.718,0.055 -1.41,0.086 -2.078,0.086 -4.48,0 -7.906,-1.301 -10.25,-3.934 -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.535 L 118.046,79.25 V 65.66 l 7.586,0.547 4.773,-20.3 z" />
- <path
- d="m 100.3,166 c 0.809,0 1.672,-0.055 2.59,-0.157 H 98.054 C 98.73,165.949 99.507,166 100.3,166 z"
- style="fill:#006225"
- id="path19" />
- <path
- id="path21"
- style="fill:#006225"
- d="m 84.85,63.98 c 2.336,5.997 3.484,16.92 3.484,32.81 0,17.7 -1.16,29.57 -3.512,35.62 -1.894,4.879 -4.527,7.902 -7.863,9.07 0.965,0.368 1.992,0.551 3.078,0.551 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -1.09,0 -2.117,0.16 -3.082,0.481 h -0.004 c 3.601,1.121 6.379,4.215 8.336,9.261 z m -2.344,114.3 c -0.113,-0.05 -0.227,-0.105 -0.336,-0.16 -0.012,-0.004 -0.023,-0.012 -0.035,-0.015 -0.102,-0.051 -0.207,-0.106 -0.309,-0.157 -0.019,-0.011 -0.039,-0.019 -0.058,-0.031 -0.09,-0.051 -0.184,-0.098 -0.278,-0.148 -0.027,-0.016 -0.054,-0.036 -0.086,-0.051 -0.082,-0.043 -0.164,-0.09 -0.242,-0.137 -0.039,-0.023 -0.078,-0.047 -0.113,-0.07 -0.07,-0.039 -0.145,-0.082 -0.215,-0.125 -0.047,-0.031 -0.094,-0.059 -0.14,-0.09 -0.059,-0.039 -0.118,-0.074 -0.176,-0.113 -0.059,-0.039 -0.114,-0.075 -0.168,-0.114 -0.051,-0.031 -0.102,-0.066 -0.149,-0.097 -0.066,-0.047 -0.132,-0.094 -0.195,-0.137 -0.039,-0.027 -0.078,-0.055 -0.113,-0.082 -0.078,-0.055 -0.153,-0.113 -0.231,-0.172 -0.023,-0.016 -0.05,-0.035 -0.078,-0.055 -0.098,-0.078 -0.199,-0.156 -0.297,-0.234 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 h -6.351 c -10.15,0.008 -18.22,3.977 -24,12.04 -6.855,9.563 -10.34,24.64 -10.34,45.07 0,18.95 2.547,33.44 7.551,43.34 4.934,9.75 12.05,15.56 21.19,17.5 1.989,9.641 5.09,16.16 9.297,19.54 3.176,2.559 7.403,3.824 12.62,3.824 0.098,0 0.199,0 0.297,-0.004 h 5.539 c -3.406,-0.05 -6.383,-0.66 -8.906,-1.828 L 82.498,178.28 z M 128.4,145.6 c -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.57 l -6.226,-0.285 v -13.59 h -6.016 v 3.035 c 0.871,3.273 1.555,6.82 2.063,10.64 l 4.164,0.192 v 51.36 c 0,6.723 1.367,11.62 4.09,14.67 2.343,2.633 5.765,3.934 10.25,3.934 h 6.015 c -4.48,0 -7.906,-1.301 -10.25,-3.934 z m 2.043,-99.66 -6.016,0 -4.668,19.88 5.911,0.422 4.773,-20.3 z" />
- </g>
-</svg>
diff --git a/examples/multimedia/video/qmlvideofx/shaders/billboard.fsh b/examples/multimedia/video/qmlvideofx/shaders/billboard.fsh
deleted file mode 100644
index b733d94ae..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/billboard.fsh
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float grid;
-uniform float dividerValue;
-uniform float step_x;
-uniform float step_y;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- float offx = floor(uv.x / (grid * step_x));
- float offy = floor(uv.y / (grid * step_y));
- vec3 res = texture2D(source, vec2(offx * grid * step_x , offy * grid * step_y)).rgb;
- vec2 prc = fract(uv / vec2(grid * step_x, grid * step_y));
- vec2 pw = pow(abs(prc - 0.5), vec2(2.0));
- float rs = pow(0.45, 2.0);
- float gr = smoothstep(rs - 0.1, rs + 0.1, pw.x + pw.y);
- float y = (res.r + res.g + res.b) / 3.0;
- vec3 ra = res / y;
- float ls = 0.3;
- float lb = ceil(y / ls);
- float lf = ls * lb + 0.3;
- res = lf * res;
- vec3 col = mix(res, vec3(0.1, 0.1, 0.1), gr);
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
- else
- gl_FragColor = qt_Opacity * texture2D(source, uv);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/blackandwhite.fsh b/examples/multimedia/video/qmlvideofx/shaders/blackandwhite.fsh
deleted file mode 100644
index 3eeff5925..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/blackandwhite.fsh
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float threshold;
-uniform float dividerValue;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 orig = texture2D(source, uv);
- vec3 col = orig.rgb;
- float y = 0.3 *col.r + 0.59 * col.g + 0.11 * col.b;
- y = y < threshold ? 0.0 : 1.0;
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(y, y, y, 1.0);
- else
- gl_FragColor = qt_Opacity * orig;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/emboss.fsh b/examples/multimedia/video/qmlvideofx/shaders/emboss.fsh
deleted file mode 100644
index 41f5f1b37..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/emboss.fsh
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-const float step_w = 0.0015625;
-const float step_h = 0.0027778;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec3 t1 = texture2D(source, vec2(uv.x - step_w, uv.y - step_h)).rgb;
- vec3 t2 = texture2D(source, vec2(uv.x, uv.y - step_h)).rgb;
- vec3 t3 = texture2D(source, vec2(uv.x + step_w, uv.y - step_h)).rgb;
- vec3 t4 = texture2D(source, vec2(uv.x - step_w, uv.y)).rgb;
- vec3 t5 = texture2D(source, uv).rgb;
- vec3 t6 = texture2D(source, vec2(uv.x + step_w, uv.y)).rgb;
- vec3 t7 = texture2D(source, vec2(uv.x - step_w, uv.y + step_h)).rgb;
- vec3 t8 = texture2D(source, vec2(uv.x, uv.y + step_h)).rgb;
- vec3 t9 = texture2D(source, vec2(uv.x + step_w, uv.y + step_h)).rgb;
- vec3 rr = -4.0 * t1 - 4.0 * t2 - 4.0 * t4 + 12.0 * t5;
- float y = (rr.r + rr.g + rr.b) / 3.0;
- vec3 col = vec3(y, y, y) + 0.3;
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
- else
- gl_FragColor = qt_Opacity * texture2D(source, uv);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/gaussianblur_h.fsh b/examples/multimedia/video/qmlvideofx/shaders/gaussianblur_h.fsh
deleted file mode 100644
index 794e371ad..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/gaussianblur_h.fsh
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-uniform float dividerValue;
-uniform float blurSize;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 c = vec4(0.0);
- if (uv.x < dividerValue) {
- c += texture2D(source, uv - vec2(4.0*blurSize, 0.0)) * 0.05;
- c += texture2D(source, uv - vec2(3.0*blurSize, 0.0)) * 0.09;
- c += texture2D(source, uv - vec2(2.0*blurSize, 0.0)) * 0.12;
- c += texture2D(source, uv - vec2(1.0*blurSize, 0.0)) * 0.15;
- c += texture2D(source, uv) * 0.18;
- c += texture2D(source, uv + vec2(1.0*blurSize, 0.0)) * 0.15;
- c += texture2D(source, uv + vec2(2.0*blurSize, 0.0)) * 0.12;
- c += texture2D(source, uv + vec2(3.0*blurSize, 0.0)) * 0.09;
- c += texture2D(source, uv + vec2(4.0*blurSize, 0.0)) * 0.05;
- } else {
- c = texture2D(source, qt_TexCoord0);
- }
- gl_FragColor = qt_Opacity * c;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/gaussianblur_v.fsh b/examples/multimedia/video/qmlvideofx/shaders/gaussianblur_v.fsh
deleted file mode 100644
index 975dfcf5d..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/gaussianblur_v.fsh
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-uniform float dividerValue;
-uniform float blurSize;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 c = vec4(0.0);
- if (uv.x < dividerValue) {
- c += texture2D(source, uv - vec2(0.0, 4.0*blurSize)) * 0.05;
- c += texture2D(source, uv - vec2(0.0, 3.0*blurSize)) * 0.09;
- c += texture2D(source, uv - vec2(0.0, 2.0*blurSize)) * 0.12;
- c += texture2D(source, uv - vec2(0.0, 1.0*blurSize)) * 0.15;
- c += texture2D(source, uv) * 0.18;
- c += texture2D(source, uv + vec2(0.0, 1.0*blurSize)) * 0.15;
- c += texture2D(source, uv + vec2(0.0, 2.0*blurSize)) * 0.12;
- c += texture2D(source, uv + vec2(0.0, 3.0*blurSize)) * 0.09;
- c += texture2D(source, uv + vec2(0.0, 4.0*blurSize)) * 0.05;
- } else {
- c = texture2D(source, qt_TexCoord0);
- }
- // First pass we don't apply opacity
- gl_FragColor = c;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/glow.fsh b/examples/multimedia/video/qmlvideofx/shaders/glow.fsh
deleted file mode 100644
index 8edc603d2..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/glow.fsh
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-const float step_w = 0.0015625;
-const float step_h = 0.0027778;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec3 t1 = texture2D(source, vec2(uv.x - step_w, uv.y - step_h)).rgb;
- vec3 t2 = texture2D(source, vec2(uv.x, uv.y - step_h)).rgb;
- vec3 t3 = texture2D(source, vec2(uv.x + step_w, uv.y - step_h)).rgb;
- vec3 t4 = texture2D(source, vec2(uv.x - step_w, uv.y)).rgb;
- vec3 t5 = texture2D(source, uv).rgb;
- vec3 t6 = texture2D(source, vec2(uv.x + step_w, uv.y)).rgb;
- vec3 t7 = texture2D(source, vec2(uv.x - step_w, uv.y + step_h)).rgb;
- vec3 t8 = texture2D(source, vec2(uv.x, uv.y + step_h)).rgb;
- vec3 t9 = texture2D(source, vec2(uv.x + step_w, uv.y + step_h)).rgb;
- vec3 xx = t1 + 2.0*t2 + t3 - t7 - 2.0*t8 - t9;
- vec3 yy = t1 - t3 + 2.0*t4 - 2.0*t6 + t7 - t9;
- vec3 rr = sqrt(xx * xx + yy * yy);
- vec3 col = rr * 2.0 * t5;
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
- else
- gl_FragColor = qt_Opacity * texture2D(source, uv);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/isolate.fsh b/examples/multimedia/video/qmlvideofx/shaders/isolate.fsh
deleted file mode 100644
index c6da45b4a..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/isolate.fsh
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float targetHue;
-uniform float windowWidth;
-uniform float dividerValue;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void rgb2hsl(vec3 rgb, out float h, out float s, float l)
-{
- float maxval = max(rgb.r, max(rgb.g, rgb.b));
- float minval = min(rgb.r, min(rgb.g, rgb.b));
- float delta = maxval - minval;
- l = (minval + maxval) / 2.0;
- s = 0.0;
- if (l > 0.0 && l < 1.0)
- s = delta / (l < 0.5 ? 2.0 * l : 2.0 - 2.0 * l);
- h = 0.0;
- if (delta > 0.0)
- {
- if (rgb.r == maxval && rgb.g != maxval)
- h += (rgb.g - rgb.b ) / delta;
- if (rgb.g == maxval && rgb.b != maxval)
- h += 2.0 + (rgb.b - rgb.r) / delta;
- if (rgb.b == maxval && rgb.r != maxval)
- h += 4.0 + (rgb.r - rgb.g) / delta;
- h *= 60.0;
- }
-}
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec3 col = texture2D(source, uv).rgb;
- float h, s, l;
- rgb2hsl(col, h, s, l);
- float h2 = (h > targetHue) ? h - 360.0 : h + 360.0;
- float y = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
- vec3 result;
- if (uv.x > dividerValue || (abs(h - targetHue) < windowWidth) || (abs(h2 - targetHue) < windowWidth))
- result = col;
- else
- result = vec3(y, y, y);
- gl_FragColor = qt_Opacity * vec4(result, 1.0);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/magnify.fsh b/examples/multimedia/video/qmlvideofx/shaders/magnify.fsh
deleted file mode 100644
index f7621bed3..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/magnify.fsh
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://www.reddit.com/r/programming/comments/losip/shader_toy/c2upn1e
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-uniform float radius;
-uniform float diffractionIndex;
-uniform float targetWidth;
-uniform float targetHeight;
-uniform float posX;
-uniform float posY;
-uniform float pixDens;
-
-void main()
-{
- vec2 tc = qt_TexCoord0;
- vec2 center = vec2(posX, posY);
- vec2 xy = gl_FragCoord.xy - center.xy;
- xy.x -= (pixDens * 14.0);
- xy.y -= (pixDens * 29.0);
- float r = sqrt(xy.x * xy.x + xy.y * xy.y);
- if (r < radius) {
- float h = diffractionIndex * 0.5 * radius;
- vec2 new_xy = r < radius ? xy * (radius - h) / sqrt(radius * radius - r * r) : xy;
- vec2 targetSize = vec2(targetWidth, targetHeight);
- tc = (new_xy + center) / targetSize;
- tc.y = 1.0 - tc.y;
- }
- gl_FragColor = qt_Opacity * texture2D(source, tc);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/pagecurl.fsh b/examples/multimedia/video/qmlvideofx/shaders/pagecurl.fsh
deleted file mode 100644
index 12a5455e6..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/pagecurl.fsh
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://rectalogic.github.com/webvfx/examples_2transition-shader-pagecurl_8html-example.html
-
-uniform float dividerValue;
-uniform float curlExtent;
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-const float minAmount = -0.16;
-const float maxAmount = 1.3;
-const float PI = 3.14159265358979323846;
-const float scale = 512.0;
-const float sharpness = 3.0;
-const vec4 bgColor = vec4(1.0, 1.0, 0.8, 1.0);
-
-float amount = curlExtent * (maxAmount - minAmount) + minAmount;
-float cylinderCenter = amount;
-// 360 degrees * amount
-float cylinderAngle = 2.0 * PI * amount;
-const float cylinderRadius = 1.0 / PI / 2.0;
-
-vec3 hitPoint(float hitAngle, float yc, vec3 point, mat3 rrotation)
-{
- float hitPoint = hitAngle / (2.0 * PI);
- point.y = hitPoint;
- return rrotation * point;
-}
-
-vec4 antiAlias(vec4 color1, vec4 color2, float distance)
-{
- distance *= scale;
- if (distance < 0.0) return color2;
- if (distance > 2.0) return color1;
- float dd = pow(1.0 - distance / 2.0, sharpness);
- return ((color2 - color1) * dd) + color1;
-}
-
-float distanceToEdge(vec3 point)
-{
- float dx = abs(point.x > 0.5 ? 1.0 - point.x : point.x);
- float dy = abs(point.y > 0.5 ? 1.0 - point.y : point.y);
- if (point.x < 0.0) dx = -point.x;
- if (point.x > 1.0) dx = point.x - 1.0;
- if (point.y < 0.0) dy = -point.y;
- if (point.y > 1.0) dy = point.y - 1.0;
- if ((point.x < 0.0 || point.x > 1.0) && (point.y < 0.0 || point.y > 1.0)) return sqrt(dx * dx + dy * dy);
- return min(dx, dy);
-}
-
-vec4 seeThrough(float yc, vec2 p, mat3 rotation, mat3 rrotation)
-{
- float hitAngle = PI - (acos(yc / cylinderRadius) - cylinderAngle);
- vec3 point = hitPoint(hitAngle, yc, rotation * vec3(p, 1.0), rrotation);
- if (yc <= 0.0 && (point.x < 0.0 || point.y < 0.0 || point.x > 1.0 || point.y > 1.0))
- return bgColor;
- if (yc > 0.0)
- return texture2D(source, p);
- vec4 color = texture2D(source, point.xy);
- vec4 tcolor = vec4(0.0);
- return antiAlias(color, tcolor, distanceToEdge(point));
-}
-
-vec4 seeThroughWithShadow(float yc, vec2 p, vec3 point, mat3 rotation, mat3 rrotation)
-{
- float shadow = distanceToEdge(point) * 30.0;
- shadow = (1.0 - shadow) / 3.0;
- if (shadow < 0.0)
- shadow = 0.0;
- else
- shadow *= amount;
- vec4 shadowColor = seeThrough(yc, p, rotation, rrotation);
- shadowColor.r -= shadow;
- shadowColor.g -= shadow;
- shadowColor.b -= shadow;
- return shadowColor;
-}
-
-vec4 backside(float yc, vec3 point)
-{
- vec4 color = texture2D(source, point.xy);
- float gray = (color.r + color.b + color.g) / 15.0;
- gray += (8.0 / 10.0) * (pow(1.0 - abs(yc / cylinderRadius), 2.0 / 10.0) / 2.0 + (5.0 / 10.0));
- color.rgb = vec3(gray);
- return color;
-}
-
-void main(void)
-{
- const float angle = 30.0 * PI / 180.0;
- float c = cos(-angle);
- float s = sin(-angle);
- mat3 rotation = mat3(
- c, s, 0,
- -s, c, 0,
- 0.12, 0.258, 1
- );
- c = cos(angle);
- s = sin(angle);
- mat3 rrotation = mat3(
- c, s, 0,
- -s, c, 0,
- 0.15, -0.5, 1
- );
- vec3 point = rotation * vec3(qt_TexCoord0, 1.0);
- float yc = point.y - cylinderCenter;
- vec4 color = vec4(1.0, 0.0, 0.0, 1.0);
- if (yc < -cylinderRadius) {
- // See through to background
- color = bgColor;
- } else if (yc > cylinderRadius) {
- // Flat surface
- color = texture2D(source, qt_TexCoord0);
- } else {
- float hitAngle = (acos(yc / cylinderRadius) + cylinderAngle) - PI;
- float hitAngleMod = mod(hitAngle, 2.0 * PI);
- if ((hitAngleMod > PI && amount < 0.5) || (hitAngleMod > PI/2.0 && amount < 0.0)) {
- color = seeThrough(yc, qt_TexCoord0, rotation, rrotation);
- } else {
- point = hitPoint(hitAngle, yc, point, rrotation);
- if (point.x < 0.0 || point.y < 0.0 || point.x > 1.0 || point.y > 1.0) {
- color = seeThroughWithShadow(yc, qt_TexCoord0, point, rotation, rrotation);
- } else {
- color = backside(yc, point);
- vec4 otherColor;
- if (yc < 0.0) {
- float shado = 1.0 - (sqrt(pow(point.x - 0.5, 2.0) + pow(point.y - 0.5, 2.0)) / 0.71);
- shado *= pow(-yc / cylinderRadius, 3.0);
- shado *= 0.5;
- otherColor = vec4(0.0, 0.0, 0.0, shado);
- } else {
- otherColor = texture2D(source, qt_TexCoord0);
- }
- color = antiAlias(color, otherColor, cylinderRadius - abs(yc));
-
- // This second antialiasing step causes the shader to fail to render, on
- // Symbian devices (tested so far using IVE3.5). Running out of scratch
- // memory?
- }
- }
- }
- gl_FragColor = qt_Opacity * color;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/pixelate.fsh b/examples/multimedia/video/qmlvideofx/shaders/pixelate.fsh
deleted file mode 100644
index b30dc60d0..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/pixelate.fsh
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://www.geeks3d.com/20101029/shader-library-pixelation-post-processing-effect-glsl/
-
-uniform float dividerValue;
-uniform float granularity;
-uniform float targetWidth;
-uniform float targetHeight;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec2 tc = qt_TexCoord0;
- if (uv.x < dividerValue && granularity > 0.0) {
- float dx = granularity / targetWidth;
- float dy = granularity / targetHeight;
- tc = vec2(dx*(floor(uv.x/dx) + 0.5),
- dy*(floor(uv.y/dy) + 0.5));
- }
- gl_FragColor = qt_Opacity * texture2D(source, tc);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/posterize.fsh b/examples/multimedia/video/qmlvideofx/shaders/posterize.fsh
deleted file mode 100644
index 350fda744..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/posterize.fsh
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://www.geeks3d.com/20091027/shader-library-posterization-post-processing-effect-glsl/
-
-uniform float dividerValue;
-uniform float gamma;
-uniform float numColors;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 c = vec4(0.0);
- if (uv.x < dividerValue) {
- vec3 x = texture2D(source, uv).rgb;
- x = pow(x, vec3(gamma, gamma, gamma));
- x = x * numColors;
- x = floor(x);
- x = x / numColors;
- x = pow(x, vec3(1.0/gamma));
- c = vec4(x, 1.0);
- } else {
- c = texture2D(source, uv);
- }
- gl_FragColor = qt_Opacity * c;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/ripple.fsh b/examples/multimedia/video/qmlvideofx/shaders/ripple.fsh
deleted file mode 100644
index aba47461f..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/ripple.fsh
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://blog.qt.io/blog/2011/03/22/the-convenient-power-of-qml-scene-graph/
-
-uniform float dividerValue;
-uniform float targetWidth;
-uniform float targetHeight;
-uniform float time;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-const float PI = 3.14159265358979323846;
-const int ITER = 7;
-const float RATE = 0.1;
-uniform float amplitude;
-uniform float n;
-uniform float pixDens;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec2 tc = uv;
- vec2 p = vec2(-1.0 + 2.0 * (gl_FragCoord.x - (pixDens * 14.0)) / targetWidth, -(-1.0 + 2.0 * (gl_FragCoord.y - (pixDens * 29.0)) / targetHeight));
- float diffx = 0.0;
- float diffy = 0.0;
- vec4 col;
- if (uv.x < dividerValue) {
- for (int i=0; i<ITER; ++i) {
- float theta = float(i) * PI / float(ITER);
- vec2 r = vec2(cos(theta) * p.x + sin(theta) * p.y, -1.0 * sin(theta) * p.x + cos(theta) * p.y);
- float diff = (sin(2.0 * PI * n * (r.y + time * RATE)) + 1.0) / 2.0;
- diffx += diff * sin(theta);
- diffy += diff * cos(theta);
- }
- tc = 0.5*(vec2(1.0,1.0) + p) + amplitude * vec2(diffx, diffy);
- }
- gl_FragColor = qt_Opacity * texture2D(source, tc);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/selectionpanel.fsh b/examples/multimedia/video/qmlvideofx/shaders/selectionpanel.fsh
deleted file mode 100644
index 09c22fe10..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/selectionpanel.fsh
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
diff --git a/examples/multimedia/video/qmlvideofx/shaders/sepia.fsh b/examples/multimedia/video/qmlvideofx/shaders/sepia.fsh
deleted file mode 100644
index 065b13318..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/sepia.fsh
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 orig = texture2D(source, uv);
- vec3 col = orig.rgb;
- float y = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(y + 0.15, y + 0.07, y - 0.12, 1.0);
- else
- gl_FragColor = qt_Opacity * orig;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/sharpen.fsh b/examples/multimedia/video/qmlvideofx/shaders/sharpen.fsh
deleted file mode 100644
index bdfe7f0be..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/sharpen.fsh
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-uniform float amount;
-const float step_w = 0.0015625;
-const float step_h = 0.0027778;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-vec3 sharpen(vec3 t1, vec3 t2, vec3 t3, vec3 t4, vec3 t5, vec3 t6, vec3 t7, vec3 t8, vec3 t9)
-{
- return -t1 - t2 - t3 - t4 + amount * t5 - t6 - t7 - t8 - t9;
-}
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec3 t1 = texture2D(source, vec2(uv.x - step_w, uv.y - step_h)).rgb;
- vec3 t2 = texture2D(source, vec2(uv.x, uv.y - step_h)).rgb;
- vec3 t3 = texture2D(source, vec2(uv.x + step_w, uv.y - step_h)).rgb;
- vec3 t4 = texture2D(source, vec2(uv.x - step_w, uv.y)).rgb;
- vec3 t5 = texture2D(source, uv).rgb;
- vec3 t6 = texture2D(source, vec2(uv.x + step_w, uv.y)).rgb;
- vec3 t7 = texture2D(source, vec2(uv.x - step_w, uv.y + step_h)).rgb;
- vec3 t8 = texture2D(source, vec2(uv.x, uv.y + step_h)).rgb;
- vec3 t9 = texture2D(source, vec2(uv.x + step_w, uv.y + step_h)).rgb;
- vec3 col = sharpen(t1, t2, t3, t4, t5, t6, t7, t8, t9);
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
- else
- gl_FragColor = qt_Opacity * texture2D(source, uv);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/shockwave.fsh b/examples/multimedia/video/qmlvideofx/shaders/shockwave.fsh
deleted file mode 100644
index 4cd32503c..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/shockwave.fsh
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://www.geeks3d.com/20091116/shader-library-2d-shockwave-post-processing-filter-glsl/
-
-uniform float centerX;
-uniform float centerY;
-uniform float dividerValue;
-uniform float granularity;
-uniform float time;
-uniform float weight;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec2 tc = qt_TexCoord0;
- vec2 center = vec2(centerX, centerY);
- const vec3 shock = vec3(10.0, 1.5, 0.1);
- if (uv.x < dividerValue) {
- float distance = distance(uv, center);
- if ((distance <= (time + shock.z)) &&
- (distance >= (time - shock.z))) {
- float diff = (distance - time);
- float powDiff = 1.0 - pow(abs(diff*shock.x), shock.y*weight);
- float diffTime = diff * powDiff;
- vec2 diffUV = normalize(uv - center);
- tc += (diffUV * diffTime);
- }
- }
- gl_FragColor = qt_Opacity * texture2D(source, tc);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/sobeledgedetection1.fsh b/examples/multimedia/video/qmlvideofx/shaders/sobeledgedetection1.fsh
deleted file mode 100644
index 9c0b33885..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/sobeledgedetection1.fsh
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on "Graphics Shaders: Theory and Practice" (http://cgeducation.org/ShadersBook/)
-
-uniform float dividerValue;
-uniform float mixLevel;
-uniform float resS;
-uniform float resT;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 c = vec4(0.0);
- if (uv.x < dividerValue) {
- vec2 st = qt_TexCoord0.st;
- vec3 irgb = texture2D(source, st).rgb;
- vec2 stp0 = vec2(1.0 / resS, 0.0);
- vec2 st0p = vec2(0.0 , 1.0 / resT);
- vec2 stpp = vec2(1.0 / resS, 1.0 / resT);
- vec2 stpm = vec2(1.0 / resS, -1.0 / resT);
- const vec3 W = vec3(0.2125, 0.7154, 0.0721);
- float i00 = dot(texture2D(source, st).rgb, W);
- float im1m1 = dot(texture2D(source, st-stpp).rgb, W);
- float ip1p1 = dot(texture2D(source, st+stpp).rgb, W);
- float im1p1 = dot(texture2D(source, st-stpm).rgb, W);
- float ip1m1 = dot(texture2D(source, st+stpm).rgb, W);
- float im10 = dot(texture2D(source, st-stp0).rgb, W);
- float ip10 = dot(texture2D(source, st+stp0).rgb, W);
- float i0m1 = dot(texture2D(source, st-st0p).rgb, W);
- float i0p1 = dot(texture2D(source, st+st0p).rgb, W);
- float h = -1.0*im1p1 - 2.0*i0p1 - 1.0*ip1p1 + 1.0*im1m1 + 2.0*i0m1 + 1.0*ip1m1;
- float v = -1.0*im1m1 - 2.0*im10 - 1.0*im1p1 + 1.0*ip1m1 + 2.0*ip10 + 1.0*ip1p1;
- float mag = 1.0 - length(vec2(h, v));
- vec3 target = vec3(mag, mag, mag);
- c = vec4(target, 1.0);
- } else {
- c = texture2D(source, qt_TexCoord0);
- }
- gl_FragColor = qt_Opacity * c;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/tiltshift.fsh b/examples/multimedia/video/qmlvideofx/shaders/tiltshift.fsh
deleted file mode 100644
index 5119011ce..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/tiltshift.fsh
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-const float step_w = 0.0015625;
-const float step_h = 0.0027778;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-vec3 blur()
-{
- vec2 uv = qt_TexCoord0.xy;
- float y = uv.y < 0.4 ? uv.y : 1.0 - uv.y;
- float dist = 8.0 - 20.0 * y;
- vec3 acc = vec3(0.0, 0.0, 0.0);
- for (float y=-2.0; y<=2.0; ++y) {
- for (float x=-2.0; x<=2.0; ++x) {
- acc += texture2D(source, vec2(uv.x + dist * x * step_w, uv.y + 0.5 * dist * y * step_h)).rgb;
- }
- }
- return acc / 25.0;
-}
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec3 col;
- if (uv.x > dividerValue || (uv.y >= 0.4 && uv.y <= 0.6))
- col = texture2D(source, uv).rgb;
- else
- col = blur();
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/toon.fsh b/examples/multimedia/video/qmlvideofx/shaders/toon.fsh
deleted file mode 100644
index 22f2116c3..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/toon.fsh
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://www.geeks3d.com/20101029/shader-library-pixelation-post-processing-effect-glsl/
-
-uniform float dividerValue;
-uniform float threshold;
-uniform float resS;
-uniform float resT;
-uniform float magTol;
-uniform float quantize;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec4 color = vec4(1.0, 0.0, 0.0, 1.1);
- vec2 uv = qt_TexCoord0.xy;
- if (uv.x < dividerValue) {
- vec2 st = qt_TexCoord0.st;
- vec3 rgb = texture2D(source, st).rgb;
- vec2 stp0 = vec2(1.0/resS, 0.0);
- vec2 st0p = vec2(0.0 , 1.0/resT);
- vec2 stpp = vec2(1.0/resS, 1.0/resT);
- vec2 stpm = vec2(1.0/resS, -1.0/resT);
- float i00 = dot( texture2D(source, st).rgb, vec3(0.2125,0.7154,0.0721));
- float im1m1 = dot( texture2D(source, st-stpp).rgb, vec3(0.2125,0.7154,0.0721));
- float ip1p1 = dot( texture2D(source, st+stpp).rgb, vec3(0.2125,0.7154,0.0721));
- float im1p1 = dot( texture2D(source, st-stpm).rgb, vec3(0.2125,0.7154,0.0721));
- float ip1m1 = dot( texture2D(source, st+stpm).rgb, vec3(0.2125,0.7154,0.0721));
- float im10 = dot( texture2D(source, st-stp0).rgb, vec3(0.2125,0.7154,0.0721));
- float ip10 = dot( texture2D(source, st+stp0).rgb, vec3(0.2125,0.7154,0.0721));
- float i0m1 = dot( texture2D(source, st-st0p).rgb, vec3(0.2125,0.7154,0.0721));
- float i0p1 = dot( texture2D(source, st+st0p).rgb, vec3(0.2125,0.7154,0.0721));
- float h = -1.*im1p1 - 2.*i0p1 - 1.*ip1p1 + 1.*im1m1 + 2.*i0m1 + 1.*ip1m1;
- float v = -1.*im1m1 - 2.*im10 - 1.*im1p1 + 1.*ip1m1 + 2.*ip10 + 1.*ip1p1;
- float mag = sqrt(h*h + v*v);
- if (mag > magTol) {
- color = vec4(0.0, 0.0, 0.0, 1.0);
- }
- else {
- rgb.rgb *= quantize;
- rgb.rgb += vec3(0.5, 0.5, 0.5);
- ivec3 irgb = ivec3(rgb.rgb);
- rgb.rgb = vec3(irgb) / quantize;
- color = vec4(rgb, 1.0);
- }
- } else {
- color = texture2D(source, uv);
- }
- gl_FragColor = qt_Opacity * color;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/vignette.fsh b/examples/multimedia/video/qmlvideofx/shaders/vignette.fsh
deleted file mode 100644
index d8a25737e..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/vignette.fsh
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 orig = texture2D(source, uv);
- float cr = pow(0.1, 2.0);
- float pt = pow(uv.x - 0.5, 2.0) + pow(uv.y - 0.5, 2.0);
- float d = pt - cr;
- float cf = 1.0;
- if (d > 0.0)
- cf = 1.0 - 2.0 * d;
- vec3 col = cf * orig.rgb;
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
- else
- gl_FragColor = qt_Opacity * orig;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/warhol.fsh b/examples/multimedia/video/qmlvideofx/shaders/warhol.fsh
deleted file mode 100644
index 0ea02c6a0..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/warhol.fsh
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://kodemongki.blogspot.com/2011/06/kameraku-custom-shader-effects-example.html
-
-uniform float dividerValue;
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec4 orig = texture2D(source, uv);
- vec3 col = orig.rgb;
- float y = 0.3 *col.r + 0.59 * col.g + 0.11 * col.b;
- y = y < 0.3 ? 0.0 : (y < 0.6 ? 0.5 : 1.0);
- if (y == 0.5)
- col = vec3(0.8, 0.0, 0.0);
- else if (y == 1.0)
- col = vec3(0.9, 0.9, 0.0);
- else
- col = vec3(0.0, 0.0, 0.0);
- if (uv.x < dividerValue)
- gl_FragColor = qt_Opacity * vec4(col, 1.0);
- else
- gl_FragColor = qt_Opacity * orig;
-}
diff --git a/examples/multimedia/video/qmlvideofx/shaders/wobble.fsh b/examples/multimedia/video/qmlvideofx/shaders/wobble.fsh
deleted file mode 100644
index 5e0b1f79c..000000000
--- a/examples/multimedia/video/qmlvideofx/shaders/wobble.fsh
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-// Based on http://blog.qt.io/blog/2011/03/22/the-convenient-power-of-qml-scene-graph/
-
-uniform float amplitude;
-uniform float dividerValue;
-uniform float frequency;
-uniform float time;
-
-uniform sampler2D source;
-uniform lowp float qt_Opacity;
-varying vec2 qt_TexCoord0;
-
-void main()
-{
- vec2 uv = qt_TexCoord0.xy;
- vec2 tc = qt_TexCoord0;
- if (uv.x < dividerValue) {
- vec2 p = sin(time + frequency * qt_TexCoord0);
- tc += amplitude * vec2(p.y, -p.x);
- }
- gl_FragColor = qt_Opacity * texture2D(source, tc);
-}
diff --git a/examples/multimedia/video/qmlvideofx/trace.h b/examples/multimedia/video/qmlvideofx/trace.h
deleted file mode 100644
index d2cb054df..000000000
--- a/examples/multimedia/video/qmlvideofx/trace.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef TRACE_H
-#define TRACE_H
-
-#include <QDebug>
-
-#define ENABLE_TRACE
-//#define VERBOSE_TRACE
-
-namespace Trace {
-
-class NullDebug
-{
-public:
- template <typename T>
- NullDebug &operator<<(const T &) { return *this; }
-};
-
-inline NullDebug nullDebug() { return NullDebug(); }
-
-template <typename T>
-struct PtrWrapper
-{
- PtrWrapper(const T *ptr) : m_ptr(ptr) { }
- const T *const m_ptr;
-};
-
-} // namespace Trace
-
-template <typename T>
-inline QDebug &operator<<(QDebug &debug, const Trace::PtrWrapper<T> &wrapper)
-{
- QDebugStateSaver saver(debug);
- debug.nospace() << '[' << static_cast<const void *>(wrapper.m_ptr) << ']';
- return debug;
-}
-
-#ifdef ENABLE_TRACE
- inline QDebug qtTrace() { return qDebug() << "[qmlvideofx]"; }
-# ifdef VERBOSE_TRACE
- inline QDebug qtVerboseTrace() { return qtTrace(); }
-# else
- inline Trace::NullDebug qtVerboseTrace() { return Trace::nullDebug(); }
-# endif
-#else
- inline Trace::NullDebug qtTrace() { return Trace::nullDebug(); }
- inline Trace::NullDebug qtVerboseTrace() { return Trace::nullDebug(); }
-#endif
-
-#endif // TRACE_H
-
diff --git a/examples/multimedia/video/recorder/AudioInputSelect.qml b/examples/multimedia/video/recorder/AudioInputSelect.qml
new file mode 100644
index 000000000..d1e30f080
--- /dev/null
+++ b/examples/multimedia/video/recorder/AudioInputSelect.qml
@@ -0,0 +1,53 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Row {
+ id: root
+ height: Style.height
+ property AudioInput selected: available ? audioInput : null
+ property bool available: (typeof comboBox.currentValue !== 'undefined') && audioSwitch.checked
+
+ Component.onCompleted: {
+ audioInputModel.populate()
+ comboBox.currentIndex = 0
+ }
+
+ MediaDevices { id: mediaDevices }
+
+ AudioInput { id: audioInput; muted: !audioSwitch.checked }
+
+ Switch {
+ id: audioSwitch;
+ height: Style.height;
+ checked: true
+ }
+
+ ListModel {
+ id: audioInputModel
+ property var audioInputs: mediaDevices.audioInputs
+
+ function populate() {
+ audioInputModel.clear()
+
+ for (var audioDevice of audioInputs)
+ audioInputModel.append({ text: audioDevice.description, value:
+ { type: 'audioDevice', audioDevice: audioDevice } })
+ }
+ }
+ ComboBox {
+ id: comboBox
+ width: Style.widthLong
+ height: Style.height
+ background: StyleRectangle { anchors.fill: parent }
+ model: audioInputModel
+ textRole: "text"
+ font.pointSize: Style.fontSize
+ displayText: typeof currentValue === 'undefined' ? "unavailable" : currentText
+ valueRole: "value"
+ onCurrentValueChanged: if (typeof comboBox.currentValue !== 'undefined') audioInput.device = currentValue.audioDevice
+ }
+}
diff --git a/examples/multimedia/video/recorder/CMakeLists.txt b/examples/multimedia/video/recorder/CMakeLists.txt
new file mode 100644
index 000000000..116a1b817
--- /dev/null
+++ b/examples/multimedia/video/recorder/CMakeLists.txt
@@ -0,0 +1,62 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(recorder LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/video/recorder")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Multimedia Quick)
+
+qt_add_executable(recorder
+ main.cpp
+)
+
+set(resource_files
+ "main.qml"
+ "main_no_permissions.qml"
+ "qmldir"
+ "MediaList.qml"
+ "AudioInputSelect.qml"
+ "VideoSourceSelect.qml"
+ "RecordButton.qml"
+ "Controls.qml"
+ "StyleParameter.qml"
+ "StyleRectangle.qml"
+ "SettingsMetaData.qml"
+ "SettingsEncoder.qml"
+ "StyleSlider.qml"
+ "Style.qml"
+ "Playback.qml"
+)
+
+qt_add_resources(recorder "recorder"
+ PREFIX
+ "/"
+ FILES
+ ${resource_files}
+)
+
+target_link_libraries(recorder PRIVATE
+ Qt6::Core
+ Qt6::Multimedia
+ Qt6::Quick
+)
+
+set_target_properties(recorder PROPERTIES
+ MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
+)
+
+install(TARGETS recorder
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimedia/video/recorder/Controls.qml b/examples/multimedia/video/recorder/Controls.qml
new file mode 100644
index 000000000..627c2fe04
--- /dev/null
+++ b/examples/multimedia/video/recorder/Controls.qml
@@ -0,0 +1,83 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtMultimedia
+
+Row {
+ id: root
+ required property MediaRecorder recorder
+
+ property bool settingsVisible: false
+ property bool capturesVisible: false
+
+ property alias audioInput: audioInputSelect.selected
+ property alias camera: videoSourceSelect.selectedCamera
+ property alias screenCapture: videoSourceSelect.selectedScreenCapture
+ property alias windowCapture: videoSourceSelect.selectedWindowCapture
+
+ spacing: Style.interSpacing * Style.ratio
+
+ Column {
+ id: inputControls
+ spacing: Style.intraSpacing
+
+ VideoSourceSelect { id: videoSourceSelect }
+ AudioInputSelect { id: audioInputSelect }
+ }
+
+ Column {
+ width: recordButton.width
+ RecordButton {
+ id: recordButton
+ recording: recorder.recorderState === MediaRecorder.RecordingState
+ onClicked: recording ? recorder.stop() : recorder.record()
+ }
+ Text {
+ id: recordingTime
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pointSize: Style.fontSize
+ color: palette.text
+ }
+ }
+
+ Column {
+ id: optionButtons
+ spacing: Style.intraSpacing
+ Button {
+ leftPadding: 0
+ rightPadding: 0
+ topPadding: 0
+ bottomPadding: 0
+ height: Style.height
+ width: Style.widthMedium
+ background: StyleRectangle { anchors.fill: parent }
+ onClicked: root.capturesVisible = !root.capturesVisible
+ text: "Captures"
+ font.pointSize: Style.fontSize
+ }
+ Button {
+ leftPadding: 0
+ rightPadding: 0
+ topPadding: 0
+ bottomPadding: 0
+ height: Style.height
+ width: Style.widthMedium
+ background: StyleRectangle { anchors.fill: parent }
+ onClicked: settingsVisible = !settingsVisible
+ text: "Settings"
+ font.pointSize: Style.fontSize
+ }
+ }
+
+ Timer {
+ running: true; interval: 100; repeat: true
+ onTriggered: {
+ var m = Math.floor(recorder.duration / 60000)
+ var ms = (recorder.duration / 1000 - m * 60).toFixed(1)
+ recordingTime.text = `${m}:${ms.padStart(4, 0)}`
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/Info.plist.in b/examples/multimedia/video/recorder/Info.plist.in
new file mode 100644
index 000000000..46a9ecf2d
--- /dev/null
+++ b/examples/multimedia/video/recorder/Info.plist.in
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+
+ <key>NSCameraUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Qt Multimedia Example</string>
+
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+</dict>
+</plist>
diff --git a/examples/multimedia/video/recorder/MediaList.qml b/examples/multimedia/video/recorder/MediaList.qml
new file mode 100644
index 000000000..5fa65393a
--- /dev/null
+++ b/examples/multimedia/video/recorder/MediaList.qml
@@ -0,0 +1,67 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+import QtQuick.Layouts
+
+Item {
+ id: root
+
+ required property Playback playback
+
+ property string mediaThumbnail
+ property string mediaUrl
+
+ function append() {
+ if (mediaUrl !== "")
+ mediaList.append({"thumbnail": root.mediaThumbnail, "url": root.mediaUrl})
+ mediaThumbnail = ""
+ mediaUrl = ""
+ }
+
+ ListModel { id: mediaList }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ model: mediaList
+ orientation: ListView.Horizontal
+ spacing: Style.intraSpacing
+
+ delegate: Frame {
+ padding: Style.intraSpacing
+ width: root.height
+ height: root.height
+ background: StyleRectangle { anchors.fill: parent }
+
+ required property string url
+ required property string thumbnail
+
+ ColumnLayout {
+ anchors.fill: parent
+ Image {
+ id: image
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ source: thumbnail
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Text {
+ Layout.fillWidth: true
+ elide: Text.ElideLeft
+ text: url
+ }
+ }
+ RoundButton {
+ anchors.centerIn: parent
+ width: 30
+ height: 30
+ text: "\u25B6";
+ onClicked: { playback.playUrl(url) }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/Playback.qml b/examples/multimedia/video/recorder/Playback.qml
new file mode 100644
index 000000000..78575ae26
--- /dev/null
+++ b/examples/multimedia/video/recorder/Playback.qml
@@ -0,0 +1,55 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtMultimedia
+import QtQuick.Controls
+
+Item {
+ id: root
+
+ property bool active: false
+ property bool playing: false
+ visible: active && playing
+
+ function playUrl(url) {
+ playing = true
+ mediaPlayer.source = url
+ mediaPlayer.play()
+ }
+
+ function stop() {
+ playing = false
+ mediaPlayer.stop()
+ }
+
+ onActiveChanged: function() {
+ if (!active)
+ stop();
+ }
+
+ VideoOutput {
+ anchors.fill: parent
+ id: videoOutput
+ }
+
+ MediaPlayer {
+ id: mediaPlayer
+ videoOutput: videoOutput
+ audioOutput: AudioOutput {}
+ }
+
+ HoverHandler { id: hover }
+
+ RoundButton {
+ width: 50
+ height: 50
+ opacity: hover.hovered && active ? 1.0 : 0.0
+ anchors.centerIn: root
+ radius: 25
+ text: "\u25A0";
+ onClicked: root.stop()
+
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ }
+}
diff --git a/examples/multimedia/video/recorder/RecordButton.qml b/examples/multimedia/video/recorder/RecordButton.qml
new file mode 100644
index 000000000..5296a3028
--- /dev/null
+++ b/examples/multimedia/video/recorder/RecordButton.qml
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Item {
+ id: root
+ width: outerRadius * 2
+ height: outerRadius * 2
+
+ required property bool recording
+
+ property int outerRadius: Style.height
+ property int innerRadius: mouse.pressedButtons === Qt.LeftButton ? outerRadius - 6 : outerRadius - 5
+
+ signal clicked
+
+ Rectangle {
+ anchors.fill: parent
+ radius: outerRadius
+ opacity: 0.5
+ border.color: "black"
+ border.width: 1
+ }
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: recording ? innerRadius * 2 - 15 : innerRadius * 2
+ height: recording ? innerRadius * 2 - 15 : innerRadius * 2
+ radius: recording ? 2 : innerRadius
+ color: "red"
+
+ Behavior on width { NumberAnimation { duration: 100 }}
+ Behavior on height { NumberAnimation { duration: 100 }}
+ Behavior on radius { NumberAnimation { duration: 100 }}
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ onClicked: root.clicked()
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/SettingsEncoder.qml b/examples/multimedia/video/recorder/SettingsEncoder.qml
new file mode 100644
index 000000000..16a9590be
--- /dev/null
+++ b/examples/multimedia/video/recorder/SettingsEncoder.qml
@@ -0,0 +1,102 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtMultimedia
+
+Column {
+ id: root
+ spacing: Style.intraSpacing
+ Component.onCompleted: root.populateModels()
+
+ required property MediaRecorder recorder
+
+ function populateModels() {
+ audioCodecModel.populate()
+ videoCodecModel.populate()
+ fileFormatModel.populate()
+ }
+
+ Connections {
+ target: recorder
+ function onMediaFormatChanged() { root.populateModels() }
+ }
+
+ Text {
+ text: "Encoder settings"
+ color: palette.text
+ }
+
+ StyleParameter {
+ label: "Quality"
+ model: ListModel {
+ ListElement { text: "very low"; value: MediaRecorder.VeryLowQuality }
+ ListElement { text: "low"; value: MediaRecorder.LowQuality }
+ ListElement { text: "normal"; value: MediaRecorder.NormalQuality }
+ ListElement { text: "high"; value: MediaRecorder.HighQuality }
+ ListElement { text: "very high"; value: MediaRecorder.VeryHighQuality }
+ }
+ onActivated: (v) => { recorder.quality = v }
+ }
+
+ StyleParameter {
+ id: audioCodecSelect
+ label: "Audio codec"
+ model: audioCodecModel
+ onActivated: (v) => { recorder.mediaFormat.audioCodec = v }
+
+ ListModel {
+ id: audioCodecModel
+ function populate() {
+ audioCodecModel.clear()
+ audioCodecModel.append({"text": "Unspecifed", "value": MediaFormat.AudioCodec.Unspecified})
+ var cs = recorder.mediaFormat.supportedAudioCodecs(MediaFormat.Encode)
+ for (var c of cs)
+ audioCodecModel.append({"text": recorder.mediaFormat.audioCodecName(c), "value": c})
+ audioCodecSelect.currentIndex = cs.indexOf(recorder.mediaFormat.audioCodec) + 1
+ }
+ }
+ }
+
+ function buildModel() {}
+
+ StyleParameter {
+ id: videoCodecSelect
+ label: "Video codec"
+ model: videoCodecModel
+ onActivated: (v) => { recorder.mediaFormat.videoCodec = v }
+
+ ListModel {
+ id: videoCodecModel
+ function populate() {
+ videoCodecModel.clear()
+ videoCodecModel.append({"text": "Unspecifed", "value": MediaFormat.VideoCodec.Unspecified})
+ var cs = recorder.mediaFormat.supportedVideoCodecs(MediaFormat.Encode)
+ for (var c of cs)
+ videoCodecModel.append({"text": recorder.mediaFormat.videoCodecName(c), "value": c})
+ videoCodecSelect.currentIndex = cs.indexOf(recorder.mediaFormat.videoCodec) + 1
+ }
+ }
+ }
+
+ StyleParameter {
+ id: fileFormatSelect
+ label: "File format"
+ model: fileFormatModel
+ onActivated: (v) => { recorder.mediaFormat.fileFormat = v }
+
+ ListModel {
+ id: fileFormatModel
+ function populate() {
+ fileFormatModel.clear()
+ fileFormatModel.append({"text": "Unspecifed", "value": MediaFormat.AudioCodec.Unspecified})
+ var cs = recorder.mediaFormat.supportedFileFormats(MediaFormat.Encode)
+ for (var c of cs)
+ fileFormatModel.append({"text": recorder.mediaFormat.fileFormatName(c), "value": c})
+ fileFormatSelect.currentIndex = cs.indexOf(recorder.mediaFormat.fileFormat) + 1
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/SettingsMetaData.qml b/examples/multimedia/video/recorder/SettingsMetaData.qml
new file mode 100644
index 000000000..7bfc2255d
--- /dev/null
+++ b/examples/multimedia/video/recorder/SettingsMetaData.qml
@@ -0,0 +1,145 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtMultimedia
+
+pragma ComponentBehavior: Bound
+
+ColumnLayout {
+ id: root
+ required property MediaRecorder recorder
+
+ Text {
+ text: "Metadata settings"
+ color: palette.text
+ }
+
+ ListModel { id: metaDataModel }
+
+ Connections {
+ target: root.recorder
+ function onMetaDataChanged() {
+ metaDataModel.clear()
+ for (var key of root.recorder.metaData.keys()) {
+ if (recorder.metaData.stringValue(key))
+ metaDataModel.append(
+ { text: recorder.metaData.metaDataKeyToString(key)
+ , value: key })
+ }
+ }
+ }
+
+ Row {
+ id: metaDataAdd
+ spacing: Style.intraSpacing
+ ComboBox {
+ id: metaDataType
+ width: Style.widthMedium
+ height: Style.height
+ font.pointSize: Style.fontSize
+ model: ListModel {
+ ListElement { text: "Title"; value: MediaMetaData.Title }
+ ListElement { text: "Author"; value: MediaMetaData.Author }
+ ListElement { text: "Comment"; value: MediaMetaData.Comment }
+ ListElement { text: "Description"; value: MediaMetaData.Description }
+ ListElement { text: "Genre"; value: MediaMetaData.Genre }
+ ListElement { text: "Publisher"; value: MediaMetaData.Publisher }
+ ListElement { text: "Copyright"; value: MediaMetaData.Copyright }
+ ListElement { text: "Date"; value: MediaMetaData.Date }
+ ListElement { text: "Url"; value: MediaMetaData.Url }
+ ListElement { text: "MediaType"; value: MediaMetaData.MediaType }
+ ListElement { text: "AlbumTitle"; value: MediaMetaData.AlbumTitle }
+ ListElement { text: "AlbumArtist"; value: MediaMetaData.AlbumArtist }
+ ListElement { text: "ContributingArtist"; value: MediaMetaData.ContributingArtist }
+ ListElement { text: "Composer"; value: MediaMetaData.Composer }
+ ListElement { text: "LeadPerformer"; value: MediaMetaData.LeadPerformer }
+ }
+ textRole: "text"
+ valueRole: "value"
+ background: StyleRectangle { anchors.fill: parent; width: metaDataType.width }
+ }
+ Item {
+ width: Style.widthMedium
+ height: Style.height
+ StyleRectangle { anchors.fill: parent }
+ TextInput {
+ id: textInput
+ anchors.fill: parent
+ anchors.bottom: parent.bottom
+ anchors.margins: 4
+ font.pointSize: Style.fontSize
+ clip: true
+ onAccepted: {
+ root.recorder.metaData.insert(metaDataType.currentValue, text)
+ recorder.metaDataChanged()
+ text = ""
+ textInput.deselect()
+ }
+ }
+ }
+ Button {
+ width: Style.widthShort
+ height: Style.height
+ text: "add"
+ font.pointSize: Style.fontSize
+
+ background: StyleRectangle { anchors.fill: parent }
+ onClicked: textInput.accepted()
+ }
+ }
+
+ ListView {
+ id: listView
+ Layout.fillHeight: true
+ Layout.minimumWidth: metaDataAdd.width
+ spacing: Style.intraSpacing
+ clip: true
+ model: metaDataModel
+
+ delegate: Row {
+ id: r
+ height: Style.height
+ spacing: Style.intraSpacing
+
+ required property string text
+ required property string value
+
+ Text {
+ width: Style.widthShort
+ height: Style.height
+ text: r.text
+ font.pointSize: Style.fontSize
+
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ }
+ Item {
+ width: Style.widthMedium
+ height: Style.height
+
+ StyleRectangle { anchors.fill: parent }
+ TextInput {
+ anchors.fill: parent
+ anchors.margins: 4
+ anchors.bottom: parent.bottom
+ font.pointSize: Style.fontSize
+ clip: true
+ text: root.recorder.metaData.stringValue(r.value)
+ onAccepted: root.recorder.metaData.insert(r.value, text)
+
+ }
+ }
+ Button {
+ width: Style.widthShort
+ height: Style.height
+ text: "del"
+ font.pointSize: Style.fontSize
+ background: StyleRectangle { anchors.fill: parent }
+ onClicked: { root.recorder.metaData.remove(r.value); recorder.metaDataChanged() }
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/Style.qml b/examples/multimedia/video/recorder/Style.qml
new file mode 100644
index 000000000..d30c3b8ef
--- /dev/null
+++ b/examples/multimedia/video/recorder/Style.qml
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+pragma Singleton
+import QtQuick
+
+QtObject {
+
+ function isMobile() {
+ return Qt.platform.os === "android" || Qt.platform.os === "ios";
+ }
+
+ function calculateRatio(windowWidth, windowHeight) {
+ var refWidth = 800.;
+ Style.ratio = windowWidth/refWidth;
+ }
+
+ property real ratio : 1
+
+ property real screenWidth: isMobile()? 400 : 800
+ property real screenHeigth: isMobile()? 900 : 600
+
+ property real height: 25
+ property real widthTiny: 40*ratio
+ property real widthShort: 80*ratio
+ property real widthMedium: 160*ratio
+ property real widthLong: 220*ratio
+ property real intraSpacing: 5
+ property real interSpacing: 15
+ property real fontSize: 11
+}
diff --git a/examples/multimedia/video/recorder/StyleParameter.qml b/examples/multimedia/video/recorder/StyleParameter.qml
new file mode 100644
index 000000000..3a7573b92
--- /dev/null
+++ b/examples/multimedia/video/recorder/StyleParameter.qml
@@ -0,0 +1,42 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Row {
+ id: root
+ spacing: Style.intraSpacing
+
+ property alias label: label.text
+ property alias model: comboBox.model
+ property alias currentIndex: comboBox.currentIndex
+ property alias currentValue: comboBox.currentValue
+ property bool enabled: true
+ signal activated(var currentValue)
+
+ Text {
+ id: label
+ height: Style.height
+ width: Style.widthShort
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ color: root.enabled ? palette.text : palette.mid
+ font.pointSize: Style.fontSize
+ }
+
+ ComboBox {
+ id: comboBox
+ height: Style.height
+ width: Style.widthLong
+ enabled: root.enabled
+
+ displayText: currentText
+ textRole: "text"
+ valueRole: "value"
+ font.pointSize: Style.fontSize
+
+ background: StyleRectangle { anchors.fill: parent }
+ onActivated: root.activated(currentValue)
+ }
+}
diff --git a/examples/multimedia/video/recorder/StyleRectangle.qml b/examples/multimedia/video/recorder/StyleRectangle.qml
new file mode 100644
index 000000000..e28cf4a19
--- /dev/null
+++ b/examples/multimedia/video/recorder/StyleRectangle.qml
@@ -0,0 +1,11 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+
+Rectangle {
+ opacity: 0.5
+ border.color: "black"
+ border.width: 1
+ radius: 3
+}
diff --git a/examples/multimedia/video/recorder/StyleSlider.qml b/examples/multimedia/video/recorder/StyleSlider.qml
new file mode 100644
index 000000000..a15304aaa
--- /dev/null
+++ b/examples/multimedia/video/recorder/StyleSlider.qml
@@ -0,0 +1,35 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Row {
+ id: root
+ spacing: Style.intraSpacing
+
+ property alias label: label.text
+ property alias from: slider.from
+ property alias to: slider.to
+ property alias value: slider.value
+ property bool enabled: true
+
+ signal moved(real currentValue)
+
+ Text {
+ id: label
+ width: Style.valueWidth
+ height: Style.height
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ color: root.enabled ? palette.text : palette.mid
+ }
+
+ Slider {
+ id: slider
+ anchors.verticalCenter: label.verticalCenter
+ width: Style.widthMedium
+ enabled: root.enabled
+ onMoved: root.moved(value)
+ }
+}
diff --git a/examples/multimedia/video/recorder/VideoSourceSelect.qml b/examples/multimedia/video/recorder/VideoSourceSelect.qml
new file mode 100644
index 000000000..7eeed99b9
--- /dev/null
+++ b/examples/multimedia/video/recorder/VideoSourceSelect.qml
@@ -0,0 +1,165 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+import QtMultimedia
+
+Row {
+ id: root
+ height: Style.height
+ property Camera selectedCamera: cameraAvailable ? camera : null
+ property ScreenCapture selectedScreenCapture: screenAvailable ? screenCapture : null
+ property WindowCapture selectedWindowCapture: windowAvailable ? windowCapture : null
+
+ property bool sourceAvailable: typeof comboBox.currentValue !== 'undefined' &&
+ comboBox.currentValue.type !== 'toggler' &&
+ videoSourceSwitch.checked
+
+ property bool cameraAvailable: sourceAvailable && comboBox.currentValue.type === 'camera'
+ property bool screenAvailable: sourceAvailable && comboBox.currentValue.type === 'screen'
+ property bool windowAvailable: sourceAvailable && comboBox.currentValue.type === 'window'
+
+ Component.onCompleted: {
+ videoSourceModel.populate()
+
+ for (var i = 0; i < videoSourceModel.count; i++) {
+ if (videoSourceModel.get(i).value.type !== 'toggler') {
+ comboBox.currentIndex = i
+ break
+ }
+ }
+ }
+
+ Camera {
+ id: camera
+ active: cameraAvailable
+ }
+
+ ScreenCapture {
+ id: screenCapture
+ active: screenAvailable
+ }
+
+ WindowCapture {
+ id: windowCapture
+ active: windowAvailable
+ }
+
+ MediaDevices { id: mediaDevices
+ onVideoInputsChanged: {
+
+ videoSourceModel.populate()
+
+ for (var i = 0; i < videoSourceModel.count; i++) {
+ if (videoSourceModel.get(i).value.type !== 'toggler') {
+ comboBox.currentIndex = i
+ break
+ }
+ }
+ }
+ }
+
+ Switch {
+ id: videoSourceSwitch
+ anchors.verticalCenter: parent.verticalCenter
+ checked: true
+ }
+
+ ListModel {
+ id: videoSourceModel
+ property var enabledSources: {
+ 'camera': true,
+ 'screen': true,
+ 'window': false
+ }
+
+ function toggleEnabledSource(type) {
+ enabledSources[type] = !enabledSources[type]
+ populate()
+ }
+
+ function appendItem(text, value) {
+ append({ text: text, value: value})
+ }
+
+ function appendToggler(name, sourceType) {
+ appendItem((enabledSources[sourceType] ? "- Hide " : "+ Show ") + name,
+ { type: 'toggler', 'sourceType': sourceType })
+ }
+
+ function populate() {
+ clear()
+
+ appendToggler('Cameras', 'camera')
+ if (enabledSources['camera'])
+ for (var camera of mediaDevices.videoInputs)
+ appendItem(camera.description, { type: 'camera', camera: camera })
+
+ appendToggler('Screens', 'screen')
+ if (enabledSources['screen'])
+ for (var screen of Application.screens)
+ appendItem(screen.name, { type: 'screen', screen: screen })
+
+ appendToggler('Windows', 'window')
+ if (enabledSources['window'])
+ for (var window of windowCapture.capturableWindows())
+ appendItem(window.description, { type: 'window', window: window })
+ }
+ }
+
+ ComboBox {
+ id: comboBox
+ width: Style.widthLong
+ height: Style.height
+ background: StyleRectangle { anchors.fill: parent }
+ model: videoSourceModel
+ displayText: typeof currentValue === 'undefined' ||
+ currentValue.type === 'toggler' ? "Unavailable" : currentText
+ font.pointSize: Style.fontSize
+ textRole: "text"
+ valueRole: "value"
+ onCurrentValueChanged: {
+ if (typeof currentValue === 'undefined')
+ return
+ if (currentValue.type === 'screen')
+ screenCapture.screen = currentValue.screen
+ else if (currentValue.type === 'camera')
+ camera.cameraDevice = currentValue.camera
+ else if (currentValue.type === 'window')
+ windowCapture.window = currentValue.window
+ else if (currentValue.type === 'toggler')
+ model.toggleEnabledSource(currentValue.sourceType)
+ }
+
+ delegate: ItemDelegate {
+ property bool isToggler: value.type === 'toggler'
+ text: model[comboBox.textRole]
+ width: comboBox.width
+ height: comboBox.height
+ highlighted: comboBox.highlightedIndex === index && !isToggler
+ font.italic: isToggler
+ font.underline: isToggler
+ font.bold: comboBox.currentIndex === index && !isToggler ||
+ isToggler && comboBox.highlightedIndex === index
+ palette.text: isToggler ? comboBox.palette.link : comboBox.palette.text
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (isToggler)
+ videoSourceModel.toggleEnabledSource(value.sourceType)
+ else {
+ comboBox.currentIndex = index
+ comboBox.popup.close()
+ }
+ }
+ }
+
+ required property var value
+ required property int index
+ required property var model
+ }
+
+ }
+}
diff --git a/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif b/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif
new file mode 100644
index 000000000..b02053ea5
--- /dev/null
+++ b/examples/multimedia/video/recorder/doc/images/qml-recorder-control-bar-overview.gif
Binary files differ
diff --git a/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif b/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif
new file mode 100644
index 000000000..2e5e39215
--- /dev/null
+++ b/examples/multimedia/video/recorder/doc/images/qml-recorder-overview.gif
Binary files differ
diff --git a/examples/multimedia/video/recorder/doc/images/qmlrecorder.jpg b/examples/multimedia/video/recorder/doc/images/qmlrecorder.jpg
new file mode 100644
index 000000000..1ef0e4447
--- /dev/null
+++ b/examples/multimedia/video/recorder/doc/images/qmlrecorder.jpg
Binary files differ
diff --git a/examples/multimedia/video/recorder/doc/src/recorder.qdoc b/examples/multimedia/video/recorder/doc/src/recorder.qdoc
new file mode 100644
index 000000000..3c0de3730
--- /dev/null
+++ b/examples/multimedia/video/recorder/doc/src/recorder.qdoc
@@ -0,0 +1,102 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example video/recorder
+ \title QML Video Recorder
+ \ingroup multimedia_examples
+ \ingroup video_examples_qml
+ \ingroup camera_examples_qml
+ \examplecategory {Multimedia}
+ \brief Recording audio and video using Qt Quick.
+ \meta {tag} {quick}
+
+ \image qmlrecorder.jpg
+
+ \e{QML Recorder} demonstrates a simple application that can record
+ audio and video separate or together, using a microphone, a camera, or
+ with screen capturing.
+
+ \include examples-run.qdocinc
+
+ \section1 Overview
+ At its core, this is a QML application, see
+ \l{Getting Started Programming with Qt Quick}. This documentation is focused
+ on how this example uses the \l{Qt Multimedia QML Types}.
+
+ \image qml-recorder-overview.gif "Animation cycling through qml objects declared in main.qml"
+
+ The example uses the QML \l Camera and \l AudioInput types connected to a
+ \l CaptureSession. A \l MediaRecorder object is then used to record the
+ captured audio and video.
+
+ In addition to QtMultimedia, features of Qt Quick Windows, Controls, and
+ Layouts are used to implement the graphic user interface and functionality.
+ Playback won't be covered here, for that see the \l{QML Media Player Example}.
+
+ The example demonstrates the following:
+ \list
+ \li Input devices can be selected.
+ \li An input type switched off.
+ \li Settings for capturing such as quality, codec choice, file format,
+ and assigning metadata.
+ \li Captured files are stored and can be played back.
+ \endlist
+
+ \section1 Recording
+
+ The application implements recording.
+
+ \section2 captureSession
+
+ In \c main.qml, \c captureSession is declared like so:
+
+ \quotefromfile video/recorder/main.qml
+ \skipto CaptureSession
+ \printto MediaRecorder
+
+ \section2 recorder
+
+ In \c main.qml, the \l MediaRecorder \c recorder handles recording media
+ as well as capturing a thumbnail for the file and appending it to a ListModel,
+ \c mediaList.
+ \printto Playback
+
+ \c mediaList is declared in the \l Frame \c mediaListFrame
+ \quotefromfile video/recorder/main.qml
+ \skipto Frame
+ \printuntil playback: playback
+
+ \section2 controls
+
+ \image qml-recorder-control-bar-overview.gif
+
+ These are defined in \c Controls.qml and declared in main.qml.
+
+ Its root is a \l Row that contains the \l{Column}{Columns} \c inputControls,
+ \c recordButton, \c optionButtons, each defined in their own .qml files.
+
+ \section3 Selecting a video source
+
+ Defined in \c VideoSourceSelect.qml, \c VideoSourceSlect is comprised of a
+ \l Switch and a \l ComboBox and enables the user to select from available
+ cameras.
+
+ \quotefromfile video/recorder/VideoSourceSelect.qml
+ \skipto Row
+ \printto ComboBox
+
+ \c comboBox, declared in the above snippet, assigns the current video source.
+
+ \printuntil camera.cameraDevice = currentValue.camera
+
+ \section3 Selecting an audio input
+
+ Implemented in the same way as \l{Selecting a video source} and defined in
+ \c AudioInputSelect.qml like so:
+
+ \quotefromfile video/recorder/AudioInputSelect.qml
+ \skipto Row
+ \printto audioInput.device = currentValue
+
+*/
diff --git a/examples/multimedia/video/recorder/main.cpp b/examples/multimedia/video/recorder/main.cpp
new file mode 100644
index 000000000..92e54cb1b
--- /dev/null
+++ b/examples/multimedia/video/recorder/main.cpp
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+#if QT_CONFIG(permissions)
+ #include <QPermission>
+#endif
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ const QUrl url(QStringLiteral("qrc:/main.qml"));
+ QObject::connect(
+ &engine, &QQmlApplicationEngine::objectCreated, &app,
+ [url](QObject *obj, const QUrl &objUrl) {
+ if (!obj && url == objUrl)
+ QCoreApplication::exit(-1);
+ },
+ Qt::QueuedConnection);
+
+#if QT_CONFIG(permissions)
+ // If the permissions are not granted, display another main window, which
+ // simply contains the error message.
+ const QUrl noPermissionsUrl(QStringLiteral("qrc:/main_no_permissions.qml"));
+ QCameraPermission cameraPermission;
+ qApp->requestPermission(cameraPermission, [&](const QPermission &permission) {
+ if (permission.status() != Qt::PermissionStatus::Granted) {
+ qWarning("Camera permission is not granted!");
+ engine.load(noPermissionsUrl);
+ return;
+ }
+ QMicrophonePermission micPermission;
+ qApp->requestPermission(micPermission, [&](const QPermission &permission) {
+ if (permission.status() != Qt::PermissionStatus::Granted) {
+ qWarning("Microphone permission is not granted!");
+ engine.load(noPermissionsUrl);
+ } else {
+ engine.load(url);
+ }
+ });
+ });
+#else
+ engine.load(url);
+#endif
+
+ return app.exec();
+}
diff --git a/examples/multimedia/video/recorder/main.qml b/examples/multimedia/video/recorder/main.qml
new file mode 100644
index 000000000..d8d1cd54f
--- /dev/null
+++ b/examples/multimedia/video/recorder/main.qml
@@ -0,0 +1,144 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Window
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtMultimedia
+
+Window {
+ id: root
+ visible: true
+ title: "Media recorder"
+ width: Style.screenWidth
+ height: Style.screenHeigth
+
+ color: palette.window
+
+ onWidthChanged:{
+ Style.calculateRatio(root.width, root.height)
+ }
+
+ VideoOutput {
+ id: videoOutput
+ anchors.fill: parent
+ visible: !playback.playing
+ }
+
+ Popup {
+ id: recorderError
+ anchors.centerIn: Overlay.overlay
+ Text { id: recorderErrorText }
+ }
+
+ CaptureSession {
+ id: captureSession
+ recorder: recorder
+ audioInput: controls.audioInput
+ camera: controls.camera
+ screenCapture: controls.screenCapture
+ windowCapture: controls.windowCapture
+ videoOutput: videoOutput
+ }
+
+ MediaRecorder {
+ id: recorder
+ onRecorderStateChanged:
+ (state) => {
+ if (state === MediaRecorder.StoppedState) {
+ root.contentOrientation = Qt.PrimaryOrientation
+ mediaList.append()
+ } else if (state === MediaRecorder.RecordingState && captureSession.camera) {
+ // lock orientation while recording and create a preview image
+ root.contentOrientation = root.screen.orientation;
+ videoOutput.grabToImage(function(res) { mediaList.mediaThumbnail = res.url })
+ }
+ }
+ onActualLocationChanged: (url) => { mediaList.mediaUrl = url }
+ onErrorOccurred: { recorderErrorText.text = recorder.errorString; recorderError.open(); }
+ }
+
+ Playback {
+ id: playback
+ anchors {
+ fill: parent
+ margins: 50
+ }
+ active: controls.capturesVisible
+ }
+
+ Frame {
+ id: mediaListFrame
+ height: 150
+ width: parent.width
+ anchors.bottom: controlsFrame.top
+ x: controls.capturesVisible ? 0 : parent.width
+ background: Rectangle {
+ anchors.fill: parent
+ color: palette.base
+ opacity: 0.8
+ }
+
+ Behavior on x { NumberAnimation { duration: 200 } }
+
+ MediaList {
+ id: mediaList
+ anchors.fill: parent
+ playback: playback
+ }
+ }
+
+ Frame {
+ id: controlsFrame
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+
+ height: controls.height + Style.interSpacing * 2 + (settingsEncoder.visible? settingsEncoder.height : 0) +(settingsMetaData.visible? settingsMetaData.height : 0)
+
+ background: Rectangle {
+ anchors.fill: parent
+ color: palette.base
+ opacity: 0.8
+ }
+
+ Behavior on height { NumberAnimation { duration: 100 } }
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ Controls {
+ Layout.alignment: Qt.AlignHCenter
+ id: controls
+ recorder: recorder
+ }
+
+ StyleRectangle {
+ Layout.alignment: Qt.AlignHCenter
+ visible: controls.settingsVisible
+ width: controls.width
+ height: 1
+ }
+
+ SettingsEncoder {
+
+ id:settingsEncoder
+ Layout.alignment: Qt.AlignHCenter
+ visible: controls.settingsVisible
+ padding: Style.interSpacing
+ recorder: recorder
+ }
+
+ SettingsMetaData {
+ id: settingsMetaData
+ Layout.alignment: Qt.AlignHCenter
+ visible: !Style.isMobile() && controls.settingsVisible
+ recorder: recorder
+ }
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/main_no_permissions.qml b/examples/multimedia/video/recorder/main_no_permissions.qml
new file mode 100644
index 000000000..8c76533b0
--- /dev/null
+++ b/examples/multimedia/video/recorder/main_no_permissions.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Window
+
+Window {
+ id: root
+ visible: true
+ title: "Media recorder"
+ width: Style.screenWidth
+ height: Style.screenHeigth
+
+ StyleRectangle {
+ anchors.fill: parent
+ Text {
+ anchors.fill: parent
+ anchors.margins: 20
+ wrapMode: Text.WordWrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ text: qsTr("The example is not usable without the permissions.\n"
+ + "Please grant all requested permissions and restart the application.")
+ }
+ }
+}
diff --git a/examples/multimedia/video/recorder/qmldir b/examples/multimedia/video/recorder/qmldir
new file mode 100644
index 000000000..400b74be5
--- /dev/null
+++ b/examples/multimedia/video/recorder/qmldir
@@ -0,0 +1,2 @@
+module CustomStyles
+singleton Style 1.0 Style.qml
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h
deleted file mode 100644
index efeb78589..000000000
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef FREQUENCYMONITOR_H
-#define FREQUENCYMONITOR_H
-
-#include <QObject>
-#include <QTimer>
-
-class FrequencyMonitorPrivate;
-
-/**
- * Class for measuring frequency of events
- *
- * Occurrence of the event is notified by the client via the notify() slot.
- * On a regular interval, both an instantaneous and a rolling average
- * event frequency are calculated.
- */
-class FrequencyMonitor : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(FrequencyMonitor)
- Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
- Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(int samplingInterval READ samplingInterval WRITE setSamplingInterval NOTIFY samplingIntervalChanged)
- Q_PROPERTY(int traceInterval READ traceInterval WRITE setTraceInterval NOTIFY traceIntervalChanged)
- Q_PROPERTY(qreal instantaneousFrequency READ instantaneousFrequency NOTIFY instantaneousFrequencyChanged)
- Q_PROPERTY(qreal averageFrequency READ averageFrequency NOTIFY averageFrequencyChanged)
-
-public:
- FrequencyMonitor(QObject *parent = 0);
- ~FrequencyMonitor();
-
- static void qmlRegisterType();
-
- QString label() const;
- bool active() const;
- int samplingInterval() const;
- int traceInterval() const;
- qreal instantaneousFrequency() const;
- qreal averageFrequency() const;
-
-signals:
- void labelChanged(const QString &value);
- void activeChanged(bool);
- void samplingIntervalChanged(int value);
- void traceIntervalChanged(int value);
- void frequencyChanged();
- void instantaneousFrequencyChanged(qreal value);
- void averageFrequencyChanged(qreal value);
-
-public slots:
- Q_INVOKABLE void notify();
- Q_INVOKABLE void trace();
- void setActive(bool value);
- void setLabel(const QString &value);
- void setSamplingInterval(int value);
- void setTraceInterval(int value);
-
-private:
- FrequencyMonitorPrivate *d_ptr;
-};
-
-#endif // FREQUENCYMONITOR_H
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri
deleted file mode 100644
index 3ac8a08c4..000000000
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitor.pri
+++ /dev/null
@@ -1,5 +0,0 @@
-HEADERS += $$PWD/frequencymonitor.h
-SOURCES += $$PWD/frequencymonitor.cpp
-INCLUDEPATH += $$PWD
-DEFINES += FREQUENCYMONITOR_SUPPORT
-
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp
deleted file mode 100644
index 0994ae213..000000000
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "frequencymonitor.h"
-#include <QtQml/qqml.h>
-
-void FrequencyMonitor::qmlRegisterType()
-{
- ::qmlRegisterType<FrequencyMonitor>("FrequencyMonitor", 1, 0, "FrequencyMonitor");
-}
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri
deleted file mode 100644
index 071b7286a..000000000
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.pri
+++ /dev/null
@@ -1,5 +0,0 @@
-include($$PWD/frequencymonitor.pri)
-QT += qml
-
-SOURCES += $$PWD/frequencymonitordeclarative.cpp
-RESOURCES += $$PWD/frequencymonitordeclarative.qrc
diff --git a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc b/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc
deleted file mode 100644
index 48e60cf1e..000000000
--- a/examples/multimedia/video/snippets/frequencymonitor/frequencymonitordeclarative.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qml/frequencymonitor/FrequencyItem.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml b/examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml
deleted file mode 100644
index 13867eb3c..000000000
--- a/examples/multimedia/video/snippets/frequencymonitor/qml/frequencymonitor/FrequencyItem.qml
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import FrequencyMonitor 1.0
-
-Rectangle {
- id: root
- property bool logging: true
- property bool displayed: true
- property bool enabled: logging || displayed
- property alias active: monitor.active
- property int samplingInterval: 500
- property color textColor: "yellow"
- property int textSize: 20
- property alias label: monitor.label
-
- border.width: 1
- border.color: "yellow"
- width: 5.5 * root.textSize
- height: 3.0 * root.textSize
- color: "black"
- opacity: 0.5
- radius: 10
- visible: displayed && active
-
- // This should ensure that the monitor is on top of all other content
- z: 999
-
- function notify() {
- monitor.notify()
- }
-
- FrequencyMonitor {
- id: monitor
- samplingInterval: root.enabled ? root.samplingInterval : 0
- onAverageFrequencyChanged: {
- if (root.logging) trace()
- averageFrequencyText.text = monitor.averageFrequency.toFixed(2)
- }
- }
-
- Text {
- id: labelText
- anchors {
- left: parent.left
- top: parent.top
- margins: 10
- }
- color: root.textColor
- font.pixelSize: 0.6 * root.textSize
- text: root.label
- width: root.width - 2*anchors.margins
- elide: Text.ElideRight
- }
-
- Text {
- id: averageFrequencyText
- anchors {
- right: parent.right
- bottom: parent.bottom
- margins: 10
- }
- color: root.textColor
- font.pixelSize: root.textSize
- }
-}
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp
deleted file mode 100644
index 204eabc5a..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "performancemonitor.h"
-
-namespace PerformanceMonitor {
-
-bool State::parseArgument(const QByteArray &arg)
-{
- bool result = false;
- if (arg == "-log-perf") {
- logging = true;
- valid = true;
- result = true;
- } else if (arg == "-no-log-perf") {
- logging = false;
- valid = true;
- result = true;
- } else if (arg == "-show-perf") {
- visible = true;
- valid = true;
- result = true;
- } else if (arg == "-hide-perf") {
- visible = false;
- valid = true;
- result = true;
- }
- return result;
-}
-
-} // namespace PerformanceMonitor
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h
deleted file mode 100644
index 97b76caf3..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef PERFORMANCEMONITOR_H
-#define PERFORMANCEMONITOR_H
-
-#include <QByteArray>
-
-namespace PerformanceMonitor {
-
-struct State
-{
- State() : valid(true), logging(false), visible(true) { }
- State(bool l, bool v) : valid(true), logging(l), visible(v) { }
- bool operator==(const State &other) const
- { return logging == other.logging && visible == other.visible; }
- bool operator!=(const State &other) const
- { return logging != other.logging || visible != other.visible; }
-
- bool parseArgument(const QByteArray &arg);
-
- bool valid;
- bool logging;
- bool visible;
-};
-
-} // namespace PerformanceMonitor
-
-#endif // PERFORMANCEMONITOR_H
-
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri b/examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri
deleted file mode 100644
index 2df3cfb13..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitor.pri
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDEPATH += $$PWD
-HEADERS += $$PWD/performancemonitor.h
-SOURCES += $$PWD/performancemonitor.cpp
-DEFINES += PERFORMANCEMONITOR_SUPPORT
-
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp
deleted file mode 100644
index 0783fdbd9..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "frequencymonitor.h"
-#include "performancemonitor.h"
-
-namespace PerformanceMonitor {
-
- void qmlRegisterTypes()
- {
- FrequencyMonitor::qmlRegisterType();
- }
-}
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h
deleted file mode 100644
index ca70657ce..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef PERFORMANCEMONITORDECLARATIVE_H
-#define PERFORMANCEMONITORDECLARATIVE_H
-
-#include "performancemonitor.h"
-
-namespace PerformanceMonitor {
- void qmlRegisterTypes();
-}
-
-#endif // PERFORMANCEMONITORDECLARATIVE_H
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri
deleted file mode 100644
index 9a18e35e5..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.pri
+++ /dev/null
@@ -1,6 +0,0 @@
-include($$PWD/../frequencymonitor/frequencymonitordeclarative.pri)
-include($$PWD/performancemonitor.pri)
-
-HEADERS += $$PWD/performancemonitordeclarative.h
-SOURCES += $$PWD/performancemonitordeclarative.cpp
-RESOURCES += $$PWD/performancemonitordeclarative.qrc
diff --git a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc b/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc
deleted file mode 100644
index 9ec54a3e4..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/performancemonitordeclarative.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qml/performancemonitor/PerformanceItem.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml b/examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml
deleted file mode 100644
index 6f5d3d7d3..000000000
--- a/examples/multimedia/video/snippets/performancemonitor/qml/performancemonitor/PerformanceItem.qml
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: root
- property bool logging: true
- property bool displayed: true
- property bool videoActive
- property int margins: 5
- property bool enabled: true
-
- color: "transparent"
-
- // This should ensure that the monitor is on top of all other content
- z: 999
-
- Column {
- id: column
- anchors {
- fill: root
- margins: 10
- }
- spacing: 10
- }
-
- QtObject {
- id: d
- property Item qmlFrameRateItem: null
- property Item videoFrameRateItem: null
- }
-
- Connections {
- id: videoFrameRateActiveConnections
- ignoreUnknownSignals: true
- onActiveChanged: root.videoActive = videoFrameRateActiveConnections.target.active
- }
-
- states: [
- State {
- name: "hidden"
- PropertyChanges {
- target: root
- opacity: 0
- }
- }
- ]
-
- transitions: [
- Transition {
- from: "*"
- to: "*"
- NumberAnimation {
- properties: "opacity"
- easing.type: Easing.OutQuart
- duration: 500
- }
- }
- ]
-
- state: enabled ? "baseState" : "hidden"
-
- function createQmlFrameRateItem() {
- var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
- if (component.status == Component.Ready)
- d.qmlFrameRateItem = component.createObject(column, { label: "QML frame rate",
- displayed: root.displayed,
- logging: root.logging
- })
- }
-
- function createVideoFrameRateItem() {
- var component = Qt.createComponent("../frequencymonitor/FrequencyItem.qml")
- if (component.status == Component.Ready)
- d.videoFrameRateItem = component.createObject(column, { label: "Video frame rate",
- displayed: root.displayed,
- logging: root.logging
- })
- videoFrameRateActiveConnections.target = d.videoFrameRateItem
- }
-
-
- function init() {
- createQmlFrameRateItem()
- createVideoFrameRateItem()
- }
-
- function videoFramePainted() {
- if (d.videoFrameRateItem)
- d.videoFrameRateItem.notify()
- }
-
- function qmlFramePainted() {
- if (d.qmlFrameRateItem)
- d.qmlFrameRateItem.notify()
- }
-
- onVideoActiveChanged: {
- if (d.videoFrameRateItem)
- d.videoFrameRateItem.active = root.videoActive
- }
-}
diff --git a/examples/multimedia/video/video.pro b/examples/multimedia/video/video.pro
index ef5bc849d..2915ce40b 100644
--- a/examples/multimedia/video/video.pro
+++ b/examples/multimedia/video/video.pro
@@ -1,9 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += qmlvideo qmlvideofx
-
-EXAMPLE_FILES += \
- qmlvideofilter_opencl \ # FIXME: this one should use a configure check instead
- snippets
-
-android: SUBDIRS += android
+SUBDIRS += qmlvideo
diff --git a/examples/multimedia/videographicsitem/CMakeLists.txt b/examples/multimedia/videographicsitem/CMakeLists.txt
new file mode 100644
index 000000000..a45e373a3
--- /dev/null
+++ b/examples/multimedia/videographicsitem/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(videographicsitem LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/videographicsitem")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia MultimediaWidgets Widgets)
+
+qt_add_executable(videographicsitem
+ main.cpp
+ videoplayer.cpp videoplayer.h
+)
+
+set_target_properties(videographicsitem PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(videographicsitem PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::MultimediaWidgets
+ Qt::Widgets
+)
+
+install(TARGETS videographicsitem
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png b/examples/multimedia/videographicsitem/doc/images/video-videographicsitem.png
index e333c54a2..e333c54a2 100644
--- a/examples/multimediawidgets/videographicsitem/doc/images/video-videographicsitem.png
+++ b/examples/multimedia/videographicsitem/doc/images/video-videographicsitem.png
Binary files differ
diff --git a/examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc b/examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc
new file mode 100644
index 000000000..74196dfeb
--- /dev/null
+++ b/examples/multimedia/videographicsitem/doc/src/videographicsitem.qdoc
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example videographicsitem
+ \title Video Graphics Item Example
+ \ingroup multimedia_examples
+ \examplecategory {Multimedia}
+ \brief Streaming video on a graphics scene.
+ \meta {tag} {widgets}
+
+ \e{Video Graphics Item} demonstrates how to implement a QGraphicsItem that
+ displays video on a graphics scene using QVideoSink.
+
+ \image video-videographicsitem.png
+
+ \sa {Video Widget Example}
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/multimedia/videographicsitem/main.cpp b/examples/multimedia/videographicsitem/main.cpp
new file mode 100644
index 000000000..725243ed9
--- /dev/null
+++ b/examples/multimedia/videographicsitem/main.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videoplayer.h"
+
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QDir>
+#include <QUrl>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("Player Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt MultiMedia Player QGraphicsView Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL to open.");
+ parser.process(app);
+
+ VideoPlayer player;
+
+ if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
+ const QUrl url = QUrl::fromUserInput(parser.positionalArguments().constFirst(),
+ QDir::currentPath(), QUrl::AssumeLocalFile);
+ player.load(url);
+ }
+
+ player.show();
+
+ return app.exec();
+}
diff --git a/examples/multimediawidgets/videographicsitem/videographicsitem.pro b/examples/multimedia/videographicsitem/videographicsitem.pro
index 30a9b6f21..3415ef64c 100644
--- a/examples/multimediawidgets/videographicsitem/videographicsitem.pro
+++ b/examples/multimedia/videographicsitem/videographicsitem.pro
@@ -8,7 +8,7 @@ HEADERS += videoplayer.h
SOURCES += main.cpp \
videoplayer.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/videographicsitem
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/videographicsitem
INSTALLS += target
QT+=widgets
diff --git a/examples/multimedia/videographicsitem/videoplayer.cpp b/examples/multimedia/videographicsitem/videoplayer.cpp
new file mode 100644
index 000000000..744a35469
--- /dev/null
+++ b/examples/multimedia/videographicsitem/videoplayer.cpp
@@ -0,0 +1,148 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videoplayer.h"
+
+#include <QBoxLayout>
+#include <QDir>
+#include <QFileDialog>
+#include <QGraphicsScene>
+#include <QGraphicsVideoItem>
+#include <QGraphicsView>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QScreen>
+#include <QSlider>
+#include <QStandardPaths>
+#include <QStyle>
+#include <QVBoxLayout>
+#include <QWidget>
+
+VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent)
+{
+ m_mediaPlayer = new QMediaPlayer(this);
+ const QSize screenGeometry = screen()->availableSize();
+ m_videoItem = new QGraphicsVideoItem;
+ m_videoItem->setSize(QSizeF(screenGeometry.width() / 3, screenGeometry.height() / 2));
+
+ QGraphicsScene *scene = new QGraphicsScene(this);
+ QGraphicsView *graphicsView = new QGraphicsView(scene);
+
+ scene->addItem(m_videoItem);
+
+ QSlider *rotateSlider = new QSlider(Qt::Horizontal);
+ rotateSlider->setToolTip(tr("Rotate Video"));
+ rotateSlider->setRange(-180, 180);
+ rotateSlider->setValue(0);
+
+ connect(rotateSlider, &QAbstractSlider::valueChanged, this, &VideoPlayer::rotateVideo);
+
+ QAbstractButton *openButton = new QPushButton(tr("Open..."));
+ connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile);
+
+ m_playButton = new QPushButton;
+ m_playButton->setEnabled(false);
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+
+ connect(m_playButton, &QAbstractButton::clicked, this, &VideoPlayer::play);
+
+ m_positionSlider = new QSlider(Qt::Horizontal);
+ m_positionSlider->setRange(0, 0);
+
+ connect(m_positionSlider, &QAbstractSlider::sliderMoved, this, &VideoPlayer::setPosition);
+
+ QBoxLayout *controlLayout = new QHBoxLayout;
+ controlLayout->setContentsMargins(0, 0, 0, 0);
+ controlLayout->addWidget(openButton);
+ controlLayout->addWidget(m_playButton);
+ controlLayout->addWidget(m_positionSlider);
+
+ QBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(graphicsView);
+ layout->addWidget(rotateSlider);
+ layout->addLayout(controlLayout);
+
+ m_mediaPlayer->setVideoOutput(m_videoItem);
+ connect(m_mediaPlayer, &QMediaPlayer::playbackStateChanged, this,
+ &VideoPlayer::mediaStateChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
+}
+
+VideoPlayer::~VideoPlayer() { }
+
+QSize VideoPlayer::sizeHint() const
+{
+ return (m_videoItem->size() * qreal(3) / qreal(2)).toSize();
+}
+
+bool VideoPlayer::isPlayerAvailable() const
+{
+ return m_mediaPlayer->isAvailable();
+}
+
+void VideoPlayer::openFile()
+{
+ QFileDialog fileDialog(this);
+ fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
+ fileDialog.setWindowTitle(tr("Open Movie"));
+ fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation)
+ .value(0, QDir::homePath()));
+ if (fileDialog.exec() == QDialog::Accepted)
+ load(fileDialog.selectedUrls().constFirst());
+}
+
+void VideoPlayer::load(const QUrl &url)
+{
+ m_mediaPlayer->setSource(url);
+ m_playButton->setEnabled(true);
+}
+
+void VideoPlayer::play()
+{
+ switch (m_mediaPlayer->playbackState()) {
+ case QMediaPlayer::PlayingState:
+ m_mediaPlayer->pause();
+ break;
+ default:
+ m_mediaPlayer->play();
+ break;
+ }
+}
+
+void VideoPlayer::mediaStateChanged(QMediaPlayer::PlaybackState state)
+{
+ switch (state) {
+ case QMediaPlayer::PlayingState:
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
+ break;
+ default:
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+ break;
+ }
+}
+
+void VideoPlayer::positionChanged(qint64 position)
+{
+ m_positionSlider->setValue(position);
+}
+
+void VideoPlayer::durationChanged(qint64 duration)
+{
+ m_positionSlider->setRange(0, duration);
+}
+
+void VideoPlayer::setPosition(int position)
+{
+ m_mediaPlayer->setPosition(position);
+}
+
+void VideoPlayer::rotateVideo(int angle)
+{
+ // rotate around the center of video element
+ qreal x = m_videoItem->boundingRect().width() / 2.0;
+ qreal y = m_videoItem->boundingRect().height() / 2.0;
+ m_videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y));
+}
+
+#include "moc_videoplayer.cpp"
diff --git a/examples/multimedia/videographicsitem/videoplayer.h b/examples/multimedia/videographicsitem/videoplayer.h
new file mode 100644
index 000000000..5cd4d7434
--- /dev/null
+++ b/examples/multimedia/videographicsitem/videoplayer.h
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOPLAYER_H
+#define VIDEOPLAYER_H
+
+#include <QMediaPlayer>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QSlider;
+class QGraphicsVideoItem;
+QT_END_NAMESPACE
+
+class VideoPlayer : public QWidget
+{
+ Q_OBJECT
+
+public:
+ VideoPlayer(QWidget *parent = nullptr);
+ ~VideoPlayer();
+
+ void load(const QUrl &url);
+ bool isPlayerAvailable() const;
+
+ QSize sizeHint() const override;
+
+public slots:
+ void openFile();
+ void play();
+
+private slots:
+ void mediaStateChanged(QMediaPlayer::PlaybackState state);
+ void positionChanged(qint64 position);
+ void durationChanged(qint64 duration);
+ void setPosition(int position);
+ void rotateVideo(int angle);
+
+private:
+ QMediaPlayer *m_mediaPlayer = nullptr;
+ QGraphicsVideoItem *m_videoItem = nullptr;
+ QAbstractButton *m_playButton = nullptr;
+ QSlider *m_positionSlider = nullptr;
+};
+
+#endif
diff --git a/examples/multimedia/videowidget/CMakeLists.txt b/examples/multimedia/videowidget/CMakeLists.txt
new file mode 100644
index 000000000..e47cea1fa
--- /dev/null
+++ b/examples/multimedia/videowidget/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(videowidget LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimedia/videowidget")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Multimedia MultimediaWidgets Widgets)
+
+qt_add_executable(videowidget
+ main.cpp
+ videoplayer.cpp videoplayer.h
+)
+
+set_target_properties(videowidget PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(videowidget PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Multimedia
+ Qt::MultimediaWidgets
+ Qt::Widgets
+)
+
+install(TARGETS videowidget
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png b/examples/multimedia/videowidget/doc/images/video-videowidget.png
index a3c7bcb44..a3c7bcb44 100644
--- a/examples/multimediawidgets/videowidget/doc/images/video-videowidget.png
+++ b/examples/multimedia/videowidget/doc/images/video-videowidget.png
Binary files differ
diff --git a/examples/multimedia/videowidget/doc/src/videowidget.qdoc b/examples/multimedia/videowidget/doc/src/videowidget.qdoc
new file mode 100644
index 000000000..65be142fe
--- /dev/null
+++ b/examples/multimedia/videowidget/doc/src/videowidget.qdoc
@@ -0,0 +1,18 @@
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example videowidget
+ \title Video Widget Example
+ \ingroup multimedia_examples
+ \examplecategory {Multimedia}
+ \brief Implementing a video player widget.
+ \meta {tag} {widgets,QVideoWidget}
+
+ \e{Video Widget} demonstrates how to implement a simple video player using
+ QVideoWidget.
+
+ \image video-videowidget.png
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/multimedia/videowidget/main.cpp b/examples/multimedia/videowidget/main.cpp
new file mode 100644
index 000000000..a4e2dc4aa
--- /dev/null
+++ b/examples/multimedia/videowidget/main.cpp
@@ -0,0 +1,40 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videoplayer.h"
+
+#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QDir>
+#include <QScreen>
+#include <QUrl>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationName("Video Widget Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QGuiApplication::setApplicationDisplayName(QCoreApplication::applicationName());
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Qt Video Widget Example");
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("url", "The URL to open.");
+ parser.process(app);
+
+ VideoPlayer player;
+ if (!parser.positionalArguments().isEmpty()) {
+ const QUrl url = QUrl::fromUserInput(parser.positionalArguments().constFirst(),
+ QDir::currentPath(), QUrl::AssumeLocalFile);
+ player.setUrl(url);
+ }
+
+ const QSize availableGeometry = player.screen()->availableSize();
+ player.resize(availableGeometry.width() / 6, availableGeometry.height() / 4);
+ player.show();
+
+ return app.exec();
+}
diff --git a/examples/multimedia/videowidget/videoplayer.cpp b/examples/multimedia/videowidget/videoplayer.cpp
new file mode 100644
index 000000000..1a778d2fb
--- /dev/null
+++ b/examples/multimedia/videowidget/videoplayer.cpp
@@ -0,0 +1,137 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "videoplayer.h"
+
+#include <QBoxLayout>
+#include <QFileDialog>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMediaPlayer>
+#include <QPushButton>
+#include <QSizePolicy>
+#include <QSlider>
+#include <QStandardPaths>
+#include <QString>
+#include <QStyle>
+#include <QVideoWidget>
+
+VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent)
+{
+ m_mediaPlayer = new QMediaPlayer(this);
+ QVideoWidget *videoWidget = new QVideoWidget;
+
+ QAbstractButton *openButton = new QPushButton(tr("Open..."));
+ connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile);
+
+ m_playButton = new QPushButton;
+ m_playButton->setEnabled(false);
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+
+ connect(m_playButton, &QAbstractButton::clicked, this, &VideoPlayer::play);
+
+ m_positionSlider = new QSlider(Qt::Horizontal);
+ m_positionSlider->setRange(0, 0);
+
+ connect(m_positionSlider, &QAbstractSlider::sliderMoved, this, &VideoPlayer::setPosition);
+
+ m_errorLabel = new QLabel;
+ m_errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
+
+ QBoxLayout *controlLayout = new QHBoxLayout;
+ controlLayout->setContentsMargins(0, 0, 0, 0);
+ controlLayout->addWidget(openButton);
+ controlLayout->addWidget(m_playButton);
+ controlLayout->addWidget(m_positionSlider);
+
+ QBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(videoWidget);
+ layout->addLayout(controlLayout);
+ layout->addWidget(m_errorLabel);
+
+ setLayout(layout);
+
+ m_mediaPlayer->setVideoOutput(videoWidget);
+ connect(m_mediaPlayer, &QMediaPlayer::playbackStateChanged, this,
+ &VideoPlayer::mediaStateChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
+ connect(m_mediaPlayer, &QMediaPlayer::errorChanged, this, &VideoPlayer::handleError);
+}
+
+VideoPlayer::~VideoPlayer() { }
+
+void VideoPlayer::openFile()
+{
+ QFileDialog fileDialog(this);
+ fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
+ fileDialog.setWindowTitle(tr("Open Movie"));
+ fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation)
+ .value(0, QDir::homePath()));
+ if (fileDialog.exec() == QDialog::Accepted)
+ setUrl(fileDialog.selectedUrls().constFirst());
+}
+
+void VideoPlayer::setUrl(const QUrl &url)
+{
+ m_errorLabel->setText(QString());
+ setWindowFilePath(url.isLocalFile() ? url.toLocalFile() : QString());
+ m_mediaPlayer->setSource(url);
+ m_playButton->setEnabled(true);
+}
+
+void VideoPlayer::play()
+{
+ switch (m_mediaPlayer->playbackState()) {
+ case QMediaPlayer::PlayingState:
+ m_mediaPlayer->pause();
+ break;
+ default:
+ m_mediaPlayer->play();
+ break;
+ }
+}
+
+void VideoPlayer::mediaStateChanged(QMediaPlayer::PlaybackState state)
+{
+ switch (state) {
+ case QMediaPlayer::PlayingState:
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
+ break;
+ default:
+ m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
+ break;
+ }
+}
+
+void VideoPlayer::positionChanged(qint64 position)
+{
+ m_positionSlider->setValue(position);
+}
+
+void VideoPlayer::durationChanged(qint64 duration)
+{
+ m_positionSlider->setRange(0, duration);
+}
+
+void VideoPlayer::setPosition(int position)
+{
+ m_mediaPlayer->setPosition(position);
+}
+
+void VideoPlayer::handleError()
+{
+ if (m_mediaPlayer->error() == QMediaPlayer::NoError)
+ return;
+
+ m_playButton->setEnabled(false);
+ const QString errorString = m_mediaPlayer->errorString();
+ QString message = "Error: ";
+ if (errorString.isEmpty())
+ message += " #" + QString::number(int(m_mediaPlayer->error()));
+ else
+ message += errorString;
+ m_errorLabel->setText(message);
+}
+
+#include "moc_videoplayer.cpp"
diff --git a/examples/multimedia/videowidget/videoplayer.h b/examples/multimedia/videowidget/videoplayer.h
new file mode 100644
index 000000000..3657a04de
--- /dev/null
+++ b/examples/multimedia/videowidget/videoplayer.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VIDEOPLAYER_H
+#define VIDEOPLAYER_H
+
+#include <QMediaPlayer>
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QAbstractButton;
+class QSlider;
+class QLabel;
+class QUrl;
+QT_END_NAMESPACE
+
+class VideoPlayer : public QWidget
+{
+ Q_OBJECT
+public:
+ VideoPlayer(QWidget *parent = nullptr);
+ ~VideoPlayer();
+
+ void setUrl(const QUrl &url);
+
+public slots:
+ void openFile();
+ void play();
+
+private slots:
+ void mediaStateChanged(QMediaPlayer::PlaybackState state);
+ void positionChanged(qint64 position);
+ void durationChanged(qint64 duration);
+ void setPosition(int position);
+ void handleError();
+
+private:
+ QMediaPlayer *m_mediaPlayer;
+ QAbstractButton *m_playButton;
+ QSlider *m_positionSlider;
+ QLabel *m_errorLabel;
+};
+
+#endif
diff --git a/examples/multimediawidgets/videowidget/videowidget.pro b/examples/multimedia/videowidget/videowidget.pro
index 603996b2e..56312a028 100644
--- a/examples/multimediawidgets/videowidget/videowidget.pro
+++ b/examples/multimedia/videowidget/videowidget.pro
@@ -10,7 +10,7 @@ SOURCES = \
main.cpp \
videoplayer.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/videowidget
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/videowidget
INSTALLS += target
QT+=widgets
diff --git a/examples/multimediawidgets/camera/camera.cpp b/examples/multimediawidgets/camera/camera.cpp
deleted file mode 100644
index d03a1d1dc..000000000
--- a/examples/multimediawidgets/camera/camera.cpp
+++ /dev/null
@@ -1,434 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "camera.h"
-#include "ui_camera.h"
-#include "videosettings.h"
-#include "imagesettings.h"
-
-#include <QMediaService>
-#include <QMediaRecorder>
-#include <QCameraViewfinder>
-#include <QCameraInfo>
-#include <QMediaMetaData>
-
-#include <QMessageBox>
-#include <QPalette>
-
-#include <QtWidgets>
-
-Q_DECLARE_METATYPE(QCameraInfo)
-
-Camera::Camera() : ui(new Ui::Camera)
-{
- ui->setupUi(this);
-
- //Camera devices:
-
- QActionGroup *videoDevicesGroup = new QActionGroup(this);
- videoDevicesGroup->setExclusive(true);
- const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras();
- for (const QCameraInfo &cameraInfo : availableCameras) {
- QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup);
- videoDeviceAction->setCheckable(true);
- videoDeviceAction->setData(QVariant::fromValue(cameraInfo));
- if (cameraInfo == QCameraInfo::defaultCamera())
- videoDeviceAction->setChecked(true);
-
- ui->menuDevices->addAction(videoDeviceAction);
- }
-
- connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice);
- connect(ui->captureWidget, &QTabWidget::currentChanged, this, &Camera::updateCaptureMode);
-
- setCamera(QCameraInfo::defaultCamera());
-}
-
-void Camera::setCamera(const QCameraInfo &cameraInfo)
-{
- m_camera.reset(new QCamera(cameraInfo));
-
- connect(m_camera.data(), &QCamera::stateChanged, this, &Camera::updateCameraState);
- connect(m_camera.data(), &QCamera::errorOccurred, this, &Camera::displayCameraError);
-
- m_mediaRecorder.reset(new QMediaRecorder(m_camera.data()));
- connect(m_mediaRecorder.data(), &QMediaRecorder::stateChanged, this, &Camera::updateRecorderState);
-
- m_imageCapture.reset(new QCameraImageCapture(m_camera.data()));
-
- connect(m_mediaRecorder.data(), &QMediaRecorder::durationChanged, this, &Camera::updateRecordTime);
- connect(m_mediaRecorder.data(), QOverload<QMediaRecorder::Error>::of(&QMediaRecorder::error),
- this, &Camera::displayRecorderError);
-
- m_mediaRecorder->setMetaData(QMediaMetaData::Title, QVariant(QLatin1String("Test Title")));
-
- connect(ui->exposureCompensation, &QAbstractSlider::valueChanged, this, &Camera::setExposureCompensation);
-
- m_camera->setViewfinder(ui->viewfinder);
-
- updateCameraState(m_camera->state());
- updateLockStatus(m_camera->lockStatus(), QCamera::UserRequest);
- updateRecorderState(m_mediaRecorder->state());
-
- connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture);
- connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
- connect(m_imageCapture.data(), &QCameraImageCapture::imageSaved, this, &Camera::imageSaved);
- connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error),
- this, &Camera::displayCaptureError);
-
- connect(m_camera.data(), QOverload<QCamera::LockStatus, QCamera::LockChangeReason>::of(&QCamera::lockStatusChanged),
- this, &Camera::updateLockStatus);
-
- ui->captureWidget->setTabEnabled(0, (m_camera->isCaptureModeSupported(QCamera::CaptureStillImage)));
- ui->captureWidget->setTabEnabled(1, (m_camera->isCaptureModeSupported(QCamera::CaptureVideo)));
-
- updateCaptureMode();
- m_camera->start();
-}
-
-void Camera::keyPressEvent(QKeyEvent * event)
-{
- if (event->isAutoRepeat())
- return;
-
- switch (event->key()) {
- case Qt::Key_CameraFocus:
- displayViewfinder();
- m_camera->searchAndLock();
- event->accept();
- break;
- case Qt::Key_Camera:
- if (m_camera->captureMode() == QCamera::CaptureStillImage) {
- takeImage();
- } else {
- if (m_mediaRecorder->state() == QMediaRecorder::RecordingState)
- stop();
- else
- record();
- }
- event->accept();
- break;
- default:
- QMainWindow::keyPressEvent(event);
- }
-}
-
-void Camera::keyReleaseEvent(QKeyEvent *event)
-{
- if (event->isAutoRepeat())
- return;
-
- switch (event->key()) {
- case Qt::Key_CameraFocus:
- m_camera->unlock();
- break;
- default:
- QMainWindow::keyReleaseEvent(event);
- }
-}
-
-void Camera::updateRecordTime()
-{
- QString str = QString("Recorded %1 sec").arg(m_mediaRecorder->duration()/1000);
- ui->statusbar->showMessage(str);
-}
-
-void Camera::processCapturedImage(int requestId, const QImage& img)
-{
- Q_UNUSED(requestId);
- QImage scaledImage = img.scaled(ui->viewfinder->size(),
- Qt::KeepAspectRatio,
- Qt::SmoothTransformation);
-
- ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage));
-
- // Display captured image for 4 seconds.
- displayCapturedImage();
- QTimer::singleShot(4000, this, &Camera::displayViewfinder);
-}
-
-void Camera::configureCaptureSettings()
-{
- switch (m_camera->captureMode()) {
- case QCamera::CaptureStillImage:
- configureImageSettings();
- break;
- case QCamera::CaptureVideo:
- configureVideoSettings();
- break;
- default:
- break;
- }
-}
-
-void Camera::configureVideoSettings()
-{
- VideoSettings settingsDialog(m_mediaRecorder.data());
- settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
-
- settingsDialog.setAudioSettings(m_audioSettings);
- settingsDialog.setVideoSettings(m_videoSettings);
- settingsDialog.setFormat(m_videoContainerFormat);
-
- if (settingsDialog.exec()) {
- m_audioSettings = settingsDialog.audioSettings();
- m_videoSettings = settingsDialog.videoSettings();
- m_videoContainerFormat = settingsDialog.format();
-
- m_mediaRecorder->setEncodingSettings(
- m_audioSettings,
- m_videoSettings,
- m_videoContainerFormat);
-
- m_camera->unload();
- m_camera->start();
- }
-}
-
-void Camera::configureImageSettings()
-{
- ImageSettings settingsDialog(m_imageCapture.data());
- settingsDialog.setWindowFlags(settingsDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
-
- settingsDialog.setImageSettings(m_imageSettings);
-
- if (settingsDialog.exec()) {
- m_imageSettings = settingsDialog.imageSettings();
- m_imageCapture->setEncodingSettings(m_imageSettings);
- }
-}
-
-void Camera::record()
-{
- m_mediaRecorder->record();
- updateRecordTime();
-}
-
-void Camera::pause()
-{
- m_mediaRecorder->pause();
-}
-
-void Camera::stop()
-{
- m_mediaRecorder->stop();
-}
-
-void Camera::setMuted(bool muted)
-{
- m_mediaRecorder->setMuted(muted);
-}
-
-void Camera::toggleLock()
-{
- switch (m_camera->lockStatus()) {
- case QCamera::Searching:
- case QCamera::Locked:
- m_camera->unlock();
- break;
- case QCamera::Unlocked:
- m_camera->searchAndLock();
- }
-}
-
-void Camera::updateLockStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason)
-{
- QColor indicationColor = Qt::black;
-
- switch (status) {
- case QCamera::Searching:
- indicationColor = Qt::yellow;
- ui->statusbar->showMessage(tr("Focusing..."));
- ui->lockButton->setText(tr("Focusing..."));
- break;
- case QCamera::Locked:
- indicationColor = Qt::darkGreen;
- ui->lockButton->setText(tr("Unlock"));
- ui->statusbar->showMessage(tr("Focused"), 2000);
- break;
- case QCamera::Unlocked:
- indicationColor = reason == QCamera::LockFailed ? Qt::red : Qt::black;
- ui->lockButton->setText(tr("Focus"));
- if (reason == QCamera::LockFailed)
- ui->statusbar->showMessage(tr("Focus Failed"), 2000);
- }
-
- QPalette palette = ui->lockButton->palette();
- palette.setColor(QPalette::ButtonText, indicationColor);
- ui->lockButton->setPalette(palette);
-}
-
-void Camera::takeImage()
-{
- m_isCapturingImage = true;
- m_imageCapture->capture();
-}
-
-void Camera::displayCaptureError(int id, const QCameraImageCapture::Error error, const QString &errorString)
-{
- Q_UNUSED(id);
- Q_UNUSED(error);
- QMessageBox::warning(this, tr("Image Capture Error"), errorString);
- m_isCapturingImage = false;
-}
-
-void Camera::startCamera()
-{
- m_camera->start();
-}
-
-void Camera::stopCamera()
-{
- m_camera->stop();
-}
-
-void Camera::updateCaptureMode()
-{
- int tabIndex = ui->captureWidget->currentIndex();
- QCamera::CaptureModes captureMode = tabIndex == 0 ? QCamera::CaptureStillImage : QCamera::CaptureVideo;
-
- if (m_camera->isCaptureModeSupported(captureMode))
- m_camera->setCaptureMode(captureMode);
-}
-
-void Camera::updateCameraState(QCamera::State state)
-{
- switch (state) {
- case QCamera::ActiveState:
- ui->actionStartCamera->setEnabled(false);
- ui->actionStopCamera->setEnabled(true);
- ui->captureWidget->setEnabled(true);
- ui->actionSettings->setEnabled(true);
- break;
- case QCamera::UnloadedState:
- case QCamera::LoadedState:
- ui->actionStartCamera->setEnabled(true);
- ui->actionStopCamera->setEnabled(false);
- ui->captureWidget->setEnabled(false);
- ui->actionSettings->setEnabled(false);
- }
-}
-
-void Camera::updateRecorderState(QMediaRecorder::State state)
-{
- switch (state) {
- case QMediaRecorder::StoppedState:
- ui->recordButton->setEnabled(true);
- ui->pauseButton->setEnabled(true);
- ui->stopButton->setEnabled(false);
- break;
- case QMediaRecorder::PausedState:
- ui->recordButton->setEnabled(true);
- ui->pauseButton->setEnabled(false);
- ui->stopButton->setEnabled(true);
- break;
- case QMediaRecorder::RecordingState:
- ui->recordButton->setEnabled(false);
- ui->pauseButton->setEnabled(true);
- ui->stopButton->setEnabled(true);
- break;
- }
-}
-
-void Camera::setExposureCompensation(int index)
-{
- m_camera->exposure()->setExposureCompensation(index*0.5);
-}
-
-void Camera::displayRecorderError()
-{
- QMessageBox::warning(this, tr("Capture Error"), m_mediaRecorder->errorString());
-}
-
-void Camera::displayCameraError()
-{
- QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString());
-}
-
-void Camera::updateCameraDevice(QAction *action)
-{
- setCamera(qvariant_cast<QCameraInfo>(action->data()));
-}
-
-void Camera::displayViewfinder()
-{
- ui->stackedWidget->setCurrentIndex(0);
-}
-
-void Camera::displayCapturedImage()
-{
- ui->stackedWidget->setCurrentIndex(1);
-}
-
-void Camera::readyForCapture(bool ready)
-{
- ui->takeImageButton->setEnabled(ready);
-}
-
-void Camera::imageSaved(int id, const QString &fileName)
-{
- Q_UNUSED(id);
- ui->statusbar->showMessage(tr("Captured \"%1\"").arg(QDir::toNativeSeparators(fileName)));
-
- m_isCapturingImage = false;
- if (m_applicationExiting)
- close();
-}
-
-void Camera::closeEvent(QCloseEvent *event)
-{
- if (m_isCapturingImage) {
- setEnabled(false);
- m_applicationExiting = true;
- event->ignore();
- } else {
- event->accept();
- }
-}
diff --git a/examples/multimediawidgets/camera/camera.h b/examples/multimediawidgets/camera/camera.h
deleted file mode 100644
index d06c770f6..000000000
--- a/examples/multimediawidgets/camera/camera.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef CAMERA_H
-#define CAMERA_H
-
-#include <QCamera>
-#include <QCameraImageCapture>
-#include <QMediaRecorder>
-#include <QScopedPointer>
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-namespace Ui { class Camera; }
-QT_END_NAMESPACE
-
-class Camera : public QMainWindow
-{
- Q_OBJECT
-
-public:
- Camera();
-
-private slots:
- void setCamera(const QCameraInfo &cameraInfo);
-
- void startCamera();
- void stopCamera();
-
- void record();
- void pause();
- void stop();
- void setMuted(bool);
-
- void toggleLock();
- void takeImage();
- void displayCaptureError(int, QCameraImageCapture::Error, const QString &errorString);
-
- void configureCaptureSettings();
- void configureVideoSettings();
- void configureImageSettings();
-
- void displayRecorderError();
- void displayCameraError();
-
- void updateCameraDevice(QAction *action);
-
- void updateCameraState(QCamera::State);
- void updateCaptureMode();
- void updateRecorderState(QMediaRecorder::State state);
- void setExposureCompensation(int index);
-
- void updateRecordTime();
-
- void processCapturedImage(int requestId, const QImage &img);
- void updateLockStatus(QCamera::LockStatus, QCamera::LockChangeReason);
-
- void displayViewfinder();
- void displayCapturedImage();
-
- void readyForCapture(bool ready);
- void imageSaved(int id, const QString &fileName);
-
-protected:
- void keyPressEvent(QKeyEvent *event) override;
- void keyReleaseEvent(QKeyEvent *event) override;
- void closeEvent(QCloseEvent *event) override;
-
-private:
- Ui::Camera *ui;
-
- QScopedPointer<QCamera> m_camera;
- QScopedPointer<QCameraImageCapture> m_imageCapture;
- QScopedPointer<QMediaRecorder> m_mediaRecorder;
-
- QImageEncoderSettings m_imageSettings;
- QAudioEncoderSettings m_audioSettings;
- QVideoEncoderSettings m_videoSettings;
- QString m_videoContainerFormat;
- bool m_isCapturingImage = false;
- bool m_applicationExiting = false;
-};
-
-#endif
diff --git a/examples/multimediawidgets/camera/camera.pro b/examples/multimediawidgets/camera/camera.pro
deleted file mode 100644
index 52c511acb..000000000
--- a/examples/multimediawidgets/camera/camera.pro
+++ /dev/null
@@ -1,28 +0,0 @@
-TEMPLATE = app
-TARGET = camera
-
-QT += multimedia multimediawidgets
-
-HEADERS = \
- camera.h \
- imagesettings.h \
- videosettings.h
-
-SOURCES = \
- main.cpp \
- camera.cpp \
- imagesettings.cpp \
- videosettings.cpp
-
-FORMS += \
- camera.ui \
- videosettings.ui \
- imagesettings.ui
-
-RESOURCES += camera.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/camera
-INSTALLS += target
-
-QT+=widgets
-include(../../multimedia/shared/shared.pri)
diff --git a/examples/multimediawidgets/camera/doc/images/camera-example.png b/examples/multimediawidgets/camera/doc/images/camera-example.png
deleted file mode 100644
index 12e1b5728..000000000
--- a/examples/multimediawidgets/camera/doc/images/camera-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/multimediawidgets/camera/doc/src/camera.qdoc b/examples/multimediawidgets/camera/doc/src/camera.qdoc
deleted file mode 100644
index 68e19aac3..000000000
--- a/examples/multimediawidgets/camera/doc/src/camera.qdoc
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-
-/*!
-
-\example multimediawidgets/camera
-\title Camera Example
-\ingroup multimedia_examples
-\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 \l{Qt Multimedia} to implement
-some basic Camera functionality to take still images and record video clips
-with audio.
-
-\include examples-run.qdocinc
-
-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
-
-*/
diff --git a/examples/multimediawidgets/camera/imagesettings.cpp b/examples/multimediawidgets/camera/imagesettings.cpp
deleted file mode 100644
index 1c8895e02..000000000
--- a/examples/multimediawidgets/camera/imagesettings.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "imagesettings.h"
-#include "ui_imagesettings.h"
-
-#include <QComboBox>
-#include <QDebug>
-#include <QCameraImageCapture>
-#include <QMediaService>
-
-
-ImageSettings::ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::ImageSettingsUi),
- imagecapture(imageCapture)
-{
- ui->setupUi(this);
-
- //image codecs
- ui->imageCodecBox->addItem(tr("Default image format"), QVariant(QString()));
- const QStringList supportedImageCodecs = imagecapture->supportedImageCodecs();
- for (const QString &codecName : supportedImageCodecs) {
- QString description = imagecapture->imageCodecDescription(codecName);
- ui->imageCodecBox->addItem(codecName + ": " + description, QVariant(codecName));
- }
-
- ui->imageQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
-
- ui->imageResolutionBox->addItem(tr("Default Resolution"));
- const QList<QSize> supportedResolutions = imagecapture->supportedResolutions();
- for (const QSize &resolution : supportedResolutions) {
- ui->imageResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()),
- QVariant(resolution));
- }
-}
-
-ImageSettings::~ImageSettings()
-{
- delete ui;
-}
-
-void ImageSettings::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-QImageEncoderSettings ImageSettings::imageSettings() const
-{
- QImageEncoderSettings settings = imagecapture->encodingSettings();
- settings.setCodec(boxValue(ui->imageCodecBox).toString());
- settings.setQuality(QMultimedia::EncodingQuality(ui->imageQualitySlider->value()));
- settings.setResolution(boxValue(ui->imageResolutionBox).toSize());
-
- return settings;
-}
-
-void ImageSettings::setImageSettings(const QImageEncoderSettings &imageSettings)
-{
- selectComboBoxItem(ui->imageCodecBox, QVariant(imageSettings.codec()));
- selectComboBoxItem(ui->imageResolutionBox, QVariant(imageSettings.resolution()));
- ui->imageQualitySlider->setValue(imageSettings.quality());
-}
-
-QVariant ImageSettings::boxValue(const QComboBox *box) const
-{
- int idx = box->currentIndex();
- if (idx == -1)
- return QVariant();
-
- return box->itemData(idx);
-}
-
-void ImageSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
-{
- for (int i = 0; i < box->count(); ++i) {
- if (box->itemData(i) == value) {
- box->setCurrentIndex(i);
- break;
- }
- }
-}
diff --git a/examples/multimediawidgets/camera/imagesettings.h b/examples/multimediawidgets/camera/imagesettings.h
deleted file mode 100644
index 1e4ac536e..000000000
--- a/examples/multimediawidgets/camera/imagesettings.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef IMAGESETTINGS_H
-#define IMAGESETTINGS_H
-
-#include <QDialog>
-#include <QAudioEncoderSettings>
-#include <QVideoEncoderSettings>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QCameraImageCapture;
-namespace Ui { class ImageSettingsUi; }
-QT_END_NAMESPACE
-
-class ImageSettings : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ImageSettings(QCameraImageCapture *imageCapture, QWidget *parent = nullptr);
- ~ImageSettings();
-
- QAudioEncoderSettings audioSettings() const;
- void setAudioSettings(const QAudioEncoderSettings &settings);
-
- QImageEncoderSettings imageSettings() const;
- void setImageSettings(const QImageEncoderSettings &settings);
-
- QString format() const;
- void setFormat(const QString &format);
-
-protected:
- void changeEvent(QEvent *e) override;
-
-private:
- QVariant boxValue(const QComboBox *box) const;
- void selectComboBoxItem(QComboBox *box, const QVariant &value);
-
- Ui::ImageSettingsUi *ui;
- QCameraImageCapture *imagecapture;
-};
-
-#endif // IMAGESETTINGS_H
diff --git a/examples/multimediawidgets/camera/main.cpp b/examples/multimediawidgets/camera/main.cpp
deleted file mode 100644
index 04982a725..000000000
--- a/examples/multimediawidgets/camera/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "camera.h"
-
-#include <QtWidgets>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- Camera camera;
- camera.show();
-
- return app.exec();
-};
diff --git a/examples/multimediawidgets/camera/videosettings.cpp b/examples/multimediawidgets/camera/videosettings.cpp
deleted file mode 100644
index f9c79fa12..000000000
--- a/examples/multimediawidgets/camera/videosettings.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videosettings.h"
-#include "ui_videosettings.h"
-
-#include <QComboBox>
-#include <QDebug>
-#include <QMediaRecorder>
-#include <QMediaService>
-
-
-VideoSettings::VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::VideoSettingsUi),
- mediaRecorder(mediaRecorder)
-{
- ui->setupUi(this);
-
- //audio codecs
- ui->audioCodecBox->addItem(tr("Default audio codec"), QVariant(QString()));
- const QStringList supportedAudioCodecs = mediaRecorder->supportedAudioCodecs();
- for (const QString &codecName : supportedAudioCodecs) {
- QString description = mediaRecorder->audioCodecDescription(codecName);
- ui->audioCodecBox->addItem(codecName + ": " + description, QVariant(codecName));
- }
-
- //sample rate:
- const QList<int>supportedAudioSampleRates = mediaRecorder->supportedAudioSampleRates();
- for (int sampleRate : supportedAudioSampleRates)
- ui->audioSampleRateBox->addItem(QString::number(sampleRate), QVariant(sampleRate));
-
- ui->audioQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
-
- //video codecs
- ui->videoCodecBox->addItem(tr("Default video codec"), QVariant(QString()));
- const QStringList supportedVideoCodecs = mediaRecorder->supportedVideoCodecs();
- for (const QString &codecName : supportedVideoCodecs) {
- QString description = mediaRecorder->videoCodecDescription(codecName);
- ui->videoCodecBox->addItem(codecName + ": " + description, QVariant(codecName));
- }
-
- ui->videoQualitySlider->setRange(0, int(QMultimedia::VeryHighQuality));
-
-
- ui->videoResolutionBox->addItem(tr("Default"));
- const QList<QSize> supportedResolutions = mediaRecorder->supportedResolutions();
- for (const QSize &resolution : supportedResolutions) {
- ui->videoResolutionBox->addItem(QString("%1x%2").arg(resolution.width()).arg(resolution.height()),
- QVariant(resolution));
- }
-
- ui->videoFramerateBox->addItem(tr("Default"));
- const QList<qreal> supportedFrameRates = mediaRecorder->supportedFrameRates();
- for (qreal rate : supportedFrameRates) {
- QString rateString = QString("%1").arg(rate, 0, 'f', 2);
- ui->videoFramerateBox->addItem(rateString, QVariant(rate));
- }
-
- //containers
- ui->containerFormatBox->addItem(tr("Default container"), QVariant(QString()));
- const QStringList formats = mediaRecorder->supportedContainers();
- for (const QString &format : formats) {
- ui->containerFormatBox->addItem(format + ": " + mediaRecorder->containerDescription(format),
- QVariant(format));
- }
-}
-
-VideoSettings::~VideoSettings()
-{
- delete ui;
-}
-
-void VideoSettings::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-QAudioEncoderSettings VideoSettings::audioSettings() const
-{
- QAudioEncoderSettings settings = mediaRecorder->audioSettings();
- settings.setCodec(boxValue(ui->audioCodecBox).toString());
- settings.setQuality(QMultimedia::EncodingQuality(ui->audioQualitySlider->value()));
- settings.setSampleRate(boxValue(ui->audioSampleRateBox).toInt());
- return settings;
-}
-
-void VideoSettings::setAudioSettings(const QAudioEncoderSettings &audioSettings)
-{
- selectComboBoxItem(ui->audioCodecBox, QVariant(audioSettings.codec()));
- selectComboBoxItem(ui->audioSampleRateBox, QVariant(audioSettings.sampleRate()));
- ui->audioQualitySlider->setValue(audioSettings.quality());
-}
-
-QVideoEncoderSettings VideoSettings::videoSettings() const
-{
- QVideoEncoderSettings settings = mediaRecorder->videoSettings();
- settings.setCodec(boxValue(ui->videoCodecBox).toString());
- settings.setQuality(QMultimedia::EncodingQuality(ui->videoQualitySlider->value()));
- settings.setResolution(boxValue(ui->videoResolutionBox).toSize());
- settings.setFrameRate(boxValue(ui->videoFramerateBox).value<qreal>());
-
- return settings;
-}
-
-void VideoSettings::setVideoSettings(const QVideoEncoderSettings &videoSettings)
-{
- selectComboBoxItem(ui->videoCodecBox, QVariant(videoSettings.codec()));
- selectComboBoxItem(ui->videoResolutionBox, QVariant(videoSettings.resolution()));
- ui->videoQualitySlider->setValue(videoSettings.quality());
-
- //special case for frame rate
- for (int i = 0; i < ui->videoFramerateBox->count(); ++i) {
- qreal itemRate = ui->videoFramerateBox->itemData(i).value<qreal>();
- if (qFuzzyCompare(itemRate, videoSettings.frameRate())) {
- ui->videoFramerateBox->setCurrentIndex(i);
- break;
- }
- }
-}
-
-QString VideoSettings::format() const
-{
- return boxValue(ui->containerFormatBox).toString();
-}
-
-void VideoSettings::setFormat(const QString &format)
-{
- selectComboBoxItem(ui->containerFormatBox, QVariant(format));
-}
-
-QVariant VideoSettings::boxValue(const QComboBox *box) const
-{
- int idx = box->currentIndex();
- if (idx == -1)
- return QVariant();
-
- return box->itemData(idx);
-}
-
-void VideoSettings::selectComboBoxItem(QComboBox *box, const QVariant &value)
-{
- for (int i = 0; i < box->count(); ++i) {
- if (box->itemData(i) == value) {
- box->setCurrentIndex(i);
- break;
- }
- }
-}
diff --git a/examples/multimediawidgets/camera/videosettings.h b/examples/multimediawidgets/camera/videosettings.h
deleted file mode 100644
index a192942a9..000000000
--- a/examples/multimediawidgets/camera/videosettings.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOSETTINGS_H
-#define VIDEOSETTINGS_H
-
-#include <QDialog>
-#include <QAudioEncoderSettings>
-#include <QVideoEncoderSettings>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QMediaRecorder;
-namespace Ui { class VideoSettingsUi; }
-QT_END_NAMESPACE
-
-class VideoSettings : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit VideoSettings(QMediaRecorder *mediaRecorder, QWidget *parent = nullptr);
- ~VideoSettings();
-
- QAudioEncoderSettings audioSettings() const;
- void setAudioSettings(const QAudioEncoderSettings&);
-
- QVideoEncoderSettings videoSettings() const;
- void setVideoSettings(const QVideoEncoderSettings&);
-
- QString format() const;
- void setFormat(const QString &format);
-
-protected:
- void changeEvent(QEvent *e) override;
-
-private:
- QVariant boxValue(const QComboBox*) const;
- void selectComboBoxItem(QComboBox *box, const QVariant &value);
-
- Ui::VideoSettingsUi *ui;
- QMediaRecorder *mediaRecorder;
-};
-
-#endif // VIDEOSETTINGS_H
diff --git a/examples/multimediawidgets/camera/videosettings.ui b/examples/multimediawidgets/camera/videosettings.ui
deleted file mode 100644
index 940b7db7a..000000000
--- a/examples/multimediawidgets/camera/videosettings.ui
+++ /dev/null
@@ -1,211 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>VideoSettingsUi</class>
- <widget class="QDialog" name="VideoSettingsUi">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>561</width>
- <height>369</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Video Settings</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QScrollArea" name="scrollArea">
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>543</width>
- <height>250</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Audio</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Audio Codec:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QComboBox" name="audioCodecBox"/>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Sample Rate:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QComboBox" name="audioSampleRateBox"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Quality:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QSlider" name="audioQualitySlider">
- <property name="maximum">
- <number>4</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="1" rowspan="3">
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Video</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>Resolution:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <widget class="QComboBox" name="videoResolutionBox"/>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLabel" name="label_9">
- <property name="text">
- <string>Framerate:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QComboBox" name="videoFramerateBox"/>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Video Codec:</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0" colspan="2">
- <widget class="QComboBox" name="videoCodecBox"/>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>Quality:</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QSlider" name="videoQualitySlider">
- <property name="maximum">
- <number>4</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Container Format:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QComboBox" name="containerFormatBox"/>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item row="1" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>14</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>VideoSettingsUi</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>322</x>
- <y>272</y>
- </hint>
- <hint type="destinationlabel">
- <x>44</x>
- <y>230</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>VideoSettingsUi</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>405</x>
- <y>262</y>
- </hint>
- <hint type="destinationlabel">
- <x>364</x>
- <y>227</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro b/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro
deleted file mode 100644
index 2fb123e77..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-TARGET = customvideoitem
-
-QT += multimedia multimediawidgets widgets
-
-qtHaveModule(opengl): QT += opengl
-
-HEADERS += videoplayer.h \
- videoitem.h
-
-SOURCES += main.cpp \
- videoplayer.cpp \
- videoitem.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideoitem
-INSTALLS += target
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp
deleted file mode 100644
index 8db790deb..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- VideoPlayer player;
- player.show();
-
- return app.exec();
-}
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp
deleted file mode 100644
index c51673344..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoitem.h"
-
-#include <QPainter>
-#include <QTransform>
-#include <QVideoSurfaceFormat>
-
-VideoItem::VideoItem(QGraphicsItem *parent)
- : QGraphicsItem(parent)
- , imageFormat(QImage::Format_Invalid)
- , framePainted(false)
-{
-}
-
-VideoItem::~VideoItem()
-{
-}
-
-QRectF VideoItem::boundingRect() const
-{
- return QRectF(QPointF(0,0), surfaceFormat().sizeHint());
-}
-
-void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) {
- const QTransform oldTransform = painter->transform();
-
- if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) {
- painter->scale(1, -1);
- painter->translate(0, -boundingRect().height());
- }
-
- painter->drawImage(boundingRect(), QImage(
- currentFrame.bits(),
- imageSize.width(),
- imageSize.height(),
- imageFormat));
-
- painter->setTransform(oldTransform);
-
- framePainted = true;
-
- currentFrame.unmap();
- }
-}
-
-QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType) const
-{
- if (handleType == QAbstractVideoBuffer::NoHandle) {
- return QList<QVideoFrame::PixelFormat>()
- << QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::Format_ARGB32_Premultiplied
- << QVideoFrame::Format_RGB565
- << QVideoFrame::Format_RGB555;
- } else {
- return QList<QVideoFrame::PixelFormat>();
- }
-}
-
-bool VideoItem::start(const QVideoSurfaceFormat &format)
-{
- if (isFormatSupported(format)) {
- imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- imageSize = format.frameSize();
- framePainted = true;
-
- QAbstractVideoSurface::start(format);
-
- prepareGeometryChange();
-
- return true;
- } else {
- return false;
- }
-}
-
-void VideoItem::stop()
-{
- currentFrame = QVideoFrame();
- framePainted = false;
-
- QAbstractVideoSurface::stop();
-}
-
-bool VideoItem::present(const QVideoFrame &frame)
-{
- if (!framePainted) {
- if (!QAbstractVideoSurface::isActive())
- setError(StoppedError);
-
- return false;
- } else {
- currentFrame = frame;
- framePainted = false;
-
- update();
-
- return true;
- }
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h
deleted file mode 100644
index 2dc121d92..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOITEM_H
-#define VIDEOITEM_H
-
-#include <QAbstractVideoSurface>
-#include <QGraphicsItem>
-
-class VideoItem
- : public QAbstractVideoSurface,
- public QGraphicsItem
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsItem)
-
-public:
- explicit VideoItem(QGraphicsItem *parentItem = 0);
- ~VideoItem();
-
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
-
- //video surface
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override;
-
- bool start(const QVideoSurfaceFormat &format) override;
- void stop() override;
- bool present(const QVideoFrame &frame) override;
-
-private:
- QImage::Format imageFormat;
- QSize imageSize;
-
- QVideoFrame currentFrame;
- bool framePainted;
-};
-
-#endif // VIDEOITEM_H
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
deleted file mode 100644
index 2a9900c2b..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-#include "videoitem.h"
-
-#include <QtWidgets>
-#include <QVideoSurfaceFormat>
-
-#if !defined(QT_NO_OPENGL)
-# include <QOpenGLWidget>
-#endif
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
- , mediaPlayer(0, QMediaPlayer::VideoSurface)
- , videoItem(0)
- , playButton(0)
- , positionSlider(0)
-{
- videoItem = new VideoItem;
-
- QGraphicsScene *scene = new QGraphicsScene(this);
- QGraphicsView *graphicsView = new QGraphicsView(scene);
-
-#if !defined(QT_NO_OPENGL)
- graphicsView->setViewport(new QOpenGLWidget);
-#endif
-
- scene->addItem(videoItem);
-
- QSlider *rotateSlider = new QSlider(Qt::Horizontal);
- rotateSlider->setRange(-180, 180);
- rotateSlider->setValue(0);
-
- connect(rotateSlider, &QSlider::valueChanged,
- this, &VideoPlayer::rotateVideo);
-
- QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, &QAbstractButton::clicked,
- this, &VideoPlayer::openFile);
-
- playButton = new QPushButton;
- playButton->setEnabled(false);
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(playButton, &QAbstractButton::clicked,
- this, &VideoPlayer::play);
-
- positionSlider = new QSlider(Qt::Horizontal);
- positionSlider->setRange(0, 0);
-
- connect(positionSlider, &QSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addWidget(playButton);
- controlLayout->addWidget(positionSlider);
-
- QBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(graphicsView);
- layout->addWidget(rotateSlider);
- layout->addLayout(controlLayout);
-
- setLayout(layout);
-
- mediaPlayer.setVideoOutput(videoItem);
- connect(&mediaPlayer, &QMediaPlayer::stateChanged,
- this, &VideoPlayer::mediaStateChanged);
- connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
- connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
-}
-
-VideoPlayer::~VideoPlayer()
-{
-}
-
-
-void VideoPlayer::openFile()
-{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath());
-
- if (!fileName.isEmpty()) {
- mediaPlayer.setMedia(QUrl::fromLocalFile(fileName));
-
- playButton->setEnabled(true);
- }
-}
-
-void VideoPlayer::play()
-{
- switch(mediaPlayer.state()) {
- case QMediaPlayer::PlayingState:
- mediaPlayer.pause();
- break;
- default:
- mediaPlayer.play();
- break;
- }
-}
-
-void VideoPlayer::mediaStateChanged(QMediaPlayer::State state)
-{
- switch(state) {
- case QMediaPlayer::PlayingState:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- default:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
-}
-
-void VideoPlayer::positionChanged(qint64 position)
-{
- positionSlider->setValue(position);
-}
-
-void VideoPlayer::durationChanged(qint64 duration)
-{
- positionSlider->setRange(0, duration);
-}
-
-void VideoPlayer::setPosition(int position)
-{
- mediaPlayer.setPosition(position);
-}
-
-
-void VideoPlayer::rotateVideo(int angle)
-{
- //rotate around the center of video element
- qreal x = videoItem->boundingRect().width() / 2.0;
- qreal y = videoItem->boundingRect().height() / 2.0;
- videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y));
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h
deleted file mode 100644
index 0ee7d751e..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QMovie>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-QT_END_NAMESPACE
-
-class VideoItem;
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoPlayer(QWidget *parent = 0);
- ~VideoPlayer();
-
- QSize sizeHint() const override { return QSize(800, 600); }
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::State state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
- void rotateVideo(int angle);
-
-private:
- QMediaPlayer mediaPlayer;
- VideoItem *videoItem;
- QAbstractButton *playButton;
- QSlider *positionSlider;
-};
-
-#endif // VIDEOPLAYER_H
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideosurface.pro b/examples/multimediawidgets/customvideosurface/customvideosurface.pro
deleted file mode 100644
index baffdaba7..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideosurface.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += customvideoitem customvideowidget
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro b/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro
deleted file mode 100644
index b4476dfb7..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = app
-TARGET = customvideowidget
-
-QT += multimedia multimediawidgets widgets
-
-HEADERS = \
- videoplayer.h \
- videowidget.h \
- videowidgetsurface.h
-
-SOURCES = \
- main.cpp \
- videoplayer.cpp \
- videowidget.cpp \
- videowidgetsurface.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideowidget
-INSTALLS += target
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp
deleted file mode 100644
index 0d5e30849..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include <QtWidgets/QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- VideoPlayer player;
- player.show();
-
- return app.exec();
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
deleted file mode 100644
index 5c1ca4221..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include "videowidget.h"
-
-#include <QtWidgets>
-#include <qvideosurfaceformat.h>
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
- , mediaPlayer(0, QMediaPlayer::VideoSurface)
- , playButton(0)
- , positionSlider(0)
-{
- VideoWidget *videoWidget = new VideoWidget;
-
- QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, &QAbstractButton::clicked,
- this, &VideoPlayer::openFile);
-
- playButton = new QPushButton;
- playButton->setEnabled(false);
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(playButton, &QAbstractButton::clicked,
- this, &VideoPlayer::play);
-
- positionSlider = new QSlider(Qt::Horizontal);
- positionSlider->setRange(0, 0);
-
- connect(positionSlider, &QSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addWidget(playButton);
- controlLayout->addWidget(positionSlider);
-
- QBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(videoWidget);
- layout->addLayout(controlLayout);
-
- setLayout(layout);
-
- mediaPlayer.setVideoOutput(videoWidget->videoSurface());
- connect(&mediaPlayer, &QMediaPlayer::stateChanged,
- this, &VideoPlayer::mediaStateChanged);
- connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
- connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
-}
-
-VideoPlayer::~VideoPlayer()
-{
-}
-
-void VideoPlayer::openFile()
-{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath());
-
- if (!fileName.isEmpty()) {
- mediaPlayer.setMedia(QUrl::fromLocalFile(fileName));
-
- playButton->setEnabled(true);
- }
-}
-
-void VideoPlayer::play()
-{
- switch(mediaPlayer.state()) {
- case QMediaPlayer::PlayingState:
- mediaPlayer.pause();
- break;
- default:
- mediaPlayer.play();
- break;
- }
-}
-
-void VideoPlayer::mediaStateChanged(QMediaPlayer::State state)
-{
- switch(state) {
- case QMediaPlayer::PlayingState:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- default:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
-}
-
-void VideoPlayer::positionChanged(qint64 position)
-{
- positionSlider->setValue(position);
-}
-
-void VideoPlayer::durationChanged(qint64 duration)
-{
- positionSlider->setRange(0, duration);
-}
-
-void VideoPlayer::setPosition(int position)
-{
- mediaPlayer.setPosition(position);
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h
deleted file mode 100644
index ea9b6cf6b..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QMovie>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-QT_END_NAMESPACE
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoPlayer(QWidget *parent = 0);
- ~VideoPlayer();
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::State state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
-
-private:
- QMediaPlayer mediaPlayer;
- QAbstractButton *playButton;
- QSlider *positionSlider;
-};
-
-#endif // VIDEOPLAYER_H
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp
deleted file mode 100644
index 12ac34a35..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videowidget.h"
-
-#include "videowidgetsurface.h"
-
-#include <QtWidgets>
-#include <qvideosurfaceformat.h>
-
-//! [0]
-VideoWidget::VideoWidget(QWidget *parent)
- : QWidget(parent)
- , surface(0)
-{
- setAutoFillBackground(false);
- setAttribute(Qt::WA_NoSystemBackground, true);
-
- QPalette palette = this->palette();
- palette.setColor(QPalette::Window, Qt::black);
- setPalette(palette);
-
- setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-
- surface = new VideoWidgetSurface(this);
-}
-//! [0]
-
-//! [1]
-VideoWidget::~VideoWidget()
-{
- delete surface;
-}
-//! [1]
-
-//! [2]
-QSize VideoWidget::sizeHint() const
-{
- return surface->surfaceFormat().sizeHint();
-}
-//! [2]
-
-
-//! [3]
-void VideoWidget::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
-
- if (surface->isActive()) {
- const QRect videoRect = surface->videoRect();
-
- if (!videoRect.contains(event->rect())) {
- QRegion region = event->region();
- region = region.subtracted(videoRect);
-
- QBrush brush = palette().window();
-
- for (const QRect &rect : region)
- painter.fillRect(rect, brush);
- }
-
- surface->paint(&painter);
- } else {
- painter.fillRect(event->rect(), palette().window());
- }
-}
-//! [3]
-
-//! [4]
-void VideoWidget::resizeEvent(QResizeEvent *event)
-{
- QWidget::resizeEvent(event);
-
- surface->updateVideoRect();
-}
-//! [4]
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h
deleted file mode 100644
index 1b90c3642..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOWIDGET_H
-#define VIDEOWIDGET_H
-
-#include "videowidgetsurface.h"
-
-#include <QWidget>
-
-//! [0]
-class VideoWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoWidget(QWidget *parent = 0);
- ~VideoWidget();
-
- QAbstractVideoSurface *videoSurface() const { return surface; }
-
- QSize sizeHint() const override;
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
-
-private:
- VideoWidgetSurface *surface;
-};
-//! [0]
-
-#endif // VIDEOWIDGET_H
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp
deleted file mode 100644
index 9937f1824..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videowidgetsurface.h"
-
-#include <QtWidgets>
-#include <qabstractvideosurface.h>
-#include <qvideosurfaceformat.h>
-
-VideoWidgetSurface::VideoWidgetSurface(QWidget *widget, QObject *parent)
- : QAbstractVideoSurface(parent)
- , widget(widget)
- , imageFormat(QImage::Format_Invalid)
-{
-}
-
-//! [0]
-QList<QVideoFrame::PixelFormat> VideoWidgetSurface::supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType) const
-{
- if (handleType == QAbstractVideoBuffer::NoHandle) {
- return QList<QVideoFrame::PixelFormat>()
- << QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::Format_ARGB32_Premultiplied
- << QVideoFrame::Format_RGB565
- << QVideoFrame::Format_RGB555;
- } else {
- return QList<QVideoFrame::PixelFormat>();
- }
-}
-//! [0]
-
-//! [1]
-bool VideoWidgetSurface::isFormatSupported(const QVideoSurfaceFormat &format) const
-{
- const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- const QSize size = format.frameSize();
-
- return imageFormat != QImage::Format_Invalid
- && !size.isEmpty()
- && format.handleType() == QAbstractVideoBuffer::NoHandle;
-}
-//! [1]
-
-//! [2]
-bool VideoWidgetSurface::start(const QVideoSurfaceFormat &format)
-{
- const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- const QSize size = format.frameSize();
-
- if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) {
- this->imageFormat = imageFormat;
- imageSize = size;
- sourceRect = format.viewport();
-
- QAbstractVideoSurface::start(format);
-
- widget->updateGeometry();
- updateVideoRect();
-
- return true;
- } else {
- return false;
- }
-}
-//! [2]
-
-//! [3]
-void VideoWidgetSurface::stop()
-{
- currentFrame = QVideoFrame();
- targetRect = QRect();
-
- QAbstractVideoSurface::stop();
-
- widget->update();
-}
-//! [3]
-
-//! [4]
-bool VideoWidgetSurface::present(const QVideoFrame &frame)
-{
- if (surfaceFormat().pixelFormat() != frame.pixelFormat()
- || surfaceFormat().frameSize() != frame.size()) {
- setError(IncorrectFormatError);
- stop();
-
- return false;
- } else {
- currentFrame = frame;
-
- widget->repaint(targetRect);
-
- return true;
- }
-}
-//! [4]
-
-//! [5]
-void VideoWidgetSurface::updateVideoRect()
-{
- QSize size = surfaceFormat().sizeHint();
- size.scale(widget->size().boundedTo(size), Qt::KeepAspectRatio);
-
- targetRect = QRect(QPoint(0, 0), size);
- targetRect.moveCenter(widget->rect().center());
-}
-//! [5]
-
-//! [6]
-void VideoWidgetSurface::paint(QPainter *painter)
-{
- if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) {
- const QTransform oldTransform = painter->transform();
-
- if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) {
- painter->scale(1, -1);
- painter->translate(0, -widget->height());
- }
-
- QImage image(
- currentFrame.bits(),
- currentFrame.width(),
- currentFrame.height(),
- currentFrame.bytesPerLine(),
- imageFormat);
-
- painter->drawImage(targetRect, image, sourceRect);
-
- painter->setTransform(oldTransform);
-
- currentFrame.unmap();
- }
-}
-//! [6]
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h
deleted file mode 100644
index d9765d836..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOWIDGETSURFACE_H
-#define VIDEOWIDGETSURFACE_H
-
-#include <QAbstractVideoSurface>
-#include <QImage>
-#include <QRect>
-#include <QVideoFrame>
-
-//! [0]
-class VideoWidgetSurface : public QAbstractVideoSurface
-{
- Q_OBJECT
-
-public:
- VideoWidgetSurface(QWidget *widget, QObject *parent = 0);
-
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override;
- bool isFormatSupported(const QVideoSurfaceFormat &format) const override;
-
- bool start(const QVideoSurfaceFormat &format) override;
- void stop() override;
-
- bool present(const QVideoFrame &frame) override;
-
- QRect videoRect() const { return targetRect; }
- void updateVideoRect();
-
- void paint(QPainter *painter);
-
-private:
- QWidget *widget;
- QImage::Format imageFormat;
- QRect targetRect;
- QSize imageSize;
- QRect sourceRect;
- QVideoFrame currentFrame;
-};
-//! [0]
-
-#endif
diff --git a/examples/multimediawidgets/multimediawidgets.pro b/examples/multimediawidgets/multimediawidgets.pro
deleted file mode 100644
index 001a78d50..000000000
--- a/examples/multimediawidgets/multimediawidgets.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-
-# These examples all need widgets for now (using creator templates that use widgets)
-qtHaveModule(widgets) {
- SUBDIRS += \
- camera \
- videographicsitem \
- videowidget \
- player \
- customvideosurface
-}
diff --git a/examples/multimediawidgets/player/doc/src/player.qdoc b/examples/multimediawidgets/player/doc/src/player.qdoc
deleted file mode 100644
index 901b57fd1..000000000
--- a/examples/multimediawidgets/player/doc/src/player.qdoc
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example multimediawidgets/player
- \title Media Player Example
- \ingroup multimedia_examples
- \brief Playing audio and video.
-
- \image mediaplayerex.jpg
-
- \e{Media Player} demonstrates a simple multimedia player that can play
- audio and or video files using various codecs.
-
- \include examples-run.qdocinc
-
- 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,
- the button clicked events emit the play() and stop() signals, which
- are connected to the play() and stop() slots of 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
-
-*/
diff --git a/examples/multimediawidgets/player/histogramwidget.cpp b/examples/multimediawidgets/player/histogramwidget.cpp
deleted file mode 100644
index bb214cad5..000000000
--- a/examples/multimediawidgets/player/histogramwidget.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "histogramwidget.h"
-#include <QPainter>
-#include <QHBoxLayout>
-
-template<class T>
-static QList<qreal> getBufferLevels(const T *buffer, int frames, int channels);
-
-class QAudioLevel : public QWidget
-{
- Q_OBJECT
-public:
- explicit QAudioLevel(QWidget *parent = nullptr);
-
- // Using [0; 1.0] range
- void setLevel(qreal level);
-
-protected:
- void paintEvent(QPaintEvent *event);
-
-private:
- qreal m_level = 0;
-};
-
-QAudioLevel::QAudioLevel(QWidget *parent)
- : QWidget(parent)
-{
- setMinimumHeight(15);
- setMaximumHeight(50);
-}
-
-void QAudioLevel::setLevel(qreal level)
-{
- if (m_level != level) {
- m_level = level;
- update();
- }
-}
-
-void QAudioLevel::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
-
- QPainter painter(this);
- // draw level
- qreal widthLevel = m_level * width();
- painter.fillRect(0, 0, widthLevel, height(), Qt::red);
- // clear the rest of the control
- painter.fillRect(widthLevel, 0, width(), height(), Qt::black);
-}
-
-HistogramWidget::HistogramWidget(QWidget *parent)
- : QWidget(parent)
-{
- m_processor.moveToThread(&m_processorThread);
- qRegisterMetaType<QList<qreal>>("QList<qreal>");
- connect(&m_processor, &FrameProcessor::histogramReady, this, &HistogramWidget::setHistogram);
- m_processorThread.start(QThread::LowestPriority);
- setLayout(new QHBoxLayout);
-}
-
-HistogramWidget::~HistogramWidget()
-{
- m_processorThread.quit();
- m_processorThread.wait(10000);
-}
-
-void HistogramWidget::processFrame(const QVideoFrame &frame)
-{
- if (m_isBusy && frame.isValid())
- return; //drop frame
-
- m_isBusy = true;
- QMetaObject::invokeMethod(&m_processor, "processFrame",
- Qt::QueuedConnection, Q_ARG(QVideoFrame, frame), Q_ARG(int, m_levels));
-}
-
-// This function returns the maximum possible sample value for a given audio format
-qreal getPeakValue(const QAudioFormat& format)
-{
- // Note: Only the most common sample formats are supported
- if (!format.isValid())
- return qreal(0);
-
- if (format.codec() != "audio/pcm")
- return qreal(0);
-
- switch (format.sampleType()) {
- case QAudioFormat::Unknown:
- break;
- case QAudioFormat::Float:
- if (format.sampleSize() != 32) // other sample formats are not supported
- return qreal(0);
- return qreal(1.00003);
- case QAudioFormat::SignedInt:
- if (format.sampleSize() == 32)
- return qreal(INT_MAX);
- if (format.sampleSize() == 16)
- return qreal(SHRT_MAX);
- if (format.sampleSize() == 8)
- return qreal(CHAR_MAX);
- break;
- case QAudioFormat::UnSignedInt:
- if (format.sampleSize() == 32)
- return qreal(UINT_MAX);
- if (format.sampleSize() == 16)
- return qreal(USHRT_MAX);
- if (format.sampleSize() == 8)
- return qreal(UCHAR_MAX);
- break;
- }
-
- return qreal(0);
-}
-
-// returns the audio level for each channel
-QList<qreal> getBufferLevels(const QAudioBuffer &buffer)
-{
- QList<qreal> values;
-
- if (!buffer.isValid())
- return values;
-
- if (!buffer.format().isValid() || buffer.format().byteOrder() != QAudioFormat::LittleEndian)
- return values;
-
- if (buffer.format().codec() != "audio/pcm")
- return values;
-
- int channelCount = buffer.format().channelCount();
- values.fill(0, channelCount);
- qreal peak_value = getPeakValue(buffer.format());
- if (qFuzzyCompare(peak_value, qreal(0)))
- return values;
-
- switch (buffer.format().sampleType()) {
- case QAudioFormat::Unknown:
- case QAudioFormat::UnSignedInt:
- if (buffer.format().sampleSize() == 32)
- values = getBufferLevels(buffer.constData<quint32>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 16)
- values = getBufferLevels(buffer.constData<quint16>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 8)
- values = getBufferLevels(buffer.constData<quint8>(), buffer.frameCount(), channelCount);
- for (int i = 0; i < values.size(); ++i)
- values[i] = qAbs(values.at(i) - peak_value / 2) / (peak_value / 2);
- break;
- case QAudioFormat::Float:
- if (buffer.format().sampleSize() == 32) {
- values = getBufferLevels(buffer.constData<float>(), buffer.frameCount(), channelCount);
- for (int i = 0; i < values.size(); ++i)
- values[i] /= peak_value;
- }
- break;
- case QAudioFormat::SignedInt:
- if (buffer.format().sampleSize() == 32)
- values = getBufferLevels(buffer.constData<qint32>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 16)
- values = getBufferLevels(buffer.constData<qint16>(), buffer.frameCount(), channelCount);
- if (buffer.format().sampleSize() == 8)
- values = getBufferLevels(buffer.constData<qint8>(), buffer.frameCount(), channelCount);
- for (int i = 0; i < values.size(); ++i)
- values[i] /= peak_value;
- break;
- }
-
- return values;
-}
-
-template<class T>
-QList<qreal> getBufferLevels(const T *buffer, int frames, int channels)
-{
- QList<qreal> max_values;
- max_values.fill(0, channels);
-
- for (int i = 0; i < frames; ++i) {
- for (int j = 0; j < channels; ++j) {
- qreal value = qAbs(qreal(buffer[i * channels + j]));
- if (value > max_values.at(j))
- max_values.replace(j, value);
- }
- }
-
- return max_values;
-}
-
-void HistogramWidget::processBuffer(const QAudioBuffer &buffer)
-{
- if (m_audioLevels.count() != buffer.format().channelCount()) {
- qDeleteAll(m_audioLevels);
- m_audioLevels.clear();
- for (int i = 0; i < buffer.format().channelCount(); ++i) {
- QAudioLevel *level = new QAudioLevel(this);
- m_audioLevels.append(level);
- layout()->addWidget(level);
- }
- }
-
- QList<qreal> levels = getBufferLevels(buffer);
- for (int i = 0; i < levels.count(); ++i)
- m_audioLevels.at(i)->setLevel(levels.at(i));
-}
-
-void HistogramWidget::setHistogram(const QList<qreal> &histogram)
-{
- m_isBusy = false;
- m_histogram = histogram;
- update();
-}
-
-void HistogramWidget::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
-
- if (!m_audioLevels.isEmpty())
- return;
-
- QPainter painter(this);
-
- if (m_histogram.isEmpty()) {
- painter.fillRect(0, 0, width(), height(), QColor::fromRgb(0, 0, 0));
- return;
- }
-
- qreal barWidth = width() / (qreal)m_histogram.size();
-
- for (int i = 0; i < m_histogram.size(); ++i) {
- qreal h = m_histogram[i] * height();
- // draw level
- painter.fillRect(barWidth * i, height() - h, barWidth * (i + 1), height(), Qt::red);
- // clear the rest of the control
- painter.fillRect(barWidth * i, 0, barWidth * (i + 1), height() - h, Qt::black);
- }
-}
-
-void FrameProcessor::processFrame(QVideoFrame frame, int levels)
-{
- QList<qreal> histogram(levels);
-
- do {
- if (!levels)
- break;
-
- if (!frame.map(QAbstractVideoBuffer::ReadOnly))
- break;
-
- if (frame.pixelFormat() == QVideoFrame::Format_YUV420P ||
- frame.pixelFormat() == QVideoFrame::Format_NV12) {
- // Process YUV data
- uchar *b = frame.bits();
- for (int y = 0; y < frame.height(); ++y) {
- uchar *lastPixel = b + frame.width();
- for (uchar *curPixel = b; curPixel < lastPixel; curPixel++)
- histogram[(*curPixel * levels) >> 8] += 1.0;
- b += frame.bytesPerLine();
- }
- } else {
- QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat());
- if (imageFormat != QImage::Format_Invalid) {
- // Process RGB data
- QImage image(frame.bits(), frame.width(), frame.height(), imageFormat);
- image = image.convertToFormat(QImage::Format_RGB32);
-
- const QRgb* b = (const QRgb*)image.bits();
- for (int y = 0; y < image.height(); ++y) {
- const QRgb *lastPixel = b + frame.width();
- for (const QRgb *curPixel = b; curPixel < lastPixel; curPixel++)
- histogram[(qGray(*curPixel) * levels) >> 8] += 1.0;
- b = (const QRgb*)((uchar*)b + image.bytesPerLine());
- }
- }
- }
-
- // find maximum value
- qreal maxValue = 0.0;
- for (int i = 0; i < histogram.size(); i++) {
- if (histogram[i] > maxValue)
- maxValue = histogram[i];
- }
-
- if (maxValue > 0.0) {
- for (int i = 0; i < histogram.size(); i++)
- histogram[i] /= maxValue;
- }
-
- frame.unmap();
- } while (false);
-
- emit histogramReady(histogram);
-}
-
-#include "histogramwidget.moc"
diff --git a/examples/multimediawidgets/player/histogramwidget.h b/examples/multimediawidgets/player/histogramwidget.h
deleted file mode 100644
index 08ba4f342..000000000
--- a/examples/multimediawidgets/player/histogramwidget.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef HISTOGRAMWIDGET_H
-#define HISTOGRAMWIDGET_H
-
-#include <QThread>
-#include <QVideoFrame>
-#include <QAudioBuffer>
-#include <QWidget>
-
-class QAudioLevel;
-
-class FrameProcessor: public QObject
-{
- Q_OBJECT
-
-public slots:
- void processFrame(QVideoFrame frame, int levels);
-
-signals:
- void histogramReady(const QList<qreal> &histogram);
-};
-
-class HistogramWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit HistogramWidget(QWidget *parent = nullptr);
- ~HistogramWidget();
- void setLevels(int levels) { m_levels = levels; }
-
-public slots:
- void processFrame(const QVideoFrame &frame);
- void processBuffer(const QAudioBuffer &buffer);
- void setHistogram(const QList<qreal> &histogram);
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-private:
- QList<qreal> m_histogram;
- int m_levels = 128;
- FrameProcessor m_processor;
- QThread m_processorThread;
- bool m_isBusy = false;
- QList<QAudioLevel *> m_audioLevels;
-};
-
-#endif // HISTOGRAMWIDGET_H
diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp
deleted file mode 100644
index a20fb1c4f..000000000
--- a/examples/multimediawidgets/player/main.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "player.h"
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QDir>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Player Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- QCommandLineOption customAudioRoleOption("custom-audio-role",
- "Set a custom audio role for the player.",
- "role");
- parser.setApplicationDescription("Qt MultiMedia Player Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addOption(customAudioRoleOption);
- parser.addPositionalArgument("url", "The URL(s) to open.");
- parser.process(app);
-
- Player player;
-
- if (parser.isSet(customAudioRoleOption))
- player.setCustomAudioRole(parser.value(customAudioRoleOption));
-
- if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
- QList<QUrl> urls;
- for (auto &a: parser.positionalArguments())
- urls.append(QUrl::fromUserInput(a, QDir::currentPath(), QUrl::AssumeLocalFile));
- player.addToPlaylist(urls);
- }
-
- player.show();
- return app.exec();
-}
diff --git a/examples/multimediawidgets/player/player.cpp b/examples/multimediawidgets/player/player.cpp
deleted file mode 100644
index 04da42587..000000000
--- a/examples/multimediawidgets/player/player.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "player.h"
-
-#include "playercontrols.h"
-#include "playlistmodel.h"
-#include "histogramwidget.h"
-#include "videowidget.h"
-
-#include <QMediaService>
-#include <QMediaPlaylist>
-#include <QVideoProbe>
-#include <QAudioProbe>
-#include <QMediaMetaData>
-#include <QtWidgets>
-
-Player::Player(QWidget *parent)
- : QWidget(parent)
-{
-//! [create-objs]
- m_player = new QMediaPlayer(this);
- m_player->setAudioRole(QAudio::VideoRole);
- qInfo() << "Supported audio roles:";
- for (QAudio::Role role : m_player->supportedAudioRoles())
- qInfo() << " " << role;
- // owned by PlaylistModel
- m_playlist = new QMediaPlaylist();
- m_player->setPlaylist(m_playlist);
-//! [create-objs]
-
- connect(m_player, &QMediaPlayer::durationChanged, this, &Player::durationChanged);
- connect(m_player, &QMediaPlayer::positionChanged, this, &Player::positionChanged);
- connect(m_player, QOverload<>::of(&QMediaPlayer::metaDataChanged), this, &Player::metaDataChanged);
- connect(m_playlist, &QMediaPlaylist::currentIndexChanged, this, &Player::playlistPositionChanged);
- connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &Player::statusChanged);
- connect(m_player, &QMediaPlayer::bufferStatusChanged, this, &Player::bufferingProgress);
- connect(m_player, &QMediaPlayer::videoAvailableChanged, this, &Player::videoAvailableChanged);
- connect(m_player, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), this, &Player::displayErrorMessage);
- connect(m_player, &QMediaPlayer::stateChanged, this, &Player::stateChanged);
-
-//! [2]
- m_videoWidget = new VideoWidget(this);
- m_player->setVideoOutput(m_videoWidget);
-
- m_playlistModel = new PlaylistModel(this);
- m_playlistModel->setPlaylist(m_playlist);
-//! [2]
-
- m_playlistView = new QListView(this);
- m_playlistView->setModel(m_playlistModel);
- m_playlistView->setCurrentIndex(m_playlistModel->index(m_playlist->currentIndex(), 0));
-
- connect(m_playlistView, &QAbstractItemView::activated, this, &Player::jump);
-
- m_slider = new QSlider(Qt::Horizontal, this);
- m_slider->setRange(0, m_player->duration() / 1000);
-
- m_labelDuration = new QLabel(this);
- connect(m_slider, &QSlider::sliderMoved, this, &Player::seek);
-
- m_labelHistogram = new QLabel(this);
- m_labelHistogram->setText("Histogram:");
- m_videoHistogram = new HistogramWidget(this);
- m_audioHistogram = new HistogramWidget(this);
- QHBoxLayout *histogramLayout = new QHBoxLayout;
- histogramLayout->addWidget(m_labelHistogram);
- histogramLayout->addWidget(m_videoHistogram, 1);
- histogramLayout->addWidget(m_audioHistogram, 2);
-
- m_videoProbe = new QVideoProbe(this);
- connect(m_videoProbe, &QVideoProbe::videoFrameProbed, m_videoHistogram, &HistogramWidget::processFrame);
- m_videoProbe->setSource(m_player);
-
- m_audioProbe = new QAudioProbe(this);
- connect(m_audioProbe, &QAudioProbe::audioBufferProbed, m_audioHistogram, &HistogramWidget::processBuffer);
- m_audioProbe->setSource(m_player);
-
- QPushButton *openButton = new QPushButton(tr("Open"), this);
-
- connect(openButton, &QPushButton::clicked, this, &Player::open);
-
- PlayerControls *controls = new PlayerControls(this);
- controls->setState(m_player->state());
- controls->setVolume(m_player->volume());
- controls->setMuted(controls->isMuted());
-
- connect(controls, &PlayerControls::play, m_player, &QMediaPlayer::play);
- connect(controls, &PlayerControls::pause, m_player, &QMediaPlayer::pause);
- connect(controls, &PlayerControls::stop, m_player, &QMediaPlayer::stop);
- connect(controls, &PlayerControls::next, m_playlist, &QMediaPlaylist::next);
- connect(controls, &PlayerControls::previous, this, &Player::previousClicked);
- connect(controls, &PlayerControls::changeVolume, m_player, &QMediaPlayer::setVolume);
- connect(controls, &PlayerControls::changeMuting, m_player, &QMediaPlayer::setMuted);
- connect(controls, &PlayerControls::changeRate, m_player, &QMediaPlayer::setPlaybackRate);
- connect(controls, &PlayerControls::stop, m_videoWidget, QOverload<>::of(&QVideoWidget::update));
-
- connect(m_player, &QMediaPlayer::stateChanged, controls, &PlayerControls::setState);
- connect(m_player, &QMediaPlayer::volumeChanged, controls, &PlayerControls::setVolume);
- connect(m_player, &QMediaPlayer::mutedChanged, controls, &PlayerControls::setMuted);
-
- m_fullScreenButton = new QPushButton(tr("FullScreen"), this);
- m_fullScreenButton->setCheckable(true);
-
- m_colorButton = new QPushButton(tr("Color Options..."), this);
- m_colorButton->setEnabled(false);
- connect(m_colorButton, &QPushButton::clicked, this, &Player::showColorDialog);
-
- QBoxLayout *displayLayout = new QHBoxLayout;
- displayLayout->addWidget(m_videoWidget, 2);
- displayLayout->addWidget(m_playlistView);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addStretch(1);
- controlLayout->addWidget(controls);
- controlLayout->addStretch(1);
- controlLayout->addWidget(m_fullScreenButton);
- controlLayout->addWidget(m_colorButton);
-
- QBoxLayout *layout = new QVBoxLayout;
- layout->addLayout(displayLayout);
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->addWidget(m_slider);
- hLayout->addWidget(m_labelDuration);
- layout->addLayout(hLayout);
- layout->addLayout(controlLayout);
- layout->addLayout(histogramLayout);
-#if defined(Q_OS_QNX)
- // On QNX, the main window doesn't have a title bar (or any other decorations).
- // Create a status bar for the status information instead.
- m_statusLabel = new QLabel;
- m_statusBar = new QStatusBar;
- m_statusBar->addPermanentWidget(m_statusLabel);
- m_statusBar->setSizeGripEnabled(false); // Without mouse grabbing, it doesn't work very well.
- layout->addWidget(m_statusBar);
-#endif
-
- setLayout(layout);
-
- if (!isPlayerAvailable()) {
- QMessageBox::warning(this, tr("Service not available"),
- tr("The QMediaPlayer object does not have a valid service.\n"\
- "Please check the media service plugins are installed."));
-
- controls->setEnabled(false);
- m_playlistView->setEnabled(false);
- openButton->setEnabled(false);
- m_colorButton->setEnabled(false);
- m_fullScreenButton->setEnabled(false);
- }
-
- metaDataChanged();
-}
-
-Player::~Player()
-{
-}
-
-bool Player::isPlayerAvailable() const
-{
- return m_player->isAvailable();
-}
-
-void Player::open()
-{
- QFileDialog fileDialog(this);
- fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
- fileDialog.setWindowTitle(tr("Open Files"));
- QStringList supportedMimeTypes = m_player->supportedMimeTypes();
- if (!supportedMimeTypes.isEmpty()) {
- supportedMimeTypes.append("audio/x-m3u"); // MP3 playlists
- fileDialog.setMimeTypeFilters(supportedMimeTypes);
- }
- fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
- if (fileDialog.exec() == QDialog::Accepted)
- addToPlaylist(fileDialog.selectedUrls());
-}
-
-static bool isPlaylist(const QUrl &url) // Check for ".m3u" playlists.
-{
- if (!url.isLocalFile())
- return false;
- const QFileInfo fileInfo(url.toLocalFile());
- return fileInfo.exists() && !fileInfo.suffix().compare(QLatin1String("m3u"), Qt::CaseInsensitive);
-}
-
-void Player::addToPlaylist(const QList<QUrl> &urls)
-{
- for (auto &url: urls) {
- if (isPlaylist(url))
- m_playlist->load(url);
- else
- m_playlist->addMedia(url);
- }
-}
-
-void Player::setCustomAudioRole(const QString &role)
-{
- m_player->setCustomAudioRole(role);
-}
-
-void Player::durationChanged(qint64 duration)
-{
- m_duration = duration / 1000;
- m_slider->setMaximum(m_duration);
-}
-
-void Player::positionChanged(qint64 progress)
-{
- if (!m_slider->isSliderDown())
- m_slider->setValue(progress / 1000);
-
- updateDurationInfo(progress / 1000);
-}
-
-void Player::metaDataChanged()
-{
- if (m_player->isMetaDataAvailable()) {
- setTrackInfo(QString("%1 - %2")
- .arg(m_player->metaData(QMediaMetaData::AlbumArtist).toString())
- .arg(m_player->metaData(QMediaMetaData::Title).toString()));
-
- if (m_coverLabel) {
- QUrl url = m_player->metaData(QMediaMetaData::CoverArtUrlLarge).value<QUrl>();
-
- m_coverLabel->setPixmap(!url.isEmpty()
- ? QPixmap(url.toString())
- : QPixmap());
- }
- }
-}
-
-void Player::previousClicked()
-{
- // Go to previous track if we are within the first 5 seconds of playback
- // Otherwise, seek to the beginning.
- if (m_player->position() <= 5000)
- m_playlist->previous();
- else
- m_player->setPosition(0);
-}
-
-void Player::jump(const QModelIndex &index)
-{
- if (index.isValid()) {
- m_playlist->setCurrentIndex(index.row());
- m_player->play();
- }
-}
-
-void Player::playlistPositionChanged(int currentItem)
-{
- clearHistogram();
- m_playlistView->setCurrentIndex(m_playlistModel->index(currentItem, 0));
-}
-
-void Player::seek(int seconds)
-{
- m_player->setPosition(seconds * 1000);
-}
-
-void Player::statusChanged(QMediaPlayer::MediaStatus status)
-{
- handleCursor(status);
-
- // handle status message
- switch (status) {
- case QMediaPlayer::UnknownMediaStatus:
- case QMediaPlayer::NoMedia:
- case QMediaPlayer::LoadedMedia:
- setStatusInfo(QString());
- break;
- case QMediaPlayer::LoadingMedia:
- setStatusInfo(tr("Loading..."));
- break;
- case QMediaPlayer::BufferingMedia:
- case QMediaPlayer::BufferedMedia:
- setStatusInfo(tr("Buffering %1%").arg(m_player->bufferStatus()));
- break;
- case QMediaPlayer::StalledMedia:
- setStatusInfo(tr("Stalled %1%").arg(m_player->bufferStatus()));
- break;
- case QMediaPlayer::EndOfMedia:
- QApplication::alert(this);
- break;
- case QMediaPlayer::InvalidMedia:
- displayErrorMessage();
- break;
- }
-}
-
-void Player::stateChanged(QMediaPlayer::State state)
-{
- if (state == QMediaPlayer::StoppedState)
- clearHistogram();
-}
-
-void Player::handleCursor(QMediaPlayer::MediaStatus status)
-{
-#ifndef QT_NO_CURSOR
- if (status == QMediaPlayer::LoadingMedia ||
- status == QMediaPlayer::BufferingMedia ||
- status == QMediaPlayer::StalledMedia)
- setCursor(QCursor(Qt::BusyCursor));
- else
- unsetCursor();
-#endif
-}
-
-void Player::bufferingProgress(int progress)
-{
- if (m_player->mediaStatus() == QMediaPlayer::StalledMedia)
- setStatusInfo(tr("Stalled %1%").arg(progress));
- else
- setStatusInfo(tr("Buffering %1%").arg(progress));
-}
-
-void Player::videoAvailableChanged(bool available)
-{
- if (!available) {
- disconnect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget, &QVideoWidget::setFullScreen);
- disconnect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton, &QPushButton::setChecked);
- m_videoWidget->setFullScreen(false);
- } else {
- connect(m_fullScreenButton, &QPushButton::clicked, m_videoWidget, &QVideoWidget::setFullScreen);
- connect(m_videoWidget, &QVideoWidget::fullScreenChanged, m_fullScreenButton, &QPushButton::setChecked);
-
- if (m_fullScreenButton->isChecked())
- m_videoWidget->setFullScreen(true);
- }
- m_colorButton->setEnabled(available);
-}
-
-void Player::setTrackInfo(const QString &info)
-{
- m_trackInfo = info;
-
- if (m_statusBar) {
- m_statusBar->showMessage(m_trackInfo);
- m_statusLabel->setText(m_statusInfo);
- } else {
- if (!m_statusInfo.isEmpty())
- setWindowTitle(QString("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
- else
- setWindowTitle(m_trackInfo);
- }
-}
-
-void Player::setStatusInfo(const QString &info)
-{
- m_statusInfo = info;
-
- if (m_statusBar) {
- m_statusBar->showMessage(m_trackInfo);
- m_statusLabel->setText(m_statusInfo);
- } else {
- if (!m_statusInfo.isEmpty())
- setWindowTitle(QString("%1 | %2").arg(m_trackInfo).arg(m_statusInfo));
- else
- setWindowTitle(m_trackInfo);
- }
-}
-
-void Player::displayErrorMessage()
-{
- setStatusInfo(m_player->errorString());
-}
-
-void Player::updateDurationInfo(qint64 currentInfo)
-{
- QString tStr;
- if (currentInfo || m_duration) {
- QTime currentTime((currentInfo / 3600) % 60, (currentInfo / 60) % 60,
- currentInfo % 60, (currentInfo * 1000) % 1000);
- QTime totalTime((m_duration / 3600) % 60, (m_duration / 60) % 60,
- m_duration % 60, (m_duration * 1000) % 1000);
- QString format = "mm:ss";
- if (m_duration > 3600)
- format = "hh:mm:ss";
- tStr = currentTime.toString(format) + " / " + totalTime.toString(format);
- }
- m_labelDuration->setText(tStr);
-}
-
-void Player::showColorDialog()
-{
- if (!m_colorDialog) {
- QSlider *brightnessSlider = new QSlider(Qt::Horizontal);
- brightnessSlider->setRange(-100, 100);
- brightnessSlider->setValue(m_videoWidget->brightness());
- connect(brightnessSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setBrightness);
- connect(m_videoWidget, &QVideoWidget::brightnessChanged, brightnessSlider, &QSlider::setValue);
-
- QSlider *contrastSlider = new QSlider(Qt::Horizontal);
- contrastSlider->setRange(-100, 100);
- contrastSlider->setValue(m_videoWidget->contrast());
- connect(contrastSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setContrast);
- connect(m_videoWidget, &QVideoWidget::contrastChanged, contrastSlider, &QSlider::setValue);
-
- QSlider *hueSlider = new QSlider(Qt::Horizontal);
- hueSlider->setRange(-100, 100);
- hueSlider->setValue(m_videoWidget->hue());
- connect(hueSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setHue);
- connect(m_videoWidget, &QVideoWidget::hueChanged, hueSlider, &QSlider::setValue);
-
- QSlider *saturationSlider = new QSlider(Qt::Horizontal);
- saturationSlider->setRange(-100, 100);
- saturationSlider->setValue(m_videoWidget->saturation());
- connect(saturationSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setSaturation);
- connect(m_videoWidget, &QVideoWidget::saturationChanged, saturationSlider, &QSlider::setValue);
-
- QFormLayout *layout = new QFormLayout;
- layout->addRow(tr("Brightness"), brightnessSlider);
- layout->addRow(tr("Contrast"), contrastSlider);
- layout->addRow(tr("Hue"), hueSlider);
- layout->addRow(tr("Saturation"), saturationSlider);
-
- QPushButton *button = new QPushButton(tr("Close"));
- layout->addRow(button);
-
- m_colorDialog = new QDialog(this);
- m_colorDialog->setWindowTitle(tr("Color Options"));
- m_colorDialog->setLayout(layout);
-
- connect(button, &QPushButton::clicked, m_colorDialog, &QDialog::close);
- }
- m_colorDialog->show();
-}
-
-void Player::clearHistogram()
-{
- QMetaObject::invokeMethod(m_videoHistogram, "processFrame", Qt::QueuedConnection, Q_ARG(QVideoFrame, QVideoFrame()));
- QMetaObject::invokeMethod(m_audioHistogram, "processBuffer", Qt::QueuedConnection, Q_ARG(QAudioBuffer, QAudioBuffer()));
-}
diff --git a/examples/multimediawidgets/player/player.h b/examples/multimediawidgets/player/player.h
deleted file mode 100644
index 3002c9811..000000000
--- a/examples/multimediawidgets/player/player.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef PLAYER_H
-#define PLAYER_H
-
-#include <QWidget>
-#include <QMediaPlayer>
-#include <QMediaPlaylist>
-
-QT_BEGIN_NAMESPACE
-class QAbstractItemView;
-class QLabel;
-class QMediaPlayer;
-class QModelIndex;
-class QPushButton;
-class QSlider;
-class QStatusBar;
-class QVideoProbe;
-class QVideoWidget;
-class QAudioProbe;
-QT_END_NAMESPACE
-
-class PlaylistModel;
-class HistogramWidget;
-
-class Player : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit Player(QWidget *parent = nullptr);
- ~Player();
-
- bool isPlayerAvailable() const;
-
- void addToPlaylist(const QList<QUrl> &urls);
- void setCustomAudioRole(const QString &role);
-
-signals:
- void fullScreenChanged(bool fullScreen);
-
-private slots:
- void open();
- void durationChanged(qint64 duration);
- void positionChanged(qint64 progress);
- void metaDataChanged();
-
- void previousClicked();
-
- void seek(int seconds);
- void jump(const QModelIndex &index);
- void playlistPositionChanged(int);
-
- void statusChanged(QMediaPlayer::MediaStatus status);
- void stateChanged(QMediaPlayer::State state);
- void bufferingProgress(int progress);
- void videoAvailableChanged(bool available);
-
- void displayErrorMessage();
-
- void showColorDialog();
-
-private:
- void clearHistogram();
- void setTrackInfo(const QString &info);
- void setStatusInfo(const QString &info);
- void handleCursor(QMediaPlayer::MediaStatus status);
- void updateDurationInfo(qint64 currentInfo);
-
- QMediaPlayer *m_player = nullptr;
- QMediaPlaylist *m_playlist = nullptr;
- QVideoWidget *m_videoWidget = nullptr;
- QLabel *m_coverLabel = nullptr;
- QSlider *m_slider = nullptr;
- QLabel *m_labelDuration = nullptr;
- QPushButton *m_fullScreenButton = nullptr;
- QPushButton *m_colorButton = nullptr;
- QDialog *m_colorDialog = nullptr;
- QLabel *m_statusLabel = nullptr;
- QStatusBar *m_statusBar = nullptr;
-
- QLabel *m_labelHistogram = nullptr;
- HistogramWidget *m_videoHistogram = nullptr;
- HistogramWidget *m_audioHistogram = nullptr;
- QVideoProbe *m_videoProbe = nullptr;
- QAudioProbe *m_audioProbe = nullptr;
-
- PlaylistModel *m_playlistModel = nullptr;
- QAbstractItemView *m_playlistView = nullptr;
- QString m_trackInfo;
- QString m_statusInfo;
- qint64 m_duration;
-};
-
-#endif // PLAYER_H
diff --git a/examples/multimediawidgets/player/playercontrols.h b/examples/multimediawidgets/player/playercontrols.h
deleted file mode 100644
index bf1f676c1..000000000
--- a/examples/multimediawidgets/player/playercontrols.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef PLAYERCONTROLS_H
-#define PLAYERCONTROLS_H
-
-#include <QMediaPlayer>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QAbstractSlider;
-class QComboBox;
-QT_END_NAMESPACE
-
-class PlayerControls : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit PlayerControls(QWidget *parent = nullptr);
-
- QMediaPlayer::State state() const;
- int volume() const;
- bool isMuted() const;
- qreal playbackRate() const;
-
-public slots:
- void setState(QMediaPlayer::State state);
- void setVolume(int volume);
- void setMuted(bool muted);
- void setPlaybackRate(float rate);
-
-signals:
- void play();
- void pause();
- void stop();
- void next();
- void previous();
- void changeVolume(int volume);
- void changeMuting(bool muting);
- void changeRate(qreal rate);
-
-private slots:
- void playClicked();
- void muteClicked();
- void updateRate();
- void onVolumeSliderValueChanged();
-
-private:
- QMediaPlayer::State m_playerState = QMediaPlayer::StoppedState;
- bool m_playerMuted = false;
- QAbstractButton *m_playButton = nullptr;
- QAbstractButton *m_stopButton = nullptr;
- QAbstractButton *m_nextButton = nullptr;
- QAbstractButton *m_previousButton = nullptr;
- QAbstractButton *m_muteButton = nullptr;
- QAbstractSlider *m_volumeSlider = nullptr;
- QComboBox *m_rateBox = nullptr;
-};
-
-#endif // PLAYERCONTROLS_H
diff --git a/examples/multimediawidgets/player/playlistmodel.cpp b/examples/multimediawidgets/player/playlistmodel.cpp
deleted file mode 100644
index 718c24d2d..000000000
--- a/examples/multimediawidgets/player/playlistmodel.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "playlistmodel.h"
-
-#include <QFileInfo>
-#include <QUrl>
-#include <QMediaPlaylist>
-
-PlaylistModel::PlaylistModel(QObject *parent)
- : QAbstractItemModel(parent)
-{
-}
-
-PlaylistModel::~PlaylistModel()
-{
-}
-
-int PlaylistModel::rowCount(const QModelIndex &parent) const
-{
- return m_playlist && !parent.isValid() ? m_playlist->mediaCount() : 0;
-}
-
-int PlaylistModel::columnCount(const QModelIndex &parent) const
-{
- return !parent.isValid() ? ColumnCount : 0;
-}
-
-QModelIndex PlaylistModel::index(int row, int column, const QModelIndex &parent) const
-{
- return m_playlist && !parent.isValid()
- && row >= 0 && row < m_playlist->mediaCount()
- && column >= 0 && column < ColumnCount
- ? createIndex(row, column)
- : QModelIndex();
-}
-
-QModelIndex PlaylistModel::parent(const QModelIndex &child) const
-{
- Q_UNUSED(child);
-
- return QModelIndex();
-}
-
-QVariant PlaylistModel::data(const QModelIndex &index, int role) const
-{
- if (index.isValid() && role == Qt::DisplayRole) {
- QVariant value = m_data[index];
- if (!value.isValid() && index.column() == Title) {
- QUrl location = m_playlist->media(index.row()).request().url();
- return QFileInfo(location.path()).fileName();
- }
-
- return value;
- }
- return QVariant();
-}
-
-QMediaPlaylist *PlaylistModel::playlist() const
-{
- return m_playlist.data();
-}
-
-void PlaylistModel::setPlaylist(QMediaPlaylist *playlist)
-{
- if (m_playlist) {
- disconnect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems);
- disconnect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems);
- disconnect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems);
- disconnect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems);
- disconnect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems);
- }
-
- beginResetModel();
- m_playlist.reset(playlist);
-
- if (m_playlist) {
- connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems);
- connect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems);
- }
-
- endResetModel();
-}
-
-bool PlaylistModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- Q_UNUSED(role);
- m_data[index] = value;
- emit dataChanged(index, index);
- return true;
-}
-
-void PlaylistModel::beginInsertItems(int start, int end)
-{
- m_data.clear();
- beginInsertRows(QModelIndex(), start, end);
-}
-
-void PlaylistModel::endInsertItems()
-{
- endInsertRows();
-}
-
-void PlaylistModel::beginRemoveItems(int start, int end)
-{
- m_data.clear();
- beginRemoveRows(QModelIndex(), start, end);
-}
-
-void PlaylistModel::endRemoveItems()
-{
- endInsertRows();
-}
-
-void PlaylistModel::changeItems(int start, int end)
-{
- m_data.clear();
- emit dataChanged(index(start,0), index(end,ColumnCount));
-}
diff --git a/examples/multimediawidgets/player/playlistmodel.h b/examples/multimediawidgets/player/playlistmodel.h
deleted file mode 100644
index a0df0e9e7..000000000
--- a/examples/multimediawidgets/player/playlistmodel.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef PLAYLISTMODEL_H
-#define PLAYLISTMODEL_H
-
-#include <QAbstractItemModel>
-#include <QScopedPointer>
-
-QT_BEGIN_NAMESPACE
-class QMediaPlaylist;
-QT_END_NAMESPACE
-
-class PlaylistModel : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- enum Column
- {
- Title = 0,
- ColumnCount
- };
-
- explicit PlaylistModel(QObject *parent = nullptr);
- ~PlaylistModel();
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
-
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
- QModelIndex parent(const QModelIndex &child) const override;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
-
- QMediaPlaylist *playlist() const;
- void setPlaylist(QMediaPlaylist *playlist);
-
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override;
-
-private slots:
- void beginInsertItems(int start, int end);
- void endInsertItems();
- void beginRemoveItems(int start, int end);
- void endRemoveItems();
- void changeItems(int start, int end);
-
-private:
- QScopedPointer<QMediaPlaylist> m_playlist;
- QMap<QModelIndex, QVariant> m_data;
-};
-
-#endif // PLAYLISTMODEL_H
diff --git a/examples/multimediawidgets/player/videowidget.cpp b/examples/multimediawidgets/player/videowidget.cpp
deleted file mode 100644
index dfed01d1d..000000000
--- a/examples/multimediawidgets/player/videowidget.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videowidget.h"
-
-#include <QKeyEvent>
-#include <QMouseEvent>
-
-VideoWidget::VideoWidget(QWidget *parent)
- : QVideoWidget(parent)
-{
- setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
-
- QPalette p = palette();
- p.setColor(QPalette::Window, Qt::black);
- setPalette(p);
-
- setAttribute(Qt::WA_OpaquePaintEvent);
-}
-
-void VideoWidget::keyPressEvent(QKeyEvent *event)
-{
- if (event->key() == Qt::Key_Escape && isFullScreen()) {
- setFullScreen(false);
- event->accept();
- } else if (event->key() == Qt::Key_Enter && event->modifiers() & Qt::Key_Alt) {
- setFullScreen(!isFullScreen());
- event->accept();
- } else {
- QVideoWidget::keyPressEvent(event);
- }
-}
-
-void VideoWidget::mouseDoubleClickEvent(QMouseEvent *event)
-{
- setFullScreen(!isFullScreen());
- event->accept();
-}
-
-void VideoWidget::mousePressEvent(QMouseEvent *event)
-{
- QVideoWidget::mousePressEvent(event);
-}
-
diff --git a/examples/multimediawidgets/player/videowidget.h b/examples/multimediawidgets/player/videowidget.h
deleted file mode 100644
index c01632e7b..000000000
--- a/examples/multimediawidgets/player/videowidget.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOWIDGET_H
-#define VIDEOWIDGET_H
-
-#include <QVideoWidget>
-
-class VideoWidget : public QVideoWidget
-{
- Q_OBJECT
-
-public:
- explicit VideoWidget(QWidget *parent = nullptr);
-
-protected:
- void keyPressEvent(QKeyEvent *event) override;
- void mouseDoubleClickEvent(QMouseEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
-};
-
-#endif // VIDEOWIDGET_H
diff --git a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc b/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc
deleted file mode 100644
index f820a38b4..000000000
--- a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\example multimediawidgets/videographicsitem
-\title Video Graphics Item Example
-\ingroup multimedia_examples
-\brief Streaming video on a graphics scene.
-
- \e{Video Graphics Item} demonstrates how to implement a QGraphicsItem that
- displays video on a graphics scene using QAbstractVideoSurface.
-
- \image video-videographicsitem.png
-
- \sa {Video Widget Example}
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/multimediawidgets/videographicsitem/main.cpp b/examples/multimediawidgets/videographicsitem/main.cpp
deleted file mode 100644
index 58542b619..000000000
--- a/examples/multimediawidgets/videographicsitem/main.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QDir>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Player Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt MultiMedia Player QGraphicsView Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("url", "The URL to open.");
- parser.process(app);
-
- VideoPlayer player;
-
- if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) {
- const QUrl url =
- QUrl::fromUserInput(parser.positionalArguments().constFirst(),
- QDir::currentPath(), QUrl::AssumeLocalFile);
- player.load(url);
- }
-
- player.show();
-
- return app.exec();
-}
-
diff --git a/examples/multimediawidgets/videographicsitem/videoplayer.cpp b/examples/multimediawidgets/videographicsitem/videoplayer.cpp
deleted file mode 100644
index 917a71f64..000000000
--- a/examples/multimediawidgets/videographicsitem/videoplayer.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include <QtWidgets>
-#include <QGraphicsVideoItem>
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
-{
- m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
- const QSize screenGeometry = screen()->availableSize();
- m_videoItem = new QGraphicsVideoItem;
- m_videoItem->setSize(QSizeF(screenGeometry.width() / 3, screenGeometry.height() / 2));
-
- QGraphicsScene *scene = new QGraphicsScene(this);
- QGraphicsView *graphicsView = new QGraphicsView(scene);
-
- scene->addItem(m_videoItem);
-
- QSlider *rotateSlider = new QSlider(Qt::Horizontal);
- rotateSlider->setToolTip(tr("Rotate Video"));
- rotateSlider->setRange(-180, 180);
- rotateSlider->setValue(0);
-
- connect(rotateSlider, &QAbstractSlider::valueChanged,
- this, &VideoPlayer::rotateVideo);
-
- QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile);
-
- m_playButton = new QPushButton;
- m_playButton->setEnabled(false);
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(m_playButton, &QAbstractButton::clicked, this, &VideoPlayer::play);
-
- m_positionSlider = new QSlider(Qt::Horizontal);
- m_positionSlider->setRange(0, 0);
-
- connect(m_positionSlider, &QAbstractSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addWidget(m_playButton);
- controlLayout->addWidget(m_positionSlider);
-
- QBoxLayout *layout = new QVBoxLayout(this);
- layout->addWidget(graphicsView);
- layout->addWidget(rotateSlider);
- layout->addLayout(controlLayout);
-
- m_mediaPlayer->setVideoOutput(m_videoItem);
- connect(m_mediaPlayer, &QMediaPlayer::stateChanged,
- this, &VideoPlayer::mediaStateChanged);
- connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
- connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
-}
-
-VideoPlayer::~VideoPlayer()
-{
-}
-
-QSize VideoPlayer::sizeHint() const
-{
- return (m_videoItem->size() * qreal(3) / qreal(2)).toSize();
-}
-
-bool VideoPlayer::isPlayerAvailable() const
-{
- return m_mediaPlayer->isAvailable();
-}
-
-void VideoPlayer::openFile()
-{
- QFileDialog fileDialog(this);
- fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
- fileDialog.setWindowTitle(tr("Open Movie"));
- const QStringList supportedMimeTypes = m_mediaPlayer->supportedMimeTypes();
- if (!supportedMimeTypes.isEmpty())
- fileDialog.setMimeTypeFilters(supportedMimeTypes);
- fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
- if (fileDialog.exec() == QDialog::Accepted)
- load(fileDialog.selectedUrls().constFirst());
-}
-
-void VideoPlayer::load(const QUrl &url)
-{
- m_mediaPlayer->setMedia(url);
- m_playButton->setEnabled(true);
-}
-
-void VideoPlayer::play()
-{
- switch (m_mediaPlayer->state()) {
- case QMediaPlayer::PlayingState:
- m_mediaPlayer->pause();
- break;
- default:
- m_mediaPlayer->play();
- break;
- }
-}
-
-void VideoPlayer::mediaStateChanged(QMediaPlayer::State state)
-{
- switch(state) {
- case QMediaPlayer::PlayingState:
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- default:
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
-}
-
-void VideoPlayer::positionChanged(qint64 position)
-{
- m_positionSlider->setValue(position);
-}
-
-void VideoPlayer::durationChanged(qint64 duration)
-{
- m_positionSlider->setRange(0, duration);
-}
-
-void VideoPlayer::setPosition(int position)
-{
- m_mediaPlayer->setPosition(position);
-}
-
-
-void VideoPlayer::rotateVideo(int angle)
-{
- //rotate around the center of video element
- qreal x = m_videoItem->boundingRect().width() / 2.0;
- qreal y = m_videoItem->boundingRect().height() / 2.0;
- m_videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y));
-}
diff --git a/examples/multimediawidgets/videographicsitem/videoplayer.h b/examples/multimediawidgets/videographicsitem/videoplayer.h
deleted file mode 100644
index 87c20c804..000000000
--- a/examples/multimediawidgets/videographicsitem/videoplayer.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-class QGraphicsVideoItem;
-QT_END_NAMESPACE
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoPlayer(QWidget *parent = nullptr);
- ~VideoPlayer();
-
- void load(const QUrl &url);
- bool isPlayerAvailable() const;
-
- QSize sizeHint() const override;
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::State state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
- void rotateVideo(int angle);
-
-private:
- QMediaPlayer *m_mediaPlayer = nullptr;
- QGraphicsVideoItem *m_videoItem = nullptr;
- QAbstractButton *m_playButton = nullptr;
- QSlider *m_positionSlider = nullptr;
-};
-
-#endif
-
diff --git a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc b/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc
deleted file mode 100644
index a766243b6..000000000
--- a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example multimediawidgets/videowidget
- \title Video Widget Example
- \ingroup multimedia_examples
- \brief Implementing a video player widget.
-
- \e{Video Widget} demonstrates how to implement a video widget using
- QAbstractVideoSurface.
-
- \image video-videowidget.png
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/multimediawidgets/videowidget/main.cpp b/examples/multimediawidgets/videowidget/main.cpp
deleted file mode 100644
index 367bc9526..000000000
--- a/examples/multimediawidgets/videowidget/main.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include <QtWidgets/QApplication>
-#include <QtCore/QCommandLineParser>
-#include <QtCore/QCommandLineOption>
-#include <QtCore/QDir>
-#include <QScreen>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Video Widget Example");
- QCoreApplication::setOrganizationName("QtProject");
- QGuiApplication::setApplicationDisplayName(QCoreApplication::applicationName());
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt Video Widget Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("url", "The URL to open.");
- parser.process(app);
-
- VideoPlayer player;
- if (!parser.positionalArguments().isEmpty()) {
- const QUrl url =
- QUrl::fromUserInput(parser.positionalArguments().constFirst(),
- QDir::currentPath(), QUrl::AssumeLocalFile);
- player.setUrl(url);
- }
-
- const QSize availableGeometry = player.screen()->availableSize();
- player.resize(availableGeometry.width() / 6, availableGeometry.height() / 4);
- player.show();
-
- return app.exec();
-}
diff --git a/examples/multimediawidgets/videowidget/videoplayer.cpp b/examples/multimediawidgets/videowidget/videoplayer.cpp
deleted file mode 100644
index 1db269503..000000000
--- a/examples/multimediawidgets/videowidget/videoplayer.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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 "videoplayer.h"
-
-#include <QtWidgets>
-#include <QVideoWidget>
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
-{
- m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
- QVideoWidget *videoWidget = new QVideoWidget;
-
- QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, &QAbstractButton::clicked, this, &VideoPlayer::openFile);
-
- m_playButton = new QPushButton;
- m_playButton->setEnabled(false);
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(m_playButton, &QAbstractButton::clicked,
- this, &VideoPlayer::play);
-
- m_positionSlider = new QSlider(Qt::Horizontal);
- m_positionSlider->setRange(0, 0);
-
- connect(m_positionSlider, &QAbstractSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
-
- m_errorLabel = new QLabel;
- m_errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addWidget(m_playButton);
- controlLayout->addWidget(m_positionSlider);
-
- QBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(videoWidget);
- layout->addLayout(controlLayout);
- layout->addWidget(m_errorLabel);
-
- setLayout(layout);
-
- m_mediaPlayer->setVideoOutput(videoWidget);
- connect(m_mediaPlayer, &QMediaPlayer::stateChanged,
- this, &VideoPlayer::mediaStateChanged);
- connect(m_mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
- connect(m_mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
- connect(m_mediaPlayer, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error),
- this, &VideoPlayer::handleError);
-}
-
-VideoPlayer::~VideoPlayer()
-{
-}
-
-void VideoPlayer::openFile()
-{
- QFileDialog fileDialog(this);
- fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
- fileDialog.setWindowTitle(tr("Open Movie"));
- QStringList supportedMimeTypes = m_mediaPlayer->supportedMimeTypes();
- if (!supportedMimeTypes.isEmpty())
- fileDialog.setMimeTypeFilters(supportedMimeTypes);
- fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
- if (fileDialog.exec() == QDialog::Accepted)
- setUrl(fileDialog.selectedUrls().constFirst());
-}
-
-void VideoPlayer::setUrl(const QUrl &url)
-{
- m_errorLabel->setText(QString());
- setWindowFilePath(url.isLocalFile() ? url.toLocalFile() : QString());
- m_mediaPlayer->setMedia(url);
- m_playButton->setEnabled(true);
-}
-
-void VideoPlayer::play()
-{
- switch (m_mediaPlayer->state()) {
- case QMediaPlayer::PlayingState:
- m_mediaPlayer->pause();
- break;
- default:
- m_mediaPlayer->play();
- break;
- }
-}
-
-void VideoPlayer::mediaStateChanged(QMediaPlayer::State state)
-{
- switch(state) {
- case QMediaPlayer::PlayingState:
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- default:
- m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
-}
-
-void VideoPlayer::positionChanged(qint64 position)
-{
- m_positionSlider->setValue(position);
-}
-
-void VideoPlayer::durationChanged(qint64 duration)
-{
- m_positionSlider->setRange(0, duration);
-}
-
-void VideoPlayer::setPosition(int position)
-{
- m_mediaPlayer->setPosition(position);
-}
-
-void VideoPlayer::handleError()
-{
- m_playButton->setEnabled(false);
- const QString errorString = m_mediaPlayer->errorString();
- QString message = "Error: ";
- if (errorString.isEmpty())
- message += " #" + QString::number(int(m_mediaPlayer->error()));
- else
- message += errorString;
- m_errorLabel->setText(message);
-}
diff --git a/examples/multimediawidgets/videowidget/videoplayer.h b/examples/multimediawidgets/videowidget/videoplayer.h
deleted file mode 100644
index 62260d167..000000000
--- a/examples/multimediawidgets/videowidget/videoplayer.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, 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 The Qt Company Ltd 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-class QLabel;
-class QUrl;
-QT_END_NAMESPACE
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-public:
- VideoPlayer(QWidget *parent = nullptr);
- ~VideoPlayer();
-
- void setUrl(const QUrl &url);
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::State state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
- void handleError();
-
-private:
- QMediaPlayer* m_mediaPlayer;
- QAbstractButton *m_playButton;
- QSlider *m_positionSlider;
- QLabel *m_errorLabel;
-};
-
-#endif
diff --git a/examples/spatialaudio/CMakeLists.txt b/examples/spatialaudio/CMakeLists.txt
new file mode 100644
index 000000000..0d92a79f5
--- /dev/null
+++ b/examples/spatialaudio/CMakeLists.txt
@@ -0,0 +1 @@
+qt_internal_add_example(audiopanning)
diff --git a/examples/spatialaudio/audiopanning/CMakeLists.txt b/examples/spatialaudio/audiopanning/CMakeLists.txt
new file mode 100644
index 000000000..00367897a
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(audiodecoder LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/spatialaudio/audiopanning")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SpatialAudio Widgets)
+
+qt_add_executable(audiopanning
+ main.cpp
+)
+
+set_target_properties(audiopanning PROPERTIES
+ WIN32_EXECUTABLE FALSE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(audiopanning PUBLIC
+ Qt::Core
+ Qt::SpatialAudio
+ Qt::Widgets
+)
+
+install(TARGETS audiopanning
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/spatialaudio/audiopanning/audiopanning.pro b/examples/spatialaudio/audiopanning/audiopanning.pro
new file mode 100644
index 000000000..3b1cce652
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/audiopanning.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+TARGET = audiopanning
+
+QT += multimedia widgets spatialaudio
+
+SOURCES = main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/spatialaudio/audiopanning
+INSTALLS += target
diff --git a/examples/spatialaudio/audiopanning/doc/images/audiopanning-example.png b/examples/spatialaudio/audiopanning/doc/images/audiopanning-example.png
new file mode 100644
index 000000000..45c53975d
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/doc/images/audiopanning-example.png
Binary files differ
diff --git a/examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc b/examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc
new file mode 100644
index 000000000..ebb18e5c7
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/doc/src/audiopanning.qdoc
@@ -0,0 +1,28 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+/*!
+
+\example audiopanning
+\title Spatial Audio Panning Example
+\ingroup spatialaudio_examples
+\ingroup audio_examples
+\examplecategory {Multimedia}
+\meta {tag} {widgets}
+\brief Shows some of the capabilities of the spatial audio engine in Qt.
+
+The Spatial Audio Example demonstrates how you can use \l{Qt Spatial Audio} to
+place sound sources in 3D space and how positioning of the sound source and
+room properties affect the listening experience.
+
+The example lets you specify a sound file to be played back at a certain
+position in 3D space relative to the listener. Using sliders you can change
+the distance and the azimuth and elevation angles to the source. You can also
+change dimensions of a virtual room, the intensity of the room reflections
+and reverb.
+
+Various other properties can also be modified such as the dimensions of a virtual
+room and the intensity of the room reflections and reverb.
+
+\image audiopanning-example.png
+
+*/
diff --git a/examples/spatialaudio/audiopanning/main.cpp b/examples/spatialaudio/audiopanning/main.cpp
new file mode 100644
index 000000000..84e5197bd
--- /dev/null
+++ b/examples/spatialaudio/audiopanning/main.cpp
@@ -0,0 +1,241 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QApplication>
+#include <QAudioEngine>
+#include <QAudioListener>
+#include <QAudioRoom>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QCommandLineParser>
+#include <QFileDialog>
+#include <QFormLayout>
+#include <QHBoxLayout>
+#include <QLibraryInfo>
+#include <QLineEdit>
+#include <QPropertyAnimation>
+#include <QPushButton>
+#include <QSlider>
+#include <QSpatialSound>
+#include <QStandardPaths>
+
+class AudioWidget : public QWidget
+{
+public:
+ AudioWidget();
+ void setFile(const QString &file);
+
+private slots:
+ void updatePosition();
+ void newOcclusion();
+ void modeChanged();
+ void fileChanged(const QString &file);
+ void openFileDialog();
+ void updateRoom();
+ void animateChanged();
+
+private:
+ QLineEdit *fileEdit = nullptr;
+ QPushButton *fileDialogButton = nullptr;
+ QSlider *azimuth = nullptr;
+ QSlider *elevation = nullptr;
+ QSlider *distance = nullptr;
+ QSlider *occlusion = nullptr;
+ QSlider *roomDimension = nullptr;
+ QSlider *reverbGain = nullptr;
+ QSlider *reflectionGain = nullptr;
+ QComboBox *mode = nullptr;
+ QCheckBox *animateButton = nullptr;
+ QPropertyAnimation *animation = nullptr;
+
+ QAudioEngine engine;
+ QAudioListener *listener = nullptr;
+ QSpatialSound *sound = nullptr;
+ QAudioRoom *room = nullptr;
+ QFileDialog *fileDialog = nullptr;
+};
+
+AudioWidget::AudioWidget()
+ : QWidget()
+{
+ setMinimumSize(400, 300);
+ auto *form = new QFormLayout(this);
+
+ auto *fileLayout = new QHBoxLayout;
+ fileEdit = new QLineEdit;
+ fileEdit->setPlaceholderText(tr("Audio File"));
+ fileLayout->addWidget(fileEdit);
+ fileDialogButton = new QPushButton(tr("Choose..."));
+ fileLayout->addWidget(fileDialogButton);
+ form->addRow(fileLayout);
+
+ azimuth = new QSlider(Qt::Horizontal);
+ azimuth->setRange(-180, 180);
+ form->addRow(tr("Azimuth (-180 - 180 degree):"), azimuth);
+
+ elevation = new QSlider(Qt::Horizontal);
+ elevation->setRange(-90, 90);
+ form->addRow(tr("Elevation (-90 - 90 degree)"), elevation);
+
+ distance = new QSlider(Qt::Horizontal);
+ distance->setRange(0, 1000);
+ distance->setValue(100);
+ form->addRow(tr("Distance (0 - 10 meter):"), distance);
+
+ occlusion = new QSlider(Qt::Horizontal);
+ occlusion->setRange(0, 400);
+ form->addRow(tr("Occlusion (0 - 4):"), occlusion);
+
+ roomDimension = new QSlider(Qt::Horizontal);
+ roomDimension->setRange(0, 10000);
+ roomDimension->setValue(1000);
+ form->addRow(tr("Room dimension (0 - 100 meter):"), roomDimension);
+
+ reverbGain = new QSlider(Qt::Horizontal);
+ reverbGain->setRange(0, 500);
+ reverbGain->setValue(0);
+ form->addRow(tr("Reverb gain (0-5):"), reverbGain);
+
+ reflectionGain = new QSlider(Qt::Horizontal);
+ reflectionGain->setRange(0, 500);
+ reflectionGain->setValue(0);
+ form->addRow(tr("Reflection gain (0-5):"), reflectionGain);
+
+ mode = new QComboBox;
+ mode->addItem(tr("Surround"), QVariant::fromValue(QAudioEngine::Surround));
+ mode->addItem(tr("Stereo"), QVariant::fromValue(QAudioEngine::Stereo));
+ mode->addItem(tr("Headphone"), QVariant::fromValue(QAudioEngine::Headphone));
+
+ form->addRow(tr("Output mode:"), mode);
+
+ animateButton = new QCheckBox(tr("Animate sound position"));
+ form->addRow(animateButton);
+
+ connect(fileEdit, &QLineEdit::textChanged, this, &AudioWidget::fileChanged);
+ connect(fileDialogButton, &QPushButton::clicked, this, &AudioWidget::openFileDialog);
+
+ connect(azimuth, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
+ connect(elevation, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
+ connect(distance, &QSlider::valueChanged, this, &AudioWidget::updatePosition);
+ connect(occlusion, &QSlider::valueChanged, this, &AudioWidget::newOcclusion);
+
+ connect(roomDimension, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
+ connect(reverbGain, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
+ connect(reflectionGain, &QSlider::valueChanged, this, &AudioWidget::updateRoom);
+
+ connect(mode, &QComboBox::currentIndexChanged, this, &AudioWidget::modeChanged);
+
+ room = new QAudioRoom(&engine);
+ room->setWallMaterial(QAudioRoom::BackWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::FrontWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::LeftWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::RightWall, QAudioRoom::BrickBare);
+ room->setWallMaterial(QAudioRoom::Floor, QAudioRoom::Marble);
+ room->setWallMaterial(QAudioRoom::Ceiling, QAudioRoom::WoodCeiling);
+ updateRoom();
+
+ listener = new QAudioListener(&engine);
+ listener->setPosition({});
+ listener->setRotation({});
+ engine.start();
+
+ sound = new QSpatialSound(&engine);
+ updatePosition();
+
+ animation = new QPropertyAnimation(azimuth, "value");
+ animation->setDuration(10000);
+ animation->setStartValue(-180);
+ animation->setEndValue(180);
+ animation->setLoopCount(-1);
+ connect(animateButton, &QCheckBox::toggled, this, &AudioWidget::animateChanged);
+}
+
+void AudioWidget::setFile(const QString &file)
+{
+ fileEdit->setText(file);
+}
+
+void AudioWidget::updatePosition()
+{
+ const float az = azimuth->value() / 180. * M_PI;
+ const float el = elevation->value() / 180. * M_PI;
+ const float d = distance->value();
+
+ const float x = d * sin(az) * cos(el);
+ const float y = d * sin(el);
+ const float z = -d * cos(az) * cos(el);
+ sound->setPosition({x, y, z});
+}
+
+void AudioWidget::newOcclusion()
+{
+ sound->setOcclusionIntensity(occlusion->value() / 100.);
+}
+
+void AudioWidget::modeChanged()
+{
+ engine.setOutputMode(mode->currentData().value<QAudioEngine::OutputMode>());
+}
+
+void AudioWidget::fileChanged(const QString &file)
+{
+ sound->setSource(QUrl::fromLocalFile(file));
+ sound->setSize(5);
+ sound->setLoops(QSpatialSound::Infinite);
+}
+
+void AudioWidget::openFileDialog()
+{
+ if (fileDialog == nullptr) {
+ const QString dir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
+ fileDialog = new QFileDialog(this, tr("Open Audio File"), dir);
+ fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
+ const QStringList mimeTypes{"audio/mpeg", "audio/aac", "audio/x-ms-wma",
+ "audio/x-flac+ogg", "audio/x-wav"};
+ fileDialog->setMimeTypeFilters(mimeTypes);
+ fileDialog->selectMimeTypeFilter(mimeTypes.constFirst());
+ }
+
+ if (fileDialog->exec() == QDialog::Accepted)
+ fileEdit->setText(fileDialog->selectedFiles().constFirst());
+}
+
+void AudioWidget::updateRoom()
+{
+ const float d = roomDimension->value();
+ room->setDimensions(QVector3D(d, d, 400));
+ room->setReflectionGain(float(reflectionGain->value()) / 100);
+ room->setReverbGain(float(reverbGain->value()) / 100);
+}
+
+void AudioWidget::animateChanged()
+{
+ if (animateButton->isChecked())
+ animation->start();
+ else
+ animation->stop();
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QCoreApplication::setApplicationVersion(qVersion());
+ QGuiApplication::setApplicationDisplayName(AudioWidget::tr("Spatial Audio test application"));
+
+ QCommandLineParser commandLineParser;
+ commandLineParser.addVersionOption();
+ commandLineParser.addHelpOption();
+ commandLineParser.addPositionalArgument("Audio File",
+ "Audio File to play");
+
+ commandLineParser.process(app);
+
+ AudioWidget w;
+ w.show();
+
+ if (!commandLineParser.positionalArguments().isEmpty())
+ w.setFile(commandLineParser.positionalArguments().constFirst());
+
+ return app.exec();
+}
diff --git a/examples/spatialaudio/spatialaudio.pro b/examples/spatialaudio/spatialaudio.pro
new file mode 100644
index 000000000..80039c1a5
--- /dev/null
+++ b/examples/spatialaudio/spatialaudio.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS += audiopanning
+